blob: 1a1d84b80a6521bed1de34ded745db7a643f0ac8 [file] [log] [blame]
Herbert Valerio Riedel555a3652007-11-12 09:05:55 +01001/*
Lennert Buytenhek9dd0b192008-03-27 14:51:41 -04002 * arch/arm/mach-orion5x/dns323-setup.c
Herbert Valerio Riedel555a3652007-11-12 09:05:55 +01003 *
4 * Copyright (C) 2007 Herbert Valerio Riedel <hvr@gnu.org>
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU Lesser General Public License as
8 * published by the Free Software Foundation; either version 2 of the
9 * License, or (at your option) any later version.
10 *
11 */
12
13#include <linux/kernel.h>
14#include <linux/init.h>
15#include <linux/platform_device.h>
16#include <linux/pci.h>
17#include <linux/irq.h>
18#include <linux/mtd/physmap.h>
19#include <linux/mv643xx_eth.h>
20#include <linux/leds.h>
21#include <linux/gpio_keys.h>
22#include <linux/input.h>
23#include <linux/i2c.h>
24#include <asm/mach-types.h>
25#include <asm/gpio.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>
Herbert Valerio Riedel555a3652007-11-12 09:05:55 +010029#include "common.h"
Lennert Buytenhek19cfd5c2008-05-10 23:25:46 +020030#include "mpp.h"
Herbert Valerio Riedel555a3652007-11-12 09:05:55 +010031
32#define DNS323_GPIO_LED_RIGHT_AMBER 1
33#define DNS323_GPIO_LED_LEFT_AMBER 2
34#define DNS323_GPIO_LED_POWER 5
35#define DNS323_GPIO_OVERTEMP 6
36#define DNS323_GPIO_RTC 7
37#define DNS323_GPIO_POWER_OFF 8
38#define DNS323_GPIO_KEY_POWER 9
39#define DNS323_GPIO_KEY_RESET 10
40
41/****************************************************************************
42 * PCI setup
43 */
44
45static int __init dns323_pci_map_irq(struct pci_dev *dev, u8 slot, u8 pin)
46{
Lennert Buytenhek92b913b2008-04-25 16:28:33 -040047 int irq;
Herbert Valerio Riedel555a3652007-11-12 09:05:55 +010048
Lennert Buytenhek92b913b2008-04-25 16:28:33 -040049 /*
50 * Check for devices with hard-wired IRQs.
51 */
52 irq = orion5x_pci_map_irq(dev, slot, pin);
53 if (irq != -1)
54 return irq;
55
Herbert Valerio Riedel555a3652007-11-12 09:05:55 +010056 return -1;
57}
58
59static struct hw_pci dns323_pci __initdata = {
Lennert Buytenhekbbdf1c12008-05-15 10:31:14 +010060 .nr_controllers = 2,
Herbert Valerio Riedel555a3652007-11-12 09:05:55 +010061 .swizzle = pci_std_swizzle,
Lennert Buytenhek9dd0b192008-03-27 14:51:41 -040062 .setup = orion5x_pci_sys_setup,
63 .scan = orion5x_pci_sys_scan_bus,
Herbert Valerio Riedel555a3652007-11-12 09:05:55 +010064 .map_irq = dns323_pci_map_irq,
65};
66
67static int __init dns323_pci_init(void)
68{
69 if (machine_is_dns323())
70 pci_common_init(&dns323_pci);
71
72 return 0;
73}
74
75subsys_initcall(dns323_pci_init);
76
77/****************************************************************************
78 * Ethernet
79 */
80
81static struct mv643xx_eth_platform_data dns323_eth_data = {
82 .phy_addr = 8,
Herbert Valerio Riedel555a3652007-11-12 09:05:55 +010083};
84
85/****************************************************************************
86 * 8MiB NOR flash (Spansion S29GL064M90TFIR4)
87 *
88 * Layout as used by D-Link:
89 * 0x00000000-0x00010000 : "MTD1"
90 * 0x00010000-0x00020000 : "MTD2"
91 * 0x00020000-0x001a0000 : "Linux Kernel"
92 * 0x001a0000-0x007d0000 : "File System"
93 * 0x007d0000-0x00800000 : "u-boot"
94 */
95
96#define DNS323_NOR_BOOT_BASE 0xf4000000
97#define DNS323_NOR_BOOT_SIZE SZ_8M
98
99static struct mtd_partition dns323_partitions[] = {
100 {
101 .name = "MTD1",
102 .size = 0x00010000,
103 .offset = 0,
104 }, {
105 .name = "MTD2",
106 .size = 0x00010000,
107 .offset = 0x00010000,
108 }, {
109 .name = "Linux Kernel",
110 .size = 0x00180000,
111 .offset = 0x00020000,
112 }, {
113 .name = "File System",
114 .size = 0x00630000,
115 .offset = 0x001A0000,
116 }, {
117 .name = "u-boot",
118 .size = 0x00030000,
119 .offset = 0x007d0000,
Lennert Buytenheke7068ad2008-05-10 16:30:01 +0200120 },
Herbert Valerio Riedel555a3652007-11-12 09:05:55 +0100121};
122
123static struct physmap_flash_data dns323_nor_flash_data = {
124 .width = 1,
125 .parts = dns323_partitions,
126 .nr_parts = ARRAY_SIZE(dns323_partitions)
127};
128
129static struct resource dns323_nor_flash_resource = {
130 .flags = IORESOURCE_MEM,
131 .start = DNS323_NOR_BOOT_BASE,
132 .end = DNS323_NOR_BOOT_BASE + DNS323_NOR_BOOT_SIZE - 1,
133};
134
135static struct platform_device dns323_nor_flash = {
136 .name = "physmap-flash",
137 .id = 0,
Lennert Buytenheke7068ad2008-05-10 16:30:01 +0200138 .dev = {
139 .platform_data = &dns323_nor_flash_data,
140 },
Herbert Valerio Riedel555a3652007-11-12 09:05:55 +0100141 .resource = &dns323_nor_flash_resource,
142 .num_resources = 1,
143};
144
145/****************************************************************************
146 * GPIO LEDs (simple - doesn't use hardware blinking support)
147 */
148
149static struct gpio_led dns323_leds[] = {
150 {
151 .name = "power:blue",
152 .gpio = DNS323_GPIO_LED_POWER,
153 .active_low = 1,
154 }, {
155 .name = "right:amber",
156 .gpio = DNS323_GPIO_LED_RIGHT_AMBER,
157 .active_low = 1,
158 }, {
159 .name = "left:amber",
160 .gpio = DNS323_GPIO_LED_LEFT_AMBER,
161 .active_low = 1,
162 },
163};
164
165static struct gpio_led_platform_data dns323_led_data = {
166 .num_leds = ARRAY_SIZE(dns323_leds),
167 .leds = dns323_leds,
168};
169
170static struct platform_device dns323_gpio_leds = {
171 .name = "leds-gpio",
172 .id = -1,
Lennert Buytenheke7068ad2008-05-10 16:30:01 +0200173 .dev = {
174 .platform_data = &dns323_led_data,
175 },
Herbert Valerio Riedel555a3652007-11-12 09:05:55 +0100176};
177
178/****************************************************************************
179 * GPIO Attached Keys
180 */
181
182static struct gpio_keys_button dns323_buttons[] = {
183 {
184 .code = KEY_RESTART,
185 .gpio = DNS323_GPIO_KEY_RESET,
186 .desc = "Reset Button",
187 .active_low = 1,
Lennert Buytenheke7068ad2008-05-10 16:30:01 +0200188 }, {
Herbert Valerio Riedel555a3652007-11-12 09:05:55 +0100189 .code = KEY_POWER,
190 .gpio = DNS323_GPIO_KEY_POWER,
191 .desc = "Power Button",
192 .active_low = 1,
Lennert Buytenheke7068ad2008-05-10 16:30:01 +0200193 },
Herbert Valerio Riedel555a3652007-11-12 09:05:55 +0100194};
195
196static struct gpio_keys_platform_data dns323_button_data = {
197 .buttons = dns323_buttons,
Lennert Buytenheke7068ad2008-05-10 16:30:01 +0200198 .nbuttons = ARRAY_SIZE(dns323_buttons),
Herbert Valerio Riedel555a3652007-11-12 09:05:55 +0100199};
200
201static struct platform_device dns323_button_device = {
202 .name = "gpio-keys",
203 .id = -1,
204 .num_resources = 0,
Lennert Buytenheke7068ad2008-05-10 16:30:01 +0200205 .dev = {
206 .platform_data = &dns323_button_data,
207 },
Herbert Valerio Riedel555a3652007-11-12 09:05:55 +0100208};
209
210/****************************************************************************
211 * General Setup
212 */
Lennert Buytenhek19cfd5c2008-05-10 23:25:46 +0200213static struct orion5x_mpp_mode dns323_mpp_modes[] __initdata = {
214 { 0, MPP_PCIE_RST_OUTn },
215 { 1, MPP_GPIO }, /* right amber LED (sata ch0) */
216 { 2, MPP_GPIO }, /* left amber LED (sata ch1) */
217 { 3, MPP_UNUSED },
218 { 4, MPP_GPIO }, /* power button LED */
219 { 5, MPP_GPIO }, /* power button LED */
220 { 6, MPP_GPIO }, /* GMT G751-2f overtemp */
221 { 7, MPP_GPIO }, /* M41T80 nIRQ/OUT/SQW */
222 { 8, MPP_GPIO }, /* triggers power off */
223 { 9, MPP_GPIO }, /* power button switch */
224 { 10, MPP_GPIO }, /* reset button switch */
225 { 11, MPP_UNUSED },
226 { 12, MPP_UNUSED },
227 { 13, MPP_UNUSED },
228 { 14, MPP_UNUSED },
229 { 15, MPP_UNUSED },
230 { 16, MPP_UNUSED },
231 { 17, MPP_UNUSED },
232 { 18, MPP_UNUSED },
233 { 19, MPP_UNUSED },
234 { -1 },
235};
Herbert Valerio Riedel555a3652007-11-12 09:05:55 +0100236
Herbert Valerio Riedel555a3652007-11-12 09:05:55 +0100237/*
238 * On the DNS-323 the following devices are attached via I2C:
239 *
240 * i2c addr | chip | description
241 * 0x3e | GMT G760Af | fan speed PWM controller
242 * 0x48 | GMT G751-2f | temp. sensor and therm. watchdog (LM75 compatible)
243 * 0x68 | ST M41T80 | RTC w/ alarm
244 */
245static struct i2c_board_info __initdata dns323_i2c_devices[] = {
246 {
247 I2C_BOARD_INFO("g760a", 0x3e),
Herbert Valerio Riedel555a3652007-11-12 09:05:55 +0100248#if 0
249 /* this entry requires the new-style driver model lm75 driver,
250 * for the meantime "insmod lm75.ko force_lm75=0,0x48" is needed */
Lennert Buytenheke7068ad2008-05-10 16:30:01 +0200251 }, {
Jean Delvare3760f732008-04-29 23:11:40 +0200252 I2C_BOARD_INFO("g751", 0x48),
Herbert Valerio Riedel555a3652007-11-12 09:05:55 +0100253#endif
Lennert Buytenheke7068ad2008-05-10 16:30:01 +0200254 }, {
Jean Delvare3760f732008-04-29 23:11:40 +0200255 I2C_BOARD_INFO("m41t80", 0x68),
Lennert Buytenheke7068ad2008-05-10 16:30:01 +0200256 },
Herbert Valerio Riedel555a3652007-11-12 09:05:55 +0100257};
258
259/* DNS-323 specific power off method */
260static void dns323_power_off(void)
261{
262 pr_info("%s: triggering power-off...\n", __func__);
263 gpio_set_value(DNS323_GPIO_POWER_OFF, 1);
264}
265
266static void __init dns323_init(void)
267{
268 /* Setup basic Orion functions. Need to be called early. */
Lennert Buytenhek9dd0b192008-03-27 14:51:41 -0400269 orion5x_init();
Herbert Valerio Riedel555a3652007-11-12 09:05:55 +0100270
Lennert Buytenhek19cfd5c2008-05-10 23:25:46 +0200271 orion5x_mpp_conf(dns323_mpp_modes);
Lennert Buytenhek79e90dd2008-05-28 16:43:48 +0200272 writel(0, MPP_DEV_CTRL); /* DEV_D[31:16] */
Herbert Valerio Riedel555a3652007-11-12 09:05:55 +0100273
Lennert Buytenhek044f6c72008-04-22 05:37:12 +0200274 /*
275 * Configure peripherals.
276 */
277 orion5x_ehci0_init();
278 orion5x_eth_init(&dns323_eth_data);
279 orion5x_i2c_init();
280 orion5x_uart0_init();
Herbert Valerio Riedel555a3652007-11-12 09:05:55 +0100281
Lennert Buytenhek044f6c72008-04-22 05:37:12 +0200282 /* setup flash mapping
283 * CS3 holds a 8 MB Spansion S29GL064M90TFIR4
284 */
285 orion5x_setup_dev_boot_win(DNS323_NOR_BOOT_BASE, DNS323_NOR_BOOT_SIZE);
286 platform_device_register(&dns323_nor_flash);
Herbert Valerio Riedel555a3652007-11-12 09:05:55 +0100287
Lennert Buytenhek044f6c72008-04-22 05:37:12 +0200288 platform_device_register(&dns323_gpio_leds);
289
290 platform_device_register(&dns323_button_device);
Herbert Valerio Riedel555a3652007-11-12 09:05:55 +0100291
292 i2c_register_board_info(0, dns323_i2c_devices,
293 ARRAY_SIZE(dns323_i2c_devices));
294
Lennert Buytenhek044f6c72008-04-22 05:37:12 +0200295 /* register dns323 specific power-off method */
296 if (gpio_request(DNS323_GPIO_POWER_OFF, "POWEROFF") != 0 ||
297 gpio_direction_output(DNS323_GPIO_POWER_OFF, 0) != 0)
298 pr_err("DNS323: failed to setup power-off GPIO\n");
299 pm_power_off = dns323_power_off;
Herbert Valerio Riedel555a3652007-11-12 09:05:55 +0100300}
301
302/* Warning: D-Link uses a wrong mach-type (=526) in their bootloader */
303MACHINE_START(DNS323, "D-Link DNS-323")
304 /* Maintainer: Herbert Valerio Riedel <hvr@gnu.org> */
Lennert Buytenhek9dd0b192008-03-27 14:51:41 -0400305 .phys_io = ORION5X_REGS_PHYS_BASE,
306 .io_pg_offst = ((ORION5X_REGS_VIRT_BASE) >> 18) & 0xFFFC,
Herbert Valerio Riedel555a3652007-11-12 09:05:55 +0100307 .boot_params = 0x00000100,
308 .init_machine = dns323_init,
Lennert Buytenhek9dd0b192008-03-27 14:51:41 -0400309 .map_io = orion5x_map_io,
310 .init_irq = orion5x_init_irq,
311 .timer = &orion5x_timer,
Guennadi Liakhovetskibe73a342008-02-29 21:12:57 +0100312 .fixup = tag_fixup_mem32,
Herbert Valerio Riedel555a3652007-11-12 09:05:55 +0100313MACHINE_END