Herbert Valerio Riedel | 555a365 | 2007-11-12 09:05:55 +0100 | [diff] [blame] | 1 | /* |
Lennert Buytenhek | 9dd0b19 | 2008-03-27 14:51:41 -0400 | [diff] [blame] | 2 | * arch/arm/mach-orion5x/dns323-setup.c |
Herbert Valerio Riedel | 555a365 | 2007-11-12 09:05:55 +0100 | [diff] [blame] | 3 | * |
| 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> |
Lennert Buytenhek | 9dd0b19 | 2008-03-27 14:51:41 -0400 | [diff] [blame] | 28 | #include <asm/arch/orion5x.h> |
Herbert Valerio Riedel | 555a365 | 2007-11-12 09:05:55 +0100 | [diff] [blame] | 29 | #include "common.h" |
| 30 | |
| 31 | #define DNS323_GPIO_LED_RIGHT_AMBER 1 |
| 32 | #define DNS323_GPIO_LED_LEFT_AMBER 2 |
| 33 | #define DNS323_GPIO_LED_POWER 5 |
| 34 | #define DNS323_GPIO_OVERTEMP 6 |
| 35 | #define DNS323_GPIO_RTC 7 |
| 36 | #define DNS323_GPIO_POWER_OFF 8 |
| 37 | #define DNS323_GPIO_KEY_POWER 9 |
| 38 | #define DNS323_GPIO_KEY_RESET 10 |
| 39 | |
| 40 | /**************************************************************************** |
| 41 | * PCI setup |
| 42 | */ |
| 43 | |
| 44 | static int __init dns323_pci_map_irq(struct pci_dev *dev, u8 slot, u8 pin) |
| 45 | { |
Lennert Buytenhek | 92b913b | 2008-04-25 16:28:33 -0400 | [diff] [blame] | 46 | int irq; |
Herbert Valerio Riedel | 555a365 | 2007-11-12 09:05:55 +0100 | [diff] [blame] | 47 | |
Lennert Buytenhek | 92b913b | 2008-04-25 16:28:33 -0400 | [diff] [blame] | 48 | /* |
| 49 | * Check for devices with hard-wired IRQs. |
| 50 | */ |
| 51 | irq = orion5x_pci_map_irq(dev, slot, pin); |
| 52 | if (irq != -1) |
| 53 | return irq; |
| 54 | |
| 55 | pr_err("%s: requested mapping for unknown device\n", __func__); |
Herbert Valerio Riedel | 555a365 | 2007-11-12 09:05:55 +0100 | [diff] [blame] | 56 | |
| 57 | return -1; |
| 58 | } |
| 59 | |
| 60 | static struct hw_pci dns323_pci __initdata = { |
Lennert Buytenhek | bbdf1c1 | 2008-05-15 10:31:14 +0100 | [diff] [blame] | 61 | .nr_controllers = 2, |
Herbert Valerio Riedel | 555a365 | 2007-11-12 09:05:55 +0100 | [diff] [blame] | 62 | .swizzle = pci_std_swizzle, |
Lennert Buytenhek | 9dd0b19 | 2008-03-27 14:51:41 -0400 | [diff] [blame] | 63 | .setup = orion5x_pci_sys_setup, |
| 64 | .scan = orion5x_pci_sys_scan_bus, |
Herbert Valerio Riedel | 555a365 | 2007-11-12 09:05:55 +0100 | [diff] [blame] | 65 | .map_irq = dns323_pci_map_irq, |
| 66 | }; |
| 67 | |
| 68 | static int __init dns323_pci_init(void) |
| 69 | { |
| 70 | if (machine_is_dns323()) |
| 71 | pci_common_init(&dns323_pci); |
| 72 | |
| 73 | return 0; |
| 74 | } |
| 75 | |
| 76 | subsys_initcall(dns323_pci_init); |
| 77 | |
| 78 | /**************************************************************************** |
| 79 | * Ethernet |
| 80 | */ |
| 81 | |
| 82 | static struct mv643xx_eth_platform_data dns323_eth_data = { |
| 83 | .phy_addr = 8, |
| 84 | .force_phy_addr = 1, |
| 85 | }; |
| 86 | |
| 87 | /**************************************************************************** |
| 88 | * 8MiB NOR flash (Spansion S29GL064M90TFIR4) |
| 89 | * |
| 90 | * Layout as used by D-Link: |
| 91 | * 0x00000000-0x00010000 : "MTD1" |
| 92 | * 0x00010000-0x00020000 : "MTD2" |
| 93 | * 0x00020000-0x001a0000 : "Linux Kernel" |
| 94 | * 0x001a0000-0x007d0000 : "File System" |
| 95 | * 0x007d0000-0x00800000 : "u-boot" |
| 96 | */ |
| 97 | |
| 98 | #define DNS323_NOR_BOOT_BASE 0xf4000000 |
| 99 | #define DNS323_NOR_BOOT_SIZE SZ_8M |
| 100 | |
| 101 | static struct mtd_partition dns323_partitions[] = { |
| 102 | { |
| 103 | .name = "MTD1", |
| 104 | .size = 0x00010000, |
| 105 | .offset = 0, |
| 106 | }, { |
| 107 | .name = "MTD2", |
| 108 | .size = 0x00010000, |
| 109 | .offset = 0x00010000, |
| 110 | }, { |
| 111 | .name = "Linux Kernel", |
| 112 | .size = 0x00180000, |
| 113 | .offset = 0x00020000, |
| 114 | }, { |
| 115 | .name = "File System", |
| 116 | .size = 0x00630000, |
| 117 | .offset = 0x001A0000, |
| 118 | }, { |
| 119 | .name = "u-boot", |
| 120 | .size = 0x00030000, |
| 121 | .offset = 0x007d0000, |
Lennert Buytenhek | e7068ad | 2008-05-10 16:30:01 +0200 | [diff] [blame^] | 122 | }, |
Herbert Valerio Riedel | 555a365 | 2007-11-12 09:05:55 +0100 | [diff] [blame] | 123 | }; |
| 124 | |
| 125 | static struct physmap_flash_data dns323_nor_flash_data = { |
| 126 | .width = 1, |
| 127 | .parts = dns323_partitions, |
| 128 | .nr_parts = ARRAY_SIZE(dns323_partitions) |
| 129 | }; |
| 130 | |
| 131 | static struct resource dns323_nor_flash_resource = { |
| 132 | .flags = IORESOURCE_MEM, |
| 133 | .start = DNS323_NOR_BOOT_BASE, |
| 134 | .end = DNS323_NOR_BOOT_BASE + DNS323_NOR_BOOT_SIZE - 1, |
| 135 | }; |
| 136 | |
| 137 | static struct platform_device dns323_nor_flash = { |
| 138 | .name = "physmap-flash", |
| 139 | .id = 0, |
Lennert Buytenhek | e7068ad | 2008-05-10 16:30:01 +0200 | [diff] [blame^] | 140 | .dev = { |
| 141 | .platform_data = &dns323_nor_flash_data, |
| 142 | }, |
Herbert Valerio Riedel | 555a365 | 2007-11-12 09:05:55 +0100 | [diff] [blame] | 143 | .resource = &dns323_nor_flash_resource, |
| 144 | .num_resources = 1, |
| 145 | }; |
| 146 | |
| 147 | /**************************************************************************** |
| 148 | * GPIO LEDs (simple - doesn't use hardware blinking support) |
| 149 | */ |
| 150 | |
| 151 | static struct gpio_led dns323_leds[] = { |
| 152 | { |
| 153 | .name = "power:blue", |
| 154 | .gpio = DNS323_GPIO_LED_POWER, |
| 155 | .active_low = 1, |
| 156 | }, { |
| 157 | .name = "right:amber", |
| 158 | .gpio = DNS323_GPIO_LED_RIGHT_AMBER, |
| 159 | .active_low = 1, |
| 160 | }, { |
| 161 | .name = "left:amber", |
| 162 | .gpio = DNS323_GPIO_LED_LEFT_AMBER, |
| 163 | .active_low = 1, |
| 164 | }, |
| 165 | }; |
| 166 | |
| 167 | static struct gpio_led_platform_data dns323_led_data = { |
| 168 | .num_leds = ARRAY_SIZE(dns323_leds), |
| 169 | .leds = dns323_leds, |
| 170 | }; |
| 171 | |
| 172 | static struct platform_device dns323_gpio_leds = { |
| 173 | .name = "leds-gpio", |
| 174 | .id = -1, |
Lennert Buytenhek | e7068ad | 2008-05-10 16:30:01 +0200 | [diff] [blame^] | 175 | .dev = { |
| 176 | .platform_data = &dns323_led_data, |
| 177 | }, |
Herbert Valerio Riedel | 555a365 | 2007-11-12 09:05:55 +0100 | [diff] [blame] | 178 | }; |
| 179 | |
| 180 | /**************************************************************************** |
| 181 | * GPIO Attached Keys |
| 182 | */ |
| 183 | |
| 184 | static struct gpio_keys_button dns323_buttons[] = { |
| 185 | { |
| 186 | .code = KEY_RESTART, |
| 187 | .gpio = DNS323_GPIO_KEY_RESET, |
| 188 | .desc = "Reset Button", |
| 189 | .active_low = 1, |
Lennert Buytenhek | e7068ad | 2008-05-10 16:30:01 +0200 | [diff] [blame^] | 190 | }, { |
Herbert Valerio Riedel | 555a365 | 2007-11-12 09:05:55 +0100 | [diff] [blame] | 191 | .code = KEY_POWER, |
| 192 | .gpio = DNS323_GPIO_KEY_POWER, |
| 193 | .desc = "Power Button", |
| 194 | .active_low = 1, |
Lennert Buytenhek | e7068ad | 2008-05-10 16:30:01 +0200 | [diff] [blame^] | 195 | }, |
Herbert Valerio Riedel | 555a365 | 2007-11-12 09:05:55 +0100 | [diff] [blame] | 196 | }; |
| 197 | |
| 198 | static struct gpio_keys_platform_data dns323_button_data = { |
| 199 | .buttons = dns323_buttons, |
Lennert Buytenhek | e7068ad | 2008-05-10 16:30:01 +0200 | [diff] [blame^] | 200 | .nbuttons = ARRAY_SIZE(dns323_buttons), |
Herbert Valerio Riedel | 555a365 | 2007-11-12 09:05:55 +0100 | [diff] [blame] | 201 | }; |
| 202 | |
| 203 | static struct platform_device dns323_button_device = { |
| 204 | .name = "gpio-keys", |
| 205 | .id = -1, |
| 206 | .num_resources = 0, |
Lennert Buytenhek | e7068ad | 2008-05-10 16:30:01 +0200 | [diff] [blame^] | 207 | .dev = { |
| 208 | .platform_data = &dns323_button_data, |
| 209 | }, |
Herbert Valerio Riedel | 555a365 | 2007-11-12 09:05:55 +0100 | [diff] [blame] | 210 | }; |
| 211 | |
| 212 | /**************************************************************************** |
| 213 | * General Setup |
| 214 | */ |
| 215 | |
| 216 | static struct platform_device *dns323_plat_devices[] __initdata = { |
| 217 | &dns323_nor_flash, |
| 218 | &dns323_gpio_leds, |
| 219 | &dns323_button_device, |
| 220 | }; |
| 221 | |
| 222 | /* |
| 223 | * On the DNS-323 the following devices are attached via I2C: |
| 224 | * |
| 225 | * i2c addr | chip | description |
| 226 | * 0x3e | GMT G760Af | fan speed PWM controller |
| 227 | * 0x48 | GMT G751-2f | temp. sensor and therm. watchdog (LM75 compatible) |
| 228 | * 0x68 | ST M41T80 | RTC w/ alarm |
| 229 | */ |
| 230 | static struct i2c_board_info __initdata dns323_i2c_devices[] = { |
| 231 | { |
| 232 | I2C_BOARD_INFO("g760a", 0x3e), |
Herbert Valerio Riedel | 555a365 | 2007-11-12 09:05:55 +0100 | [diff] [blame] | 233 | #if 0 |
| 234 | /* this entry requires the new-style driver model lm75 driver, |
| 235 | * for the meantime "insmod lm75.ko force_lm75=0,0x48" is needed */ |
Lennert Buytenhek | e7068ad | 2008-05-10 16:30:01 +0200 | [diff] [blame^] | 236 | }, { |
Jean Delvare | 3760f73 | 2008-04-29 23:11:40 +0200 | [diff] [blame] | 237 | I2C_BOARD_INFO("g751", 0x48), |
Herbert Valerio Riedel | 555a365 | 2007-11-12 09:05:55 +0100 | [diff] [blame] | 238 | #endif |
Lennert Buytenhek | e7068ad | 2008-05-10 16:30:01 +0200 | [diff] [blame^] | 239 | }, { |
Jean Delvare | 3760f73 | 2008-04-29 23:11:40 +0200 | [diff] [blame] | 240 | I2C_BOARD_INFO("m41t80", 0x68), |
Lennert Buytenhek | e7068ad | 2008-05-10 16:30:01 +0200 | [diff] [blame^] | 241 | }, |
Herbert Valerio Riedel | 555a365 | 2007-11-12 09:05:55 +0100 | [diff] [blame] | 242 | }; |
| 243 | |
| 244 | /* DNS-323 specific power off method */ |
| 245 | static void dns323_power_off(void) |
| 246 | { |
| 247 | pr_info("%s: triggering power-off...\n", __func__); |
| 248 | gpio_set_value(DNS323_GPIO_POWER_OFF, 1); |
| 249 | } |
| 250 | |
| 251 | static void __init dns323_init(void) |
| 252 | { |
| 253 | /* Setup basic Orion functions. Need to be called early. */ |
Lennert Buytenhek | 9dd0b19 | 2008-03-27 14:51:41 -0400 | [diff] [blame] | 254 | orion5x_init(); |
Herbert Valerio Riedel | 555a365 | 2007-11-12 09:05:55 +0100 | [diff] [blame] | 255 | |
| 256 | /* setup flash mapping |
| 257 | * CS3 holds a 8 MB Spansion S29GL064M90TFIR4 |
| 258 | */ |
Lennert Buytenhek | 9dd0b19 | 2008-03-27 14:51:41 -0400 | [diff] [blame] | 259 | orion5x_setup_dev_boot_win(DNS323_NOR_BOOT_BASE, DNS323_NOR_BOOT_SIZE); |
Herbert Valerio Riedel | 555a365 | 2007-11-12 09:05:55 +0100 | [diff] [blame] | 260 | |
Lennert Buytenhek | b46926b | 2008-04-25 16:31:32 -0400 | [diff] [blame] | 261 | /* DNS-323 has a Marvell 88X7042 SATA controller attached via PCIe |
Herbert Valerio Riedel | 555a365 | 2007-11-12 09:05:55 +0100 | [diff] [blame] | 262 | * |
Lennert Buytenhek | b46926b | 2008-04-25 16:31:32 -0400 | [diff] [blame] | 263 | * Open a special address decode windows for the PCIe WA. |
Herbert Valerio Riedel | 555a365 | 2007-11-12 09:05:55 +0100 | [diff] [blame] | 264 | */ |
Lennert Buytenhek | 9dd0b19 | 2008-03-27 14:51:41 -0400 | [diff] [blame] | 265 | orion5x_setup_pcie_wa_win(ORION5X_PCIE_WA_PHYS_BASE, |
| 266 | ORION5X_PCIE_WA_SIZE); |
Herbert Valerio Riedel | 555a365 | 2007-11-12 09:05:55 +0100 | [diff] [blame] | 267 | |
| 268 | /* set MPP to 0 as D-Link's 2.6.12.6 kernel did */ |
Lennert Buytenhek | 9dd0b19 | 2008-03-27 14:51:41 -0400 | [diff] [blame] | 269 | orion5x_write(MPP_0_7_CTRL, 0); |
| 270 | orion5x_write(MPP_8_15_CTRL, 0); |
| 271 | orion5x_write(MPP_16_19_CTRL, 0); |
| 272 | orion5x_write(MPP_DEV_CTRL, 0); |
Herbert Valerio Riedel | 555a365 | 2007-11-12 09:05:55 +0100 | [diff] [blame] | 273 | |
| 274 | /* Define used GPIO pins |
| 275 | |
| 276 | GPIO Map: |
| 277 | |
| 278 | | 0 | | PEX_RST_OUT (not controlled by GPIO) |
| 279 | | 1 | Out | right amber LED (= sata ch0 LED) (low-active) |
| 280 | | 2 | Out | left amber LED (= sata ch1 LED) (low-active) |
| 281 | | 3 | Out | //unknown// |
| 282 | | 4 | Out | power button LED (low-active, together with pin #5) |
| 283 | | 5 | Out | power button LED (low-active, together with pin #4) |
| 284 | | 6 | In | GMT G751-2f overtemp. shutdown signal (low-active) |
| 285 | | 7 | In | M41T80 nIRQ/OUT/SQW signal |
| 286 | | 8 | Out | triggers power off (high-active) |
| 287 | | 9 | In | power button switch (low-active) |
| 288 | | 10 | In | reset button switch (low-active) |
| 289 | | 11 | Out | //unknown// |
| 290 | | 12 | Out | //unknown// |
| 291 | | 13 | Out | //unknown// |
| 292 | | 14 | Out | //unknown// |
| 293 | | 15 | Out | //unknown// |
| 294 | */ |
Lennert Buytenhek | 9dd0b19 | 2008-03-27 14:51:41 -0400 | [diff] [blame] | 295 | orion5x_gpio_set_valid_pins(0x07f6); |
Herbert Valerio Riedel | 555a365 | 2007-11-12 09:05:55 +0100 | [diff] [blame] | 296 | |
| 297 | /* register dns323 specific power-off method */ |
Lennert Buytenhek | e7068ad | 2008-05-10 16:30:01 +0200 | [diff] [blame^] | 298 | if (gpio_request(DNS323_GPIO_POWER_OFF, "POWEROFF") != 0 || |
| 299 | gpio_direction_output(DNS323_GPIO_POWER_OFF, 0) != 0) |
Herbert Valerio Riedel | 555a365 | 2007-11-12 09:05:55 +0100 | [diff] [blame] | 300 | pr_err("DNS323: failed to setup power-off GPIO\n"); |
| 301 | |
| 302 | pm_power_off = dns323_power_off; |
| 303 | |
| 304 | /* register flash and other platform devices */ |
| 305 | platform_add_devices(dns323_plat_devices, |
| 306 | ARRAY_SIZE(dns323_plat_devices)); |
| 307 | |
| 308 | i2c_register_board_info(0, dns323_i2c_devices, |
| 309 | ARRAY_SIZE(dns323_i2c_devices)); |
| 310 | |
Lennert Buytenhek | 9dd0b19 | 2008-03-27 14:51:41 -0400 | [diff] [blame] | 311 | orion5x_eth_init(&dns323_eth_data); |
Herbert Valerio Riedel | 555a365 | 2007-11-12 09:05:55 +0100 | [diff] [blame] | 312 | } |
| 313 | |
| 314 | /* Warning: D-Link uses a wrong mach-type (=526) in their bootloader */ |
| 315 | MACHINE_START(DNS323, "D-Link DNS-323") |
| 316 | /* Maintainer: Herbert Valerio Riedel <hvr@gnu.org> */ |
Lennert Buytenhek | 9dd0b19 | 2008-03-27 14:51:41 -0400 | [diff] [blame] | 317 | .phys_io = ORION5X_REGS_PHYS_BASE, |
| 318 | .io_pg_offst = ((ORION5X_REGS_VIRT_BASE) >> 18) & 0xFFFC, |
Herbert Valerio Riedel | 555a365 | 2007-11-12 09:05:55 +0100 | [diff] [blame] | 319 | .boot_params = 0x00000100, |
| 320 | .init_machine = dns323_init, |
Lennert Buytenhek | 9dd0b19 | 2008-03-27 14:51:41 -0400 | [diff] [blame] | 321 | .map_io = orion5x_map_io, |
| 322 | .init_irq = orion5x_init_irq, |
| 323 | .timer = &orion5x_timer, |
Guennadi Liakhovetski | be73a34 | 2008-02-29 21:12:57 +0100 | [diff] [blame] | 324 | .fixup = tag_fixup_mem32, |
Herbert Valerio Riedel | 555a365 | 2007-11-12 09:05:55 +0100 | [diff] [blame] | 325 | MACHINE_END |