blob: d0e129566fbc8dccf059699e49546eefa80df5f8 [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>
Rod Whitby1208ebf2008-02-02 00:03:56 +010017#include <linux/leds.h>
Rod Whitbya9a424c2008-01-29 00:40:02 +010018#include <linux/i2c.h>
Michael-Luke Jones5a4a2382008-01-27 18:14:46 +010019#include <linux/i2c-gpio.h>
Michael-Luke Jones28bd3a02007-04-28 08:31:40 +010020
21#include <asm/mach-types.h>
22#include <asm/mach/arch.h>
23#include <asm/mach/flash.h>
Michael-Luke Jones435c5da2007-05-23 22:38:45 +010024#include <asm/mach/time.h>
Michael-Luke Jones28bd3a02007-04-28 08:31:40 +010025
26static struct flash_platform_data dsmg600_flash_data = {
27 .map_name = "cfi_probe",
28 .width = 2,
29};
30
31static struct resource dsmg600_flash_resource = {
32 .flags = IORESOURCE_MEM,
33};
34
35static struct platform_device dsmg600_flash = {
36 .name = "IXP4XX-Flash",
37 .id = 0,
38 .dev.platform_data = &dsmg600_flash_data,
39 .num_resources = 1,
40 .resource = &dsmg600_flash_resource,
41};
42
Michael-Luke Jones5a4a2382008-01-27 18:14:46 +010043static struct i2c_gpio_platform_data dsmg600_i2c_gpio_data = {
Michael-Luke Jones28bd3a02007-04-28 08:31:40 +010044 .sda_pin = DSMG600_SDA_PIN,
45 .scl_pin = DSMG600_SCL_PIN,
46};
47
Michael-Luke Jones5a4a2382008-01-27 18:14:46 +010048static struct platform_device dsmg600_i2c_gpio = {
49 .name = "i2c-gpio",
Michael-Luke Jones28bd3a02007-04-28 08:31:40 +010050 .id = 0,
Michael-Luke Jones5a4a2382008-01-27 18:14:46 +010051 .dev = {
52 .platform_data = &dsmg600_i2c_gpio_data,
53 },
Michael-Luke Jones28bd3a02007-04-28 08:31:40 +010054};
55
Rod Whitbya9a424c2008-01-29 00:40:02 +010056static struct i2c_board_info __initdata dsmg600_i2c_board_info [] = {
57 {
58 I2C_BOARD_INFO("rtc-pcf8563", 0x51),
59 },
60};
61
Rod Whitby1208ebf2008-02-02 00:03:56 +010062static struct gpio_led dsmg600_led_pins[] = {
Michael-Luke Jones28bd3a02007-04-28 08:31:40 +010063 {
Rod Whitby1208ebf2008-02-02 00:03:56 +010064 .name = "power",
65 .gpio = DSMG600_LED_PWR_GPIO,
Michael-Luke Jones28bd3a02007-04-28 08:31:40 +010066 },
67 {
Rod Whitby1208ebf2008-02-02 00:03:56 +010068 .name = "wlan",
69 .gpio = DSMG600_LED_WLAN_GPIO,
70 .active_low = true,
Michael-Luke Jones28bd3a02007-04-28 08:31:40 +010071 },
72};
73
Rod Whitby1208ebf2008-02-02 00:03:56 +010074static struct gpio_led_platform_data dsmg600_led_data = {
75 .num_leds = ARRAY_SIZE(dsmg600_led_pins),
76 .leds = dsmg600_led_pins,
Michael-Luke Jones28bd3a02007-04-28 08:31:40 +010077};
Rod Whitby1208ebf2008-02-02 00:03:56 +010078
79static struct platform_device dsmg600_leds = {
80 .name = "leds-gpio",
81 .id = -1,
82 .dev.platform_data = &dsmg600_led_data,
83};
Michael-Luke Jones28bd3a02007-04-28 08:31:40 +010084
85static struct resource dsmg600_uart_resources[] = {
86 {
87 .start = IXP4XX_UART1_BASE_PHYS,
88 .end = IXP4XX_UART1_BASE_PHYS + 0x0fff,
89 .flags = IORESOURCE_MEM,
90 },
91 {
92 .start = IXP4XX_UART2_BASE_PHYS,
93 .end = IXP4XX_UART2_BASE_PHYS + 0x0fff,
94 .flags = IORESOURCE_MEM,
95 }
96};
97
98static struct plat_serial8250_port dsmg600_uart_data[] = {
99 {
100 .mapbase = IXP4XX_UART1_BASE_PHYS,
101 .membase = (char *)IXP4XX_UART1_BASE_VIRT + REG_OFFSET,
102 .irq = IRQ_IXP4XX_UART1,
103 .flags = UPF_BOOT_AUTOCONF,
104 .iotype = UPIO_MEM,
105 .regshift = 2,
106 .uartclk = IXP4XX_UART_XTAL,
107 },
108 {
109 .mapbase = IXP4XX_UART2_BASE_PHYS,
110 .membase = (char *)IXP4XX_UART2_BASE_VIRT + REG_OFFSET,
111 .irq = IRQ_IXP4XX_UART2,
112 .flags = UPF_BOOT_AUTOCONF,
113 .iotype = UPIO_MEM,
114 .regshift = 2,
115 .uartclk = IXP4XX_UART_XTAL,
116 },
117 { }
118};
119
120static struct platform_device dsmg600_uart = {
121 .name = "serial8250",
122 .id = PLAT8250_DEV_PLATFORM,
123 .dev.platform_data = dsmg600_uart_data,
124 .num_resources = ARRAY_SIZE(dsmg600_uart_resources),
125 .resource = dsmg600_uart_resources,
126};
127
128static struct platform_device *dsmg600_devices[] __initdata = {
Michael-Luke Jones5a4a2382008-01-27 18:14:46 +0100129 &dsmg600_i2c_gpio,
Michael-Luke Jones28bd3a02007-04-28 08:31:40 +0100130 &dsmg600_flash,
Rod Whitby1208ebf2008-02-02 00:03:56 +0100131 &dsmg600_leds,
Michael-Luke Jones28bd3a02007-04-28 08:31:40 +0100132};
133
134static void dsmg600_power_off(void)
135{
136 /* enable the pwr cntl gpio */
137 gpio_line_config(DSMG600_PO_GPIO, IXP4XX_GPIO_OUT);
138
139 /* poweroff */
140 gpio_line_set(DSMG600_PO_GPIO, IXP4XX_GPIO_HIGH);
141}
142
Michael-Luke Jones435c5da2007-05-23 22:38:45 +0100143static void __init dsmg600_timer_init(void)
144{
145 /* The xtal on this machine is non-standard. */
146 ixp4xx_timer_freq = DSMG600_FREQ;
147
148 /* Call standard timer_init function. */
149 ixp4xx_timer_init();
150}
151
152static struct sys_timer dsmg600_timer = {
153 .init = dsmg600_timer_init,
154};
155
Michael-Luke Jones28bd3a02007-04-28 08:31:40 +0100156static void __init dsmg600_init(void)
157{
158 ixp4xx_sys_init();
159
160 /* Make sure that GPIO14 and GPIO15 are not used as clocks */
161 *IXP4XX_GPIO_GPCLKR = 0;
162
163 dsmg600_flash_resource.start = IXP4XX_EXP_BUS_BASE(0);
164 dsmg600_flash_resource.end =
165 IXP4XX_EXP_BUS_BASE(0) + ixp4xx_exp_bus_size - 1;
166
167 pm_power_off = dsmg600_power_off;
168
Rod Whitbya9a424c2008-01-29 00:40:02 +0100169 i2c_register_board_info(0, dsmg600_i2c_board_info,
170 ARRAY_SIZE(dsmg600_i2c_board_info));
171
Michael-Luke Jones28bd3a02007-04-28 08:31:40 +0100172 /* The UART is required on the DSM-G600 (Redboot cannot use the
173 * NIC) -- do it here so that it does *not* get removed if
174 * platform_add_devices fails!
175 */
176 (void)platform_device_register(&dsmg600_uart);
177
178 platform_add_devices(dsmg600_devices, ARRAY_SIZE(dsmg600_devices));
Michael-Luke Jones28bd3a02007-04-28 08:31:40 +0100179}
180
Michael-Luke Jones28bd3a02007-04-28 08:31:40 +0100181MACHINE_START(DSMG600, "D-Link DSM-G600 RevA")
182 /* Maintainer: www.nslu2-linux.org */
183 .phys_io = IXP4XX_PERIPHERAL_BASE_PHYS,
184 .io_pg_offst = ((IXP4XX_PERIPHERAL_BASE_VIRT) >> 18) & 0xFFFC,
185 .boot_params = 0x00000100,
Michael-Luke Jones28bd3a02007-04-28 08:31:40 +0100186 .map_io = ixp4xx_map_io,
187 .init_irq = ixp4xx_init_irq,
Michael-Luke Jones435c5da2007-05-23 22:38:45 +0100188 .timer = &dsmg600_timer,
Michael-Luke Jones28bd3a02007-04-28 08:31:40 +0100189 .init_machine = dsmg600_init,
190MACHINE_END