blob: c473d408aa7c10b64ab3cf4ee8156c45a2833946 [file] [log] [blame]
Michael-Luke Jones28bd3a02007-04-28 08:31:40 +01001/*
2 * DSM-G600 board-setup
3 *
4 * Copyright (C) 2006 Tower Technologies
5 * Author: Alessandro Zummo <a.zummo@towertech.it>
6 *
7 * based ixdp425-setup.c:
8 * Copyright (C) 2003-2004 MontaVista Software, Inc.
9 *
10 * Author: Alessandro Zummo <a.zummo@towertech.it>
11 * Maintainers: http://www.nslu2-linux.org/
12 */
13
14#include <linux/kernel.h>
15#include <linux/serial.h>
16#include <linux/serial_8250.h>
Michael-Luke Jones5a4a2382008-01-27 18:14:46 +010017#include <linux/i2c-gpio.h>
Michael-Luke Jones28bd3a02007-04-28 08:31:40 +010018
19#include <asm/mach-types.h>
20#include <asm/mach/arch.h>
21#include <asm/mach/flash.h>
Michael-Luke Jones435c5da2007-05-23 22:38:45 +010022#include <asm/mach/time.h>
Michael-Luke Jones28bd3a02007-04-28 08:31:40 +010023
24static struct flash_platform_data dsmg600_flash_data = {
25 .map_name = "cfi_probe",
26 .width = 2,
27};
28
29static struct resource dsmg600_flash_resource = {
30 .flags = IORESOURCE_MEM,
31};
32
33static struct platform_device dsmg600_flash = {
34 .name = "IXP4XX-Flash",
35 .id = 0,
36 .dev.platform_data = &dsmg600_flash_data,
37 .num_resources = 1,
38 .resource = &dsmg600_flash_resource,
39};
40
Michael-Luke Jones5a4a2382008-01-27 18:14:46 +010041static struct i2c_gpio_platform_data dsmg600_i2c_gpio_data = {
Michael-Luke Jones28bd3a02007-04-28 08:31:40 +010042 .sda_pin = DSMG600_SDA_PIN,
43 .scl_pin = DSMG600_SCL_PIN,
44};
45
Michael-Luke Jones5a4a2382008-01-27 18:14:46 +010046static struct platform_device dsmg600_i2c_gpio = {
47 .name = "i2c-gpio",
Michael-Luke Jones28bd3a02007-04-28 08:31:40 +010048 .id = 0,
Michael-Luke Jones5a4a2382008-01-27 18:14:46 +010049 .dev = {
50 .platform_data = &dsmg600_i2c_gpio_data,
51 },
Michael-Luke Jones28bd3a02007-04-28 08:31:40 +010052};
53
54#ifdef CONFIG_LEDS_CLASS
55static struct resource dsmg600_led_resources[] = {
56 {
57 .name = "power",
58 .start = DSMG600_LED_PWR_GPIO,
59 .end = DSMG600_LED_PWR_GPIO,
60 .flags = IXP4XX_GPIO_HIGH,
61 },
62 {
63 .name = "wlan",
64 .start = DSMG600_LED_WLAN_GPIO,
65 .end = DSMG600_LED_WLAN_GPIO,
66 .flags = IXP4XX_GPIO_LOW,
67 },
68};
69
70static struct platform_device dsmg600_leds = {
71 .name = "IXP4XX-GPIO-LED",
72 .id = -1,
73 .num_resources = ARRAY_SIZE(dsmg600_led_resources),
74 .resource = dsmg600_led_resources,
75};
76#endif
77
78static struct resource dsmg600_uart_resources[] = {
79 {
80 .start = IXP4XX_UART1_BASE_PHYS,
81 .end = IXP4XX_UART1_BASE_PHYS + 0x0fff,
82 .flags = IORESOURCE_MEM,
83 },
84 {
85 .start = IXP4XX_UART2_BASE_PHYS,
86 .end = IXP4XX_UART2_BASE_PHYS + 0x0fff,
87 .flags = IORESOURCE_MEM,
88 }
89};
90
91static struct plat_serial8250_port dsmg600_uart_data[] = {
92 {
93 .mapbase = IXP4XX_UART1_BASE_PHYS,
94 .membase = (char *)IXP4XX_UART1_BASE_VIRT + REG_OFFSET,
95 .irq = IRQ_IXP4XX_UART1,
96 .flags = UPF_BOOT_AUTOCONF,
97 .iotype = UPIO_MEM,
98 .regshift = 2,
99 .uartclk = IXP4XX_UART_XTAL,
100 },
101 {
102 .mapbase = IXP4XX_UART2_BASE_PHYS,
103 .membase = (char *)IXP4XX_UART2_BASE_VIRT + REG_OFFSET,
104 .irq = IRQ_IXP4XX_UART2,
105 .flags = UPF_BOOT_AUTOCONF,
106 .iotype = UPIO_MEM,
107 .regshift = 2,
108 .uartclk = IXP4XX_UART_XTAL,
109 },
110 { }
111};
112
113static struct platform_device dsmg600_uart = {
114 .name = "serial8250",
115 .id = PLAT8250_DEV_PLATFORM,
116 .dev.platform_data = dsmg600_uart_data,
117 .num_resources = ARRAY_SIZE(dsmg600_uart_resources),
118 .resource = dsmg600_uart_resources,
119};
120
121static struct platform_device *dsmg600_devices[] __initdata = {
Michael-Luke Jones5a4a2382008-01-27 18:14:46 +0100122 &dsmg600_i2c_gpio,
Michael-Luke Jones28bd3a02007-04-28 08:31:40 +0100123 &dsmg600_flash,
124};
125
126static void dsmg600_power_off(void)
127{
128 /* enable the pwr cntl gpio */
129 gpio_line_config(DSMG600_PO_GPIO, IXP4XX_GPIO_OUT);
130
131 /* poweroff */
132 gpio_line_set(DSMG600_PO_GPIO, IXP4XX_GPIO_HIGH);
133}
134
Michael-Luke Jones435c5da2007-05-23 22:38:45 +0100135static void __init dsmg600_timer_init(void)
136{
137 /* The xtal on this machine is non-standard. */
138 ixp4xx_timer_freq = DSMG600_FREQ;
139
140 /* Call standard timer_init function. */
141 ixp4xx_timer_init();
142}
143
144static struct sys_timer dsmg600_timer = {
145 .init = dsmg600_timer_init,
146};
147
Michael-Luke Jones28bd3a02007-04-28 08:31:40 +0100148static void __init dsmg600_init(void)
149{
150 ixp4xx_sys_init();
151
152 /* Make sure that GPIO14 and GPIO15 are not used as clocks */
153 *IXP4XX_GPIO_GPCLKR = 0;
154
155 dsmg600_flash_resource.start = IXP4XX_EXP_BUS_BASE(0);
156 dsmg600_flash_resource.end =
157 IXP4XX_EXP_BUS_BASE(0) + ixp4xx_exp_bus_size - 1;
158
159 pm_power_off = dsmg600_power_off;
160
161 /* The UART is required on the DSM-G600 (Redboot cannot use the
162 * NIC) -- do it here so that it does *not* get removed if
163 * platform_add_devices fails!
164 */
165 (void)platform_device_register(&dsmg600_uart);
166
167 platform_add_devices(dsmg600_devices, ARRAY_SIZE(dsmg600_devices));
168
169#ifdef CONFIG_LEDS_CLASS
170 /* We don't care whether or not this works. */
171 (void)platform_device_register(&dsmg600_leds);
172#endif
173}
174
Michael-Luke Jones28bd3a02007-04-28 08:31:40 +0100175MACHINE_START(DSMG600, "D-Link DSM-G600 RevA")
176 /* Maintainer: www.nslu2-linux.org */
177 .phys_io = IXP4XX_PERIPHERAL_BASE_PHYS,
178 .io_pg_offst = ((IXP4XX_PERIPHERAL_BASE_VIRT) >> 18) & 0xFFFC,
179 .boot_params = 0x00000100,
Michael-Luke Jones28bd3a02007-04-28 08:31:40 +0100180 .map_io = ixp4xx_map_io,
181 .init_irq = ixp4xx_init_irq,
Michael-Luke Jones435c5da2007-05-23 22:38:45 +0100182 .timer = &dsmg600_timer,
Michael-Luke Jones28bd3a02007-04-28 08:31:40 +0100183 .init_machine = dsmg600_init,
184MACHINE_END