summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--firmware/SOURCES5
-rw-r--r--firmware/common/timefuncs.c9
-rw-r--r--firmware/drivers/nand_id.c73
-rw-r--r--firmware/drivers/rtc/rtc_jz4740.c307
-rw-r--r--firmware/export/config-ondavx747.h8
-rw-r--r--firmware/export/nand_id.h (renamed from firmware/target/mips/ingenic_jz47xx/ata-jz4740.c)36
-rw-r--r--firmware/target/mips/ingenic_jz47xx/ata-nand-jz4740.c68
-rw-r--r--firmware/target/mips/ingenic_jz47xx/onda_vx747/button-onda_vx747.c33
-rw-r--r--firmware/target/mips/ingenic_jz47xx/system-jz4740.c8
9 files changed, 503 insertions, 44 deletions
diff --git a/firmware/SOURCES b/firmware/SOURCES
index 89f5a26c78..99e880c19a 100644
--- a/firmware/SOURCES
+++ b/firmware/SOURCES
@@ -155,6 +155,8 @@ drivers/rtc/rtc_mr100.c
155drivers/rtc/rtc_mc13783.c 155drivers/rtc/rtc_mc13783.c
156#elif (CONFIG_RTC == RTC_TCC77X) 156#elif (CONFIG_RTC == RTC_TCC77X)
157drivers/rtc/rtc_tcc77x.c 157drivers/rtc/rtc_tcc77x.c
158#elif (CONFIG_RTC == RTC_JZ47XX)
159drivers/rtc/rtc_jz4740.c
158#endif /* (CONFIG_RTC == RTC_) */ 160#endif /* (CONFIG_RTC == RTC_) */
159#endif /* SIMULATOR */ 161#endif /* SIMULATOR */
160 162
@@ -1073,9 +1075,10 @@ target/arm/s5l8700/meizu-m6sl/lcd-m6sl.c
1073#endif /* MEIZU_M6SL */ 1075#endif /* MEIZU_M6SL */
1074 1076
1075#if CONFIG_CPU==JZ4732 1077#if CONFIG_CPU==JZ4732
1076target/mips/ingenic_jz47xx/ata-jz4740.c 1078target/mips/ingenic_jz47xx/ata-nand-jz4740.c
1077target/mips/ingenic_jz47xx/lcd-jz4740.c 1079target/mips/ingenic_jz47xx/lcd-jz4740.c
1078target/mips/ingenic_jz47xx/system-jz4740.c 1080target/mips/ingenic_jz47xx/system-jz4740.c
1081drivers/nand_id.c
1079#endif 1082#endif
1080 1083
1081#ifdef ONDA_VX747 1084#ifdef ONDA_VX747
diff --git a/firmware/common/timefuncs.c b/firmware/common/timefuncs.c
index 1bf29d203c..d46b961a8c 100644
--- a/firmware/common/timefuncs.c
+++ b/firmware/common/timefuncs.c
@@ -52,10 +52,12 @@ struct tm *get_time(void)
52 static long timeout = 0; 52 static long timeout = 0;
53 53
54 /* Don't read the RTC more than once per second */ 54 /* Don't read the RTC more than once per second */
55 if (current_tick > timeout) { 55 if (current_tick > timeout)
56 char rtcbuf[7]; 56 {
57 /* Once per second, 1/10th of a second off */ 57 /* Once per second, 1/10th of a second off */
58 timeout = HZ * (current_tick / HZ + 1) + HZ / 5; 58 timeout = HZ * (current_tick / HZ + 1) + HZ / 5;
59#if CONFIG_RTC != RTC_JZ47XX
60 char rtcbuf[7];
59 rtc_read_datetime(rtcbuf); 61 rtc_read_datetime(rtcbuf);
60 62
61 tm.tm_sec = ((rtcbuf[0] & 0x70) >> 4) * 10 + (rtcbuf[0] & 0x0f); 63 tm.tm_sec = ((rtcbuf[0] & 0x70) >> 4) * 10 + (rtcbuf[0] & 0x0f);
@@ -76,6 +78,9 @@ struct tm *get_time(void)
76 78
77 tm.tm_yday = 0; /* Not implemented for now */ 79 tm.tm_yday = 0; /* Not implemented for now */
78 tm.tm_isdst = -1; /* Not implemented for now */ 80 tm.tm_isdst = -1; /* Not implemented for now */
81#else
82 rtc_read_datetime((unsigned char*)&tm);
83#endif
79 } 84 }
80#else 85#else
81 tm.tm_sec = 0; 86 tm.tm_sec = 0;
diff --git a/firmware/drivers/nand_id.c b/firmware/drivers/nand_id.c
new file mode 100644
index 0000000000..ab10ecec07
--- /dev/null
+++ b/firmware/drivers/nand_id.c
@@ -0,0 +1,73 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
9 *
10 * Copyright (C) 2008 by Maurus Cuelenaere
11 *
12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License
14 * as published by the Free Software Foundation; either version 2
15 * of the License, or (at your option) any later version.
16 *
17 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
18 * KIND, either express or implied.
19 *
20 ****************************************************************************/
21
22#include <stdlib.h>
23#include "nand_id.h"
24
25struct nand_manufacturer
26{
27 unsigned char id;
28 struct nand_info* info;
29 unsigned short total;
30};
31
32/* { pages_per_block, blocks_per_bank, page_size, spare_size, col_cycles, row_cycles } */
33
34static const struct nand_info samsung[] =
35{
36 /* K9K8G08UOM */
37 {0xD3, 0x51, 64, 8192, 2048, 64, 2, 3},
38 /* K9LAG08UOM */
39 {0xD5, 0x55, 128, 8192, 2048, 64, 2, 3},
40 /* K9LBG08UOM, K9HBG08U1M, K9MCG08U5M */
41 {0xD7, 0x55, 128, 8192, 4096, 128, 2, 3},
42};
43
44#define M(id, x) {id, (struct nand_info*)x, (sizeof(x)/sizeof(struct nand_info))}
45static const struct nand_manufacturer all[] =
46{
47 M(0xEC, samsung),
48};
49
50struct nand_info* nand_identify(unsigned char data[5])
51 {
52 unsigned int i;
53 int found = -1;
54 for(i = 0; i < (sizeof(all)/sizeof(struct nand_manufacturer)); i++)
55 {
56 if(data[0] == all[i].id)
57 {
58 found = i;
59 break;
60 }
61 }
62 if(found < 0)
63 return NULL;
64
65 for(i = 0; i < all[found].total; i++)
66 {
67 if(data[1] == all[found].info[i].dev_id &&
68 data[2] == all[found].info[i].dev_id2)
69 return &all[found].info[i];
70 }
71
72 return NULL;
73}
diff --git a/firmware/drivers/rtc/rtc_jz4740.c b/firmware/drivers/rtc/rtc_jz4740.c
new file mode 100644
index 0000000000..b9cceec9af
--- /dev/null
+++ b/firmware/drivers/rtc/rtc_jz4740.c
@@ -0,0 +1,307 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
9 *
10 * Copyright (C) 2008 by Maurus Cuelenaere
11 *
12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License
14 * as published by the Free Software Foundation; either version 2
15 * of the License, or (at your option) any later version.
16 *
17 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
18 * KIND, either express or implied.
19 *
20 ****************************************************************************/
21
22/*
23 * Jz OnChip Real Time Clock interface for Linux
24 *
25 */
26
27#include "config.h"
28#include "jz4740.h"
29#include "rtc.h"
30#include "timefuncs.h"
31
32static unsigned int epoch = 1900;
33static const unsigned char days_in_mo[] = {
34 0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31
35};
36
37static const unsigned int yearday[5] = {0, 366, 366+365, 366+365*2, 366+365*3};
38static const unsigned int sweekday = 6;
39static const unsigned int sum_monthday[13] = {
40 0,
41 31,
42 31+28,
43 31+28+31,
44 31+28+31+30,
45 31+28+31+30+31,
46 31+28+31+30+31+30,
47 31+28+31+30+31+30+31,
48 31+28+31+30+31+30+31+31,
49 31+28+31+30+31+30+31+31+30,
50 31+28+31+30+31+30+31+31+30+31,
51 31+28+31+30+31+30+31+31+30+31+30,
52 365
53};
54
55static unsigned int jz_mktime(int year, int mon, int day, int hour, int min, int sec)
56{
57 unsigned int seccounter;
58
59 if (year < 2000)
60 year = 2000;
61 year -= 2000;
62 seccounter = (year/4)*(365*3+366);
63 seccounter += yearday[year%4];
64 if (year%4)
65 seccounter += sum_monthday[mon-1];
66 else
67 if (mon >= 3)
68 seccounter += sum_monthday[mon-1]+1;
69 else
70 seccounter += sum_monthday[mon-1];
71 seccounter += day-1;
72 seccounter *= 24;
73 seccounter += hour;
74 seccounter *= 60;
75 seccounter += min;
76 seccounter *= 60;
77 seccounter += sec;
78
79 return seccounter;
80}
81
82static void jz_gettime(unsigned int rtc, int *year, int *mon, int *day, int *hour,
83 int *min, int *sec, int *weekday)
84{
85 unsigned int tday, tsec, i, tmp;
86
87 tday = rtc/(24*3600);
88 *weekday = ((tday % 7) + sweekday) % 7;
89 *year = (tday/(366+365*3)) * 4;
90 tday = tday%(366+365*3);
91 for (i=0;i<5;i++)
92 {
93 if (tday<yearday[i])
94 {
95 *year += i-1;
96 tday -= yearday[i-1];
97 break;
98 }
99 }
100 for (i=0;i<13;i++)
101 {
102 tmp = sum_monthday[i];
103 if (((*year%4) == 0) && (i>=2))
104 tmp += 1;
105 if (tday<tmp)
106 {
107 *mon = i;
108 tmp = sum_monthday[i-1];
109 if (((*year%4) == 0) && ((i-1)>=2))
110 tmp += 1;
111 *day = tday - tmp + 1;
112 break;
113 }
114 }
115 tsec = rtc % (24 * 3600);
116 *hour = tsec / 3600;
117 *min = (tsec / 60) % 60;
118 *sec = tsec - *hour*3600 - *min*60;
119 *year += 2000;
120}
121
122int rtc_read_datetime(unsigned char* buf)
123{
124 struct tm rtc_tm;
125 unsigned int sec,mon,mday,wday,year,hour,min;
126
127 /*
128 * Only the values that we read from the RTC are set. We leave
129 * tm_wday, tm_yday and tm_isdst untouched. Even though the
130 * RTC has RTC_DAY_OF_WEEK, we ignore it, as it is only updated
131 * by the RTC when initially set to a non-zero value.
132 */
133 jz_gettime(REG_RTC_RSR, &year, &mon, &mday, &hour, &min, &sec, &wday);
134
135 year -= 2000;
136
137 rtc_tm.tm_sec = sec;
138 rtc_tm.tm_min = min;
139 rtc_tm.tm_hour = hour;
140 rtc_tm.tm_mday = mday;
141 rtc_tm.tm_wday = wday;
142 /* Don't use centry, but start from year 1970 */
143 rtc_tm.tm_mon = mon;
144 if ((year += (epoch - 1900)) <= 69)
145 year += 100;
146 rtc_tm.tm_year = year + 1900;
147
148 rtc_tm.tm_yday = 0; /* Not implemented for now */
149 rtc_tm.tm_isdst = -1; /* Not implemented for now */
150
151 (*((struct tm*)buf)) = rtc_tm;
152 return 1;
153}
154
155#if 0
156void get_rtc_alm_time(struct rtc_time *alm_tm)
157{
158 unsigned int sec,mon,mday,wday,year,hour,min;
159 unsigned int lval;
160 unsigned long flags;
161 /*
162 * Only the values that we read from the RTC are set. That
163 * means only tm_hour, tm_min, and tm_sec.
164 */
165 lval = REG_RTC_RSAR;
166 jz_gettime(lval, &year, &mon, &mday, &hour, &min, &sec, &wday);
167
168 alm_tm->tm_sec = sec;
169 alm_tm->tm_min = min;
170 alm_tm->tm_hour = hour;
171}
172
173
174int rtc_ioctl(unsigned int cmd,struct rtc_time *val,unsigned int epo)
175{
176 struct rtc_time wtime;
177 switch (cmd) {
178 case RTC_ALM_READ: /* Read the present alarm time */
179 /*
180 * This returns a struct rtc_time. Reading >= 0xc0
181 * means "don't care" or "match all". Only the tm_hour,
182 * tm_min, and tm_sec values are filled in.
183 */
184 get_rtc_alm_time(val);
185 break;
186 case RTC_ALM_SET: /* Store a time into the alarm */
187 {
188 unsigned char ahrs, amin, asec;
189 unsigned int sec,mon,mday,wday,year,hour,min;
190 unsigned int lval;
191 unsigned long flags;
192 struct rtc_time alm_tm;
193
194 alm_tm = *val;
195 ahrs = alm_tm.tm_hour;
196 amin = alm_tm.tm_min;
197 asec = alm_tm.tm_sec;
198
199
200
201 if (ahrs >= 24)
202 return -1;
203
204 if (amin >= 60)
205 return -1;
206
207 if (asec >= 60)
208 return -1;
209
210 flags = spin_lock_irqsave();
211 lval = REG_RTC_RSR;
212 jz_gettime(lval, &year, &mon, &mday, &hour, &min, &sec, &wday);
213 hour = ahrs;
214 min = amin;
215 sec = asec;
216 lval = jz_mktime(year, mon, mday, hour, min, sec);
217 REG_RTC_RSAR = lval;
218 spin_unlock_irqrestore(flags);
219 break;
220 }
221 case RTC_RD_TIME: /* Read the time/date from RTC */
222 get_rtc_time(val);
223 break;
224 case RTC_SET_TIME: /* Set the RTC */
225 {
226 struct rtc_time rtc_tm;
227 unsigned int mon, day, hrs, min, sec, leap_yr, date;
228 unsigned int yrs;
229 unsigned int lval;
230 unsigned long flags;
231
232 rtc_tm = *val;
233 yrs = rtc_tm.tm_year;// + 1900;
234 mon = rtc_tm.tm_mon + 1; /* tm_mon starts at zero */
235 day = rtc_tm.tm_wday;
236 date = rtc_tm.tm_mday;
237 hrs = rtc_tm.tm_hour;
238 min = rtc_tm.tm_min;
239 sec = rtc_tm.tm_sec;
240
241
242 if (yrs < 1970)
243 return -EINVAL;
244 leap_yr = ((!(yrs % 4) && (yrs % 100)) || !(yrs % 400));
245
246 if ((mon > 12) || (date == 0))
247 return -EINVAL;
248
249 if (date > (days_in_mo[mon] + ((mon == 2) && leap_yr)))
250 return -EINVAL;
251
252 if ((hrs >= 24) || (min >= 60) || (sec >= 60))
253 return -EINVAL;
254
255 if ((yrs -= epoch) > 255) /* They are unsigned */
256 return -EINVAL;
257
258 flags = spin_lock_irqsave();
259 /* These limits and adjustments are independant of
260 * whether the chip is in binary mode or not.
261 */
262
263 if (yrs > 169) {
264 spin_unlock_irqrestore(flags);
265 return -EINVAL;
266 }
267
268 yrs += epoch;
269 lval = jz_mktime(yrs, mon, date, hrs, min, sec);
270 REG_RTC_RSR = lval;
271 /* FIXME: maybe we need to write alarm register here. */
272 spin_unlock_irqrestore(flags);
273
274 return 0;
275 }
276 break;
277 case RTC_EPOCH_READ: /* Read the epoch. */
278 epo = epoch;
279 return 0;
280 case RTC_EPOCH_SET: /* Set the epoch. */
281 /*
282 * There were no RTC clocks before 1900.
283 */
284 if (epo < 1900)
285 return -EINVAL;
286
287 epoch = epo;
288 return 0;
289 default:
290 return -EINVAL;
291 }
292 return -EINVAL;
293}
294#endif
295
296#define udelay(x) for(i=0; i<x*100000; i++) asm("nop");
297void rtc_init(void)
298{
299 int i;
300 REG_RTC_RSR = 0;
301 while(!(REG_RTC_RCR & 0x80));
302 REG_RTC_RCR = 1;
303 udelay(70);
304 while(!(REG_RTC_RCR & 0x80));
305 REG_RTC_RGR = 0x7fff;
306 udelay(70);
307}
diff --git a/firmware/export/config-ondavx747.h b/firmware/export/config-ondavx747.h
index c61ee17648..96057710c0 100644
--- a/firmware/export/config-ondavx747.h
+++ b/firmware/export/config-ondavx747.h
@@ -69,7 +69,6 @@
69 69
70#define CONFIG_KEYPAD ONDAVX747_PAD 70#define CONFIG_KEYPAD ONDAVX747_PAD
71#define HAS_BUTTON_HOLD 71#define HAS_BUTTON_HOLD
72//#define HAVE_HEADPHONE_DETECTION
73#define HAVE_TOUCHPAD 72#define HAVE_TOUCHPAD
74#define HAVE_BUTTON_DATA 73#define HAVE_BUTTON_DATA
75 74
@@ -77,7 +76,7 @@
77#define CONFIG_CODEC SWCODEC 76#define CONFIG_CODEC SWCODEC
78 77
79/* define this if you have a real-time clock */ 78/* define this if you have a real-time clock */
80//#define CONFIG_RTC RTC_RX5X348AB 79#define CONFIG_RTC RTC_JZ47XX
81 80
82/* Define this for LCD backlight available */ 81/* Define this for LCD backlight available */
83#define HAVE_BACKLIGHT 82#define HAVE_BACKLIGHT
@@ -92,7 +91,6 @@
92 91
93/* Define this if you have a software controlled poweroff */ 92/* Define this if you have a software controlled poweroff */
94//#define HAVE_SW_POWEROFF 93//#define HAVE_SW_POWEROFF
95//TODO: enable this back
96 94
97/* The number of bytes reserved for loadable codecs */ 95/* The number of bytes reserved for loadable codecs */
98#define CODEC_SIZE 0x80000 96#define CODEC_SIZE 0x80000
@@ -101,7 +99,7 @@
101#define PLUGIN_BUFFER_SIZE 0x100000 99#define PLUGIN_BUFFER_SIZE 0x100000
102 100
103/* Define this if you have the */ 101/* Define this if you have the */
104//#define HAVE_TLV320 102//#define HAVE_INGENIC_CODEC
105 103
106#define CONFIG_I2C I2C_JZ47XX 104#define CONFIG_I2C I2C_JZ47XX
107 105
@@ -129,7 +127,7 @@
129#define HAVE_POWEROFF_WHILE_CHARGING 127#define HAVE_POWEROFF_WHILE_CHARGING
130 128
131/* Define this to the CPU frequency */ 129/* Define this to the CPU frequency */
132#define CPU_FREQ 16934400 130#define CPU_FREQ 3686400
133 131
134/* define this if you have a flash memory storage */ 132/* define this if you have a flash memory storage */
135#define HAVE_FLASH_STORAGE 133#define HAVE_FLASH_STORAGE
diff --git a/firmware/target/mips/ingenic_jz47xx/ata-jz4740.c b/firmware/export/nand_id.h
index b907bb86df..a47a38eea2 100644
--- a/firmware/target/mips/ingenic_jz47xx/ata-jz4740.c
+++ b/firmware/export/nand_id.h
@@ -5,9 +5,9 @@
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < 5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ 6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/ 7 * \/ \/ \/ \/ \/
8 * $Id$ 8 * $Id: ata.h 17847 2008-06-28 18:10:04Z bagder $
9 * 9 *
10 * Copyright (C) 2008 by Maurus Cuelenaere 10 * Copyright (C) 2002 by Alan Korr
11 * 11 *
12 * This program is free software; you can redistribute it and/or 12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License 13 * modify it under the terms of the GNU General Public License
@@ -18,23 +18,21 @@
18 * KIND, either express or implied. 18 * KIND, either express or implied.
19 * 19 *
20 ****************************************************************************/ 20 ****************************************************************************/
21 21#ifndef __NAND_ID_H__
22#include "config.h" 22#define __NAND_ID_H__
23#include "jz4740.h"
24#include "ata.h"
25 23
26int ata_read_sectors(IF_MV2(int drive,) unsigned long start, int count, void* buf) 24struct nand_info
27{ 25{
28 (void)start; 26 unsigned char dev_id;
29 (void)count; 27 unsigned char dev_id2;
30 (void)buf; 28 unsigned short pages_per_block;
31 return 0; 29 unsigned short blocks_per_bank;
32} 30 unsigned short page_size;
31 unsigned short spare_size;
32 unsigned short col_cycles;
33 unsigned short row_cycles;
34};
33 35
34int ata_write_sectors(IF_MV2(int drive,) unsigned long start, int count, const void* buf) 36struct nand_info* nand_identify(unsigned char data[5]);
35{ 37
36 (void)start; 38#endif /* __NAND_ID_H__ */
37 (void)count;
38 (void)buf;
39 return 0;
40}
diff --git a/firmware/target/mips/ingenic_jz47xx/ata-nand-jz4740.c b/firmware/target/mips/ingenic_jz47xx/ata-nand-jz4740.c
new file mode 100644
index 0000000000..ad053c7deb
--- /dev/null
+++ b/firmware/target/mips/ingenic_jz47xx/ata-nand-jz4740.c
@@ -0,0 +1,68 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
9 *
10 * Copyright (C) 2008 by Maurus Cuelenaere
11 *
12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License
14 * as published by the Free Software Foundation; either version 2
15 * of the License, or (at your option) any later version.
16 *
17 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
18 * KIND, either express or implied.
19 *
20 ****************************************************************************/
21
22#include "config.h"
23#include "jz4740.h"
24#include "ata.h"
25
26#define NAND_CMD_READ1_00 0x00
27#define NAND_CMD_READ1_01 0x01
28#define NAND_CMD_READ2 0x50
29#define NAND_CMD_READ_ID1 0x90
30#define NAND_CMD_READ_ID2 0x91
31#define NAND_CMD_RESET 0xFF
32#define NAND_CMD_PAGE_PROGRAM_START 0x80
33#define NAND_CMD_PAGE_PROGRAM_STOP 0x10
34#define NAND_CMD_BLOCK_ERASE_START 0x60
35#define NAND_CMD_BLOCK_ERASE_CONFIRM 0xD0
36#define NAND_CMD_READ_STATUS 0x70
37
38#define NANDFLASH_CLE 0x00008000 //PA[15]
39#define NANDFLASH_ALE 0x00010000 //PA[16]
40
41#define NANDFLASH_BASE 0xB8000000
42#define REG_NAND_DATA (*((volatile unsigned char *) NANDFLASH_BASE))
43#define REG_NAND_CMD (*((volatile unsigned char *) (NANDFLASH_BASE + NANDFLASH_CLE)))
44#define REG_NAND_ADDR (*((volatile unsigned char *) (NANDFLASH_BASE + NANDFLASH_ALE)))
45
46#define JZ_NAND_SET_CLE (NANDFLASH_BASE |= NANDFLASH_CLE)
47#define JZ_NAND_CLR_CLE (NANDFLASH_BASE &= ~NANDFLASH_CLE)
48#define JZ_NAND_SET_ALE (NANDFLASH_BASE |= NANDFLASH_ALE)
49#define JZ_NAND_CLR_ALE (NANDFLASH_BASE &= ~NANDFLASH_ALE)
50
51#define JZ_NAND_SELECT (REG_EMC_NFCSR |= EMC_NFCSR_NFCE1 )
52#define JZ_NAND_DESELECT (REG_EMC_NFCSR &= ~(EMC_NFCSR_NFCE1))
53
54int ata_read_sectors(IF_MV2(int drive,) unsigned long start, int count, void* buf)
55{
56 (void)start;
57 (void)count;
58 (void)buf;
59 return 0;
60}
61
62int ata_write_sectors(IF_MV2(int drive,) unsigned long start, int count, const void* buf)
63{
64 (void)start;
65 (void)count;
66 (void)buf;
67 return 0;
68}
diff --git a/firmware/target/mips/ingenic_jz47xx/onda_vx747/button-onda_vx747.c b/firmware/target/mips/ingenic_jz47xx/onda_vx747/button-onda_vx747.c
index 90dc0b83fb..950fc51d69 100644
--- a/firmware/target/mips/ingenic_jz47xx/onda_vx747/button-onda_vx747.c
+++ b/firmware/target/mips/ingenic_jz47xx/onda_vx747/button-onda_vx747.c
@@ -32,16 +32,16 @@
32 | BTN_MENU | BTN_OFF ) 32 | BTN_MENU | BTN_OFF )
33 33
34#define SADC_CFG_INIT ( \ 34#define SADC_CFG_INIT ( \
35 (2 << SADC_CFG_CLKOUT_NUM_BIT) | \ 35 (2 << SADC_CFG_CLKOUT_NUM_BIT) | \
36 SADC_CFG_XYZ1Z2 | \ 36 SADC_CFG_XYZ1Z2 | \
37 SADC_CFG_SNUM_5 | \ 37 SADC_CFG_SNUM_5 | \
38 (1 << SADC_CFG_CLKDIV_BIT) | \ 38 (1 << SADC_CFG_CLKDIV_BIT) | \
39 SADC_CFG_PBAT_HIGH | \ 39 SADC_CFG_PBAT_HIGH | \
40 SADC_CFG_CMD_INT_PEN ) 40 SADC_CFG_CMD_INT_PEN )
41 41
42bool button_hold(void) 42bool button_hold(void)
43{ 43{
44 return (REG_GPIO_PXPIN(3) ^ BTN_HOLD ? 1 : 0); 44 return (~REG_GPIO_PXPIN(3) & BTN_HOLD ? 1 : 0);
45} 45}
46 46
47void button_init_device(void) 47void button_init_device(void)
@@ -54,7 +54,7 @@ void button_init_device(void)
54 REG_SADC_CFG = SADC_CFG_INIT; 54 REG_SADC_CFG = SADC_CFG_INIT;
55 55
56 REG_SADC_SAMETIME = 1; 56 REG_SADC_SAMETIME = 1;
57 REG_SADC_WAITTIME = 1000; //per 100 HZ 57 REG_SADC_WAITTIME = 1000; /* per 100 HZ */
58 REG_SADC_STATE &= (~REG_SADC_STATE); 58 REG_SADC_STATE &= (~REG_SADC_STATE);
59 REG_SADC_CTRL &= (~(SADC_CTRL_PENDM | SADC_CTRL_TSRDYM)); 59 REG_SADC_CTRL &= (~(SADC_CTRL_PENDM | SADC_CTRL_TSRDYM));
60 REG_SADC_ENA = SADC_ENA_TSEN; // | REG_SADC_ENA;//SADC_ENA_TSEN | SADC_ENA_PBATEN | SADC_ENA_SADCINEN; 60 REG_SADC_ENA = SADC_ENA_TSEN; // | REG_SADC_ENA;//SADC_ENA_TSEN | SADC_ENA_PBATEN | SADC_ENA_SADCINEN;
@@ -66,14 +66,21 @@ static int touch_to_pixels(short x, short y)
66 x -= 300; 66 x -= 300;
67 y -= 300; 67 y -= 300;
68 68
69 x /= 3200 / LCD_WIDTH; 69 /* X & Y are switched */
70 y /= 3600 / LCD_HEIGHT; 70 x /= 3200 / LCD_HEIGHT;
71 71 y /= 3600 / LCD_WIDTH;
72 return (x << 16) | y; 72
73 x = LCD_HEIGHT - x;
74 y = LCD_WIDTH - y;
75
76 return (y << 16) | x;
73} 77}
74 78
75int button_read_device(int *data) 79int button_read_device(int *data)
76{ 80{
81 if(button_hold())
82 return 0;
83
77 unsigned int key = ~REG_GPIO_PXPIN(3); 84 unsigned int key = ~REG_GPIO_PXPIN(3);
78 int ret = 0; 85 int ret = 0;
79 if(key & BTN_MASK) 86 if(key & BTN_MASK)
@@ -114,6 +121,8 @@ int button_read_device(int *data)
114 REG_SADC_STATE = 0; 121 REG_SADC_STATE = 0;
115 //__intc_unmask_irq(IRQ_SADC); 122 //__intc_unmask_irq(IRQ_SADC);
116 } 123 }
124 else
125 *data = 0;
117 126
118 return ret; 127 return ret;
119} 128}
diff --git a/firmware/target/mips/ingenic_jz47xx/system-jz4740.c b/firmware/target/mips/ingenic_jz47xx/system-jz4740.c
index 4963cac517..ee50520243 100644
--- a/firmware/target/mips/ingenic_jz47xx/system-jz4740.c
+++ b/firmware/target/mips/ingenic_jz47xx/system-jz4740.c
@@ -22,19 +22,17 @@
22#include "config.h" 22#include "config.h"
23#include "jz4740.h" 23#include "jz4740.h"
24#include "mipsregs.h" 24#include "mipsregs.h"
25#include "panic.h"
25 26
26void intr_handler(void) 27void intr_handler(void)
27{ 28{
29 _printf("Interrupt!");
28 return; 30 return;
29} 31}
30 32
31void except_handler(void* stack_ptr, unsigned int cause, unsigned int epc) 33void except_handler(void* stack_ptr, unsigned int cause, unsigned int epc)
32{ 34{
33 (void)stack_ptr; 35 panicf("Exception occurred: [0x%x] at 0x%x (stack at 0x%x)", cause, epc, (unsigned int)stack_ptr);
34 (void)cause;
35 (void)epc;
36 REG8(USB_REG_POWER) &= ~USB_POWER_SOFTCONN;
37 while(1);
38} 36}
39 37
40void system_reboot(void) 38void system_reboot(void)