blob: 65faaa34de61382c6f74e2a90f0070f69c2adf58 [file] [log] [blame]
Sylver Bruneau7ec753c2008-06-10 01:00:38 +02001/*
2 * Maxtor Shared Storage II Board Setup
3 *
4 * Maintainer: Sylver Bruneau <sylver.bruneau@googlemail.com>
5 *
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License
8 * as published by the Free Software Foundation; either version
9 * 2 of the License, or (at your option) any later version.
10 */
11
12#include <linux/kernel.h>
13#include <linux/init.h>
14#include <linux/platform_device.h>
15#include <linux/pci.h>
16#include <linux/irq.h>
17#include <linux/mtd/physmap.h>
18#include <linux/mv643xx_eth.h>
19#include <linux/leds.h>
20#include <linux/gpio_keys.h>
21#include <linux/input.h>
22#include <linux/i2c.h>
23#include <linux/ata_platform.h>
24#include <linux/gpio.h>
25#include <asm/mach-types.h>
26#include <asm/mach/arch.h>
27#include <asm/mach/pci.h>
Russell Kinga09e64f2008-08-05 16:14:15 +010028#include <mach/orion5x.h>
Nicolas Pitrefdd8b072009-04-22 20:08:17 +010029#include <mach/bridge-regs.h>
Sylver Bruneau7ec753c2008-06-10 01:00:38 +020030#include "common.h"
31#include "mpp.h"
32
33#define MSS2_NOR_BOOT_BASE 0xff800000
34#define MSS2_NOR_BOOT_SIZE SZ_256K
35
36/*****************************************************************************
37 * Maxtor Shared Storage II Info
38 ****************************************************************************/
39
40/*
41 * Maxtor Shared Storage II hardware :
42 * - Marvell 88F5182-A2 C500
43 * - Marvell 88E1111 Gigabit Ethernet PHY
44 * - RTC M41T81 (@0x68) on I2C bus
45 * - 256KB NOR flash
46 * - 64MB of RAM
47 */
48
49/*****************************************************************************
50 * 256KB NOR Flash on BOOT Device
51 ****************************************************************************/
52
53static struct physmap_flash_data mss2_nor_flash_data = {
54 .width = 1,
55};
56
57static struct resource mss2_nor_flash_resource = {
58 .flags = IORESOURCE_MEM,
59 .start = MSS2_NOR_BOOT_BASE,
60 .end = MSS2_NOR_BOOT_BASE + MSS2_NOR_BOOT_SIZE - 1,
61};
62
63static struct platform_device mss2_nor_flash = {
64 .name = "physmap-flash",
65 .id = 0,
66 .dev = {
67 .platform_data = &mss2_nor_flash_data,
68 },
69 .resource = &mss2_nor_flash_resource,
70 .num_resources = 1,
71};
72
73/****************************************************************************
74 * PCI setup
75 ****************************************************************************/
Ralf Baechled5341942011-06-10 15:30:21 +010076static int __init mss2_pci_map_irq(const struct pci_dev *dev, u8 slot, u8 pin)
Sylver Bruneau7ec753c2008-06-10 01:00:38 +020077{
78 int irq;
79
80 /*
81 * Check for devices with hard-wired IRQs.
82 */
83 irq = orion5x_pci_map_irq(dev, slot, pin);
84 if (irq != -1)
85 return irq;
86
87 return -1;
88}
89
90static struct hw_pci mss2_pci __initdata = {
91 .nr_controllers = 2,
92 .swizzle = pci_std_swizzle,
93 .setup = orion5x_pci_sys_setup,
94 .scan = orion5x_pci_sys_scan_bus,
95 .map_irq = mss2_pci_map_irq,
96};
97
98static int __init mss2_pci_init(void)
99{
100 if (machine_is_mss2())
101 pci_common_init(&mss2_pci);
102
103 return 0;
104}
105subsys_initcall(mss2_pci_init);
106
107
108/*****************************************************************************
109 * Ethernet
110 ****************************************************************************/
111
112static struct mv643xx_eth_platform_data mss2_eth_data = {
Lennert Buytenhekac840602008-08-26 14:06:47 +0200113 .phy_addr = MV643XX_ETH_PHY_ADDR(8),
Sylver Bruneau7ec753c2008-06-10 01:00:38 +0200114};
115
116/*****************************************************************************
117 * SATA
118 ****************************************************************************/
119
120static struct mv_sata_platform_data mss2_sata_data = {
121 .n_ports = 2,
122};
123
124/*****************************************************************************
125 * GPIO buttons
126 ****************************************************************************/
127
128#define MSS2_GPIO_KEY_RESET 12
129#define MSS2_GPIO_KEY_POWER 11
130
131static struct gpio_keys_button mss2_buttons[] = {
132 {
133 .code = KEY_POWER,
134 .gpio = MSS2_GPIO_KEY_POWER,
135 .desc = "Power",
136 .active_low = 1,
137 }, {
138 .code = KEY_RESTART,
139 .gpio = MSS2_GPIO_KEY_RESET,
140 .desc = "Reset",
141 .active_low = 1,
142 },
143};
144
145static struct gpio_keys_platform_data mss2_button_data = {
146 .buttons = mss2_buttons,
147 .nbuttons = ARRAY_SIZE(mss2_buttons),
148};
149
150static struct platform_device mss2_button_device = {
151 .name = "gpio-keys",
152 .id = -1,
153 .dev = {
154 .platform_data = &mss2_button_data,
155 },
156};
157
158/*****************************************************************************
159 * RTC m41t81 on I2C bus
160 ****************************************************************************/
161
162#define MSS2_GPIO_RTC_IRQ 3
163
164static struct i2c_board_info __initdata mss2_i2c_rtc = {
165 I2C_BOARD_INFO("m41t81", 0x68),
166};
167
168/*****************************************************************************
169 * MSS2 power off method
170 ****************************************************************************/
171/*
172 * On the Maxtor Shared Storage II, the shutdown process is the following :
173 * - Userland modifies U-boot env to tell U-boot to go idle at next boot
174 * - The board reboots
175 * - U-boot starts and go into an idle mode until the user press "power"
176 */
177static void mss2_power_off(void)
178{
179 u32 reg;
180
181 /*
182 * Enable and issue soft reset
183 */
Thomas Reitmayr6462c612009-06-01 13:38:33 +0200184 reg = readl(RSTOUTn_MASK);
Sylver Bruneau7ec753c2008-06-10 01:00:38 +0200185 reg |= 1 << 2;
Thomas Reitmayr6462c612009-06-01 13:38:33 +0200186 writel(reg, RSTOUTn_MASK);
Sylver Bruneau7ec753c2008-06-10 01:00:38 +0200187
188 reg = readl(CPU_SOFT_RESET);
189 reg |= 1;
190 writel(reg, CPU_SOFT_RESET);
191}
192
193/****************************************************************************
194 * General Setup
195 ****************************************************************************/
Andrew Lunn554cdae2011-05-15 13:32:53 +0200196static unsigned int mss2_mpp_modes[] __initdata = {
197 MPP0_GPIO, /* Power LED */
198 MPP1_GPIO, /* Error LED */
199 MPP2_UNUSED,
200 MPP3_GPIO, /* RTC interrupt */
201 MPP4_GPIO, /* HDD ind. (Single/Dual)*/
202 MPP5_GPIO, /* HD0 5V control */
203 MPP6_GPIO, /* HD0 12V control */
204 MPP7_GPIO, /* HD1 5V control */
205 MPP8_GPIO, /* HD1 12V control */
206 MPP9_UNUSED,
207 MPP10_GPIO, /* Fan control */
208 MPP11_GPIO, /* Power button */
209 MPP12_GPIO, /* Reset button */
210 MPP13_UNUSED,
211 MPP14_SATA_LED, /* SATA 0 active */
212 MPP15_SATA_LED, /* SATA 1 active */
213 MPP16_UNUSED,
214 MPP17_UNUSED,
215 MPP18_UNUSED,
216 MPP19_UNUSED,
217 0,
Sylver Bruneau7ec753c2008-06-10 01:00:38 +0200218};
219
220static void __init mss2_init(void)
221{
222 /* Setup basic Orion functions. Need to be called early. */
223 orion5x_init();
224
225 orion5x_mpp_conf(mss2_mpp_modes);
226
227 /*
228 * MPP[20] Unused
229 * MPP[21] PCI clock
230 * MPP[22] USB 0 over current
231 * MPP[23] USB 1 over current
232 */
233
234 /*
235 * Configure peripherals.
236 */
237 orion5x_ehci0_init();
238 orion5x_ehci1_init();
239 orion5x_eth_init(&mss2_eth_data);
240 orion5x_i2c_init();
241 orion5x_sata_init(&mss2_sata_data);
242 orion5x_uart0_init();
Saeed Bishara1d5a1a62008-06-16 23:25:12 -1100243 orion5x_xor_init();
Sylver Bruneau7ec753c2008-06-10 01:00:38 +0200244
245 orion5x_setup_dev_boot_win(MSS2_NOR_BOOT_BASE, MSS2_NOR_BOOT_SIZE);
246 platform_device_register(&mss2_nor_flash);
247
248 platform_device_register(&mss2_button_device);
249
250 if (gpio_request(MSS2_GPIO_RTC_IRQ, "rtc") == 0) {
251 if (gpio_direction_input(MSS2_GPIO_RTC_IRQ) == 0)
252 mss2_i2c_rtc.irq = gpio_to_irq(MSS2_GPIO_RTC_IRQ);
253 else
254 gpio_free(MSS2_GPIO_RTC_IRQ);
255 }
256 i2c_register_board_info(0, &mss2_i2c_rtc, 1);
257
258 /* register mss2 specific power-off method */
259 pm_power_off = mss2_power_off;
260}
261
262MACHINE_START(MSS2, "Maxtor Shared Storage II")
263 /* Maintainer: Sylver Bruneau <sylver.bruneau@googlemail.com> */
Nicolas Pitre65aa1b12011-07-05 22:38:15 -0400264 .atag_offset = 0x100,
Sylver Bruneau7ec753c2008-06-10 01:00:38 +0200265 .init_machine = mss2_init,
266 .map_io = orion5x_map_io,
Lennert Buytenhek4ee1f6b2010-10-15 16:50:26 +0200267 .init_early = orion5x_init_early,
Sylver Bruneau7ec753c2008-06-10 01:00:38 +0200268 .init_irq = orion5x_init_irq,
269 .timer = &orion5x_timer,
Russell King764cbcc2011-11-05 10:13:41 +0000270 .fixup = tag_fixup_mem32,
271 .restart = orion5x_restart,
Sylver Bruneau7ec753c2008-06-10 01:00:38 +0200272MACHINE_END