Commit 51f607c7 authored by Atsushi Nemoto's avatar Atsushi Nemoto Committed by Ralf Baechle

MIPS: TXx9: Add mtd support

Add helper routines to register physmap-flash platform devices for NOR
flashes.
Signed-off-by: default avatarAtsushi Nemoto <anemo@mba.ocn.ne.jp>
Signed-off-by: default avatarRalf Baechle <ralf@linux-mips.org>
parent c7b95bcb
...@@ -22,6 +22,7 @@ ...@@ -22,6 +22,7 @@
#include <linux/gpio.h> #include <linux/gpio.h>
#include <linux/platform_device.h> #include <linux/platform_device.h>
#include <linux/serial_core.h> #include <linux/serial_core.h>
#include <linux/mtd/physmap.h>
#include <asm/bootinfo.h> #include <asm/bootinfo.h>
#include <asm/time.h> #include <asm/time.h>
#include <asm/reboot.h> #include <asm/reboot.h>
...@@ -593,3 +594,43 @@ static unsigned long __swizzle_addr_none(unsigned long port) ...@@ -593,3 +594,43 @@ static unsigned long __swizzle_addr_none(unsigned long port)
unsigned long (*__swizzle_addr_b)(unsigned long port) = __swizzle_addr_none; unsigned long (*__swizzle_addr_b)(unsigned long port) = __swizzle_addr_none;
EXPORT_SYMBOL(__swizzle_addr_b); EXPORT_SYMBOL(__swizzle_addr_b);
#endif #endif
void __init txx9_physmap_flash_init(int no, unsigned long addr,
unsigned long size,
const struct physmap_flash_data *pdata)
{
#if defined(CONFIG_MTD_PHYSMAP) || defined(CONFIG_MTD_PHYSMAP_MODULE)
struct resource res = {
.start = addr,
.end = addr + size - 1,
.flags = IORESOURCE_MEM,
};
struct platform_device *pdev;
#ifdef CONFIG_MTD_PARTITIONS
static struct mtd_partition parts[2];
struct physmap_flash_data pdata_part;
/* If this area contained boot area, make separate partition */
if (pdata->nr_parts == 0 && !pdata->parts &&
addr < 0x1fc00000 && addr + size > 0x1fc00000 &&
!parts[0].name) {
parts[0].name = "boot";
parts[0].offset = 0x1fc00000 - addr;
parts[0].size = addr + size - 0x1fc00000;
parts[1].name = "user";
parts[1].offset = 0;
parts[1].size = 0x1fc00000 - addr;
pdata_part = *pdata;
pdata_part.nr_parts = ARRAY_SIZE(parts);
pdata_part.parts = parts;
pdata = &pdata_part;
}
#endif
pdev = platform_device_alloc("physmap-flash", no);
if (!pdev ||
platform_device_add_resources(pdev, &res, 1) ||
platform_device_add_data(pdev, pdata, sizeof(*pdata)) ||
platform_device_add(pdev))
platform_device_put(pdev);
#endif
}
...@@ -15,6 +15,7 @@ ...@@ -15,6 +15,7 @@
#include <linux/delay.h> #include <linux/delay.h>
#include <linux/param.h> #include <linux/param.h>
#include <linux/io.h> #include <linux/io.h>
#include <linux/mtd/physmap.h>
#include <asm/mipsregs.h> #include <asm/mipsregs.h>
#include <asm/txx9irq.h> #include <asm/txx9irq.h>
#include <asm/txx9tmr.h> #include <asm/txx9tmr.h>
...@@ -121,3 +122,16 @@ void __init tx3927_sio_init(unsigned int sclk, unsigned int cts_mask) ...@@ -121,3 +122,16 @@ void __init tx3927_sio_init(unsigned int sclk, unsigned int cts_mask)
TXX9_IRQ_BASE + TX3927_IR_SIO(i), TXX9_IRQ_BASE + TX3927_IR_SIO(i),
i, sclk, (1 << i) & cts_mask); i, sclk, (1 << i) & cts_mask);
} }
void __init tx3927_mtd_init(int ch)
{
struct physmap_flash_data pdata = {
.width = TX3927_ROMC_WIDTH(ch) / 8,
};
unsigned long start = txx9_ce_res[ch].start;
unsigned long size = txx9_ce_res[ch].end - start + 1;
if (!(tx3927_romcptr->cr[ch] & 0x8))
return; /* disabled */
txx9_physmap_flash_init(ch, start, size, &pdata);
}
...@@ -14,6 +14,7 @@ ...@@ -14,6 +14,7 @@
#include <linux/ioport.h> #include <linux/ioport.h>
#include <linux/delay.h> #include <linux/delay.h>
#include <linux/param.h> #include <linux/param.h>
#include <linux/mtd/physmap.h>
#include <asm/txx9irq.h> #include <asm/txx9irq.h>
#include <asm/txx9tmr.h> #include <asm/txx9tmr.h>
#include <asm/txx9pio.h> #include <asm/txx9pio.h>
...@@ -187,3 +188,16 @@ void __init tx4927_sio_init(unsigned int sclk, unsigned int cts_mask) ...@@ -187,3 +188,16 @@ void __init tx4927_sio_init(unsigned int sclk, unsigned int cts_mask)
TXX9_IRQ_BASE + TX4927_IR_SIO(i), TXX9_IRQ_BASE + TX4927_IR_SIO(i),
i, sclk, (1 << i) & cts_mask); i, sclk, (1 << i) & cts_mask);
} }
void __init tx4927_mtd_init(int ch)
{
struct physmap_flash_data pdata = {
.width = TX4927_EBUSC_WIDTH(ch) / 8,
};
unsigned long start = txx9_ce_res[ch].start;
unsigned long size = txx9_ce_res[ch].end - start + 1;
if (!(TX4927_EBUSC_CR(ch) & 0x8))
return; /* disabled */
txx9_physmap_flash_init(ch, start, size, &pdata);
}
...@@ -14,6 +14,7 @@ ...@@ -14,6 +14,7 @@
#include <linux/ioport.h> #include <linux/ioport.h>
#include <linux/delay.h> #include <linux/delay.h>
#include <linux/param.h> #include <linux/param.h>
#include <linux/mtd/physmap.h>
#include <asm/txx9irq.h> #include <asm/txx9irq.h>
#include <asm/txx9tmr.h> #include <asm/txx9tmr.h>
#include <asm/txx9pio.h> #include <asm/txx9pio.h>
...@@ -269,3 +270,16 @@ void __init tx4938_ethaddr_init(unsigned char *addr0, unsigned char *addr1) ...@@ -269,3 +270,16 @@ void __init tx4938_ethaddr_init(unsigned char *addr0, unsigned char *addr1)
if (addr1 && (pcfg & TX4938_PCFG_ETH1_SEL)) if (addr1 && (pcfg & TX4938_PCFG_ETH1_SEL))
txx9_ethaddr_init(TXX9_IRQ_BASE + TX4938_IR_ETH1, addr1); txx9_ethaddr_init(TXX9_IRQ_BASE + TX4938_IR_ETH1, addr1);
} }
void __init tx4938_mtd_init(int ch)
{
struct physmap_flash_data pdata = {
.width = TX4938_EBUSC_WIDTH(ch) / 8,
};
unsigned long start = txx9_ce_res[ch].start;
unsigned long size = txx9_ce_res[ch].end - start + 1;
if (!(TX4938_EBUSC_CR(ch) & 0x8))
return; /* disabled */
txx9_physmap_flash_init(ch, start, size, &pdata);
}
...@@ -190,11 +190,20 @@ static void __init jmr3927_rtc_init(void) ...@@ -190,11 +190,20 @@ static void __init jmr3927_rtc_init(void)
platform_device_register_simple("rtc-ds1742", -1, &res, 1); platform_device_register_simple("rtc-ds1742", -1, &res, 1);
} }
static void __init jmr3927_mtd_init(void)
{
int i;
for (i = 0; i < 2; i++)
tx3927_mtd_init(i);
}
static void __init jmr3927_device_init(void) static void __init jmr3927_device_init(void)
{ {
__swizzle_addr_b = jmr3927_swizzle_addr_b; __swizzle_addr_b = jmr3927_swizzle_addr_b;
jmr3927_rtc_init(); jmr3927_rtc_init();
tx3927_wdt_init(); tx3927_wdt_init();
jmr3927_mtd_init();
} }
struct txx9_board_vec jmr3927_vec __initdata = { struct txx9_board_vec jmr3927_vec __initdata = {
......
...@@ -307,11 +307,20 @@ static void __init rbtx4927_ne_init(void) ...@@ -307,11 +307,20 @@ static void __init rbtx4927_ne_init(void)
platform_device_register_simple("ne", -1, res, ARRAY_SIZE(res)); platform_device_register_simple("ne", -1, res, ARRAY_SIZE(res));
} }
static void __init rbtx4927_mtd_init(void)
{
int i;
for (i = 0; i < 2; i++)
tx4927_mtd_init(i);
}
static void __init rbtx4927_device_init(void) static void __init rbtx4927_device_init(void)
{ {
toshiba_rbtx4927_rtc_init(); toshiba_rbtx4927_rtc_init();
rbtx4927_ne_init(); rbtx4927_ne_init();
tx4927_wdt_init(); tx4927_wdt_init();
rbtx4927_mtd_init();
} }
struct txx9_board_vec rbtx4927_vec __initdata = { struct txx9_board_vec rbtx4927_vec __initdata = {
......
...@@ -15,6 +15,7 @@ ...@@ -15,6 +15,7 @@
#include <linux/delay.h> #include <linux/delay.h>
#include <linux/platform_device.h> #include <linux/platform_device.h>
#include <linux/gpio.h> #include <linux/gpio.h>
#include <linux/mtd/physmap.h>
#include <asm/reboot.h> #include <asm/reboot.h>
#include <asm/io.h> #include <asm/io.h>
...@@ -294,6 +295,42 @@ static int __init rbtx4938_spi_init(void) ...@@ -294,6 +295,42 @@ static int __init rbtx4938_spi_init(void)
return 0; return 0;
} }
static void __init rbtx4938_mtd_init(void)
{
struct physmap_flash_data pdata = {
.width = 4,
};
switch (readb(rbtx4938_bdipsw_addr) & 7) {
case 0:
/* Boot */
txx9_physmap_flash_init(0, 0x1fc00000, 0x400000, &pdata);
/* System */
txx9_physmap_flash_init(1, 0x1e000000, 0x1000000, &pdata);
break;
case 1:
/* System */
txx9_physmap_flash_init(0, 0x1f000000, 0x1000000, &pdata);
/* Boot */
txx9_physmap_flash_init(1, 0x1ec00000, 0x400000, &pdata);
break;
case 2:
/* Ext */
txx9_physmap_flash_init(0, 0x1f000000, 0x1000000, &pdata);
/* System */
txx9_physmap_flash_init(1, 0x1e000000, 0x1000000, &pdata);
/* Boot */
txx9_physmap_flash_init(2, 0x1dc00000, 0x400000, &pdata);
break;
case 3:
/* Boot */
txx9_physmap_flash_init(1, 0x1bc00000, 0x400000, &pdata);
/* System */
txx9_physmap_flash_init(2, 0x1a000000, 0x1000000, &pdata);
break;
}
}
static void __init rbtx4938_arch_init(void) static void __init rbtx4938_arch_init(void)
{ {
gpiochip_add(&rbtx4938_spi_gpio_chip); gpiochip_add(&rbtx4938_spi_gpio_chip);
...@@ -306,6 +343,7 @@ static void __init rbtx4938_device_init(void) ...@@ -306,6 +343,7 @@ static void __init rbtx4938_device_init(void)
rbtx4938_ethaddr_init(); rbtx4938_ethaddr_init();
rbtx4938_ne_init(); rbtx4938_ne_init();
tx4938_wdt_init(); tx4938_wdt_init();
rbtx4938_mtd_init();
} }
struct txx9_board_vec rbtx4938_vec __initdata = { struct txx9_board_vec rbtx4938_vec __initdata = {
......
...@@ -59,4 +59,8 @@ static inline void txx9_sio_putchar_init(unsigned long baseaddr) ...@@ -59,4 +59,8 @@ static inline void txx9_sio_putchar_init(unsigned long baseaddr)
} }
#endif #endif
struct physmap_flash_data;
void txx9_physmap_flash_init(int no, unsigned long addr, unsigned long size,
const struct physmap_flash_data *pdata);
#endif /* __ASM_TXX9_GENERIC_H */ #endif /* __ASM_TXX9_GENERIC_H */
...@@ -325,6 +325,7 @@ struct tx3927_ccfg_reg { ...@@ -325,6 +325,7 @@ struct tx3927_ccfg_reg {
#define TX3927_ROMC_BA(ch) (tx3927_romcptr->cr[(ch)] & 0xfff00000) #define TX3927_ROMC_BA(ch) (tx3927_romcptr->cr[(ch)] & 0xfff00000)
#define TX3927_ROMC_SIZE(ch) \ #define TX3927_ROMC_SIZE(ch) \
(0x00100000 << ((tx3927_romcptr->cr[(ch)] >> 8) & 0xf)) (0x00100000 << ((tx3927_romcptr->cr[(ch)] >> 8) & 0xf))
#define TX3927_ROMC_WIDTH(ch) (32 >> ((tx3927_romcptr->cr[(ch)] >> 7) & 0x1))
void tx3927_wdt_init(void); void tx3927_wdt_init(void);
void tx3927_setup(void); void tx3927_setup(void);
...@@ -335,5 +336,6 @@ void tx3927_pcic_setup(struct pci_controller *channel, ...@@ -335,5 +336,6 @@ void tx3927_pcic_setup(struct pci_controller *channel,
unsigned long sdram_size, int extarb); unsigned long sdram_size, int extarb);
void tx3927_setup_pcierr_irq(void); void tx3927_setup_pcierr_irq(void);
void tx3927_irq_init(void); void tx3927_irq_init(void);
void tx3927_mtd_init(int ch);
#endif /* __ASM_TXX9_TX3927_H */ #endif /* __ASM_TXX9_TX3927_H */
...@@ -196,6 +196,8 @@ struct tx4927_ccfg_reg { ...@@ -196,6 +196,8 @@ struct tx4927_ccfg_reg {
#define TX4927_EBUSC_BA(ch) ((TX4927_EBUSC_CR(ch) >> 48) << 20) #define TX4927_EBUSC_BA(ch) ((TX4927_EBUSC_CR(ch) >> 48) << 20)
#define TX4927_EBUSC_SIZE(ch) \ #define TX4927_EBUSC_SIZE(ch) \
(0x00100000 << ((unsigned long)(TX4927_EBUSC_CR(ch) >> 8) & 0xf)) (0x00100000 << ((unsigned long)(TX4927_EBUSC_CR(ch) >> 8) & 0xf))
#define TX4927_EBUSC_WIDTH(ch) \
(64 >> ((__u32)(TX4927_EBUSC_CR(ch) >> 20) & 0x3))
/* utilities */ /* utilities */
static inline void txx9_clear64(__u64 __iomem *adr, __u64 bits) static inline void txx9_clear64(__u64 __iomem *adr, __u64 bits)
...@@ -251,5 +253,6 @@ int tx4927_report_pciclk(void); ...@@ -251,5 +253,6 @@ int tx4927_report_pciclk(void);
int tx4927_pciclk66_setup(void); int tx4927_pciclk66_setup(void);
void tx4927_setup_pcierr_irq(void); void tx4927_setup_pcierr_irq(void);
void tx4927_irq_init(void); void tx4927_irq_init(void);
void tx4927_mtd_init(int ch);
#endif /* __ASM_TXX9_TX4927_H */ #endif /* __ASM_TXX9_TX4927_H */
...@@ -274,6 +274,7 @@ struct tx4938_ccfg_reg { ...@@ -274,6 +274,7 @@ struct tx4938_ccfg_reg {
#define TX4938_EBUSC_CR(ch) TX4927_EBUSC_CR(ch) #define TX4938_EBUSC_CR(ch) TX4927_EBUSC_CR(ch)
#define TX4938_EBUSC_BA(ch) TX4927_EBUSC_BA(ch) #define TX4938_EBUSC_BA(ch) TX4927_EBUSC_BA(ch)
#define TX4938_EBUSC_SIZE(ch) TX4927_EBUSC_SIZE(ch) #define TX4938_EBUSC_SIZE(ch) TX4927_EBUSC_SIZE(ch)
#define TX4938_EBUSC_WIDTH(ch) TX4927_EBUSC_WIDTH(ch)
#define tx4938_get_mem_size() tx4927_get_mem_size() #define tx4938_get_mem_size() tx4927_get_mem_size()
void tx4938_wdt_init(void); void tx4938_wdt_init(void);
...@@ -289,5 +290,6 @@ struct pci_dev; ...@@ -289,5 +290,6 @@ struct pci_dev;
int tx4938_pcic1_map_irq(const struct pci_dev *dev, u8 slot); int tx4938_pcic1_map_irq(const struct pci_dev *dev, u8 slot);
void tx4938_setup_pcierr_irq(void); void tx4938_setup_pcierr_irq(void);
void tx4938_irq_init(void); void tx4938_irq_init(void);
void tx4938_mtd_init(int ch);
#endif #endif
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment