Path: blob/master/arch/arm/mach-orion5x/d2net-setup.c
10819 views
/*1* arch/arm/mach-orion5x/d2net-setup.c2*3* LaCie d2Network and Big Disk Network NAS setup4*5* Copyright (C) 2009 Simon Guinot <[email protected]>6*7* This file is licensed under the terms of the GNU General Public8* License version 2. This program is licensed "as is" without any9* warranty of any kind, whether express or implied.10*/1112#include <linux/kernel.h>13#include <linux/init.h>14#include <linux/platform_device.h>15#include <linux/pci.h>16#include <linux/irq.h>17#include <linux/mtd/physmap.h>18#include <linux/mv643xx_eth.h>19#include <linux/leds.h>20#include <linux/gpio_keys.h>21#include <linux/input.h>22#include <linux/i2c.h>23#include <linux/ata_platform.h>24#include <linux/gpio.h>25#include <asm/mach-types.h>26#include <asm/mach/arch.h>27#include <asm/mach/pci.h>28#include <mach/orion5x.h>29#include "common.h"30#include "mpp.h"3132/*****************************************************************************33* LaCie d2 Network Info34****************************************************************************/3536/*37* 512KB NOR flash Device bus boot chip select38*/3940#define D2NET_NOR_BOOT_BASE 0xfff8000041#define D2NET_NOR_BOOT_SIZE SZ_512K4243/*****************************************************************************44* 512KB NOR Flash on Boot Device45****************************************************************************/4647/*48* TODO: Check write support on flash MX29LV400CBTC-70G49*/5051static struct mtd_partition d2net_partitions[] = {52{53.name = "Full512kb",54.size = MTDPART_SIZ_FULL,55.offset = 0,56.mask_flags = MTD_WRITEABLE,57},58};5960static struct physmap_flash_data d2net_nor_flash_data = {61.width = 1,62.parts = d2net_partitions,63.nr_parts = ARRAY_SIZE(d2net_partitions),64};6566static struct resource d2net_nor_flash_resource = {67.flags = IORESOURCE_MEM,68.start = D2NET_NOR_BOOT_BASE,69.end = D2NET_NOR_BOOT_BASE70+ D2NET_NOR_BOOT_SIZE - 1,71};7273static struct platform_device d2net_nor_flash = {74.name = "physmap-flash",75.id = 0,76.dev = {77.platform_data = &d2net_nor_flash_data,78},79.num_resources = 1,80.resource = &d2net_nor_flash_resource,81};8283/*****************************************************************************84* Ethernet85****************************************************************************/8687static struct mv643xx_eth_platform_data d2net_eth_data = {88.phy_addr = MV643XX_ETH_PHY_ADDR(8),89};9091/*****************************************************************************92* I2C devices93****************************************************************************/9495/*96* i2c addr | chip | description97* 0x32 | Ricoh 5C372b | RTC98* 0x3e | GMT G762 | PWM fan controller99* 0x50 | HT24LC08 | eeprom (1kB)100*101* TODO: Add G762 support to the g760a driver.102*/103static struct i2c_board_info __initdata d2net_i2c_devices[] = {104{105I2C_BOARD_INFO("rs5c372b", 0x32),106}, {107I2C_BOARD_INFO("24c08", 0x50),108},109};110111/*****************************************************************************112* SATA113****************************************************************************/114115static struct mv_sata_platform_data d2net_sata_data = {116.n_ports = 2,117};118119#define D2NET_GPIO_SATA0_POWER 3120#define D2NET_GPIO_SATA1_POWER 12121122static void __init d2net_sata_power_init(void)123{124int err;125126err = gpio_request(D2NET_GPIO_SATA0_POWER, "SATA0 power");127if (err == 0) {128err = gpio_direction_output(D2NET_GPIO_SATA0_POWER, 1);129if (err)130gpio_free(D2NET_GPIO_SATA0_POWER);131}132if (err)133pr_err("d2net: failed to configure SATA0 power GPIO\n");134135err = gpio_request(D2NET_GPIO_SATA1_POWER, "SATA1 power");136if (err == 0) {137err = gpio_direction_output(D2NET_GPIO_SATA1_POWER, 1);138if (err)139gpio_free(D2NET_GPIO_SATA1_POWER);140}141if (err)142pr_err("d2net: failed to configure SATA1 power GPIO\n");143}144145/*****************************************************************************146* GPIO LED's147****************************************************************************/148149/*150* The blue front LED is wired to the CPLD and can blink in relation with the151* SATA activity.152*153* The following array detail the different LED registers and the combination154* of their possible values:155*156* led_off | blink_ctrl | SATA active | LED state157* | | |158* 1 | x | x | off159* 0 | 0 | 0 | off160* 0 | 1 | 0 | blink (rate 300ms)161* 0 | x | 1 | on162*163* Notes: The blue and the red front LED's can't be on at the same time.164* Red LED have priority.165*/166167#define D2NET_GPIO_RED_LED 6168#define D2NET_GPIO_BLUE_LED_BLINK_CTRL 16169#define D2NET_GPIO_BLUE_LED_OFF 23170171static struct gpio_led d2net_leds[] = {172{173.name = "d2net:blue:sata",174.default_trigger = "default-on",175.gpio = D2NET_GPIO_BLUE_LED_OFF,176.active_low = 1,177},178{179.name = "d2net:red:fail",180.gpio = D2NET_GPIO_RED_LED,181},182};183184static struct gpio_led_platform_data d2net_led_data = {185.num_leds = ARRAY_SIZE(d2net_leds),186.leds = d2net_leds,187};188189static struct platform_device d2net_gpio_leds = {190.name = "leds-gpio",191.id = -1,192.dev = {193.platform_data = &d2net_led_data,194},195};196197static void __init d2net_gpio_leds_init(void)198{199int err;200201/* Configure GPIO over MPP max number. */202orion_gpio_set_valid(D2NET_GPIO_BLUE_LED_OFF, 1);203204/* Configure register blink_ctrl to allow SATA activity LED blinking. */205err = gpio_request(D2NET_GPIO_BLUE_LED_BLINK_CTRL, "blue LED blink");206if (err == 0) {207err = gpio_direction_output(D2NET_GPIO_BLUE_LED_BLINK_CTRL, 1);208if (err)209gpio_free(D2NET_GPIO_BLUE_LED_BLINK_CTRL);210}211if (err)212pr_err("d2net: failed to configure blue LED blink GPIO\n");213214platform_device_register(&d2net_gpio_leds);215}216217/****************************************************************************218* GPIO keys219****************************************************************************/220221#define D2NET_GPIO_PUSH_BUTTON 18222#define D2NET_GPIO_POWER_SWITCH_ON 8223#define D2NET_GPIO_POWER_SWITCH_OFF 9224225#define D2NET_SWITCH_POWER_ON 0x1226#define D2NET_SWITCH_POWER_OFF 0x2227228static struct gpio_keys_button d2net_buttons[] = {229{230.type = EV_SW,231.code = D2NET_SWITCH_POWER_OFF,232.gpio = D2NET_GPIO_POWER_SWITCH_OFF,233.desc = "Power rocker switch (auto|off)",234.active_low = 0,235},236{237.type = EV_SW,238.code = D2NET_SWITCH_POWER_ON,239.gpio = D2NET_GPIO_POWER_SWITCH_ON,240.desc = "Power rocker switch (on|auto)",241.active_low = 0,242},243{244.type = EV_KEY,245.code = KEY_POWER,246.gpio = D2NET_GPIO_PUSH_BUTTON,247.desc = "Front Push Button",248.active_low = 0,249},250};251252static struct gpio_keys_platform_data d2net_button_data = {253.buttons = d2net_buttons,254.nbuttons = ARRAY_SIZE(d2net_buttons),255};256257static struct platform_device d2net_gpio_buttons = {258.name = "gpio-keys",259.id = -1,260.dev = {261.platform_data = &d2net_button_data,262},263};264265/*****************************************************************************266* General Setup267****************************************************************************/268269static unsigned int d2net_mpp_modes[] __initdata = {270MPP0_GPIO, /* Board ID (bit 0) */271MPP1_GPIO, /* Board ID (bit 1) */272MPP2_GPIO, /* Board ID (bit 2) */273MPP3_GPIO, /* SATA 0 power */274MPP4_UNUSED,275MPP5_GPIO, /* Fan fail detection */276MPP6_GPIO, /* Red front LED */277MPP7_UNUSED,278MPP8_GPIO, /* Rear power switch (on|auto) */279MPP9_GPIO, /* Rear power switch (auto|off) */280MPP10_UNUSED,281MPP11_UNUSED,282MPP12_GPIO, /* SATA 1 power */283MPP13_UNUSED,284MPP14_SATA_LED, /* SATA 0 active */285MPP15_SATA_LED, /* SATA 1 active */286MPP16_GPIO, /* Blue front LED blink control */287MPP17_UNUSED,288MPP18_GPIO, /* Front button (0 = Released, 1 = Pushed ) */289MPP19_UNUSED,2900,291/* 22: USB port 1 fuse (0 = Fail, 1 = Ok) */292/* 23: Blue front LED off */293/* 24: Inhibit board power off (0 = Disabled, 1 = Enabled) */294};295296#define D2NET_GPIO_INHIBIT_POWER_OFF 24297298static void __init d2net_init(void)299{300/*301* Setup basic Orion functions. Need to be called early.302*/303orion5x_init();304305orion5x_mpp_conf(d2net_mpp_modes);306307/*308* Configure peripherals.309*/310orion5x_ehci0_init();311orion5x_eth_init(&d2net_eth_data);312orion5x_i2c_init();313orion5x_uart0_init();314315d2net_sata_power_init();316orion5x_sata_init(&d2net_sata_data);317318orion5x_setup_dev_boot_win(D2NET_NOR_BOOT_BASE,319D2NET_NOR_BOOT_SIZE);320platform_device_register(&d2net_nor_flash);321322platform_device_register(&d2net_gpio_buttons);323324d2net_gpio_leds_init();325326pr_notice("d2net: Flash write are not yet supported.\n");327328i2c_register_board_info(0, d2net_i2c_devices,329ARRAY_SIZE(d2net_i2c_devices));330331orion_gpio_set_valid(D2NET_GPIO_INHIBIT_POWER_OFF, 1);332}333334/* Warning: LaCie use a wrong mach-type (0x20e=526) in their bootloader. */335336#ifdef CONFIG_MACH_D2NET337MACHINE_START(D2NET, "LaCie d2 Network")338.boot_params = 0x00000100,339.init_machine = d2net_init,340.map_io = orion5x_map_io,341.init_early = orion5x_init_early,342.init_irq = orion5x_init_irq,343.timer = &orion5x_timer,344.fixup = tag_fixup_mem32,345MACHINE_END346#endif347348#ifdef CONFIG_MACH_BIGDISK349MACHINE_START(BIGDISK, "LaCie Big Disk Network")350.boot_params = 0x00000100,351.init_machine = d2net_init,352.map_io = orion5x_map_io,353.init_early = orion5x_init_early,354.init_irq = orion5x_init_irq,355.timer = &orion5x_timer,356.fixup = tag_fixup_mem32,357MACHINE_END358#endif359360361362