summaryrefslogtreecommitdiff
path: root/utils/hwstub/stub/atj213x/target.c
diff options
context:
space:
mode:
authorMarcin Bukat <marcin.bukat@gmail.com>2014-09-23 13:30:17 +0200
committerMarcin Bukat <marcin.bukat@gmail.com>2014-11-05 08:18:59 +0100
commitd11704fed5fd218b2ed26182de877bc6e5b513a4 (patch)
tree0eceaf96f006e9047b698ea99bf452faa79884d3 /utils/hwstub/stub/atj213x/target.c
parent791be56cff14a7a41774ce80ce401384291985d9 (diff)
downloadrockbox-d11704fed5fd218b2ed26182de877bc6e5b513a4.tar.gz
rockbox-d11704fed5fd218b2ed26182de877bc6e5b513a4.zip
hwstub: Add atj213x supportbootloader_zenxfi3_v1
Change-Id: Ic32200f9ab2c6977e503307a9cbe43a1328d0341
Diffstat (limited to 'utils/hwstub/stub/atj213x/target.c')
-rw-r--r--utils/hwstub/stub/atj213x/target.c113
1 files changed, 113 insertions, 0 deletions
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 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 *
9 * Copyright (C) 2014 by Marcin Bukat
10 *
11 * This program is free software; you can redistribute it and/or
12 * modify it under the terms of the GNU General Public License
13 * as published by the Free Software Foundation; either version 2
14 * of the License, or (at your option) any later version.
15 *
16 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
17 * KIND, either express or implied.
18 *
19 ****************************************************************************/
20#include "stddef.h"
21#include "target.h"
22#include "system.h"
23#include "logf.h"
24#include "atj213x.h"
25
26#define CORE_FREQ 7500000
27#define HZ 1000000
28
29static void backlight_init(void)
30{
31 /* backlight clock enable, select backlight clock as 32kHz */
32 CMU_FMCLK = (CMU_FMCLK & ~(CMU_FMCLK_BCLK_MASK)) | CMU_FMCLK_BCKE | CMU_FMCLK_BCLK_32K;
33
34 /* baclight enable */
35 PMU_CTL |= PMU_CTL_BL_EN;
36
37 /* pwm output, phase high, some initial duty cycle set as 24/32 */
38 PMU_CHG = ((PMU_CHG & ~PMU_CHG_PDOUT_MASK)| PMU_CHG_PBLS_PWM | PMU_CHG_PPHS_HIGH | PMU_CHG_PDUT(24));
39
40}
41
42void backlight_set(int level)
43{
44 /* set duty cycle in 1/32 units */
45 PMU_CHG = ((PMU_CHG & ~PMU_CHG_PDOUT_MASK) | PMU_CHG_PDUT(level));
46}
47
48void target_udelay(int us)
49{
50 unsigned int i = us * (CORE_FREQ / 2000000);
51 asm volatile (
52 ".set noreorder \n"
53 "1: \n"
54 "bnez %0, 1b \n"
55 "addiu %0, %0, -1 \n"
56 ".set reorder \n"
57 : "=r" (i)
58 : "0" (i)
59 );
60}
61
62void target_mdelay(int ms)
63{
64 return target_udelay(ms * 1000);
65}
66
67void blink(int cnt)
68{
69 int i;
70
71 for (i=0; i<cnt; i++)
72 {
73 backlight_set(0);
74 target_mdelay(300);
75 backlight_set(24);
76 target_mdelay(300);
77 }
78}
79
80void target_init(void)
81{
82 RTC_WDCTL = (RTC_WDCTL & ~(1<<4))|(1<<6)|1; /* disable WDT */
83
84 /* Configure USB interrupt as IP6. IP6 is unmasked in crt0.S */
85 INTC_CFG0 = 0;
86 INTC_CFG1 = 0;
87 INTC_CFG2 = (1<<4);
88
89 /* mask all interrupts to avoid pending irq servicing */
90 INTC_MSK = 0;
91
92 backlight_init();
93}
94
95struct hwstub_target_desc_t __attribute__((aligned(2))) target_descriptor =
96{
97 sizeof(struct hwstub_target_desc_t),
98 HWSTUB_DT_TARGET,
99 HWSTUB_TARGET_ATJ,
100 "ATJ213X"
101};
102
103void target_get_desc(int desc, void **buffer)
104{
105 (void) desc;
106 *buffer = NULL;
107}
108
109void target_get_config_desc(void *buffer, int *size)
110{
111 (void) buffer;
112 (void) size;
113}