aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/mtd/nand/edb7312.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/mtd/nand/edb7312.c')
-rw-r--r--drivers/mtd/nand/edb7312.c53
1 files changed, 26 insertions, 27 deletions
diff --git a/drivers/mtd/nand/edb7312.c b/drivers/mtd/nand/edb7312.c
index 9b1fd2f387fa..8467d770710c 100644
--- a/drivers/mtd/nand/edb7312.c
+++ b/drivers/mtd/nand/edb7312.c
@@ -25,7 +25,7 @@
25#include <linux/mtd/nand.h> 25#include <linux/mtd/nand.h>
26#include <linux/mtd/partitions.h> 26#include <linux/mtd/partitions.h>
27#include <asm/io.h> 27#include <asm/io.h>
28#include <asm/arch/hardware.h> /* for CLPS7111_VIRT_BASE */ 28#include <asm/arch/hardware.h> /* for CLPS7111_VIRT_BASE */
29#include <asm/sizes.h> 29#include <asm/sizes.h>
30#include <asm/hardware/clps7111.h> 30#include <asm/hardware/clps7111.h>
31 31
@@ -54,29 +54,29 @@ static struct mtd_info *ep7312_mtd = NULL;
54 */ 54 */
55 55
56static unsigned long ep7312_fio_pbase = EP7312_FIO_PBASE; 56static unsigned long ep7312_fio_pbase = EP7312_FIO_PBASE;
57static void __iomem * ep7312_pxdr = (void __iomem *) EP7312_PXDR; 57static void __iomem *ep7312_pxdr = (void __iomem *)EP7312_PXDR;
58static void __iomem * ep7312_pxddr = (void __iomem *) EP7312_PXDDR; 58static void __iomem *ep7312_pxddr = (void __iomem *)EP7312_PXDDR;
59 59
60#ifdef CONFIG_MTD_PARTITIONS 60#ifdef CONFIG_MTD_PARTITIONS
61/* 61/*
62 * Define static partitions for flash device 62 * Define static partitions for flash device
63 */ 63 */
64static struct mtd_partition partition_info[] = { 64static struct mtd_partition partition_info[] = {
65 { .name = "EP7312 Nand Flash", 65 {.name = "EP7312 Nand Flash",
66 .offset = 0, 66 .offset = 0,
67 .size = 8*1024*1024 } 67 .size = 8 * 1024 * 1024}
68}; 68};
69
69#define NUM_PARTITIONS 1 70#define NUM_PARTITIONS 1
70 71
71#endif 72#endif
72 73
73
74/* 74/*
75 * hardware specific access to control-lines 75 * hardware specific access to control-lines
76 */ 76 */
77static void ep7312_hwcontrol(struct mtd_info *mtd, int cmd) 77static void ep7312_hwcontrol(struct mtd_info *mtd, int cmd)
78{ 78{
79 switch(cmd) { 79 switch (cmd) {
80 80
81 case NAND_CTL_SETCLE: 81 case NAND_CTL_SETCLE:
82 clps_writeb(clps_readb(ep7312_pxdr) | 0x10, ep7312_pxdr); 82 clps_writeb(clps_readb(ep7312_pxdr) | 0x10, ep7312_pxdr);
@@ -108,6 +108,7 @@ static int ep7312_device_ready(struct mtd_info *mtd)
108{ 108{
109 return 1; 109 return 1;
110} 110}
111
111#ifdef CONFIG_MTD_PARTITIONS 112#ifdef CONFIG_MTD_PARTITIONS
112const char *part_probes[] = { "cmdlinepart", NULL }; 113const char *part_probes[] = { "cmdlinepart", NULL };
113#endif 114#endif
@@ -115,18 +116,16 @@ const char *part_probes[] = { "cmdlinepart", NULL };
115/* 116/*
116 * Main initialization routine 117 * Main initialization routine
117 */ 118 */
118static int __init ep7312_init (void) 119static int __init ep7312_init(void)
119{ 120{
120 struct nand_chip *this; 121 struct nand_chip *this;
121 const char *part_type = 0; 122 const char *part_type = 0;
122 int mtd_parts_nb = 0; 123 int mtd_parts_nb = 0;
123 struct mtd_partition *mtd_parts = 0; 124 struct mtd_partition *mtd_parts = 0;
124 void __iomem * ep7312_fio_base; 125 void __iomem *ep7312_fio_base;
125 126
126 /* Allocate memory for MTD device structure and private data */ 127 /* Allocate memory for MTD device structure and private data */
127 ep7312_mtd = kmalloc(sizeof(struct mtd_info) + 128 ep7312_mtd = kmalloc(sizeof(struct mtd_info) + sizeof(struct nand_chip), GFP_KERNEL);
128 sizeof(struct nand_chip),
129 GFP_KERNEL);
130 if (!ep7312_mtd) { 129 if (!ep7312_mtd) {
131 printk("Unable to allocate EDB7312 NAND MTD device structure.\n"); 130 printk("Unable to allocate EDB7312 NAND MTD device structure.\n");
132 return -ENOMEM; 131 return -ENOMEM;
@@ -134,18 +133,18 @@ static int __init ep7312_init (void)
134 133
135 /* map physical adress */ 134 /* map physical adress */
136 ep7312_fio_base = ioremap(ep7312_fio_pbase, SZ_1K); 135 ep7312_fio_base = ioremap(ep7312_fio_pbase, SZ_1K);
137 if(!ep7312_fio_base) { 136 if (!ep7312_fio_base) {
138 printk("ioremap EDB7312 NAND flash failed\n"); 137 printk("ioremap EDB7312 NAND flash failed\n");
139 kfree(ep7312_mtd); 138 kfree(ep7312_mtd);
140 return -EIO; 139 return -EIO;
141 } 140 }
142 141
143 /* Get pointer to private data */ 142 /* Get pointer to private data */
144 this = (struct nand_chip *) (&ep7312_mtd[1]); 143 this = (struct nand_chip *)(&ep7312_mtd[1]);
145 144
146 /* Initialize structures */ 145 /* Initialize structures */
147 memset((char *) ep7312_mtd, 0, sizeof(struct mtd_info)); 146 memset(ep7312_mtd, 0, sizeof(struct mtd_info));
148 memset((char *) this, 0, sizeof(struct nand_chip)); 147 memset(this, 0, sizeof(struct nand_chip));
149 148
150 /* Link the private data with the MTD structure */ 149 /* Link the private data with the MTD structure */
151 ep7312_mtd->priv = this; 150 ep7312_mtd->priv = this;
@@ -165,16 +164,14 @@ static int __init ep7312_init (void)
165 this->chip_delay = 15; 164 this->chip_delay = 15;
166 165
167 /* Scan to find existence of the device */ 166 /* Scan to find existence of the device */
168 if (nand_scan (ep7312_mtd, 1)) { 167 if (nand_scan(ep7312_mtd, 1)) {
169 iounmap((void *)ep7312_fio_base); 168 iounmap((void *)ep7312_fio_base);
170 kfree (ep7312_mtd); 169 kfree(ep7312_mtd);
171 return -ENXIO; 170 return -ENXIO;
172 } 171 }
173
174#ifdef CONFIG_MTD_PARTITIONS 172#ifdef CONFIG_MTD_PARTITIONS
175 ep7312_mtd->name = "edb7312-nand"; 173 ep7312_mtd->name = "edb7312-nand";
176 mtd_parts_nb = parse_mtd_partitions(ep7312_mtd, part_probes, 174 mtd_parts_nb = parse_mtd_partitions(ep7312_mtd, part_probes, &mtd_parts, 0);
177 &mtd_parts, 0);
178 if (mtd_parts_nb > 0) 175 if (mtd_parts_nb > 0)
179 part_type = "command line"; 176 part_type = "command line";
180 else 177 else
@@ -193,24 +190,26 @@ static int __init ep7312_init (void)
193 /* Return happy */ 190 /* Return happy */
194 return 0; 191 return 0;
195} 192}
193
196module_init(ep7312_init); 194module_init(ep7312_init);
197 195
198/* 196/*
199 * Clean up routine 197 * Clean up routine
200 */ 198 */
201static void __exit ep7312_cleanup (void) 199static void __exit ep7312_cleanup(void)
202{ 200{
203 struct nand_chip *this = (struct nand_chip *) &ep7312_mtd[1]; 201 struct nand_chip *this = (struct nand_chip *)&ep7312_mtd[1];
204 202
205 /* Release resources, unregister device */ 203 /* Release resources, unregister device */
206 nand_release (ap7312_mtd); 204 nand_release(ap7312_mtd);
207 205
208 /* Free internal data buffer */ 206 /* Free internal data buffer */
209 kfree (this->data_buf); 207 kfree(this->data_buf);
210 208
211 /* Free the MTD device structure */ 209 /* Free the MTD device structure */
212 kfree (ep7312_mtd); 210 kfree(ep7312_mtd);
213} 211}
212
214module_exit(ep7312_cleanup); 213module_exit(ep7312_cleanup);
215 214
216MODULE_LICENSE("GPL"); 215MODULE_LICENSE("GPL");