2 * arch/arm/mach-orion5x/dns323-setup.c
4 * Copyright (C) 2007 Herbert Valerio Riedel <hvr@gnu.org>
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.
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>
26 #include <asm/mach/arch.h>
27 #include <asm/mach/pci.h>
28 #include <asm/arch/orion5x.h>
32 #define DNS323_GPIO_LED_RIGHT_AMBER 1
33 #define DNS323_GPIO_LED_LEFT_AMBER 2
34 #define DNS323_GPIO_LED_POWER 5
35 #define DNS323_GPIO_OVERTEMP 6
36 #define DNS323_GPIO_RTC 7
37 #define DNS323_GPIO_POWER_OFF 8
38 #define DNS323_GPIO_KEY_POWER 9
39 #define DNS323_GPIO_KEY_RESET 10
41 /****************************************************************************
45 static int __init
dns323_pci_map_irq(struct pci_dev
*dev
, u8 slot
, u8 pin
)
50 * Check for devices with hard-wired IRQs.
52 irq
= orion5x_pci_map_irq(dev
, slot
, pin
);
56 pr_err("%s: requested mapping for unknown device\n", __func__
);
61 static struct hw_pci dns323_pci __initdata
= {
63 .swizzle
= pci_std_swizzle
,
64 .setup
= orion5x_pci_sys_setup
,
65 .scan
= orion5x_pci_sys_scan_bus
,
66 .map_irq
= dns323_pci_map_irq
,
69 static int __init
dns323_pci_init(void)
71 if (machine_is_dns323())
72 pci_common_init(&dns323_pci
);
77 subsys_initcall(dns323_pci_init
);
79 /****************************************************************************
83 static struct mv643xx_eth_platform_data dns323_eth_data
= {
88 /****************************************************************************
89 * 8MiB NOR flash (Spansion S29GL064M90TFIR4)
91 * Layout as used by D-Link:
92 * 0x00000000-0x00010000 : "MTD1"
93 * 0x00010000-0x00020000 : "MTD2"
94 * 0x00020000-0x001a0000 : "Linux Kernel"
95 * 0x001a0000-0x007d0000 : "File System"
96 * 0x007d0000-0x00800000 : "u-boot"
99 #define DNS323_NOR_BOOT_BASE 0xf4000000
100 #define DNS323_NOR_BOOT_SIZE SZ_8M
102 static struct mtd_partition dns323_partitions
[] = {
110 .offset
= 0x00010000,
112 .name
= "Linux Kernel",
114 .offset
= 0x00020000,
116 .name
= "File System",
118 .offset
= 0x001A0000,
122 .offset
= 0x007d0000,
126 static struct physmap_flash_data dns323_nor_flash_data
= {
128 .parts
= dns323_partitions
,
129 .nr_parts
= ARRAY_SIZE(dns323_partitions
)
132 static struct resource dns323_nor_flash_resource
= {
133 .flags
= IORESOURCE_MEM
,
134 .start
= DNS323_NOR_BOOT_BASE
,
135 .end
= DNS323_NOR_BOOT_BASE
+ DNS323_NOR_BOOT_SIZE
- 1,
138 static struct platform_device dns323_nor_flash
= {
139 .name
= "physmap-flash",
142 .platform_data
= &dns323_nor_flash_data
,
144 .resource
= &dns323_nor_flash_resource
,
148 /****************************************************************************
149 * GPIO LEDs (simple - doesn't use hardware blinking support)
152 static struct gpio_led dns323_leds
[] = {
154 .name
= "power:blue",
155 .gpio
= DNS323_GPIO_LED_POWER
,
158 .name
= "right:amber",
159 .gpio
= DNS323_GPIO_LED_RIGHT_AMBER
,
162 .name
= "left:amber",
163 .gpio
= DNS323_GPIO_LED_LEFT_AMBER
,
168 static struct gpio_led_platform_data dns323_led_data
= {
169 .num_leds
= ARRAY_SIZE(dns323_leds
),
173 static struct platform_device dns323_gpio_leds
= {
177 .platform_data
= &dns323_led_data
,
181 /****************************************************************************
185 static struct gpio_keys_button dns323_buttons
[] = {
188 .gpio
= DNS323_GPIO_KEY_RESET
,
189 .desc
= "Reset Button",
193 .gpio
= DNS323_GPIO_KEY_POWER
,
194 .desc
= "Power Button",
199 static struct gpio_keys_platform_data dns323_button_data
= {
200 .buttons
= dns323_buttons
,
201 .nbuttons
= ARRAY_SIZE(dns323_buttons
),
204 static struct platform_device dns323_button_device
= {
209 .platform_data
= &dns323_button_data
,
213 /****************************************************************************
216 static struct orion5x_mpp_mode dns323_mpp_modes
[] __initdata
= {
217 { 0, MPP_PCIE_RST_OUTn
},
218 { 1, MPP_GPIO
}, /* right amber LED (sata ch0) */
219 { 2, MPP_GPIO
}, /* left amber LED (sata ch1) */
221 { 4, MPP_GPIO
}, /* power button LED */
222 { 5, MPP_GPIO
}, /* power button LED */
223 { 6, MPP_GPIO
}, /* GMT G751-2f overtemp */
224 { 7, MPP_GPIO
}, /* M41T80 nIRQ/OUT/SQW */
225 { 8, MPP_GPIO
}, /* triggers power off */
226 { 9, MPP_GPIO
}, /* power button switch */
227 { 10, MPP_GPIO
}, /* reset button switch */
241 * On the DNS-323 the following devices are attached via I2C:
243 * i2c addr | chip | description
244 * 0x3e | GMT G760Af | fan speed PWM controller
245 * 0x48 | GMT G751-2f | temp. sensor and therm. watchdog (LM75 compatible)
246 * 0x68 | ST M41T80 | RTC w/ alarm
248 static struct i2c_board_info __initdata dns323_i2c_devices
[] = {
250 I2C_BOARD_INFO("g760a", 0x3e),
252 /* this entry requires the new-style driver model lm75 driver,
253 * for the meantime "insmod lm75.ko force_lm75=0,0x48" is needed */
255 I2C_BOARD_INFO("g751", 0x48),
258 I2C_BOARD_INFO("m41t80", 0x68),
262 /* DNS-323 specific power off method */
263 static void dns323_power_off(void)
265 pr_info("%s: triggering power-off...\n", __func__
);
266 gpio_set_value(DNS323_GPIO_POWER_OFF
, 1);
269 static void __init
dns323_init(void)
271 /* Setup basic Orion functions. Need to be called early. */
274 orion5x_mpp_conf(dns323_mpp_modes
);
275 orion5x_write(MPP_DEV_CTRL
, 0); /* DEV_D[31:16] */
278 * Configure peripherals.
280 orion5x_ehci0_init();
281 orion5x_eth_init(&dns323_eth_data
);
283 orion5x_uart0_init();
285 /* setup flash mapping
286 * CS3 holds a 8 MB Spansion S29GL064M90TFIR4
288 orion5x_setup_dev_boot_win(DNS323_NOR_BOOT_BASE
, DNS323_NOR_BOOT_SIZE
);
289 platform_device_register(&dns323_nor_flash
);
291 platform_device_register(&dns323_gpio_leds
);
293 platform_device_register(&dns323_button_device
);
295 i2c_register_board_info(0, dns323_i2c_devices
,
296 ARRAY_SIZE(dns323_i2c_devices
));
298 /* register dns323 specific power-off method */
299 if (gpio_request(DNS323_GPIO_POWER_OFF
, "POWEROFF") != 0 ||
300 gpio_direction_output(DNS323_GPIO_POWER_OFF
, 0) != 0)
301 pr_err("DNS323: failed to setup power-off GPIO\n");
302 pm_power_off
= dns323_power_off
;
305 /* Warning: D-Link uses a wrong mach-type (=526) in their bootloader */
306 MACHINE_START(DNS323
, "D-Link DNS-323")
307 /* Maintainer: Herbert Valerio Riedel <hvr@gnu.org> */
308 .phys_io
= ORION5X_REGS_PHYS_BASE
,
309 .io_pg_offst
= ((ORION5X_REGS_VIRT_BASE
) >> 18) & 0xFFFC,
310 .boot_params
= 0x00000100,
311 .init_machine
= dns323_init
,
312 .map_io
= orion5x_map_io
,
313 .init_irq
= orion5x_init_irq
,
314 .timer
= &orion5x_timer
,
315 .fixup
= tag_fixup_mem32
,