From d11704fed5fd218b2ed26182de877bc6e5b513a4 Mon Sep 17 00:00:00 2001 From: Marcin Bukat Date: Tue, 23 Sep 2014 13:30:17 +0200 Subject: hwstub: Add atj213x support Change-Id: Ic32200f9ab2c6977e503307a9cbe43a1328d0341 --- utils/hwstub/stub/atj213x/target.c | 113 +++++++++++++++++++++++++++++++++++++ 1 file changed, 113 insertions(+) create mode 100644 utils/hwstub/stub/atj213x/target.c (limited to 'utils/hwstub/stub/atj213x/target.c') diff --git a/utils/hwstub/stub/atj213x/target.c b/utils/hwstub/stub/atj213x/target.c new file mode 100644 index 0000000000..04762bca00 --- /dev/null +++ b/utils/hwstub/stub/atj213x/target.c @@ -0,0 +1,113 @@ +/*************************************************************************** + * __________ __ ___. + * Open \______ \ ____ ____ | | _\_ |__ _______ ___ + * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / + * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < + * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ + * \/ \/ \/ \/ \/ + * + * Copyright (C) 2014 by Marcin Bukat + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY + * KIND, either express or implied. + * + ****************************************************************************/ +#include "stddef.h" +#include "target.h" +#include "system.h" +#include "logf.h" +#include "atj213x.h" + +#define CORE_FREQ 7500000 +#define HZ 1000000 + +static void backlight_init(void) +{ + /* backlight clock enable, select backlight clock as 32kHz */ + CMU_FMCLK = (CMU_FMCLK & ~(CMU_FMCLK_BCLK_MASK)) | CMU_FMCLK_BCKE | CMU_FMCLK_BCLK_32K; + + /* baclight enable */ + PMU_CTL |= PMU_CTL_BL_EN; + + /* pwm output, phase high, some initial duty cycle set as 24/32 */ + PMU_CHG = ((PMU_CHG & ~PMU_CHG_PDOUT_MASK)| PMU_CHG_PBLS_PWM | PMU_CHG_PPHS_HIGH | PMU_CHG_PDUT(24)); + +} + +void backlight_set(int level) +{ + /* set duty cycle in 1/32 units */ + PMU_CHG = ((PMU_CHG & ~PMU_CHG_PDOUT_MASK) | PMU_CHG_PDUT(level)); +} + +void target_udelay(int us) +{ + unsigned int i = us * (CORE_FREQ / 2000000); + asm volatile ( + ".set noreorder \n" + "1: \n" + "bnez %0, 1b \n" + "addiu %0, %0, -1 \n" + ".set reorder \n" + : "=r" (i) + : "0" (i) + ); +} + +void target_mdelay(int ms) +{ + return target_udelay(ms * 1000); +} + +void blink(int cnt) +{ + int i; + + for (i=0; i