Bug#688989: src:linux-2.6: Add support for Buffalo Linkstation LS-XHL and LS-CHLv2
Package: src:linux-2.6
Severity: wishlist
Tags: d-i patch
This patch add new hardware support for the Buffalo Linkstation LS-XHL and
LS-CHLv2. Both systems are supported by the upstream linux kernel as per
commit 4aff38a3db1f63494812834f1fbbdb1f00579c66. While the upstream support
is device tree based, this patch uses the old fashioned machine setup.
-- System Information:
Debian Release: 6.0.4
APT prefers stable
APT policy: (500, 'stable')
Architecture: i386 (i686)
Kernel: Linux 2.6.32-5-686-bigmem (SMP w/2 CPU cores)
Locale: LANG=de_DE.UTF-8, LC_CTYPE=de_DE.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/bash
Index: linux-source-2.6.32/arch/arm/mach-kirkwood/Kconfig
===================================================================
--- linux-source-2.6.32.orig/arch/arm/mach-kirkwood/Kconfig 2012-09-24 22:21:10.986381439 +0200
+++ linux-source-2.6.32/arch/arm/mach-kirkwood/Kconfig 2012-09-24 22:24:50.486881580 +0200
@@ -93,6 +93,12 @@
Say 'Y' here if you want your kernel to support the
HP t5325 Thin Client.
+config MACH_LSXL
+ bool "Buffalo Linkstation LS-XHL, LS-CHLv2"
+ help
+ Say 'Y' here if you want your kernel to support the
+ Buffalo Linkstation LS-XHL & LS-CHLv2 devices.
+
endmenu
endif
Index: linux-source-2.6.32/arch/arm/mach-kirkwood/Makefile
===================================================================
--- linux-source-2.6.32.orig/arch/arm/mach-kirkwood/Makefile 2012-09-24 22:21:14.922381454 +0200
+++ linux-source-2.6.32/arch/arm/mach-kirkwood/Makefile 2012-09-24 22:37:09.426381572 +0200
@@ -12,5 +12,6 @@
obj-$(CONFIG_MACH_DOCKSTAR) += dockstar-setup.o
obj-$(CONFIG_MACH_OPENRD) += openrd-setup.o
obj-$(CONFIG_MACH_T5325) += t5325-setup.o
+obj-$(CONFIG_MACH_LSXL) += lsxl-setup.o
obj-$(CONFIG_CPU_IDLE) += cpuidle.o
Index: linux-source-2.6.32/arch/arm/mach-kirkwood/lsxl-setup.c
===================================================================
--- /dev/null 1970-01-01 00:00:00.000000000 +0000
+++ linux-source-2.6.32/arch/arm/mach-kirkwood/lsxl-setup.c 2012-09-24 23:16:28.234847792 +0200
@@ -0,0 +1,331 @@
+/*
+ * Copyright 2012 (C), Michael Walle <michael@walle.cc>
+ *
+ * arch/arm/mach-kirkwood/lsxl-setup.c
+ *
+ * Buffalo Linkstation LS-XHL and LS-CHLv2 setup
+ *
+ * This file is licensed under the terms of the GNU General Public
+ * License version 2. This program is licensed "as is" without any
+ * warranty of any kind, whether express or implied.
+ */
+
+#include <linux/kernel.h>
+#include <linux/init.h>
+#include <linux/platform_device.h>
+#include <linux/mtd/physmap.h>
+#include <linux/ata_platform.h>
+#include <linux/spi/flash.h>
+#include <linux/spi/spi.h>
+#include <linux/mv643xx_eth.h>
+#include <linux/gpio.h>
+#include <linux/gpio_keys.h>
+#include <linux/gpio-fan.h>
+#include <linux/input.h>
+#include <linux/leds.h>
+#include <asm/mach-types.h>
+#include <asm/mach/arch.h>
+#include <mach/kirkwood.h>
+#include <plat/mvsdio.h>
+#include "common.h"
+#include "mpp.h"
+
+/*****************************************************************************
+ * 512KB SPI Flash on BOOT Device
+ ****************************************************************************/
+static struct mtd_partition lsxl_partitions[] = {
+ {
+ .name = "uboot",
+ .size = 0x60000,
+ .offset = 0x00000,
+ .mask_flags = MTD_WRITEABLE,
+ },
+ {
+ .name = "dtb",
+ .size = 0x10000,
+ .offset = 0x60000,
+ .mask_flags = MTD_WRITEABLE,
+ },
+ {
+ .name = "uboot_env",
+ .size = 0x10000,
+ .offset = 0x70000,
+ }
+};
+
+static struct flash_platform_data lsxl_spi_slave_data = {
+ .type = "m25p40",
+ .parts = lsxl_partitions,
+ .nr_parts = ARRAY_SIZE(lsxl_partitions),
+};
+
+static struct spi_board_info __initdata lsxl_spi_slave_info[] = {
+ {
+ .modalias = "m25p80",
+ .platform_data = &lsxl_spi_slave_data,
+ .irq = -1,
+ .max_speed_hz = 20000000,
+ .bus_num = 0,
+ .chip_select = 0,
+ }
+};
+
+/*****************************************************************************
+ * Ethernet
+ ****************************************************************************/
+static struct mv643xx_eth_platform_data lsxl_ge00_data = {
+ .phy_addr = MV643XX_ETH_PHY_ADDR(0),
+};
+
+static struct mv643xx_eth_platform_data lsxl_ge01_data = {
+ .phy_addr = MV643XX_ETH_PHY_ADDR(8),
+};
+
+/*****************************************************************************
+ * SATA
+ ****************************************************************************/
+static struct mv_sata_platform_data lsxl_sata_data = {
+ .n_ports = 1,
+};
+
+/*****************************************************************************
+ * LEDs attached to GPIO
+ ****************************************************************************/
+#define LSXL_GPIO_LED_ALARM 37
+#define LSXL_GPIO_LED_INFO 38
+#define LSXL_GPIO_LED_PWR 39
+#define LSXL_GPIO_LED_FUNC_BLUE 36
+#define LSXL_GPIO_LED_FUNC_RED 48
+
+static struct gpio_led lsxl_led_pins[] = {
+ {
+ .name = "lsxl:red:alarm",
+ .gpio = LSXL_GPIO_LED_ALARM,
+ .active_low = 1,
+ },
+ {
+ .name = "lsxl:amber:info",
+ .gpio = LSXL_GPIO_LED_INFO,
+ .active_low = 1,
+ },
+ {
+ .name = "lsxl:blue:power",
+ .default_trigger = "default-on",
+ .gpio = LSXL_GPIO_LED_PWR,
+ .active_low = 1,
+ },
+ {
+ .name = "lsxl:blue:func",
+ .gpio = LSXL_GPIO_LED_FUNC_BLUE,
+ .active_low = 1,
+ },
+ {
+ .name = "lsxl:red:func",
+ .gpio = LSXL_GPIO_LED_FUNC_RED,
+ .active_low = 1,
+ },
+};
+
+static struct gpio_led_platform_data lsxl_led_data = {
+ .leds = lsxl_led_pins,
+ .num_leds = ARRAY_SIZE(lsxl_led_pins),
+};
+
+static struct platform_device lsxl_leds = {
+ .name = "leds-gpio",
+ .id = -1,
+ .dev = {
+ .platform_data = &lsxl_led_data,
+ }
+};
+
+/*****************************************************************************
+ * General Setup
+ ****************************************************************************/
+#define LSXL_GPIO_HDD_POWER 10
+#define LSXL_GPIO_USB_POWER 11
+
+/*****************************************************************************
+ * GPIO Attached Keys
+ ****************************************************************************/
+#define LSXL_GPIO_KEY_FUNC 41
+#define LSXL_GPIO_KEY_POWER 42
+#define LSXL_GPIO_KEY_AUTOPOWER 43
+
+#define LSXL_SW_POWER 0
+#define LSXL_SW_AUTOPOWER 1
+
+static struct gpio_keys_button lsxl_buttons[] = {
+ {
+ .type = EV_SW,
+ .code = LSXL_SW_POWER,
+ .gpio = LSXL_GPIO_KEY_POWER,
+ .desc = "Power-on Switch",
+ .active_low = 1,
+ }, {
+ .type = EV_SW,
+ .code = LSXL_SW_AUTOPOWER,
+ .gpio = LSXL_GPIO_KEY_AUTOPOWER,
+ .desc = "Power-auto Switch",
+ .active_low = 1,
+ }, {
+ .code = KEY_OPTION,
+ .gpio = LSXL_GPIO_KEY_FUNC,
+ .desc = "Function Button",
+ .active_low = 1,
+ },
+};
+
+static struct gpio_keys_platform_data lsxl_button_data = {
+ .buttons = lsxl_buttons,
+ .nbuttons = ARRAY_SIZE(lsxl_buttons),
+};
+
+static struct platform_device lsxl_button_device = {
+ .name = "gpio-keys",
+ .id = -1,
+ .num_resources = 0,
+ .dev = {
+ .platform_data = &lsxl_button_data,
+ },
+};
+
+/*****************************************************************************
+ * GPIO Fan
+ ****************************************************************************/
+#define LSXL_GPIO_FAN_HIGH 18
+#define LSXL_GPIO_FAN_LOW 19
+#define LSXL_GPIO_FAN_LOCK 40
+
+static struct gpio_fan_alarm lsxl_alarm = {
+ .gpio = LSXL_GPIO_FAN_LOCK,
+};
+
+static struct gpio_fan_speed lsxl_speeds[] = {
+ {
+ .rpm = 0,
+ .ctrl_val = 3,
+ }, {
+ .rpm = 1500,
+ .ctrl_val = 1,
+ }, {
+ .rpm = 3250,
+ .ctrl_val = 2,
+ }, {
+ .rpm = 5000,
+ .ctrl_val = 0,
+ }
+};
+
+static int lsxl_gpio_list[] = {
+ LSXL_GPIO_FAN_HIGH, LSXL_GPIO_FAN_LOW,
+};
+
+static struct gpio_fan_platform_data lsxl_fan_data = {
+ .num_ctrl = ARRAY_SIZE(lsxl_gpio_list),
+ .ctrl = lsxl_gpio_list,
+ .alarm = &lsxl_alarm,
+ .num_speed = ARRAY_SIZE(lsxl_speeds),
+ .speed = lsxl_speeds,
+};
+
+static struct platform_device lsxl_fan_device = {
+ .name = "gpio-fan",
+ .id = -1,
+ .num_resources = 0,
+ .dev = {
+ .platform_data = &lsxl_fan_data,
+ },
+};
+
+/*****************************************************************************
+ * GPIO Data
+ ****************************************************************************/
+
+static unsigned int lsxl_mpp_config[] __initdata = {
+ MPP10_GPO, /* HDD Power Enable */
+ MPP11_GPIO, /* USB Vbus Enable */
+ MPP18_GPO, /* FAN High Enable# */
+ MPP19_GPO, /* FAN Low Enable# */
+ MPP36_GPIO, /* Function Blue LED */
+ MPP37_GPIO, /* Alarm LED */
+ MPP38_GPIO, /* Info LED */
+ MPP39_GPIO, /* Power LED */
+ MPP40_GPIO, /* Fan Lock */
+ MPP41_GPIO, /* Function Button */
+ MPP42_GPIO, /* Power Switch */
+ MPP43_GPIO, /* Power Auto Switch */
+ MPP48_GPIO, /* Function Red LED */
+ 0
+};
+
+/*****************************************************************************
+ * LS-XL specific power off method: reboot
+ ****************************************************************************/
+/*
+ * On the LS-XL, the shutdown process is following:
+ * - Userland monitors key events until the power switch goes to off position
+ * - The board reboots
+ * - U-boot starts and goes into an idle mode waiting for the user
+ * to move the switch to ON position
+ *
+ */
+
+static void lsxl_power_off(void)
+{
+ arm_machine_restart('h', NULL);
+}
+
+static void __init lsxl_init(void)
+{
+ /*
+ * Basic setup. Needs to be called early.
+ */
+ kirkwood_init();
+ kirkwood_mpp_conf(lsxl_mpp_config);
+
+ /*
+ * Configure peripherals.
+ */
+ kirkwood_uart0_init();
+ kirkwood_ehci_init();
+ kirkwood_ge00_init(&lsxl_ge00_data);
+ kirkwood_ge01_init(&lsxl_ge01_data);
+ kirkwood_sata_init(&lsxl_sata_data);
+ kirkwood_spi_init();
+
+ platform_device_register(&lsxl_leds);
+ platform_device_register(&lsxl_button_device);
+ platform_device_register(&lsxl_fan_device);
+
+ spi_register_board_info(lsxl_spi_slave_info,
+ ARRAY_SIZE(lsxl_spi_slave_info));
+
+ /* usb power on */
+ gpio_set_value(LSXL_GPIO_USB_POWER, 1);
+
+ /* register power-off method */
+ pm_power_off = lsxl_power_off;
+
+ pr_info("%s: finished\n", __func__);
+}
+
+MACHINE_START(LINKSTATION_CHLV2, "Buffalo LS-CHLv2")
+ .phys_io = KIRKWOOD_REGS_PHYS_BASE,
+ .io_pg_offst = ((KIRKWOOD_REGS_VIRT_BASE) >> 18) & 0xfffc,
+ .boot_params = 0x00000100,
+ .init_machine = lsxl_init,
+ .map_io = kirkwood_map_io,
+ .init_irq = kirkwood_init_irq,
+ .timer = &kirkwood_timer,
+MACHINE_END
+
+MACHINE_START(LSXHL, "Buffalo LS-XHL")
+ .phys_io = KIRKWOOD_REGS_PHYS_BASE,
+ .io_pg_offst = ((KIRKWOOD_REGS_VIRT_BASE) >> 18) & 0xfffc,
+ .boot_params = 0x00000100,
+ .init_machine = lsxl_init,
+ .map_io = kirkwood_map_io,
+ .init_irq = kirkwood_init_irq,
+ .timer = &kirkwood_timer,
+MACHINE_END
Index: linux-source-2.6.32/arch/arm/configs/kirkwood_defconfig
===================================================================
--- linux-source-2.6.32.orig/arch/arm/configs/kirkwood_defconfig 2012-09-24 22:20:55.862381759 +0200
+++ linux-source-2.6.32/arch/arm/configs/kirkwood_defconfig 2012-09-24 23:03:49.070381843 +0200
@@ -196,6 +196,7 @@
CONFIG_MACH_SHEEVAPLUG=y
CONFIG_MACH_TS219=y
CONFIG_MACH_OPENRD_BASE=y
+CONFIG_MACH_LSXL=y
CONFIG_PLAT_ORION=y
#
Reply to: