Path: blob/master/arch/arm/mach-orion5x/ls_hgl-setup.c
10819 views
/*1* arch/arm/mach-orion5x/ls_hgl-setup.c2*3* Maintainer: Zhu Qingsen <[email protected]>4*5* This file is licensed under the terms of the GNU General Public6* License version 2. This program is licensed "as is" without any7* warranty of any kind, whether express or implied.8*/910#include <linux/kernel.h>11#include <linux/init.h>12#include <linux/platform_device.h>13#include <linux/mtd/physmap.h>14#include <linux/mv643xx_eth.h>15#include <linux/leds.h>16#include <linux/gpio_keys.h>17#include <linux/input.h>18#include <linux/i2c.h>19#include <linux/ata_platform.h>20#include <linux/gpio.h>21#include <asm/mach-types.h>22#include <asm/mach/arch.h>23#include <asm/system.h>24#include <mach/orion5x.h>25#include "common.h"26#include "mpp.h"2728/*****************************************************************************29* Linkstation LS-HGL Info30****************************************************************************/3132/*33* 256K NOR flash Device bus boot chip select34*/3536#define LS_HGL_NOR_BOOT_BASE 0xf400000037#define LS_HGL_NOR_BOOT_SIZE SZ_256K3839/*****************************************************************************40* 256KB NOR Flash on BOOT Device41****************************************************************************/4243static struct physmap_flash_data ls_hgl_nor_flash_data = {44.width = 1,45};4647static struct resource ls_hgl_nor_flash_resource = {48.flags = IORESOURCE_MEM,49.start = LS_HGL_NOR_BOOT_BASE,50.end = LS_HGL_NOR_BOOT_BASE + LS_HGL_NOR_BOOT_SIZE - 1,51};5253static struct platform_device ls_hgl_nor_flash = {54.name = "physmap-flash",55.id = 0,56.dev = {57.platform_data = &ls_hgl_nor_flash_data,58},59.num_resources = 1,60.resource = &ls_hgl_nor_flash_resource,61};6263/*****************************************************************************64* Ethernet65****************************************************************************/6667static struct mv643xx_eth_platform_data ls_hgl_eth_data = {68.phy_addr = 8,69};7071/*****************************************************************************72* RTC 5C372a on I2C bus73****************************************************************************/7475static struct i2c_board_info __initdata ls_hgl_i2c_rtc = {76I2C_BOARD_INFO("rs5c372a", 0x32),77};7879/*****************************************************************************80* LEDs attached to GPIO81****************************************************************************/8283#define LS_HGL_GPIO_LED_ALARM 284#define LS_HGL_GPIO_LED_INFO 385#define LS_HGL_GPIO_LED_FUNC 1786#define LS_HGL_GPIO_LED_PWR 0878889static struct gpio_led ls_hgl_led_pins[] = {90{91.name = "alarm:red",92.gpio = LS_HGL_GPIO_LED_ALARM,93.active_low = 1,94}, {95.name = "info:amber",96.gpio = LS_HGL_GPIO_LED_INFO,97.active_low = 1,98}, {99.name = "func:blue:top",100.gpio = LS_HGL_GPIO_LED_FUNC,101.active_low = 1,102}, {103.name = "power:blue:bottom",104.gpio = LS_HGL_GPIO_LED_PWR,105},106};107108static struct gpio_led_platform_data ls_hgl_led_data = {109.leds = ls_hgl_led_pins,110.num_leds = ARRAY_SIZE(ls_hgl_led_pins),111};112113static struct platform_device ls_hgl_leds = {114.name = "leds-gpio",115.id = -1,116.dev = {117.platform_data = &ls_hgl_led_data,118},119};120121/****************************************************************************122* GPIO Attached Keys123****************************************************************************/124#define LS_HGL_GPIO_KEY_FUNC 15125#define LS_HGL_GPIO_KEY_POWER 8126#define LS_HGL_GPIO_KEY_AUTOPOWER 10127128#define LS_HGL_SW_POWER 0x00129#define LS_HGL_SW_AUTOPOWER 0x01130131static struct gpio_keys_button ls_hgl_buttons[] = {132{133.code = KEY_OPTION,134.gpio = LS_HGL_GPIO_KEY_FUNC,135.desc = "Function Button",136.active_low = 1,137}, {138.type = EV_SW,139.code = LS_HGL_SW_POWER,140.gpio = LS_HGL_GPIO_KEY_POWER,141.desc = "Power-on Switch",142.active_low = 1,143}, {144.type = EV_SW,145.code = LS_HGL_SW_AUTOPOWER,146.gpio = LS_HGL_GPIO_KEY_AUTOPOWER,147.desc = "Power-auto Switch",148.active_low = 1,149},150};151152static struct gpio_keys_platform_data ls_hgl_button_data = {153.buttons = ls_hgl_buttons,154.nbuttons = ARRAY_SIZE(ls_hgl_buttons),155};156157static struct platform_device ls_hgl_button_device = {158.name = "gpio-keys",159.id = -1,160.num_resources = 0,161.dev = {162.platform_data = &ls_hgl_button_data,163},164};165166167/*****************************************************************************168* SATA169****************************************************************************/170static struct mv_sata_platform_data ls_hgl_sata_data = {171.n_ports = 2,172};173174175/*****************************************************************************176* Linkstation LS-HGL specific power off method: reboot177****************************************************************************/178/*179* On the Linkstation LS-HGL, the shutdown process is following:180* - Userland monitors key events until the power switch goes to off position181* - The board reboots182* - U-boot starts and goes into an idle mode waiting for the user183* to move the switch to ON position184*/185186static void ls_hgl_power_off(void)187{188arm_machine_restart('h', NULL);189}190191192/*****************************************************************************193* General Setup194****************************************************************************/195196#define LS_HGL_GPIO_USB_POWER 9197#define LS_HGL_GPIO_AUTO_POWER 10198#define LS_HGL_GPIO_POWER 8199200#define LS_HGL_GPIO_HDD_POWER 1201202static unsigned int ls_hgl_mpp_modes[] __initdata = {203MPP0_GPIO, /* LED_PWR */204MPP1_GPIO, /* HDD_PWR */205MPP2_GPIO, /* LED_ALARM */206MPP3_GPIO, /* LED_INFO */207MPP4_UNUSED,208MPP5_UNUSED,209MPP6_GPIO, /* FAN_LCK */210MPP7_GPIO, /* INIT */211MPP8_GPIO, /* POWER */212MPP9_GPIO, /* USB_PWR */213MPP10_GPIO, /* AUTO_POWER */214MPP11_UNUSED, /* LED_ETH (dummy) */215MPP12_UNUSED,216MPP13_UNUSED,217MPP14_UNUSED,218MPP15_GPIO, /* FUNC */219MPP16_UNUSED,220MPP17_GPIO, /* LED_FUNC */221MPP18_UNUSED,222MPP19_UNUSED,2230,224};225226static void __init ls_hgl_init(void)227{228/*229* Setup basic Orion functions. Need to be called early.230*/231orion5x_init();232233orion5x_mpp_conf(ls_hgl_mpp_modes);234235/*236* Configure peripherals.237*/238orion5x_ehci0_init();239orion5x_ehci1_init();240orion5x_eth_init(&ls_hgl_eth_data);241orion5x_i2c_init();242orion5x_sata_init(&ls_hgl_sata_data);243orion5x_uart0_init();244orion5x_xor_init();245246orion5x_setup_dev_boot_win(LS_HGL_NOR_BOOT_BASE,247LS_HGL_NOR_BOOT_SIZE);248platform_device_register(&ls_hgl_nor_flash);249250platform_device_register(&ls_hgl_button_device);251252platform_device_register(&ls_hgl_leds);253254i2c_register_board_info(0, &ls_hgl_i2c_rtc, 1);255256/* enable USB power */257gpio_set_value(LS_HGL_GPIO_USB_POWER, 1);258259/* register power-off method */260pm_power_off = ls_hgl_power_off;261262pr_info("%s: finished\n", __func__);263}264265MACHINE_START(LINKSTATION_LS_HGL, "Buffalo Linkstation LS-HGL")266/* Maintainer: Zhu Qingsen <[email protected]> */267.boot_params = 0x00000100,268.init_machine = ls_hgl_init,269.map_io = orion5x_map_io,270.init_early = orion5x_init_early,271.init_irq = orion5x_init_irq,272.timer = &orion5x_timer,273.fixup = tag_fixup_mem32,274MACHINE_END275276277