MIPS: Alchemy: Improved DB1550 support, with audio and serial busses.
[deliverable/linux.git] / arch / mips / alchemy / mtx-1 / platform.c
CommitLineData
26c288f8
FF
1/*
2 * MTX-1 platform devices registration
3 *
a1b021d3 4 * Copyright (C) 2007-2009, Florian Fainelli <florian@openwrt.org>
26c288f8
FF
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
19 */
20
21#include <linux/init.h>
26c288f8
FF
22#include <linux/platform_device.h>
23#include <linux/leds.h>
1ff1a78c 24#include <linux/gpio.h>
f6ed10ab
FF
25#include <linux/gpio_keys.h>
26#include <linux/input.h>
95283563
YY
27#include <linux/mtd/partitions.h>
28#include <linux/mtd/physmap.h>
29#include <mtd/mtd-abi.h>
26c288f8 30
bf3a1eb8
FF
31#include <asm/mach-au1x00/au1xxx_eth.h>
32
f6ed10ab
FF
33static struct gpio_keys_button mtx1_gpio_button[] = {
34 {
35 .gpio = 207,
36 .code = BTN_0,
37 .desc = "System button",
38 }
39};
40
41static struct gpio_keys_platform_data mtx1_buttons_data = {
42 .buttons = mtx1_gpio_button,
43 .nbuttons = ARRAY_SIZE(mtx1_gpio_button),
44};
45
46static struct platform_device mtx1_button = {
47 .name = "gpio-keys",
48 .id = -1,
49 .dev = {
50 .platform_data = &mtx1_buttons_data,
51 }
52};
53
26c288f8
FF
54static struct resource mtx1_wdt_res[] = {
55 [0] = {
b7f720d6
ML
56 .start = 215,
57 .end = 215,
26c288f8
FF
58 .name = "mtx1-wdt-gpio",
59 .flags = IORESOURCE_IRQ,
60 }
61};
62
26c288f8
FF
63static struct platform_device mtx1_wdt = {
64 .name = "mtx1-wdt",
65 .id = 0,
66 .num_resources = ARRAY_SIZE(mtx1_wdt_res),
67 .resource = mtx1_wdt_res,
68};
69
70static struct gpio_led default_leds[] = {
71 {
72 .name = "mtx1:green",
73 .gpio = 211,
74 }, {
75 .name = "mtx1:red",
76 .gpio = 212,
77 },
78};
79
80static struct gpio_led_platform_data mtx1_led_data = {
81 .num_leds = ARRAY_SIZE(default_leds),
82 .leds = default_leds,
83};
84
85static struct platform_device mtx1_gpio_leds = {
86 .name = "leds-gpio",
87 .id = -1,
88 .dev = {
89 .platform_data = &mtx1_led_data,
90 }
91};
92
95283563
YY
93static struct mtd_partition mtx1_mtd_partitions[] = {
94 {
95 .name = "filesystem",
96 .size = 0x01C00000,
97 .offset = 0,
98 },
99 {
100 .name = "yamon",
101 .size = 0x00100000,
102 .offset = MTDPART_OFS_APPEND,
103 .mask_flags = MTD_WRITEABLE,
104 },
105 {
106 .name = "kernel",
107 .size = 0x002c0000,
108 .offset = MTDPART_OFS_APPEND,
109 },
110 {
111 .name = "yamon env",
112 .size = 0x00040000,
113 .offset = MTDPART_OFS_APPEND,
114 },
115};
116
117static struct physmap_flash_data mtx1_flash_data = {
118 .width = 4,
119 .nr_parts = 4,
120 .parts = mtx1_mtd_partitions,
121};
122
123static struct resource mtx1_mtd_resource = {
124 .start = 0x1e000000,
125 .end = 0x1fffffff,
126 .flags = IORESOURCE_MEM,
127};
128
129static struct platform_device mtx1_mtd = {
130 .name = "physmap-flash",
131 .dev = {
132 .platform_data = &mtx1_flash_data,
133 },
134 .num_resources = 1,
135 .resource = &mtx1_mtd_resource,
136};
137
7517de34
ML
138static struct resource alchemy_pci_host_res[] = {
139 [0] = {
140 .start = AU1500_PCI_PHYS_ADDR,
141 .end = AU1500_PCI_PHYS_ADDR + 0xfff,
142 .flags = IORESOURCE_MEM,
143 },
144};
145
146static int mtx1_pci_idsel(unsigned int devsel, int assert)
147{
148 /* This function is only necessary to support a proprietary Cardbus
149 * adapter on the mtx-1 "singleboard" variant. It triggers a custom
150 * logic chip connected to EXT_IO3 (GPIO1) to suppress IDSEL signals.
151 */
152 if (assert && devsel != 0)
153 /* Suppress signal to Cardbus */
154 alchemy_gpio_set_value(1, 0); /* set EXT_IO3 OFF */
155 else
156 alchemy_gpio_set_value(1, 1); /* set EXT_IO3 ON */
157
158 udelay(1);
159 return 1;
160}
161
162static const char mtx1_irqtab[][5] = {
163 [0] = { -1, AU1500_PCI_INTA, AU1500_PCI_INTA, 0xff, 0xff }, /* IDSEL 00 - AdapterA-Slot0 (top) */
164 [1] = { -1, AU1500_PCI_INTB, AU1500_PCI_INTA, 0xff, 0xff }, /* IDSEL 01 - AdapterA-Slot1 (bottom) */
165 [2] = { -1, AU1500_PCI_INTC, AU1500_PCI_INTD, 0xff, 0xff }, /* IDSEL 02 - AdapterB-Slot0 (top) */
166 [3] = { -1, AU1500_PCI_INTD, AU1500_PCI_INTC, 0xff, 0xff }, /* IDSEL 03 - AdapterB-Slot1 (bottom) */
167 [4] = { -1, AU1500_PCI_INTA, AU1500_PCI_INTB, 0xff, 0xff }, /* IDSEL 04 - AdapterC-Slot0 (top) */
168 [5] = { -1, AU1500_PCI_INTB, AU1500_PCI_INTA, 0xff, 0xff }, /* IDSEL 05 - AdapterC-Slot1 (bottom) */
169 [6] = { -1, AU1500_PCI_INTC, AU1500_PCI_INTD, 0xff, 0xff }, /* IDSEL 06 - AdapterD-Slot0 (top) */
170 [7] = { -1, AU1500_PCI_INTD, AU1500_PCI_INTC, 0xff, 0xff }, /* IDSEL 07 - AdapterD-Slot1 (bottom) */
171};
172
173static int mtx1_map_pci_irq(const struct pci_dev *d, u8 slot, u8 pin)
174{
175 return mtx1_irqtab[slot][pin];
176}
177
178static struct alchemy_pci_platdata mtx1_pci_pd = {
179 .board_map_irq = mtx1_map_pci_irq,
180 .board_pci_idsel = mtx1_pci_idsel,
181 .pci_cfg_set = PCI_CONFIG_AEN | PCI_CONFIG_R2H | PCI_CONFIG_R1H |
182 PCI_CONFIG_CH |
183#if defined(__MIPSEB__)
184 PCI_CONFIG_SIC_HWA_DAT | PCI_CONFIG_SM,
185#else
186 0,
187#endif
188};
189
190static struct platform_device mtx1_pci_host = {
191 .dev.platform_data = &mtx1_pci_pd,
192 .name = "alchemy-pci",
193 .id = 0,
194 .num_resources = ARRAY_SIZE(alchemy_pci_host_res),
195 .resource = alchemy_pci_host_res,
196};
197
198
26c288f8 199static struct __initdata platform_device * mtx1_devs[] = {
7517de34 200 &mtx1_pci_host,
26c288f8 201 &mtx1_gpio_leds,
f6ed10ab 202 &mtx1_wdt,
95283563
YY
203 &mtx1_button,
204 &mtx1_mtd,
26c288f8
FF
205};
206
bf3a1eb8
FF
207static struct au1000_eth_platform_data mtx1_au1000_eth0_pdata = {
208 .phy_search_highest_addr = 1,
209 .phy1_search_mac0 = 1,
210};
211
26c288f8
FF
212static int __init mtx1_register_devices(void)
213{
a1b021d3
FF
214 int rc;
215
bf3a1eb8
FF
216 au1xxx_override_eth_cfg(0, &mtx1_au1000_eth0_pdata);
217
a1b021d3
FF
218 rc = gpio_request(mtx1_gpio_button[0].gpio,
219 mtx1_gpio_button[0].desc);
220 if (rc < 0) {
221 printk(KERN_INFO "mtx1: failed to request %d\n",
222 mtx1_gpio_button[0].gpio);
223 goto out;
224 }
225 gpio_direction_input(mtx1_gpio_button[0].gpio);
226out:
26c288f8
FF
227 return platform_add_devices(mtx1_devs, ARRAY_SIZE(mtx1_devs));
228}
229
230arch_initcall(mtx1_register_devices);
This page took 0.396219 seconds and 5 git commands to generate.