aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/mtd/nand/h1910.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/mtd/nand/h1910.c')
-rw-r--r--drivers/mtd/nand/h1910.c60
1 files changed, 29 insertions, 31 deletions
diff --git a/drivers/mtd/nand/h1910.c b/drivers/mtd/nand/h1910.c
index f68f7a99a630..9848eb09b884 100644
--- a/drivers/mtd/nand/h1910.c
+++ b/drivers/mtd/nand/h1910.c
@@ -4,7 +4,7 @@
4 * Copyright (C) 2003 Joshua Wise (joshua@joshuawise.com) 4 * Copyright (C) 2003 Joshua Wise (joshua@joshuawise.com)
5 * 5 *
6 * Derived from drivers/mtd/nand/edb7312.c 6 * Derived from drivers/mtd/nand/edb7312.c
7 * Copyright (C) 2002 Marius Grger (mag@sysgo.de) 7 * Copyright (C) 2002 Marius Grรถger (mag@sysgo.de)
8 * Copyright (c) 2001 Thomas Gleixner (gleixner@autronix.de) 8 * Copyright (c) 2001 Thomas Gleixner (gleixner@autronix.de)
9 * 9 *
10 * $Id: h1910.c,v 1.6 2005/11/07 11:14:30 gleixner Exp $ 10 * $Id: h1910.c,v 1.6 2005/11/07 11:14:30 gleixner Exp $
@@ -26,7 +26,7 @@
26#include <linux/mtd/nand.h> 26#include <linux/mtd/nand.h>
27#include <linux/mtd/partitions.h> 27#include <linux/mtd/partitions.h>
28#include <asm/io.h> 28#include <asm/io.h>
29#include <asm/arch/hardware.h> /* for CLPS7111_VIRT_BASE */ 29#include <asm/arch/hardware.h> /* for CLPS7111_VIRT_BASE */
30#include <asm/sizes.h> 30#include <asm/sizes.h>
31#include <asm/arch/h1900-gpio.h> 31#include <asm/arch/h1900-gpio.h>
32#include <asm/arch/ipaq.h> 32#include <asm/arch/ipaq.h>
@@ -45,23 +45,23 @@ static struct mtd_info *h1910_nand_mtd = NULL;
45 * Define static partitions for flash device 45 * Define static partitions for flash device
46 */ 46 */
47static struct mtd_partition partition_info[] = { 47static struct mtd_partition partition_info[] = {
48 { name: "h1910 NAND Flash", 48 {name:"h1910 NAND Flash",
49 offset: 0, 49 offset:0,
50 size: 16*1024*1024 } 50 size:16 * 1024 * 1024}
51}; 51};
52
52#define NUM_PARTITIONS 1 53#define NUM_PARTITIONS 1
53 54
54#endif 55#endif
55 56
56
57/* 57/*
58 * hardware specific access to control-lines 58 * hardware specific access to control-lines
59 */ 59 */
60static void h1910_hwcontrol(struct mtd_info *mtd, int cmd) 60static void h1910_hwcontrol(struct mtd_info *mtd, int cmd)
61{ 61{
62 struct nand_chip* this = (struct nand_chip *) (mtd->priv); 62 struct nand_chip *this = (struct nand_chip *)(mtd->priv);
63 63
64 switch(cmd) { 64 switch (cmd) {
65 65
66 case NAND_CTL_SETCLE: 66 case NAND_CTL_SETCLE:
67 this->IO_ADDR_R |= (1 << 2); 67 this->IO_ADDR_R |= (1 << 2);
@@ -101,7 +101,7 @@ static int h1910_device_ready(struct mtd_info *mtd)
101/* 101/*
102 * Main initialization routine 102 * Main initialization routine
103 */ 103 */
104static int __init h1910_init (void) 104static int __init h1910_init(void)
105{ 105{
106 struct nand_chip *this; 106 struct nand_chip *this;
107 const char *part_type = 0; 107 const char *part_type = 0;
@@ -119,24 +119,23 @@ static int __init h1910_init (void)
119 } 119 }
120 120
121 /* Allocate memory for MTD device structure and private data */ 121 /* Allocate memory for MTD device structure and private data */
122 h1910_nand_mtd = kmalloc(sizeof(struct mtd_info) + 122 h1910_nand_mtd = kmalloc(sizeof(struct mtd_info) + sizeof(struct nand_chip), GFP_KERNEL);
123 sizeof(struct nand_chip),
124 GFP_KERNEL);
125 if (!h1910_nand_mtd) { 123 if (!h1910_nand_mtd) {
126 printk("Unable to allocate h1910 NAND MTD device structure.\n"); 124 printk("Unable to allocate h1910 NAND MTD device structure.\n");
127 iounmap ((void *) nandaddr); 125 iounmap((void *)nandaddr);
128 return -ENOMEM; 126 return -ENOMEM;
129 } 127 }
130 128
131 /* Get pointer to private data */ 129 /* Get pointer to private data */
132 this = (struct nand_chip *) (&h1910_nand_mtd[1]); 130 this = (struct nand_chip *)(&h1910_nand_mtd[1]);
133 131
134 /* Initialize structures */ 132 /* Initialize structures */
135 memset((char *) h1910_nand_mtd, 0, sizeof(struct mtd_info)); 133 memset(h1910_nand_mtd, 0, sizeof(struct mtd_info));
136 memset((char *) this, 0, sizeof(struct nand_chip)); 134 memset(this, 0, sizeof(struct nand_chip));
137 135
138 /* Link the private data with the MTD structure */ 136 /* Link the private data with the MTD structure */
139 h1910_nand_mtd->priv = this; 137 h1910_nand_mtd->priv = this;
138 h1910_nand_mtd->owner = THIS_MODULE;
140 139
141 /* 140 /*
142 * Enable VPEN 141 * Enable VPEN
@@ -154,23 +153,20 @@ static int __init h1910_init (void)
154 this->options = NAND_NO_AUTOINCR; 153 this->options = NAND_NO_AUTOINCR;
155 154
156 /* Scan to find existence of the device */ 155 /* Scan to find existence of the device */
157 if (nand_scan (h1910_nand_mtd, 1)) { 156 if (nand_scan(h1910_nand_mtd, 1)) {
158 printk(KERN_NOTICE "No NAND device - returning -ENXIO\n"); 157 printk(KERN_NOTICE "No NAND device - returning -ENXIO\n");
159 kfree (h1910_nand_mtd); 158 kfree(h1910_nand_mtd);
160 iounmap ((void *) nandaddr); 159 iounmap((void *)nandaddr);
161 return -ENXIO; 160 return -ENXIO;
162 } 161 }
163
164#ifdef CONFIG_MTD_CMDLINE_PARTS 162#ifdef CONFIG_MTD_CMDLINE_PARTS
165 mtd_parts_nb = parse_cmdline_partitions(h1910_nand_mtd, &mtd_parts, 163 mtd_parts_nb = parse_cmdline_partitions(h1910_nand_mtd, &mtd_parts, "h1910-nand");
166 "h1910-nand");
167 if (mtd_parts_nb > 0) 164 if (mtd_parts_nb > 0)
168 part_type = "command line"; 165 part_type = "command line";
169 else 166 else
170 mtd_parts_nb = 0; 167 mtd_parts_nb = 0;
171#endif 168#endif
172 if (mtd_parts_nb == 0) 169 if (mtd_parts_nb == 0) {
173 {
174 mtd_parts = partition_info; 170 mtd_parts = partition_info;
175 mtd_parts_nb = NUM_PARTITIONS; 171 mtd_parts_nb = NUM_PARTITIONS;
176 part_type = "static"; 172 part_type = "static";
@@ -183,24 +179,26 @@ static int __init h1910_init (void)
183 /* Return happy */ 179 /* Return happy */
184 return 0; 180 return 0;
185} 181}
182
186module_init(h1910_init); 183module_init(h1910_init);
187 184
188/* 185/*
189 * Clean up routine 186 * Clean up routine
190 */ 187 */
191static void __exit h1910_cleanup (void) 188static void __exit h1910_cleanup(void)
192{ 189{
193 struct nand_chip *this = (struct nand_chip *) &h1910_nand_mtd[1]; 190 struct nand_chip *this = (struct nand_chip *)&h1910_nand_mtd[1];
194 191
195 /* Release resources, unregister device */ 192 /* Release resources, unregister device */
196 nand_release (h1910_nand_mtd); 193 nand_release(h1910_nand_mtd);
197 194
198 /* Release io resource */ 195 /* Release io resource */
199 iounmap ((void *) this->IO_ADDR_W); 196 iounmap((void *)this->IO_ADDR_W);
200 197
201 /* Free the MTD device structure */ 198 /* Free the MTD device structure */
202 kfree (h1910_nand_mtd); 199 kfree(h1910_nand_mtd);
203} 200}
201
204module_exit(h1910_cleanup); 202module_exit(h1910_cleanup);
205 203
206MODULE_LICENSE("GPL"); 204MODULE_LICENSE("GPL");