Path: blob/master/arch/arm/mach-orion5x/ls-chl-setup.c
10819 views
/*1* arch/arm/mach-orion5x/ls-chl-setup.c2*3* Maintainer: Ash Hughes <[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/gpio-fan.h>18#include <linux/input.h>19#include <linux/i2c.h>20#include <linux/ata_platform.h>21#include <linux/gpio.h>22#include <asm/mach-types.h>23#include <asm/mach/arch.h>24#include <asm/system.h>25#include <mach/orion5x.h>26#include "common.h"27#include "mpp.h"2829/*****************************************************************************30* Linkstation LS-CHL Info31****************************************************************************/3233/*34* 256K NOR flash Device bus boot chip select35*/3637#define LSCHL_NOR_BOOT_BASE 0xf400000038#define LSCHL_NOR_BOOT_SIZE SZ_256K3940/*****************************************************************************41* 256KB NOR Flash on BOOT Device42****************************************************************************/4344static struct physmap_flash_data lschl_nor_flash_data = {45.width = 1,46};4748static struct resource lschl_nor_flash_resource = {49.flags = IORESOURCE_MEM,50.start = LSCHL_NOR_BOOT_BASE,51.end = LSCHL_NOR_BOOT_BASE + LSCHL_NOR_BOOT_SIZE - 1,52};5354static struct platform_device lschl_nor_flash = {55.name = "physmap-flash",56.id = 0,57.dev = {58.platform_data = &lschl_nor_flash_data,59},60.num_resources = 1,61.resource = &lschl_nor_flash_resource,62};6364/*****************************************************************************65* Ethernet66****************************************************************************/6768static struct mv643xx_eth_platform_data lschl_eth_data = {69.phy_addr = MV643XX_ETH_PHY_ADDR(8),70};7172/*****************************************************************************73* RTC 5C372a on I2C bus74****************************************************************************/7576static struct i2c_board_info __initdata lschl_i2c_rtc = {77I2C_BOARD_INFO("rs5c372a", 0x32),78};7980/*****************************************************************************81* LEDs attached to GPIO82****************************************************************************/8384#define LSCHL_GPIO_LED_ALARM 285#define LSCHL_GPIO_LED_INFO 386#define LSCHL_GPIO_LED_FUNC 1787#define LSCHL_GPIO_LED_PWR 08889static struct gpio_led lschl_led_pins[] = {90{91.name = "alarm:red",92.gpio = LSCHL_GPIO_LED_ALARM,93.active_low = 1,94}, {95.name = "info:amber",96.gpio = LSCHL_GPIO_LED_INFO,97.active_low = 1,98}, {99.name = "func:blue:top",100.gpio = LSCHL_GPIO_LED_FUNC,101.active_low = 1,102}, {103.name = "power:blue:bottom",104.gpio = LSCHL_GPIO_LED_PWR,105},106};107108static struct gpio_led_platform_data lschl_led_data = {109.leds = lschl_led_pins,110.num_leds = ARRAY_SIZE(lschl_led_pins),111};112113static struct platform_device lschl_leds = {114.name = "leds-gpio",115.id = -1,116.dev = {117.platform_data = &lschl_led_data,118},119};120121/*****************************************************************************122* SATA123****************************************************************************/124static struct mv_sata_platform_data lschl_sata_data = {125.n_ports = 2,126};127128/*****************************************************************************129* LS-CHL specific power off method: reboot130****************************************************************************/131/*132* On the LS-CHL, the shutdown process is following:133* - Userland monitors key events until the power switch goes to off position134* - The board reboots135* - U-boot starts and goes into an idle mode waiting for the user136* to move the switch to ON position137*138*/139140static void lschl_power_off(void)141{142arm_machine_restart('h', NULL);143}144145/*****************************************************************************146* General Setup147****************************************************************************/148#define LSCHL_GPIO_USB_POWER 9149#define LSCHL_GPIO_AUTO_POWER 17150#define LSCHL_GPIO_POWER 18151152/****************************************************************************153* GPIO Attached Keys154****************************************************************************/155#define LSCHL_GPIO_KEY_FUNC 15156#define LSCHL_GPIO_KEY_POWER 8157#define LSCHL_GPIO_KEY_AUTOPOWER 10158#define LSCHL_SW_POWER 0x00159#define LSCHL_SW_AUTOPOWER 0x01160#define LSCHL_SW_FUNC 0x02161162static struct gpio_keys_button lschl_buttons[] = {163{164.type = EV_SW,165.code = LSCHL_SW_POWER,166.gpio = LSCHL_GPIO_KEY_POWER,167.desc = "Power-on Switch",168.active_low = 1,169}, {170.type = EV_SW,171.code = LSCHL_SW_AUTOPOWER,172.gpio = LSCHL_GPIO_KEY_AUTOPOWER,173.desc = "Power-auto Switch",174.active_low = 1,175}, {176.type = EV_SW,177.code = LSCHL_SW_FUNC,178.gpio = LSCHL_GPIO_KEY_FUNC,179.desc = "Function Switch",180.active_low = 1,181},182};183184static struct gpio_keys_platform_data lschl_button_data = {185.buttons = lschl_buttons,186.nbuttons = ARRAY_SIZE(lschl_buttons),187};188189static struct platform_device lschl_button_device = {190.name = "gpio-keys",191.id = -1,192.num_resources = 0,193.dev = {194.platform_data = &lschl_button_data,195},196};197198#define LSCHL_GPIO_HDD_POWER 1199200/****************************************************************************201* GPIO Fan202****************************************************************************/203204#define LSCHL_GPIO_FAN_LOW 16205#define LSCHL_GPIO_FAN_HIGH 14206#define LSCHL_GPIO_FAN_LOCK 6207208static struct gpio_fan_alarm lschl_alarm = {209.gpio = LSCHL_GPIO_FAN_LOCK,210};211212static struct gpio_fan_speed lschl_speeds[] = {213{214.rpm = 0,215.ctrl_val = 3,216}, {217.rpm = 1500,218.ctrl_val = 2,219}, {220.rpm = 3250,221.ctrl_val = 1,222}, {223.rpm = 5000,224.ctrl_val = 0,225},226};227228static int lschl_gpio_list[] = {229LSCHL_GPIO_FAN_HIGH, LSCHL_GPIO_FAN_LOW,230};231232static struct gpio_fan_platform_data lschl_fan_data = {233.num_ctrl = ARRAY_SIZE(lschl_gpio_list),234.ctrl = lschl_gpio_list,235.alarm = &lschl_alarm,236.num_speed = ARRAY_SIZE(lschl_speeds),237.speed = lschl_speeds,238};239240static struct platform_device lschl_fan_device = {241.name = "gpio-fan",242.id = -1,243.num_resources = 0,244.dev = {245.platform_data = &lschl_fan_data,246},247};248249/****************************************************************************250* GPIO Data251****************************************************************************/252253static unsigned int lschl_mpp_modes[] __initdata = {254MPP0_GPIO, /* LED POWER */255MPP1_GPIO, /* HDD POWER */256MPP2_GPIO, /* LED ALARM */257MPP3_GPIO, /* LED INFO */258MPP4_UNUSED,259MPP5_UNUSED,260MPP6_GPIO, /* FAN LOCK */261MPP7_GPIO, /* SW INIT */262MPP8_GPIO, /* SW POWER */263MPP9_GPIO, /* USB POWER */264MPP10_GPIO, /* SW AUTO POWER */265MPP11_UNUSED,266MPP12_UNUSED,267MPP13_UNUSED,268MPP14_GPIO, /* FAN HIGH */269MPP15_GPIO, /* SW FUNC */270MPP16_GPIO, /* FAN LOW */271MPP17_GPIO, /* LED FUNC */272MPP18_UNUSED,273MPP19_UNUSED,2740,275};276277static void __init lschl_init(void)278{279/*280* Setup basic Orion functions. Needs to be called early.281*/282orion5x_init();283284orion5x_mpp_conf(lschl_mpp_modes);285286/*287* Configure peripherals.288*/289orion5x_ehci0_init();290orion5x_ehci1_init();291orion5x_eth_init(&lschl_eth_data);292orion5x_i2c_init();293orion5x_sata_init(&lschl_sata_data);294orion5x_uart0_init();295orion5x_xor_init();296297orion5x_setup_dev_boot_win(LSCHL_NOR_BOOT_BASE,298LSCHL_NOR_BOOT_SIZE);299platform_device_register(&lschl_nor_flash);300301platform_device_register(&lschl_leds);302303platform_device_register(&lschl_button_device);304305platform_device_register(&lschl_fan_device);306307i2c_register_board_info(0, &lschl_i2c_rtc, 1);308309/* usb power on */310gpio_set_value(LSCHL_GPIO_USB_POWER, 1);311312/* register power-off method */313pm_power_off = lschl_power_off;314315pr_info("%s: finished\n", __func__);316}317318MACHINE_START(LINKSTATION_LSCHL, "Buffalo Linkstation LiveV3 (LS-CHL)")319/* Maintainer: Ash Hughes <[email protected]> */320.boot_params = 0x00000100,321.init_machine = lschl_init,322.map_io = orion5x_map_io,323.init_early = orion5x_init_early,324.init_irq = orion5x_init_irq,325.timer = &orion5x_timer,326.fixup = tag_fixup_mem32,327MACHINE_END328329330