2 * Ralink RT305x SoC platform device registration
4 * Copyright (C) 2009 Gabor Juhos <juhosg@openwrt.org>
6 * This program is free software; you can redistribute it and/or modify it
7 * under the terms of the GNU General Public License version 2 as published
8 * by the Free Software Foundation.
11 #include <linux/kernel.h>
12 #include <linux/platform_device.h>
13 #include <linux/mtd/mtd.h>
14 #include <linux/mtd/physmap.h>
16 #include <asm/addrspace.h>
18 #include <asm/mach-ralink/rt305x.h>
19 #include <asm/mach-ralink/rt305x_regs.h>
22 static struct resource rt305x_flash0_resources
[] = {
24 .flags
= IORESOURCE_MEM
,
25 .start
= KSEG1ADDR(RT305X_FLASH0_BASE
),
26 .end
= KSEG1ADDR(RT305X_FLASH0_BASE
) +
27 RT305X_FLASH0_SIZE
- 1,
31 static struct platform_device rt305x_flash0_device
= {
32 .name
= "physmap-flash",
33 .resource
= rt305x_flash0_resources
,
34 .num_resources
= ARRAY_SIZE(rt305x_flash0_resources
),
37 static struct resource rt305x_flash1_resources
[] = {
39 .flags
= IORESOURCE_MEM
,
40 .start
= KSEG1ADDR(RT305X_FLASH1_BASE
),
41 .end
= KSEG1ADDR(RT305X_FLASH1_BASE
) +
42 RT305X_FLASH1_SIZE
- 1,
46 static struct platform_device rt305x_flash1_device
= {
47 .name
= "physmap-flash",
48 .resource
= rt305x_flash1_resources
,
49 .num_resources
= ARRAY_SIZE(rt305x_flash1_resources
),
52 static int rt305x_flash_instance __initdata
;
53 void __init
rt305x_register_flash(unsigned int id
,
54 struct physmap_flash_data
*pdata
)
56 struct platform_device
*pdev
;
62 pdev
= &rt305x_flash0_device
;
63 reg
= MEMC_REG_FLASH_CFG0
;
66 pdev
= &rt305x_flash1_device
;
67 reg
= MEMC_REG_FLASH_CFG1
;
73 t
= rt305x_memc_rr(reg
);
74 t
= (t
>> FLASH_CFG_WIDTH_SHIFT
) & FLASH_CFG_WIDTH_MASK
;
77 case FLASH_CFG_WIDTH_8BIT
:
80 case FLASH_CFG_WIDTH_16BIT
:
83 case FLASH_CFG_WIDTH_32BIT
:
87 printk(KERN_ERR
"RT305x: flash bank%u witdh is invalid\n", id
);
91 pdev
->dev
.platform_data
= pdata
;
92 pdev
->id
= rt305x_flash_instance
;
94 platform_device_register(pdev
);
95 rt305x_flash_instance
++;