ar71xx: move AP94 specific PCI init code into a separate file
[openwrt/openwrt.git] / target / linux / ar71xx / files / arch / mips / ar71xx / mach-pb44.c
1 /*
2 * Atheros PB44 board support
3 *
4 * Copyright (C) 2009 Gabor Juhos <juhosg@openwrt.org>
5 *
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.
9 */
10
11 #include <linux/init.h>
12 #include <linux/bitops.h>
13 #include <linux/input.h>
14 #include <linux/delay.h>
15 #include <linux/platform_device.h>
16 #include <linux/spi/spi.h>
17 #include <linux/spi/flash.h>
18 #include <linux/spi/vsc7385.h>
19 #include <linux/i2c.h>
20 #include <linux/i2c-gpio.h>
21 #include <linux/i2c/pcf857x.h>
22
23 #include <asm/mips_machine.h>
24 #include <asm/mach-ar71xx/ar71xx.h>
25 #include <asm/mach-ar71xx/pci.h>
26
27 #include "devices.h"
28
29 #define PB44_PCF8757_VSC7395_CS 0
30 #define PB44_PCF8757_STEREO_CS 1
31 #define PB44_PCF8757_SLIC_CS0 2
32 #define PB44_PCF8757_SLIC_TEST 3
33 #define PB44_PCF8757_SLIC_INT0 4
34 #define PB44_PCF8757_SLIC_INT1 5
35 #define PB44_PCF8757_SW_RESET 6
36 #define PB44_PCF8757_SW_JUMP 8
37 #define PB44_PCF8757_LED_JUMP1 9
38 #define PB44_PCF8757_LED_JUMP2 10
39 #define PB44_PCF8757_TP24 11
40 #define PB44_PCF8757_TP25 12
41 #define PB44_PCF8757_TP26 13
42 #define PB44_PCF8757_TP27 14
43 #define PB44_PCF8757_TP28 15
44
45 #define PB44_GPIO_I2C_SCL 0
46 #define PB44_GPIO_I2C_SDA 1
47
48 #define PB44_GPIO_EXP_BASE 16
49 #define PB44_GPIO_VSC7395_CS (PB44_GPIO_EXP_BASE + PB44_PCF8757_VSC7395_CS)
50 #define PB44_GPIO_SW_RESET (PB44_GPIO_EXP_BASE + PB44_PCF8757_SW_RESET)
51 #define PB44_GPIO_SW_JUMP (PB44_GPIO_EXP_BASE + PB44_PCF8757_SW_JUMP)
52 #define PB44_GPIO_LED_JUMP1 (PB44_GPIO_EXP_BASE + PB44_PCF8757_LED_JUMP1)
53 #define PB44_GPIO_LED_JUMP2 (PB44_GPIO_EXP_BASE + PB44_PCF8757_LED_JUMP2)
54
55 static struct ar71xx_pci_irq pb44_pci_irqs[] __initdata = {
56 {
57 .slot = 0,
58 .pin = 1,
59 .irq = AR71XX_PCI_IRQ_DEV0,
60 }, {
61 .slot = 1,
62 .pin = 1,
63 .irq = AR71XX_PCI_IRQ_DEV1,
64 }, {
65 .slot = 2,
66 .pin = 1,
67 .irq = AR71XX_PCI_IRQ_DEV2,
68 }
69 };
70
71 static struct i2c_gpio_platform_data pb44_i2c_gpio_data = {
72 .sda_pin = PB44_GPIO_I2C_SDA,
73 .scl_pin = PB44_GPIO_I2C_SCL,
74 };
75
76 static struct platform_device pb44_i2c_gpio_device = {
77 .name = "i2c-gpio",
78 .id = 0,
79 .dev = {
80 .platform_data = &pb44_i2c_gpio_data,
81 }
82 };
83
84 static struct pcf857x_platform_data pb44_pcf857x_data = {
85 .gpio_base = PB44_GPIO_EXP_BASE,
86 };
87
88 static struct i2c_board_info pb44_i2c_board_info[] __initdata = {
89 {
90 I2C_BOARD_INFO("pcf8575", 0x20),
91 .platform_data = &pb44_pcf857x_data,
92 },
93 };
94
95 static struct gpio_led pb44_leds_gpio[] __initdata = {
96 {
97 .name = "pb44:amber:jump1",
98 .gpio = PB44_GPIO_LED_JUMP1,
99 .active_low = 1,
100 }, {
101 .name = "pb44:green:jump2",
102 .gpio = PB44_GPIO_LED_JUMP2,
103 .active_low = 1,
104 },
105 };
106
107 static struct gpio_button pb44_gpio_buttons[] __initdata = {
108 {
109 .desc = "soft_reset",
110 .type = EV_KEY,
111 .code = BTN_0,
112 .threshold = 5,
113 .gpio = PB44_GPIO_SW_RESET,
114 .active_low = 1,
115 } , {
116 .desc = "jumpstart",
117 .type = EV_KEY,
118 .code = BTN_1,
119 .threshold = 5,
120 .gpio = PB44_GPIO_SW_JUMP,
121 .active_low = 1,
122 }
123 };
124
125 static void pb44_vsc7395_reset(void)
126 {
127 ar71xx_device_stop(RESET_MODULE_GE1_PHY);
128 udelay(10);
129 ar71xx_device_start(RESET_MODULE_GE1_PHY);
130 mdelay(50);
131 }
132
133 static struct vsc7385_platform_data pb44_vsc7395_data = {
134 .reset = pb44_vsc7395_reset,
135 .ucode_name = "vsc7395_ucode_pb44.bin",
136 .mac_cfg = {
137 .tx_ipg = 6,
138 .bit2 = 1,
139 .clk_sel = 0,
140 },
141 };
142
143 static struct spi_board_info pb44_spi_info[] = {
144 {
145 .bus_num = 0,
146 .chip_select = 0,
147 .max_speed_hz = 25000000,
148 .modalias = "m25p80",
149 }, {
150 .bus_num = 0,
151 .chip_select = 1,
152 .max_speed_hz = 25000000,
153 .modalias = "spi-vsc7385",
154 .platform_data = &pb44_vsc7395_data,
155 .controller_data = (void *) PB44_GPIO_VSC7395_CS,
156 },
157 };
158
159 static struct resource pb44_spi_resources[] = {
160 [0] = {
161 .start = AR71XX_SPI_BASE,
162 .end = AR71XX_SPI_BASE + AR71XX_SPI_SIZE - 1,
163 .flags = IORESOURCE_MEM,
164 },
165 };
166
167 static struct ar71xx_spi_platform_data pb44_spi_data = {
168 .bus_num = 0,
169 .num_chipselect = 2,
170 };
171
172 static struct platform_device pb44_spi_device = {
173 .name = "pb44-spi",
174 .id = -1,
175 .resource = pb44_spi_resources,
176 .num_resources = ARRAY_SIZE(pb44_spi_resources),
177 .dev = {
178 .platform_data = &pb44_spi_data,
179 },
180 };
181
182 #define PB44_WAN_PHYMASK BIT(0)
183 #define PB44_LAN_PHYMASK 0
184 #define PB44_MDIO_PHYMASK (PB44_LAN_PHYMASK | PB44_WAN_PHYMASK)
185
186 static void __init pb44_init(void)
187 {
188 ar71xx_add_device_mdio(~PB44_MDIO_PHYMASK);
189
190 ar71xx_eth0_data.phy_if_mode = PHY_INTERFACE_MODE_RGMII;
191 ar71xx_eth0_data.phy_mask = PB44_WAN_PHYMASK;
192
193 ar71xx_add_device_eth(0);
194
195 ar71xx_eth1_data.phy_if_mode = PHY_INTERFACE_MODE_RGMII;
196 ar71xx_eth1_data.phy_mask = PB44_LAN_PHYMASK;
197 ar71xx_eth1_data.speed = SPEED_1000;
198 ar71xx_eth1_data.duplex = DUPLEX_FULL;
199 ar71xx_eth1_pll_data.pll_1000 = 0x110000;
200
201 ar71xx_add_device_eth(1);
202
203 ar71xx_add_device_usb();
204
205 ar71xx_pci_init(ARRAY_SIZE(pb44_pci_irqs), pb44_pci_irqs);
206
207 i2c_register_board_info(0, pb44_i2c_board_info,
208 ARRAY_SIZE(pb44_i2c_board_info));
209
210 platform_device_register(&pb44_i2c_gpio_device);
211
212 spi_register_board_info(pb44_spi_info, ARRAY_SIZE(pb44_spi_info));
213 platform_device_register(&pb44_spi_device);
214
215 ar71xx_add_device_leds_gpio(-1, ARRAY_SIZE(pb44_leds_gpio),
216 pb44_leds_gpio);
217
218 ar71xx_add_device_gpio_buttons(-1, 20, ARRAY_SIZE(pb44_gpio_buttons),
219 pb44_gpio_buttons);
220 }
221
222 MIPS_MACHINE(AR71XX_MACH_PB44, "Atheros PB44", pb44_init);