1 Index: u-boot/common/cmd_nand.c
2 ===================================================================
3 --- u-boot.orig/common/cmd_nand.c
4 +++ u-boot/common/cmd_nand.c
7 ret = nand->write_oob(nand, off, size, &size,
9 + } else if (s != NULL && !strcmp(s, ".otp")) {
10 + /* read out-of-band data */
12 + ret = nand->read_otp(nand, off, size, &size,
15 + ret = nand->write_otp(nand, off, size, &size,
19 ret = nand_read(nand, off, &size, (u_char *)addr);
21 "nand - NAND sub-system\n",
22 "info - show available NAND devices\n"
23 "nand device [dev] - show or set current device\n"
24 - "nand read[.jffs2] - addr off|partition size\n"
25 - "nand write[.jffs2] - addr off|partiton size - read/write `size' bytes starting\n"
26 + "nand read[.jffs2, .oob, .otp] addr off|partition size\n"
27 + "nand write[.jffs2, .oob, .otp] addr off|partiton size\n"
28 + " - read/write `size' bytes starting\n"
29 " at offset `off' to/from memory address `addr'\n"
30 "nand erase [clean] [off size] - erase `size' bytes from\n"
31 " offset `off' (entire device if not specified)\n"
32 Index: u-boot/cpu/arm920t/s3c24x0/nand.c
33 ===================================================================
34 --- u-boot.orig/cpu/arm920t/s3c24x0/nand.c
35 +++ u-boot/cpu/arm920t/s3c24x0/nand.c
40 -int board_nand_init(struct nand_chip *nand)
41 +int s3c24x0_nand_init(struct nand_chip *nand)
44 u_int8_t tacls, twrph0, twrph1;
45 Index: u-boot/drivers/nand/nand_base.c
46 ===================================================================
47 --- u-boot.orig/drivers/nand/nand_base.c
48 +++ u-boot/drivers/nand/nand_base.c
49 @@ -2042,6 +2042,32 @@
54 + * See nand_read_oob and nand_write_oob
57 +static int nand_read_otp(struct mtd_info *mtd, loff_t from, size_t len,
58 + size_t *retlen, u_char *buf)
60 + struct nand_chip *this = mtd->priv;
62 + if (!this->read_otp)
64 + return this->read_otp(mtd, from, len, retlen, buf);
68 +static int nand_write_otp(struct mtd_info *mtd, loff_t to, size_t len,
69 + size_t *retlen, const u_char *buf)
71 + struct nand_chip *this = mtd->priv;
73 + if (!this->write_otp)
75 + return this->write_otp(mtd, to, len, retlen, buf);
80 * single_erease_cmd - [GENERIC] NAND standard block erase command function
81 * @mtd: MTD device structure
83 mtd->write_ecc = nand_write_ecc;
84 mtd->read_oob = nand_read_oob;
85 mtd->write_oob = nand_write_oob;
86 + mtd->read_otp = nand_read_otp;
87 + mtd->write_otp = nand_write_otp;
91 Index: u-boot/include/linux/mtd/mtd.h
92 ===================================================================
93 --- u-boot.orig/include/linux/mtd/mtd.h
94 +++ u-boot/include/linux/mtd/mtd.h
96 int (*read_oob) (struct mtd_info *mtd, loff_t from, size_t len, size_t *retlen, u_char *buf);
97 int (*write_oob) (struct mtd_info *mtd, loff_t to, size_t len, size_t *retlen, const u_char *buf);
99 + int (*read_otp) (struct mtd_info *mtd, loff_t from, size_t len, size_t *retlen, u_char *buf);
100 + int (*write_otp) (struct mtd_info *mtd, loff_t to, size_t len, size_t *retlen, const u_char *buf);
103 * Methods to access the protection register area, present in some
104 * flash devices. The user data is one time programmable but the
105 Index: u-boot/include/linux/mtd/nand.h
106 ===================================================================
107 --- u-boot.orig/include/linux/mtd/nand.h
108 +++ u-boot/include/linux/mtd/nand.h
110 void (*enable_hwecc)(struct mtd_info *mtd, int mode);
111 void (*erase_cmd)(struct mtd_info *mtd, int page);
112 int (*scan_bbt)(struct mtd_info *mtd);
113 + int (*read_otp)(struct mtd_info *mtd, loff_t from,
114 + size_t len, size_t *retlen, u_char *buf);
115 + int (*write_otp) (struct mtd_info *mtd, loff_t to,
116 + size_t len, size_t *retlen, const u_char *buf);
120 Index: u-boot/board/neo1973/gta01/Makefile
121 ===================================================================
122 --- u-boot.orig/board/neo1973/gta01/Makefile
123 +++ u-boot/board/neo1973/gta01/Makefile
128 -OBJS := gta01.o pcf50606.o ../common/cmd_neo1973.o ../common/jbt6k74.o ../common/udc.o ../common/bootmenu.o
129 +OBJS := gta01.o pcf50606.o nand.o ../common/cmd_neo1973.o ../common/jbt6k74.o ../common/udc.o ../common/bootmenu.o
130 SOBJS := ../common/lowlevel_init.o
133 Index: u-boot/board/neo1973/gta01/nand.c
134 ===================================================================
136 +++ u-boot/board/neo1973/gta01/nand.c
139 + * nand.c - Board-specific NAND setup
141 + * Copyright (C) 2007 by OpenMoko, Inc.
142 + * Written by Werner Almesberger <werner@openmoko.org>
143 + * All Rights Reserved
145 + * This program is free software; you can redistribute it and/or
146 + * modify it under the terms of the GNU General Public License as
147 + * published by the Free Software Foundation; either version 2 of
148 + * the License, or (at your option) any later version.
150 + * This program is distributed in the hope that it will be useful,
151 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
152 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
153 + * GNU General Public License for more details.
155 + * You should have received a copy of the GNU General Public License
156 + * along with this program; if not, write to the Free Software
157 + * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
158 + * MA 02111-1307 USA
162 +#include "config.h" /* nand.h needs NAND_MAX_CHIPS */
163 +#include "linux/mtd/mtd.h"
164 +#include "linux/mtd/nand.h"
165 +#include "asm/errno.h"
168 +int s3c24x0_nand_init(struct nand_chip *nand);
171 +static void samsung_nand_begin_otp(struct mtd_info *mtd)
173 + struct nand_chip *this = mtd->priv;
175 + /* @@@FIXME: this is ugly - we select the NAND chip to send the
176 + mode switch commands, knowing that it will be switched off later */
177 + this->select_chip(mtd, 0);
178 + /* "magic" mode change */
179 + this->cmdfunc(mtd, 0x30, -1, -1);
180 + this->cmdfunc(mtd, 0x65, -1, -1);
184 +static void samsung_nand_end_otp(struct mtd_info *mtd)
186 + struct nand_chip *this = mtd->priv;
188 + /* read/write deselected the chip so now we need to select again */
189 + this->select_chip(mtd, 0);
190 + this->cmdfunc(mtd, NAND_CMD_RESET, -1, -1);
191 + this->select_chip(mtd, -1);
195 +static loff_t otp_page[] = {
196 + 0x15, /* 00-XX-00-00, with XX = 15h-19h */
201 + 0x1b, /* 00-1B-00-00 */
204 +#define OTP_PAGES (sizeof(otp_page)/sizeof(*otp_page))
207 +static int convert_otp_address(loff_t *addr, size_t *len)
211 + if (*len && *addr >> 9 != (*addr+*len-1) >> 9)
216 + if (page >= OTP_PAGES)
218 + *addr = otp_page[page] << 9;
223 +static int samsung_nand_read_otp(struct mtd_info *mtd, loff_t from,
224 + size_t len, size_t *retlen, u_char *buf)
228 + ret = convert_otp_address(&from, &len);
231 + samsung_nand_begin_otp(mtd);
232 + ret = mtd->read(mtd, from, len, retlen, buf);
233 + samsung_nand_end_otp(mtd);
238 +static int samsung_nand_write_otp(struct mtd_info *mtd, loff_t to,
239 + size_t len, size_t *retlen, const u_char *buf)
243 + ret = convert_otp_address(&to, &len);
246 + samsung_nand_begin_otp(mtd);
247 + ret = mtd->write(mtd, to, len, retlen, buf);
248 + samsung_nand_end_otp(mtd);
253 +int board_nand_init(struct nand_chip *nand)
255 + nand->read_otp = samsung_nand_read_otp;
256 + nand->write_otp = samsung_nand_write_otp;
257 + return s3c24x0_nand_init(nand);
259 Index: u-boot/board/neo1973/gta02/nand.c
260 ===================================================================
262 +++ u-boot/board/neo1973/gta02/nand.c
265 + * nand.c - Board-specific NAND setup
267 + * Copyright (C) 2007 by OpenMoko, Inc.
268 + * Written by Werner Almesberger <werner@openmoko.org>
269 + * All Rights Reserved
271 + * This program is free software; you can redistribute it and/or
272 + * modify it under the terms of the GNU General Public License as
273 + * published by the Free Software Foundation; either version 2 of
274 + * the License, or (at your option) any later version.
276 + * This program is distributed in the hope that it will be useful,
277 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
278 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
279 + * GNU General Public License for more details.
281 + * You should have received a copy of the GNU General Public License
282 + * along with this program; if not, write to the Free Software
283 + * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
284 + * MA 02111-1307 USA
288 +#include "config.h" /* nand.h needs NAND_MAX_CHIPS */
289 +#include "linux/mtd/mtd.h"
290 +#include "linux/mtd/nand.h"
293 +int s3c24x0_nand_init(struct nand_chip *nand);
296 +/* Add OTP et al later */
299 +int board_nand_init(struct nand_chip *nand)
301 + return s3c24x0_nand_init(nand);