1 Index: stblinux-2.6.12/drivers/mtd/nand/Kconfig
2 ===================================================================
3 --- stblinux-2.6.12.orig/drivers/mtd/nand/Kconfig 2006-10-10 20:27:00.000000000 +0200
4 +++ stblinux-2.6.12/drivers/mtd/nand/Kconfig 2007-04-25 02:36:25.000000000 +0200
7 Enables access to the Smart Media card interface on the AT91RM9200.
9 +config MTD_NAND_DM8000
10 + bool "DM8000 NAND support"
13 config MTD_NAND_NANDSIM
14 tristate "Support for NAND Flash Simulator"
15 depends on m && MTD_NAND && MTD_PARTITIONS
16 Index: stblinux-2.6.12/drivers/mtd/nand/Makefile
17 ===================================================================
18 --- stblinux-2.6.12.orig/drivers/mtd/nand/Makefile 2006-10-10 20:27:00.000000000 +0200
19 +++ stblinux-2.6.12/drivers/mtd/nand/Makefile 2007-04-25 02:36:25.000000000 +0200
21 obj-$(CONFIG_MTD_NAND_AU1550) += au1550nd.o
22 obj-$(CONFIG_MTD_NAND_PPCHAMELEONEVB) += ppchameleonevb.o
23 obj-$(CONFIG_MTD_NAND_S3C2410) += s3c2410.o
24 +obj-$(CONFIG_MTD_NAND_DM8000) += dm8000.o
25 obj-$(CONFIG_MTD_NAND_DISKONCHIP) += diskonchip.o
26 obj-$(CONFIG_MTD_NAND_H1900) += h1910.o
27 obj-$(CONFIG_MTD_NAND_RTC_FROM4) += rtc_from4.o
28 Index: stblinux-2.6.12/drivers/mtd/nand/dm8000.c
29 ===================================================================
30 --- /dev/null 1970-01-01 00:00:00.000000000 +0000
31 +++ stblinux-2.6.12/drivers/mtd/nand/dm8000.c 2007-04-25 16:09:12.000000000 +0200
34 + * drivers/mtd/nand/dm8000.c
36 + * Copyright (C) 2000 Steven J. Hill (sjhill@realitydiluted.com)
38 + * Modified for Dreambox DM8000 by Felix Domke <tmbinc@elitedvb.net>
41 + * This program is free software; you can redistribute it and/or modify
42 + * it under the terms of the GNU General Public License version 2 as
43 + * published by the Free Software Foundation.
46 + * This is a device driver for the NAND flash device found on the
51 +#include <linux/slab.h>
52 +#include <linux/module.h>
53 +#include <linux/mtd/mtd.h>
54 +#include <linux/mtd/nand.h>
55 +#include <linux/mtd/partitions.h>
58 +static struct mtd_info *dm8000_mtd = NULL;
60 + * Define partitions for flash device
62 +const static struct mtd_partition partition_info[] = {
66 + .size = 256*1024*1024
74 + .name = "boot partition",
75 + .offset = 1024*1024,
79 + .name = "root partition",
80 + .offset = 4*1024*1024,
81 + .size = 60*1024*1024
84 + .name = "home partition",
85 + .offset = 64*1024*1024,
86 + .size = 64*1024*1024
89 + .name = "unused partition",
90 + .offset = 128*1024*1024,
91 + .size = 120*1024*1024
94 + .name = "preset partition",
95 + .offset = 248*1024*1024,
99 +#define NUM_PARTITIONS 7
102 + * hardware specific access to control-lines
103 + * our hardware logic handles the line according to the addresses.
105 +static void dm8000_hwcontrol(struct mtd_info *mtd, int cmd)
107 + struct nand_chip *this = mtd->priv;
111 + case NAND_CTL_SETCLE: this->IO_ADDR_W = (void*)0xBF030000; break; // COMMAND
112 + case NAND_CTL_CLRCLE: this->IO_ADDR_W = (void*)0xBF030004; break; // DATA
114 + case NAND_CTL_SETALE: this->IO_ADDR_W = (void*)0xBF030002; break; // ADDRESS
115 + case NAND_CTL_CLRALE: this->IO_ADDR_W = (void*)0xBF030004; break; // DATA
117 + case NAND_CTL_SETNCE: break; // CE will automatically set on command
118 + case NAND_CTL_CLRNCE: *(volatile unsigned char*)0xBF030003 = 0; break; // TERM
124 +static void dm8000_nand_read_buf(struct mtd_info *mtd, u_char *buf, int len)
126 +// struct nand_chip *this = mtd->priv;
128 + *(volatile unsigned char*)0xBF030002;
132 + *(long*)buf = *(volatile long*)(0xBF030004);
133 + *(long*)(buf+4) = *(volatile long*)(0xBF030004);
134 + *(long*)(buf+8) = *(volatile long*)(0xBF030004);
135 + *(long*)(buf+12) = *(volatile long*)(0xBF030004);
141 + *buf++ = *(volatile unsigned char*)(0xBF030004);
144 +static int dm8000_dev_ready(struct mtd_info *mtd)
146 + *(volatile unsigned char*)0xBF030002;
151 + * Main initialization routine
153 +int __init dm8000_init (void)
155 + struct nand_chip *this;
156 + unsigned char probe[4];
159 + /* Allocate memory for MTD device structure and private data */
160 + dm8000_mtd = kmalloc (sizeof(struct mtd_info) + sizeof (struct nand_chip),
163 + printk ("Unable to allocate DM8000 NAND MTD device structure.\n");
167 + /* Get pointer to private data */
168 + this = (struct nand_chip *) (&dm8000_mtd[1]);
170 + *(volatile unsigned char*)(0xBF030000) = 0x90;
171 + *(volatile unsigned char*)(0xBF030002) = 0;
172 + probe[0] = *(volatile unsigned char*)(0xBF030004);
173 + probe[1] = *(volatile unsigned char*)(0xBF030004);
174 + probe[2] = *(volatile unsigned char*)(0xBF030004);
175 + probe[3] = *(volatile unsigned char*)(0xBF030004);
176 + *(volatile unsigned char*)(0xBF030003) = 0; // term
179 + for (i=0; i<1000*1000/4; ++i)
180 + *(volatile unsigned long*)(0xBF030004);
181 + printk("%ld kb/s\n", 1000 * HZ / (jiffies-j));
183 + printk(" - NAND PROBE: %02x %02x %02x %02x\n",
184 + probe[0], probe[1], probe[2], probe[3]);
186 + /* Initialize structures */
187 + memset((char *) dm8000_mtd, 0, sizeof(struct mtd_info));
188 + memset((char *) this, 0, sizeof(struct nand_chip));
190 + /* Link the private data with the MTD structure */
191 + dm8000_mtd->priv = this;
193 + /* Set address of NAND IO lines */
194 + this->IO_ADDR_R = (void*)0xBF030004;
195 + this->IO_ADDR_W = (void*)0xBF030004;
197 + /* Set address of hardware control function */
198 + this->hwcontrol = dm8000_hwcontrol;
199 + this->read_buf = dm8000_nand_read_buf;
200 + this->dev_ready = 0; // don't use dm8000_dev_ready
201 + /* 15 us command delay time */
202 + this->chip_delay = 15;
203 + this->eccmode = NAND_ECC_SOFT;
205 + /* Scan to find existence of the device */
206 + if (nand_scan (dm8000_mtd, 1)) {
207 + kfree (dm8000_mtd);
211 + /* Allocate memory for internal data buffer */
212 + this->data_buf = kmalloc (sizeof(u_char) * (dm8000_mtd->oobblock + dm8000_mtd->oobsize), GFP_KERNEL);
213 + if (!this->data_buf) {
214 + printk ("Unable to allocate NAND data buffer for Dreambox.\n");
215 + kfree (dm8000_mtd);
219 + /* Register the partitions */
220 + add_mtd_partitions(dm8000_mtd, partition_info, NUM_PARTITIONS);
225 +module_init(dm8000_init);
231 +static void __exit dm8000_cleanup (void)
233 + struct nand_chip *this = (struct nand_chip *) &dm8000_mtd[1];
235 + /* Unregister the device */
236 + del_mtd_device (dm8000_mtd);
238 + /* Free internal data buffer */
239 + kfree (this->data_buf);
241 + /* Free the MTD device structure */
242 + kfree (dm8000_mtd);
244 +module_exit(dm8000_cleanup);
247 +MODULE_LICENSE("GPL");
248 +MODULE_AUTHOR("Felix Domke <tmbinc@elitedvb.net>");
249 +MODULE_DESCRIPTION("Dream-Multimedia DM8000 NAND flash board glue");