blob: 54d884fb2517a5207b2b5699d5b89e936917d6c1 [file] [log] [blame]
Rod Whitby3145d8a2006-01-04 17:17:11 +00001/*
2 * arch/arm/mach-ixp4xx/nas100d-setup.c
3 *
4 * NAS 100d board-setup
5 *
6 * based ixdp425-setup.c:
7 * Copyright (C) 2003-2004 MontaVista Software, Inc.
8 *
9 * Author: Alessandro Zummo <a.zummo@towertech.it>
10 * Author: Rod Whitby <rod@whitby.id.au>
11 * Maintainers: http://www.nslu2-linux.org/
12 *
13 */
14
15#include <linux/kernel.h>
16#include <linux/serial.h>
17#include <linux/serial_8250.h>
Rod Whitbydf6934b2006-06-22 22:21:01 +010018#include <linux/leds.h>
Michael-Luke Jones5a4a2382008-01-27 18:14:46 +010019#include <linux/i2c-gpio.h>
Rod Whitby3145d8a2006-01-04 17:17:11 +000020
21#include <asm/mach-types.h>
22#include <asm/mach/arch.h>
23#include <asm/mach/flash.h>
24
25static struct flash_platform_data nas100d_flash_data = {
26 .map_name = "cfi_probe",
27 .width = 2,
28};
29
30static struct resource nas100d_flash_resource = {
Rod Whitby3145d8a2006-01-04 17:17:11 +000031 .flags = IORESOURCE_MEM,
32};
33
34static struct platform_device nas100d_flash = {
35 .name = "IXP4XX-Flash",
36 .id = 0,
37 .dev.platform_data = &nas100d_flash_data,
38 .num_resources = 1,
39 .resource = &nas100d_flash_resource,
40};
41
Rod Whitbydf6934b2006-06-22 22:21:01 +010042#ifdef CONFIG_LEDS_IXP4XX
43static struct resource nas100d_led_resources[] = {
44 {
45 .name = "wlan", /* green led */
46 .start = 0,
47 .end = 0,
48 .flags = IXP4XX_GPIO_LOW,
49 },
50 {
51 .name = "ready", /* blue power led (off is flashing!) */
52 .start = 15,
53 .end = 15,
54 .flags = IXP4XX_GPIO_LOW,
55 },
56 {
57 .name = "disk", /* yellow led */
58 .start = 3,
59 .end = 3,
60 .flags = IXP4XX_GPIO_LOW,
61 },
62};
63
64static struct platform_device nas100d_leds = {
65 .name = "IXP4XX-GPIO-LED",
66 .id = -1,
67 .num_resources = ARRAY_SIZE(nas100d_led_resources),
68 .resource = nas100d_led_resources,
69};
70#endif
71
Michael-Luke Jones5a4a2382008-01-27 18:14:46 +010072static struct i2c_gpio_platform_data nas100d_i2c_gpio_data = {
Rod Whitby3145d8a2006-01-04 17:17:11 +000073 .sda_pin = NAS100D_SDA_PIN,
74 .scl_pin = NAS100D_SCL_PIN,
75};
76
Michael-Luke Jones5a4a2382008-01-27 18:14:46 +010077static struct platform_device nas100d_i2c_gpio = {
78 .name = "i2c-gpio",
Rod Whitby3145d8a2006-01-04 17:17:11 +000079 .id = 0,
Michael-Luke Jones5a4a2382008-01-27 18:14:46 +010080 .dev = {
81 .platform_data = &nas100d_i2c_gpio_data,
82 },
Rod Whitby3145d8a2006-01-04 17:17:11 +000083};
84
85static struct resource nas100d_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 nas100d_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 nas100d_uart = {
121 .name = "serial8250",
122 .id = PLAT8250_DEV_PLATFORM,
123 .dev.platform_data = nas100d_uart_data,
124 .num_resources = 2,
125 .resource = nas100d_uart_resources,
126};
127
128static struct platform_device *nas100d_devices[] __initdata = {
Michael-Luke Jones5a4a2382008-01-27 18:14:46 +0100129 &nas100d_i2c_gpio,
Rod Whitby3145d8a2006-01-04 17:17:11 +0000130 &nas100d_flash,
Rod Whitbydf6934b2006-06-22 22:21:01 +0100131#ifdef CONFIG_LEDS_IXP4XX
132 &nas100d_leds,
133#endif
Rod Whitby3145d8a2006-01-04 17:17:11 +0000134};
135
136static void nas100d_power_off(void)
137{
138 /* This causes the box to drop the power and go dead. */
139
140 /* enable the pwr cntl gpio */
141 gpio_line_config(NAS100D_PO_GPIO, IXP4XX_GPIO_OUT);
142
143 /* do the deed */
144 gpio_line_set(NAS100D_PO_GPIO, IXP4XX_GPIO_HIGH);
145}
146
147static void __init nas100d_init(void)
148{
149 ixp4xx_sys_init();
150
Alessandro Zummodcc8fa52006-03-08 23:45:10 +0000151 /* gpio 14 and 15 are _not_ clocks */
152 *IXP4XX_GPIO_GPCLKR = 0;
153
Deepak Saxena54e269e2006-01-05 20:59:29 +0000154 nas100d_flash_resource.start = IXP4XX_EXP_BUS_BASE(0);
155 nas100d_flash_resource.end =
156 IXP4XX_EXP_BUS_BASE(0) + ixp4xx_exp_bus_size - 1;
157
Rod Whitby3145d8a2006-01-04 17:17:11 +0000158 pm_power_off = nas100d_power_off;
159
Michael-Luke Jonescc50a0d2007-05-23 22:41:53 +0100160 /*
161 * This is only useful on a modified machine, but it is valuable
Rod Whitbydf6934b2006-06-22 22:21:01 +0100162 * to have it first in order to see debug messages, and so that
163 * it does *not* get removed if platform_add_devices fails!
164 */
165 (void)platform_device_register(&nas100d_uart);
166
Rod Whitby3145d8a2006-01-04 17:17:11 +0000167 platform_add_devices(nas100d_devices, ARRAY_SIZE(nas100d_devices));
168}
169
170MACHINE_START(NAS100D, "Iomega NAS 100d")
171 /* Maintainer: www.nslu2-linux.org */
Rod Whitby3145d8a2006-01-04 17:17:11 +0000172 .phys_io = IXP4XX_PERIPHERAL_BASE_PHYS,
173 .io_pg_offst = ((IXP4XX_PERIPHERAL_BASE_VIRT) >> 18) & 0xFFFC,
174 .boot_params = 0x00000100,
175 .map_io = ixp4xx_map_io,
176 .init_irq = ixp4xx_init_irq,
177 .timer = &ixp4xx_timer,
178 .init_machine = nas100d_init,
179MACHINE_END