2 * Ralink RT305x SoC platform device registration
4 * Copyright (C) 2009-2010 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 #include <ramips_eth_platform.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(RT305X_RESET_FE, SYSC_REG_RESET_CTRL);
103 rt305x_sysc_wr(0, SYSC_REG_RESET_CTRL);
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 static struct resource rt305x_esw_resources[] = {
135 .start = RT305X_SWITCH_BASE,
136 .end = RT305X_SWITCH_BASE + PAGE_SIZE - 1,
137 .flags = IORESOURCE_MEM,
141 struct rt305x_esw_platform_data rt305x_esw_data;
142 static struct platform_device rt305x_esw_device = {
143 .name = "rt305x-esw",
144 .resource = rt305x_esw_resources,
145 .num_resources = ARRAY_SIZE(rt305x_esw_resources),
147 .platform_data = &rt305x_esw_data,
151 void __init rt305x_register_ethernet(void)
153 ramips_eth_data.sys_freq = rt305x_sys_freq;
155 platform_device_register(&rt305x_esw_device);
156 platform_device_register(&rt305x_eth_device);
159 static struct resource rt305x_wifi_resources[] = {
161 .start = RT305X_WMAC_BASE,
162 .end = RT305X_WMAC_BASE + 0x3FFFF,
163 .flags = IORESOURCE_MEM,
165 .start = RT305X_CPU_IRQ_WNIC,
166 .end = RT305X_CPU_IRQ_WNIC,
167 .flags = IORESOURCE_IRQ,
171 static struct platform_device rt305x_wifi_device = {
172 .name = "rt2800_wmac",
173 .resource = rt305x_wifi_resources,
174 .num_resources = ARRAY_SIZE(rt305x_wifi_resources),
176 .platform_data = NULL,
180 void __init rt305x_register_wifi(void)
182 platform_device_register(&rt305x_wifi_device);