Michael-Luke Jones | 28bd3a0 | 2007-04-28 08:31:40 +0100 | [diff] [blame] | 1 | /* |
| 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 Whitby | a9a424c | 2008-01-29 00:40:02 +0100 | [diff] [blame^] | 17 | #include <linux/i2c.h> |
Michael-Luke Jones | 5a4a238 | 2008-01-27 18:14:46 +0100 | [diff] [blame] | 18 | #include <linux/i2c-gpio.h> |
Michael-Luke Jones | 28bd3a0 | 2007-04-28 08:31:40 +0100 | [diff] [blame] | 19 | |
| 20 | #include <asm/mach-types.h> |
| 21 | #include <asm/mach/arch.h> |
| 22 | #include <asm/mach/flash.h> |
Michael-Luke Jones | 435c5da | 2007-05-23 22:38:45 +0100 | [diff] [blame] | 23 | #include <asm/mach/time.h> |
Michael-Luke Jones | 28bd3a0 | 2007-04-28 08:31:40 +0100 | [diff] [blame] | 24 | |
| 25 | static struct flash_platform_data dsmg600_flash_data = { |
| 26 | .map_name = "cfi_probe", |
| 27 | .width = 2, |
| 28 | }; |
| 29 | |
| 30 | static struct resource dsmg600_flash_resource = { |
| 31 | .flags = IORESOURCE_MEM, |
| 32 | }; |
| 33 | |
| 34 | static struct platform_device dsmg600_flash = { |
| 35 | .name = "IXP4XX-Flash", |
| 36 | .id = 0, |
| 37 | .dev.platform_data = &dsmg600_flash_data, |
| 38 | .num_resources = 1, |
| 39 | .resource = &dsmg600_flash_resource, |
| 40 | }; |
| 41 | |
Michael-Luke Jones | 5a4a238 | 2008-01-27 18:14:46 +0100 | [diff] [blame] | 42 | static struct i2c_gpio_platform_data dsmg600_i2c_gpio_data = { |
Michael-Luke Jones | 28bd3a0 | 2007-04-28 08:31:40 +0100 | [diff] [blame] | 43 | .sda_pin = DSMG600_SDA_PIN, |
| 44 | .scl_pin = DSMG600_SCL_PIN, |
| 45 | }; |
| 46 | |
Michael-Luke Jones | 5a4a238 | 2008-01-27 18:14:46 +0100 | [diff] [blame] | 47 | static struct platform_device dsmg600_i2c_gpio = { |
| 48 | .name = "i2c-gpio", |
Michael-Luke Jones | 28bd3a0 | 2007-04-28 08:31:40 +0100 | [diff] [blame] | 49 | .id = 0, |
Michael-Luke Jones | 5a4a238 | 2008-01-27 18:14:46 +0100 | [diff] [blame] | 50 | .dev = { |
| 51 | .platform_data = &dsmg600_i2c_gpio_data, |
| 52 | }, |
Michael-Luke Jones | 28bd3a0 | 2007-04-28 08:31:40 +0100 | [diff] [blame] | 53 | }; |
| 54 | |
Rod Whitby | a9a424c | 2008-01-29 00:40:02 +0100 | [diff] [blame^] | 55 | static struct i2c_board_info __initdata dsmg600_i2c_board_info [] = { |
| 56 | { |
| 57 | I2C_BOARD_INFO("rtc-pcf8563", 0x51), |
| 58 | }, |
| 59 | }; |
| 60 | |
Michael-Luke Jones | 28bd3a0 | 2007-04-28 08:31:40 +0100 | [diff] [blame] | 61 | #ifdef CONFIG_LEDS_CLASS |
| 62 | static struct resource dsmg600_led_resources[] = { |
| 63 | { |
| 64 | .name = "power", |
| 65 | .start = DSMG600_LED_PWR_GPIO, |
| 66 | .end = DSMG600_LED_PWR_GPIO, |
| 67 | .flags = IXP4XX_GPIO_HIGH, |
| 68 | }, |
| 69 | { |
| 70 | .name = "wlan", |
| 71 | .start = DSMG600_LED_WLAN_GPIO, |
| 72 | .end = DSMG600_LED_WLAN_GPIO, |
| 73 | .flags = IXP4XX_GPIO_LOW, |
| 74 | }, |
| 75 | }; |
| 76 | |
| 77 | static struct platform_device dsmg600_leds = { |
| 78 | .name = "IXP4XX-GPIO-LED", |
| 79 | .id = -1, |
| 80 | .num_resources = ARRAY_SIZE(dsmg600_led_resources), |
| 81 | .resource = dsmg600_led_resources, |
| 82 | }; |
| 83 | #endif |
| 84 | |
| 85 | static 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 | |
| 98 | static 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 | |
| 120 | static 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 | |
| 128 | static struct platform_device *dsmg600_devices[] __initdata = { |
Michael-Luke Jones | 5a4a238 | 2008-01-27 18:14:46 +0100 | [diff] [blame] | 129 | &dsmg600_i2c_gpio, |
Michael-Luke Jones | 28bd3a0 | 2007-04-28 08:31:40 +0100 | [diff] [blame] | 130 | &dsmg600_flash, |
| 131 | }; |
| 132 | |
| 133 | static void dsmg600_power_off(void) |
| 134 | { |
| 135 | /* enable the pwr cntl gpio */ |
| 136 | gpio_line_config(DSMG600_PO_GPIO, IXP4XX_GPIO_OUT); |
| 137 | |
| 138 | /* poweroff */ |
| 139 | gpio_line_set(DSMG600_PO_GPIO, IXP4XX_GPIO_HIGH); |
| 140 | } |
| 141 | |
Michael-Luke Jones | 435c5da | 2007-05-23 22:38:45 +0100 | [diff] [blame] | 142 | static void __init dsmg600_timer_init(void) |
| 143 | { |
| 144 | /* The xtal on this machine is non-standard. */ |
| 145 | ixp4xx_timer_freq = DSMG600_FREQ; |
| 146 | |
| 147 | /* Call standard timer_init function. */ |
| 148 | ixp4xx_timer_init(); |
| 149 | } |
| 150 | |
| 151 | static struct sys_timer dsmg600_timer = { |
| 152 | .init = dsmg600_timer_init, |
| 153 | }; |
| 154 | |
Michael-Luke Jones | 28bd3a0 | 2007-04-28 08:31:40 +0100 | [diff] [blame] | 155 | static void __init dsmg600_init(void) |
| 156 | { |
| 157 | ixp4xx_sys_init(); |
| 158 | |
| 159 | /* Make sure that GPIO14 and GPIO15 are not used as clocks */ |
| 160 | *IXP4XX_GPIO_GPCLKR = 0; |
| 161 | |
| 162 | dsmg600_flash_resource.start = IXP4XX_EXP_BUS_BASE(0); |
| 163 | dsmg600_flash_resource.end = |
| 164 | IXP4XX_EXP_BUS_BASE(0) + ixp4xx_exp_bus_size - 1; |
| 165 | |
| 166 | pm_power_off = dsmg600_power_off; |
| 167 | |
Rod Whitby | a9a424c | 2008-01-29 00:40:02 +0100 | [diff] [blame^] | 168 | i2c_register_board_info(0, dsmg600_i2c_board_info, |
| 169 | ARRAY_SIZE(dsmg600_i2c_board_info)); |
| 170 | |
Michael-Luke Jones | 28bd3a0 | 2007-04-28 08:31:40 +0100 | [diff] [blame] | 171 | /* The UART is required on the DSM-G600 (Redboot cannot use the |
| 172 | * NIC) -- do it here so that it does *not* get removed if |
| 173 | * platform_add_devices fails! |
| 174 | */ |
| 175 | (void)platform_device_register(&dsmg600_uart); |
| 176 | |
| 177 | platform_add_devices(dsmg600_devices, ARRAY_SIZE(dsmg600_devices)); |
| 178 | |
| 179 | #ifdef CONFIG_LEDS_CLASS |
| 180 | /* We don't care whether or not this works. */ |
| 181 | (void)platform_device_register(&dsmg600_leds); |
| 182 | #endif |
| 183 | } |
| 184 | |
Michael-Luke Jones | 28bd3a0 | 2007-04-28 08:31:40 +0100 | [diff] [blame] | 185 | MACHINE_START(DSMG600, "D-Link DSM-G600 RevA") |
| 186 | /* Maintainer: www.nslu2-linux.org */ |
| 187 | .phys_io = IXP4XX_PERIPHERAL_BASE_PHYS, |
| 188 | .io_pg_offst = ((IXP4XX_PERIPHERAL_BASE_VIRT) >> 18) & 0xFFFC, |
| 189 | .boot_params = 0x00000100, |
Michael-Luke Jones | 28bd3a0 | 2007-04-28 08:31:40 +0100 | [diff] [blame] | 190 | .map_io = ixp4xx_map_io, |
| 191 | .init_irq = ixp4xx_init_irq, |
Michael-Luke Jones | 435c5da | 2007-05-23 22:38:45 +0100 | [diff] [blame] | 192 | .timer = &dsmg600_timer, |
Michael-Luke Jones | 28bd3a0 | 2007-04-28 08:31:40 +0100 | [diff] [blame] | 193 | .init_machine = dsmg600_init, |
| 194 | MACHINE_END |