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>
24 static struct resource rt305x_flash0_resources
[] = {
26 .flags
= IORESOURCE_MEM
,
27 .start
= KSEG1ADDR(RT305X_FLASH0_BASE
),
28 .end
= KSEG1ADDR(RT305X_FLASH0_BASE
) +
29 RT305X_FLASH0_SIZE
- 1,
33 static struct platform_device rt305x_flash0_device
= {
34 .name
= "physmap-flash",
35 .resource
= rt305x_flash0_resources
,
36 .num_resources
= ARRAY_SIZE(rt305x_flash0_resources
),
39 static struct resource rt305x_flash1_resources
[] = {
41 .flags
= IORESOURCE_MEM
,
42 .start
= KSEG1ADDR(RT305X_FLASH1_BASE
),
43 .end
= KSEG1ADDR(RT305X_FLASH1_BASE
) +
44 RT305X_FLASH1_SIZE
- 1,
48 static struct platform_device rt305x_flash1_device
= {
49 .name
= "physmap-flash",
50 .resource
= rt305x_flash1_resources
,
51 .num_resources
= ARRAY_SIZE(rt305x_flash1_resources
),
54 static int rt305x_flash_instance __initdata
;
55 void __init
rt305x_register_flash(unsigned int id
,
56 struct physmap_flash_data
*pdata
)
58 struct platform_device
*pdev
;
64 pdev
= &rt305x_flash0_device
;
65 reg
= MEMC_REG_FLASH_CFG0
;
68 pdev
= &rt305x_flash1_device
;
69 reg
= MEMC_REG_FLASH_CFG1
;
75 t
= rt305x_memc_rr(reg
);
76 t
= (t
>> FLASH_CFG_WIDTH_SHIFT
) & FLASH_CFG_WIDTH_MASK
;
79 case FLASH_CFG_WIDTH_8BIT
:
82 case FLASH_CFG_WIDTH_16BIT
:
85 case FLASH_CFG_WIDTH_32BIT
:
89 printk(KERN_ERR
"RT305x: flash bank%u witdh is invalid\n", id
);
93 pdev
->dev
.platform_data
= pdata
;
94 pdev
->id
= rt305x_flash_instance
;
96 platform_device_register(pdev
);
97 rt305x_flash_instance
++;
100 static void rt305x_fe_reset(void)
102 rt305x_sysc_wr(RAMIPS_FE_RESET_BIT
, RAMIPS_FE_RESET
);
103 rt305x_sysc_wr(0, RAMIPS_FE_RESET
);
106 static struct resource rt305x_eth_resources
[] = {
108 .start
= RT305X_FE_BASE
,
109 .end
= RT305X_FE_BASE
+ PAGE_SIZE
- 1,
110 .flags
= IORESOURCE_MEM
,
112 .start
= RT305X_CPU_IRQ_FE
,
113 .end
= RT305X_CPU_IRQ_FE
,
114 .flags
= IORESOURCE_IRQ
,
118 static struct ramips_eth_platform_data ramips_eth_data
= {
119 .mac
= { 0x00, 0x11, 0x22, 0x33, 0x44, 0x55 },
120 .reset_fe
= rt305x_fe_reset
,
124 static struct platform_device rt305x_eth_device
= {
125 .name
= "ramips_eth",
126 .resource
= rt305x_eth_resources
,
127 .num_resources
= ARRAY_SIZE(rt305x_eth_resources
),
129 .platform_data
= &ramips_eth_data
,
133 void __init
rt305x_register_ethernet(void)
135 platform_device_register(&rt305x_eth_device
);