aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAtsushi Nemoto <anemo@mba.ocn.ne.jp>2008-08-19 09:55:11 -0400
committerRalf Baechle <ralf@linux-mips.org>2008-10-11 11:18:42 -0400
commit51f607c76e1e7bd089dcad97b6b0a58649be06a3 (patch)
treebcf9389a1e3bcd347d7c560163d2c014d804a162
parentc7b95bcb38ea492fd025008ef99501a2b90aa237 (diff)
MIPS: TXx9: Add mtd support
Add helper routines to register physmap-flash platform devices for NOR flashes. Signed-off-by: Atsushi Nemoto <anemo@mba.ocn.ne.jp> Signed-off-by: Ralf Baechle <ralf@linux-mips.org>
-rw-r--r--arch/mips/txx9/generic/setup.c41
-rw-r--r--arch/mips/txx9/generic/setup_tx3927.c14
-rw-r--r--arch/mips/txx9/generic/setup_tx4927.c14
-rw-r--r--arch/mips/txx9/generic/setup_tx4938.c14
-rw-r--r--arch/mips/txx9/jmr3927/setup.c9
-rw-r--r--arch/mips/txx9/rbtx4927/setup.c9
-rw-r--r--arch/mips/txx9/rbtx4938/setup.c38
-rw-r--r--include/asm-mips/txx9/generic.h4
-rw-r--r--include/asm-mips/txx9/tx3927.h2
-rw-r--r--include/asm-mips/txx9/tx4927.h3
-rw-r--r--include/asm-mips/txx9/tx4938.h2
11 files changed, 150 insertions, 0 deletions
diff --git a/arch/mips/txx9/generic/setup.c b/arch/mips/txx9/generic/setup.c
index fa45f174b0ee..cfa3ccf493bb 100644
--- a/arch/mips/txx9/generic/setup.c
+++ b/arch/mips/txx9/generic/setup.c
@@ -22,6 +22,7 @@
22#include <linux/gpio.h> 22#include <linux/gpio.h>
23#include <linux/platform_device.h> 23#include <linux/platform_device.h>
24#include <linux/serial_core.h> 24#include <linux/serial_core.h>
25#include <linux/mtd/physmap.h>
25#include <asm/bootinfo.h> 26#include <asm/bootinfo.h>
26#include <asm/time.h> 27#include <asm/time.h>
27#include <asm/reboot.h> 28#include <asm/reboot.h>
@@ -593,3 +594,43 @@ static unsigned long __swizzle_addr_none(unsigned long port)
593unsigned long (*__swizzle_addr_b)(unsigned long port) = __swizzle_addr_none; 594unsigned long (*__swizzle_addr_b)(unsigned long port) = __swizzle_addr_none;
594EXPORT_SYMBOL(__swizzle_addr_b); 595EXPORT_SYMBOL(__swizzle_addr_b);
595#endif 596#endif
597
598void __init txx9_physmap_flash_init(int no, unsigned long addr,
599 unsigned long size,
600 const struct physmap_flash_data *pdata)
601{
602#if defined(CONFIG_MTD_PHYSMAP) || defined(CONFIG_MTD_PHYSMAP_MODULE)
603 struct resource res = {
604 .start = addr,
605 .end = addr + size - 1,
606 .flags = IORESOURCE_MEM,
607 };
608 struct platform_device *pdev;
609#ifdef CONFIG_MTD_PARTITIONS
610 static struct mtd_partition parts[2];
611 struct physmap_flash_data pdata_part;
612
613 /* If this area contained boot area, make separate partition */
614 if (pdata->nr_parts == 0 && !pdata->parts &&
615 addr < 0x1fc00000 && addr + size > 0x1fc00000 &&
616 !parts[0].name) {
617 parts[0].name = "boot";
618 parts[0].offset = 0x1fc00000 - addr;
619 parts[0].size = addr + size - 0x1fc00000;
620 parts[1].name = "user";
621 parts[1].offset = 0;
622 parts[1].size = 0x1fc00000 - addr;
623 pdata_part = *pdata;
624 pdata_part.nr_parts = ARRAY_SIZE(parts);
625 pdata_part.parts = parts;
626 pdata = &pdata_part;
627 }
628#endif
629 pdev = platform_device_alloc("physmap-flash", no);
630 if (!pdev ||
631 platform_device_add_resources(pdev, &res, 1) ||
632 platform_device_add_data(pdev, pdata, sizeof(*pdata)) ||
633 platform_device_add(pdev))
634 platform_device_put(pdev);
635#endif
636}
diff --git a/arch/mips/txx9/generic/setup_tx3927.c b/arch/mips/txx9/generic/setup_tx3927.c
index 06c492576078..9505d58454c8 100644
--- a/arch/mips/txx9/generic/setup_tx3927.c
+++ b/arch/mips/txx9/generic/setup_tx3927.c
@@ -15,6 +15,7 @@
15#include <linux/delay.h> 15#include <linux/delay.h>
16#include <linux/param.h> 16#include <linux/param.h>
17#include <linux/io.h> 17#include <linux/io.h>
18#include <linux/mtd/physmap.h>
18#include <asm/mipsregs.h> 19#include <asm/mipsregs.h>
19#include <asm/txx9irq.h> 20#include <asm/txx9irq.h>
20#include <asm/txx9tmr.h> 21#include <asm/txx9tmr.h>
@@ -121,3 +122,16 @@ void __init tx3927_sio_init(unsigned int sclk, unsigned int cts_mask)
121 TXX9_IRQ_BASE + TX3927_IR_SIO(i), 122 TXX9_IRQ_BASE + TX3927_IR_SIO(i),
122 i, sclk, (1 << i) & cts_mask); 123 i, sclk, (1 << i) & cts_mask);
123} 124}
125
126void __init tx3927_mtd_init(int ch)
127{
128 struct physmap_flash_data pdata = {
129 .width = TX3927_ROMC_WIDTH(ch) / 8,
130 };
131 unsigned long start = txx9_ce_res[ch].start;
132 unsigned long size = txx9_ce_res[ch].end - start + 1;
133
134 if (!(tx3927_romcptr->cr[ch] & 0x8))
135 return; /* disabled */
136 txx9_physmap_flash_init(ch, start, size, &pdata);
137}
diff --git a/arch/mips/txx9/generic/setup_tx4927.c b/arch/mips/txx9/generic/setup_tx4927.c
index e679c79a4b0f..0840ef930e40 100644
--- a/arch/mips/txx9/generic/setup_tx4927.c
+++ b/arch/mips/txx9/generic/setup_tx4927.c
@@ -14,6 +14,7 @@
14#include <linux/ioport.h> 14#include <linux/ioport.h>
15#include <linux/delay.h> 15#include <linux/delay.h>
16#include <linux/param.h> 16#include <linux/param.h>
17#include <linux/mtd/physmap.h>
17#include <asm/txx9irq.h> 18#include <asm/txx9irq.h>
18#include <asm/txx9tmr.h> 19#include <asm/txx9tmr.h>
19#include <asm/txx9pio.h> 20#include <asm/txx9pio.h>
@@ -187,3 +188,16 @@ void __init tx4927_sio_init(unsigned int sclk, unsigned int cts_mask)
187 TXX9_IRQ_BASE + TX4927_IR_SIO(i), 188 TXX9_IRQ_BASE + TX4927_IR_SIO(i),
188 i, sclk, (1 << i) & cts_mask); 189 i, sclk, (1 << i) & cts_mask);
189} 190}
191
192void __init tx4927_mtd_init(int ch)
193{
194 struct physmap_flash_data pdata = {
195 .width = TX4927_EBUSC_WIDTH(ch) / 8,
196 };
197 unsigned long start = txx9_ce_res[ch].start;
198 unsigned long size = txx9_ce_res[ch].end - start + 1;
199
200 if (!(TX4927_EBUSC_CR(ch) & 0x8))
201 return; /* disabled */
202 txx9_physmap_flash_init(ch, start, size, &pdata);
203}
diff --git a/arch/mips/txx9/generic/setup_tx4938.c b/arch/mips/txx9/generic/setup_tx4938.c
index 95c058f0a96c..630a7aac61f6 100644
--- a/arch/mips/txx9/generic/setup_tx4938.c
+++ b/arch/mips/txx9/generic/setup_tx4938.c
@@ -14,6 +14,7 @@
14#include <linux/ioport.h> 14#include <linux/ioport.h>
15#include <linux/delay.h> 15#include <linux/delay.h>
16#include <linux/param.h> 16#include <linux/param.h>
17#include <linux/mtd/physmap.h>
17#include <asm/txx9irq.h> 18#include <asm/txx9irq.h>
18#include <asm/txx9tmr.h> 19#include <asm/txx9tmr.h>
19#include <asm/txx9pio.h> 20#include <asm/txx9pio.h>
@@ -269,3 +270,16 @@ void __init tx4938_ethaddr_init(unsigned char *addr0, unsigned char *addr1)
269 if (addr1 && (pcfg & TX4938_PCFG_ETH1_SEL)) 270 if (addr1 && (pcfg & TX4938_PCFG_ETH1_SEL))
270 txx9_ethaddr_init(TXX9_IRQ_BASE + TX4938_IR_ETH1, addr1); 271 txx9_ethaddr_init(TXX9_IRQ_BASE + TX4938_IR_ETH1, addr1);
271} 272}
273
274void __init tx4938_mtd_init(int ch)
275{
276 struct physmap_flash_data pdata = {
277 .width = TX4938_EBUSC_WIDTH(ch) / 8,
278 };
279 unsigned long start = txx9_ce_res[ch].start;
280 unsigned long size = txx9_ce_res[ch].end - start + 1;
281
282 if (!(TX4938_EBUSC_CR(ch) & 0x8))
283 return; /* disabled */
284 txx9_physmap_flash_init(ch, start, size, &pdata);
285}
diff --git a/arch/mips/txx9/jmr3927/setup.c b/arch/mips/txx9/jmr3927/setup.c
index 2e40a9268254..0f3843c92cf7 100644
--- a/arch/mips/txx9/jmr3927/setup.c
+++ b/arch/mips/txx9/jmr3927/setup.c
@@ -190,11 +190,20 @@ static void __init jmr3927_rtc_init(void)
190 platform_device_register_simple("rtc-ds1742", -1, &res, 1); 190 platform_device_register_simple("rtc-ds1742", -1, &res, 1);
191} 191}
192 192
193static void __init jmr3927_mtd_init(void)
194{
195 int i;
196
197 for (i = 0; i < 2; i++)
198 tx3927_mtd_init(i);
199}
200
193static void __init jmr3927_device_init(void) 201static void __init jmr3927_device_init(void)
194{ 202{
195 __swizzle_addr_b = jmr3927_swizzle_addr_b; 203 __swizzle_addr_b = jmr3927_swizzle_addr_b;
196 jmr3927_rtc_init(); 204 jmr3927_rtc_init();
197 tx3927_wdt_init(); 205 tx3927_wdt_init();
206 jmr3927_mtd_init();
198} 207}
199 208
200struct txx9_board_vec jmr3927_vec __initdata = { 209struct txx9_board_vec jmr3927_vec __initdata = {
diff --git a/arch/mips/txx9/rbtx4927/setup.c b/arch/mips/txx9/rbtx4927/setup.c
index 0464a39b39ac..abe32c1a79dc 100644
--- a/arch/mips/txx9/rbtx4927/setup.c
+++ b/arch/mips/txx9/rbtx4927/setup.c
@@ -307,11 +307,20 @@ static void __init rbtx4927_ne_init(void)
307 platform_device_register_simple("ne", -1, res, ARRAY_SIZE(res)); 307 platform_device_register_simple("ne", -1, res, ARRAY_SIZE(res));
308} 308}
309 309
310static void __init rbtx4927_mtd_init(void)
311{
312 int i;
313
314 for (i = 0; i < 2; i++)
315 tx4927_mtd_init(i);
316}
317
310static void __init rbtx4927_device_init(void) 318static void __init rbtx4927_device_init(void)
311{ 319{
312 toshiba_rbtx4927_rtc_init(); 320 toshiba_rbtx4927_rtc_init();
313 rbtx4927_ne_init(); 321 rbtx4927_ne_init();
314 tx4927_wdt_init(); 322 tx4927_wdt_init();
323 rbtx4927_mtd_init();
315} 324}
316 325
317struct txx9_board_vec rbtx4927_vec __initdata = { 326struct txx9_board_vec rbtx4927_vec __initdata = {
diff --git a/arch/mips/txx9/rbtx4938/setup.c b/arch/mips/txx9/rbtx4938/setup.c
index 9ab48dec0fe8..e7bc5b8c7db8 100644
--- a/arch/mips/txx9/rbtx4938/setup.c
+++ b/arch/mips/txx9/rbtx4938/setup.c
@@ -15,6 +15,7 @@
15#include <linux/delay.h> 15#include <linux/delay.h>
16#include <linux/platform_device.h> 16#include <linux/platform_device.h>
17#include <linux/gpio.h> 17#include <linux/gpio.h>
18#include <linux/mtd/physmap.h>
18 19
19#include <asm/reboot.h> 20#include <asm/reboot.h>
20#include <asm/io.h> 21#include <asm/io.h>
@@ -294,6 +295,42 @@ static int __init rbtx4938_spi_init(void)
294 return 0; 295 return 0;
295} 296}
296 297
298static void __init rbtx4938_mtd_init(void)
299{
300 struct physmap_flash_data pdata = {
301 .width = 4,
302 };
303
304 switch (readb(rbtx4938_bdipsw_addr) & 7) {
305 case 0:
306 /* Boot */
307 txx9_physmap_flash_init(0, 0x1fc00000, 0x400000, &pdata);
308 /* System */
309 txx9_physmap_flash_init(1, 0x1e000000, 0x1000000, &pdata);
310 break;
311 case 1:
312 /* System */
313 txx9_physmap_flash_init(0, 0x1f000000, 0x1000000, &pdata);
314 /* Boot */
315 txx9_physmap_flash_init(1, 0x1ec00000, 0x400000, &pdata);
316 break;
317 case 2:
318 /* Ext */
319 txx9_physmap_flash_init(0, 0x1f000000, 0x1000000, &pdata);
320 /* System */
321 txx9_physmap_flash_init(1, 0x1e000000, 0x1000000, &pdata);
322 /* Boot */
323 txx9_physmap_flash_init(2, 0x1dc00000, 0x400000, &pdata);
324 break;
325 case 3:
326 /* Boot */
327 txx9_physmap_flash_init(1, 0x1bc00000, 0x400000, &pdata);
328 /* System */
329 txx9_physmap_flash_init(2, 0x1a000000, 0x1000000, &pdata);
330 break;
331 }
332}
333
297static void __init rbtx4938_arch_init(void) 334static void __init rbtx4938_arch_init(void)
298{ 335{
299 gpiochip_add(&rbtx4938_spi_gpio_chip); 336 gpiochip_add(&rbtx4938_spi_gpio_chip);
@@ -306,6 +343,7 @@ static void __init rbtx4938_device_init(void)
306 rbtx4938_ethaddr_init(); 343 rbtx4938_ethaddr_init();
307 rbtx4938_ne_init(); 344 rbtx4938_ne_init();
308 tx4938_wdt_init(); 345 tx4938_wdt_init();
346 rbtx4938_mtd_init();
309} 347}
310 348
311struct txx9_board_vec rbtx4938_vec __initdata = { 349struct txx9_board_vec rbtx4938_vec __initdata = {
diff --git a/include/asm-mips/txx9/generic.h b/include/asm-mips/txx9/generic.h
index 0a225bf73496..1982c4437b1d 100644
--- a/include/asm-mips/txx9/generic.h
+++ b/include/asm-mips/txx9/generic.h
@@ -59,4 +59,8 @@ static inline void txx9_sio_putchar_init(unsigned long baseaddr)
59} 59}
60#endif 60#endif
61 61
62struct physmap_flash_data;
63void txx9_physmap_flash_init(int no, unsigned long addr, unsigned long size,
64 const struct physmap_flash_data *pdata);
65
62#endif /* __ASM_TXX9_GENERIC_H */ 66#endif /* __ASM_TXX9_GENERIC_H */
diff --git a/include/asm-mips/txx9/tx3927.h b/include/asm-mips/txx9/tx3927.h
index 587deb9592d2..dc30c8d42061 100644
--- a/include/asm-mips/txx9/tx3927.h
+++ b/include/asm-mips/txx9/tx3927.h
@@ -325,6 +325,7 @@ struct tx3927_ccfg_reg {
325#define TX3927_ROMC_BA(ch) (tx3927_romcptr->cr[(ch)] & 0xfff00000) 325#define TX3927_ROMC_BA(ch) (tx3927_romcptr->cr[(ch)] & 0xfff00000)
326#define TX3927_ROMC_SIZE(ch) \ 326#define TX3927_ROMC_SIZE(ch) \
327 (0x00100000 << ((tx3927_romcptr->cr[(ch)] >> 8) & 0xf)) 327 (0x00100000 << ((tx3927_romcptr->cr[(ch)] >> 8) & 0xf))
328#define TX3927_ROMC_WIDTH(ch) (32 >> ((tx3927_romcptr->cr[(ch)] >> 7) & 0x1))
328 329
329void tx3927_wdt_init(void); 330void tx3927_wdt_init(void);
330void tx3927_setup(void); 331void tx3927_setup(void);
@@ -335,5 +336,6 @@ void tx3927_pcic_setup(struct pci_controller *channel,
335 unsigned long sdram_size, int extarb); 336 unsigned long sdram_size, int extarb);
336void tx3927_setup_pcierr_irq(void); 337void tx3927_setup_pcierr_irq(void);
337void tx3927_irq_init(void); 338void tx3927_irq_init(void);
339void tx3927_mtd_init(int ch);
338 340
339#endif /* __ASM_TXX9_TX3927_H */ 341#endif /* __ASM_TXX9_TX3927_H */
diff --git a/include/asm-mips/txx9/tx4927.h b/include/asm-mips/txx9/tx4927.h
index 195f6515db9a..36a9241b0cac 100644
--- a/include/asm-mips/txx9/tx4927.h
+++ b/include/asm-mips/txx9/tx4927.h
@@ -196,6 +196,8 @@ struct tx4927_ccfg_reg {
196#define TX4927_EBUSC_BA(ch) ((TX4927_EBUSC_CR(ch) >> 48) << 20) 196#define TX4927_EBUSC_BA(ch) ((TX4927_EBUSC_CR(ch) >> 48) << 20)
197#define TX4927_EBUSC_SIZE(ch) \ 197#define TX4927_EBUSC_SIZE(ch) \
198 (0x00100000 << ((unsigned long)(TX4927_EBUSC_CR(ch) >> 8) & 0xf)) 198 (0x00100000 << ((unsigned long)(TX4927_EBUSC_CR(ch) >> 8) & 0xf))
199#define TX4927_EBUSC_WIDTH(ch) \
200 (64 >> ((__u32)(TX4927_EBUSC_CR(ch) >> 20) & 0x3))
199 201
200/* utilities */ 202/* utilities */
201static inline void txx9_clear64(__u64 __iomem *adr, __u64 bits) 203static inline void txx9_clear64(__u64 __iomem *adr, __u64 bits)
@@ -251,5 +253,6 @@ int tx4927_report_pciclk(void);
251int tx4927_pciclk66_setup(void); 253int tx4927_pciclk66_setup(void);
252void tx4927_setup_pcierr_irq(void); 254void tx4927_setup_pcierr_irq(void);
253void tx4927_irq_init(void); 255void tx4927_irq_init(void);
256void tx4927_mtd_init(int ch);
254 257
255#endif /* __ASM_TXX9_TX4927_H */ 258#endif /* __ASM_TXX9_TX4927_H */
diff --git a/include/asm-mips/txx9/tx4938.h b/include/asm-mips/txx9/tx4938.h
index 8175d4ccbc39..989e7751135a 100644
--- a/include/asm-mips/txx9/tx4938.h
+++ b/include/asm-mips/txx9/tx4938.h
@@ -274,6 +274,7 @@ struct tx4938_ccfg_reg {
274#define TX4938_EBUSC_CR(ch) TX4927_EBUSC_CR(ch) 274#define TX4938_EBUSC_CR(ch) TX4927_EBUSC_CR(ch)
275#define TX4938_EBUSC_BA(ch) TX4927_EBUSC_BA(ch) 275#define TX4938_EBUSC_BA(ch) TX4927_EBUSC_BA(ch)
276#define TX4938_EBUSC_SIZE(ch) TX4927_EBUSC_SIZE(ch) 276#define TX4938_EBUSC_SIZE(ch) TX4927_EBUSC_SIZE(ch)
277#define TX4938_EBUSC_WIDTH(ch) TX4927_EBUSC_WIDTH(ch)
277 278
278#define tx4938_get_mem_size() tx4927_get_mem_size() 279#define tx4938_get_mem_size() tx4927_get_mem_size()
279void tx4938_wdt_init(void); 280void tx4938_wdt_init(void);
@@ -289,5 +290,6 @@ struct pci_dev;
289int tx4938_pcic1_map_irq(const struct pci_dev *dev, u8 slot); 290int tx4938_pcic1_map_irq(const struct pci_dev *dev, u8 slot);
290void tx4938_setup_pcierr_irq(void); 291void tx4938_setup_pcierr_irq(void);
291void tx4938_irq_init(void); 292void tx4938_irq_init(void);
293void tx4938_mtd_init(int ch);
292 294
293#endif 295#endif