summaryrefslogtreecommitdiff
path: root/utils/hwstub/stub/jz4760b/target.c
diff options
context:
space:
mode:
Diffstat (limited to 'utils/hwstub/stub/jz4760b/target.c')
-rw-r--r--utils/hwstub/stub/jz4760b/target.c84
1 files changed, 84 insertions, 0 deletions
diff --git a/utils/hwstub/stub/jz4760b/target.c b/utils/hwstub/stub/jz4760b/target.c
new file mode 100644
index 0000000000..1678bfeba7
--- /dev/null
+++ b/utils/hwstub/stub/jz4760b/target.c
@@ -0,0 +1,84 @@
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 "jz4760b.h"
25
26#define PIN_BL (4 * 32 + 1)
27
28struct hwstub_target_desc_t __attribute__((aligned(2))) target_descriptor =
29{
30 sizeof(struct hwstub_target_desc_t),
31 HWSTUB_DT_TARGET,
32 HWSTUB_TARGET_JZ,
33 "JZ4760(B)"
34};
35
36static struct hwstub_jz_desc_t jz_descriptor =
37{
38 sizeof(struct hwstub_jz_desc_t),
39 HWSTUB_DT_JZ,
40 0x4760,
41 'B'
42};
43
44
45void target_udelay(int us)
46{
47 /* use OS timer running at 3MHz */
48 uint32_t end = REG_OST_OSTCNTL + 3 * us;
49 while(REG_OST_OSTCNTL < end) {}
50}
51
52void ost_init(void)
53{
54 /* Init OS Timer: don't compare, use EXTCLK (12MHz) and set prescaler to 4
55 * so that it increases at 3MHz */
56 REG_TCU_TECR = TECR_OST; /* disable OST */
57 REG_OST_OSTCSR = OSTCSR_CNT_MD | OSTCSR_PRESCALE4 | OSTCSR_EXT_EN;
58 REG_OST_OSTCNTL = 0;
59 REG_TCU_TESR = TESR_OST; /* enable OST */
60}
61
62void target_mdelay(int ms)
63{
64 return target_udelay(ms * 1000);
65}
66
67void target_init(void)
68{
69 ost_init();
70}
71
72void target_get_desc(int desc, void **buffer)
73{
74 if(desc == HWSTUB_DT_JZ)
75 *buffer = &jz_descriptor;
76 else
77 *buffer = NULL;
78}
79
80void target_get_config_desc(void *buffer, int *size)
81{
82 (void) buffer;
83 (void) size;
84}