diff options
-rw-r--r-- | bootloader/samsung_yps3.c | 14 | ||||
-rw-r--r-- | firmware/SOURCES | 1 | ||||
-rw-r--r-- | firmware/target/arm/s5l8700/yps3/nand-target.h | 33 | ||||
-rw-r--r-- | firmware/target/arm/s5l8700/yps3/nand-yps3.c | 109 |
4 files changed, 157 insertions, 0 deletions
diff --git a/bootloader/samsung_yps3.c b/bootloader/samsung_yps3.c index e541ff2f53..6d12f684fc 100644 --- a/bootloader/samsung_yps3.c +++ b/bootloader/samsung_yps3.c | |||
@@ -55,6 +55,7 @@ | |||
55 | #include "si4700.h" | 55 | #include "si4700.h" |
56 | #include "fmradio_i2c.h" | 56 | #include "fmradio_i2c.h" |
57 | #include "wmcodec.h" | 57 | #include "wmcodec.h" |
58 | #include "nand-target.h" | ||
58 | 59 | ||
59 | char version[] = APPSVERSION; | 60 | char version[] = APPSVERSION; |
60 | #define LONG_DELAY 200000 | 61 | #define LONG_DELAY 200000 |
@@ -82,6 +83,7 @@ void main(void) | |||
82 | unsigned int button; | 83 | unsigned int button; |
83 | unsigned int fm_frequency = 100700000; | 84 | unsigned int fm_frequency = 100700000; |
84 | int audiovol = 0x60; | 85 | int audiovol = 0x60; |
86 | unsigned nand_ids[4]; | ||
85 | 87 | ||
86 | // enable all peripherals | 88 | // enable all peripherals |
87 | PWRCON = 0; | 89 | PWRCON = 0; |
@@ -141,6 +143,11 @@ void main(void) | |||
141 | PCON5 = (PCON5 & ~0x0000000F) | 0x00000001; | 143 | PCON5 = (PCON5 & ~0x0000000F) | 0x00000001; |
142 | PDAT5 |= 1; | 144 | PDAT5 |= 1; |
143 | 145 | ||
146 | nand_ll_init(); | ||
147 | for (i = 0; i < 4; i++) { | ||
148 | nand_ids[i] = nand_ll_read_id(i); | ||
149 | } | ||
150 | |||
144 | while (true) | 151 | while (true) |
145 | { | 152 | { |
146 | line = 1; | 153 | line = 1; |
@@ -279,6 +286,13 @@ void main(void) | |||
279 | lcd_puts(0, line++, mystring); | 286 | lcd_puts(0, line++, mystring); |
280 | #endif | 287 | #endif |
281 | 288 | ||
289 | #if 1 /* NAND debug */ | ||
290 | snprintf(mystring, 64, "NAND ID: %08X %08X", nand_ids[0], nand_ids[1]); | ||
291 | lcd_puts(0, line++, mystring); | ||
292 | snprintf(mystring, 64, "NAND ID: %08X %08X", nand_ids[2], nand_ids[3]); | ||
293 | lcd_puts(0, line++, mystring); | ||
294 | #endif | ||
295 | |||
282 | lcd_update(); | 296 | lcd_update(); |
283 | } | 297 | } |
284 | } | 298 | } |
diff --git a/firmware/SOURCES b/firmware/SOURCES index 6c2ba41dcc..bed22c97c8 100644 --- a/firmware/SOURCES +++ b/firmware/SOURCES | |||
@@ -1421,6 +1421,7 @@ target/arm/s5l8700/yps3/button-yps3.c | |||
1421 | target/arm/s5l8700/yps3/lcd-yps3.c | 1421 | target/arm/s5l8700/yps3/lcd-yps3.c |
1422 | target/arm/s5l8700/yps3/fmradio-i2c-yps3.c | 1422 | target/arm/s5l8700/yps3/fmradio-i2c-yps3.c |
1423 | target/arm/s5l8700/yps3/backlight-yps3.c | 1423 | target/arm/s5l8700/yps3/backlight-yps3.c |
1424 | target/arm/s5l8700/yps3/nand-yps3.c | ||
1424 | target/arm/s5l8700/yps3/power-yps3.c | 1425 | target/arm/s5l8700/yps3/power-yps3.c |
1425 | #endif /* SAMSUNG_YPS3 */ | 1426 | #endif /* SAMSUNG_YPS3 */ |
1426 | 1427 | ||
diff --git a/firmware/target/arm/s5l8700/yps3/nand-target.h b/firmware/target/arm/s5l8700/yps3/nand-target.h new file mode 100644 index 0000000000..b617c2c27f --- /dev/null +++ b/firmware/target/arm/s5l8700/yps3/nand-target.h | |||
@@ -0,0 +1,33 @@ | |||
1 | /*************************************************************************** | ||
2 | * __________ __ ___. | ||
3 | * Open \______ \ ____ ____ | | _\_ |__ _______ ___ | ||
4 | * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / | ||
5 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < | ||
6 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ | ||
7 | * \/ \/ \/ \/ \/ | ||
8 | * $Id$ | ||
9 | * | ||
10 | * Copyright (C) 2009 Bertrik Sikken | ||
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 | #ifndef _NAND_TARGET_H_ | ||
23 | #define _NAND_TARGET_H_ | ||
24 | |||
25 | #include "config.h" | ||
26 | |||
27 | void nand_ll_init(void); | ||
28 | unsigned int nand_ll_read_id(int bank); | ||
29 | |||
30 | /* TODO later: create nand_ll_read/write/erase prototypes */ | ||
31 | |||
32 | #endif /* _NAND_TARGET_H_ */ | ||
33 | |||
diff --git a/firmware/target/arm/s5l8700/yps3/nand-yps3.c b/firmware/target/arm/s5l8700/yps3/nand-yps3.c new file mode 100644 index 0000000000..743c74261a --- /dev/null +++ b/firmware/target/arm/s5l8700/yps3/nand-yps3.c | |||
@@ -0,0 +1,109 @@ | |||
1 | /*************************************************************************** | ||
2 | * __________ __ ___. | ||
3 | * Open \______ \ ____ ____ | | _\_ |__ _______ ___ | ||
4 | * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / | ||
5 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < | ||
6 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ | ||
7 | * \/ \/ \/ \/ \/ | ||
8 | * $Id$ | ||
9 | * | ||
10 | * Copyright (C) 2009 Bertrik Sikken | ||
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 | #include <string.h> | ||
22 | |||
23 | #include "config.h" | ||
24 | #include "s5l8700.h" | ||
25 | #include "nand-target.h" | ||
26 | |||
27 | /* Driver for the S5L8700 flash memory controller for low-level access to the | ||
28 | NAND flash of the Samsung YP-S3. | ||
29 | |||
30 | The YP-S3 seems to use the pins P6.5 and P6.6 as chip selects in GPIO mode | ||
31 | instead of using the regular pins P6.3 and P6.4. | ||
32 | */ | ||
33 | |||
34 | #define FMSTAT_RBB (1<<0) | ||
35 | #define FMSTAT_RBBDone (1<<1) | ||
36 | #define FMSTAT_CMDDone (1<<2) | ||
37 | #define FMSTAT_AddrDone (1<<3) | ||
38 | #define FMSTAT_TransDone (1<<4) | ||
39 | #define FMSTAT_WFIFO_HEMPTY (1<<5) | ||
40 | #define FMSTAT_RFIFO_HFULL (1<<6) | ||
41 | #define FMSTAT_WFIFO_EMPTY (1<<8) | ||
42 | #define FMSTAT_RFIFO_FULL (1<<9) | ||
43 | #define FMSTAT_EndECC (1<<10) | ||
44 | |||
45 | #define FMCTRL1_DoTransAddr (1<<0) | ||
46 | #define FMCTRL1_DoReadData (1<<1) | ||
47 | #define FMCTRL1_DoWriteData (1<<2) | ||
48 | #define FMCTRL1_WriteREQSEL (1<<4) | ||
49 | #define FMCTRL1_ClearSyndPtr (1<<5) | ||
50 | #define FMCTRL1_ClearWFIFO (1<<6) | ||
51 | #define FMCTRL1_ClearRFIFO (1<<7) | ||
52 | #define FMCTRL1_ParityPtr (1<<8) | ||
53 | #define FMCTRL1_SyndPtr (1<<9) | ||
54 | |||
55 | static void nand_chip_select(int bank) | ||
56 | { | ||
57 | unsigned int select; | ||
58 | |||
59 | select = (1 << bank); | ||
60 | FMCTRL0 = 0x1821 | ((select & 3) << 1); | ||
61 | PDAT6 = (PDAT6 & ~0x60) | ((~select & 0xC) << 3); | ||
62 | } | ||
63 | |||
64 | void nand_ll_init(void) | ||
65 | { | ||
66 | /* enable flash memory controller */ | ||
67 | PWRCON &= ~(1 << 1); | ||
68 | |||
69 | /* P2.X is SMC I/O */ | ||
70 | PCON2 = 0x55555555; | ||
71 | /* P4.1 = CLE, P4.4 = nWR, P4.5 = nRD */ | ||
72 | PCON4 = (PCON4 & ~0x00FF00F0) | 0x00550050; | ||
73 | /* P6.0 = nf_rbn, P6.1 = smc_ce0, P6.2 = smc_ce1, | ||
74 | P6.5 = smc_ce2 (as GPIO), P6.6 = smc_ce3 (as GPIO), P6.7 = ALE */ | ||
75 | PCON6 = (PCON6 & ~0xFFF00FFF) | 0x51100555; | ||
76 | PDAT6 |= 0x60; | ||
77 | } | ||
78 | |||
79 | unsigned int nand_ll_read_id(int bank) | ||
80 | { | ||
81 | unsigned int nand_id; | ||
82 | |||
83 | nand_chip_select(bank); | ||
84 | |||
85 | /* send "read id" command */ | ||
86 | FMCMD = 0x90; | ||
87 | while ((FMCSTAT & FMSTAT_CMDDone) == 0); | ||
88 | FMCSTAT = FMSTAT_CMDDone; | ||
89 | |||
90 | /* transfer address */ | ||
91 | FMANUM = 0; | ||
92 | FMADDR0 = 0; | ||
93 | FMCTRL1 = FMCTRL1_DoTransAddr; | ||
94 | while ((FMCSTAT & FMSTAT_AddrDone) == 0); | ||
95 | FMCSTAT = FMSTAT_AddrDone; | ||
96 | |||
97 | /* read back data */ | ||
98 | FMDNUM = 3; | ||
99 | FMCTRL1 = FMCTRL1_DoReadData; | ||
100 | while ((FMCSTAT & FMSTAT_TransDone) == 0); | ||
101 | FMCSTAT = FMSTAT_TransDone; | ||
102 | nand_id = FMFIFO; | ||
103 | |||
104 | /* clear read FIFO */ | ||
105 | FMCTRL1 = FMCTRL1_ClearRFIFO; | ||
106 | |||
107 | return nand_id; | ||
108 | } | ||
109 | |||