Simon Baatz | f552036 | 2012-04-30 23:55:17 +0200 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2012 (C), Simon Baatz <gmbnomis@gmail.com> |
| 3 | * |
| 4 | * arch/arm/mach-kirkwood/board-ib62x0.c |
| 5 | * |
| 6 | * RaidSonic ICY BOX IB-NAS6210 & IB-NAS6220 init for drivers not |
| 7 | * converted to flattened device tree yet. |
| 8 | * |
| 9 | * This file is licensed under the terms of the GNU General Public |
| 10 | * License version 2. This program is licensed "as is" without any |
| 11 | * warranty of any kind, whether express or implied. |
| 12 | */ |
| 13 | |
| 14 | #include <linux/kernel.h> |
| 15 | #include <linux/init.h> |
| 16 | #include <linux/platform_device.h> |
| 17 | #include <linux/mtd/partitions.h> |
| 18 | #include <linux/ata_platform.h> |
| 19 | #include <linux/mv643xx_eth.h> |
| 20 | #include <linux/gpio.h> |
| 21 | #include <linux/gpio_keys.h> |
| 22 | #include <linux/input.h> |
| 23 | #include <linux/leds.h> |
| 24 | #include <asm/mach-types.h> |
| 25 | #include <asm/mach/arch.h> |
| 26 | #include <mach/kirkwood.h> |
| 27 | #include "common.h" |
| 28 | #include "mpp.h" |
| 29 | |
| 30 | #define IB62X0_GPIO_POWER_OFF 24 |
| 31 | |
| 32 | static struct mv643xx_eth_platform_data ib62x0_ge00_data = { |
| 33 | .phy_addr = MV643XX_ETH_PHY_ADDR(8), |
| 34 | }; |
| 35 | |
| 36 | static struct mv_sata_platform_data ib62x0_sata_data = { |
| 37 | .n_ports = 2, |
| 38 | }; |
| 39 | |
| 40 | static unsigned int ib62x0_mpp_config[] __initdata = { |
| 41 | MPP0_NF_IO2, |
| 42 | MPP1_NF_IO3, |
| 43 | MPP2_NF_IO4, |
| 44 | MPP3_NF_IO5, |
| 45 | MPP4_NF_IO6, |
| 46 | MPP5_NF_IO7, |
| 47 | MPP18_NF_IO0, |
| 48 | MPP19_NF_IO1, |
| 49 | MPP22_GPIO, /* OS LED red */ |
| 50 | MPP24_GPIO, /* Power off device */ |
| 51 | MPP25_GPIO, /* OS LED green */ |
| 52 | MPP27_GPIO, /* USB transfer LED */ |
| 53 | MPP28_GPIO, /* Reset button */ |
| 54 | MPP29_GPIO, /* USB Copy button */ |
| 55 | 0 |
| 56 | }; |
| 57 | |
| 58 | static struct gpio_led ib62x0_led_pins[] = { |
| 59 | { |
| 60 | .name = "ib62x0:green:os", |
| 61 | .default_trigger = "default-on", |
| 62 | .gpio = 25, |
| 63 | .active_low = 0, |
| 64 | }, |
| 65 | { |
| 66 | .name = "ib62x0:red:os", |
| 67 | .default_trigger = "none", |
| 68 | .gpio = 22, |
| 69 | .active_low = 0, |
| 70 | }, |
| 71 | { |
| 72 | .name = "ib62x0:red:usb_copy", |
| 73 | .default_trigger = "none", |
| 74 | .gpio = 27, |
| 75 | .active_low = 0, |
| 76 | }, |
| 77 | }; |
| 78 | |
| 79 | static struct gpio_led_platform_data ib62x0_led_data = { |
| 80 | .leds = ib62x0_led_pins, |
| 81 | .num_leds = ARRAY_SIZE(ib62x0_led_pins), |
| 82 | }; |
| 83 | |
| 84 | static struct platform_device ib62x0_led_device = { |
| 85 | .name = "leds-gpio", |
| 86 | .id = -1, |
| 87 | .dev = { |
| 88 | .platform_data = &ib62x0_led_data, |
| 89 | } |
| 90 | }; |
| 91 | |
| 92 | static struct gpio_keys_button ib62x0_button_pins[] = { |
| 93 | { |
| 94 | .code = KEY_COPY, |
| 95 | .gpio = 29, |
| 96 | .desc = "USB Copy", |
| 97 | .active_low = 1, |
| 98 | }, |
| 99 | { |
| 100 | .code = KEY_RESTART, |
| 101 | .gpio = 28, |
| 102 | .desc = "Reset", |
| 103 | .active_low = 1, |
| 104 | }, |
| 105 | }; |
| 106 | |
| 107 | static struct gpio_keys_platform_data ib62x0_button_data = { |
| 108 | .buttons = ib62x0_button_pins, |
| 109 | .nbuttons = ARRAY_SIZE(ib62x0_button_pins), |
| 110 | }; |
| 111 | |
| 112 | static struct platform_device ib62x0_button_device = { |
| 113 | .name = "gpio-keys", |
| 114 | .id = -1, |
| 115 | .num_resources = 0, |
| 116 | .dev = { |
| 117 | .platform_data = &ib62x0_button_data, |
| 118 | } |
| 119 | }; |
| 120 | |
| 121 | static void ib62x0_power_off(void) |
| 122 | { |
| 123 | gpio_set_value(IB62X0_GPIO_POWER_OFF, 1); |
| 124 | } |
| 125 | |
| 126 | void __init ib62x0_init(void) |
| 127 | { |
| 128 | /* |
| 129 | * Basic setup. Needs to be called early. |
| 130 | */ |
| 131 | kirkwood_mpp_conf(ib62x0_mpp_config); |
| 132 | |
| 133 | kirkwood_ehci_init(); |
| 134 | kirkwood_ge00_init(&ib62x0_ge00_data); |
| 135 | kirkwood_sata_init(&ib62x0_sata_data); |
| 136 | platform_device_register(&ib62x0_led_device); |
| 137 | platform_device_register(&ib62x0_button_device); |
| 138 | if (gpio_request(IB62X0_GPIO_POWER_OFF, "ib62x0:power:off") == 0 && |
| 139 | gpio_direction_output(IB62X0_GPIO_POWER_OFF, 0) == 0) |
| 140 | pm_power_off = ib62x0_power_off; |
| 141 | else |
| 142 | pr_err("board-ib62x0: failed to configure power-off GPIO\n"); |
| 143 | } |