Hack BBS

[全部のスレッド一覧][新規投稿][記事の削除・変更] [Home Page]

返信投稿はタイトルのリンクをクリックして下さい
スレッド【No.5968】の中の記事をすべて表示しています

【No.5968】のスレッド
12/03/12(月) 19:56:50 投稿者[通りすがり] [No.5968]のスレッド内
【No.5968】 タイトル[LS-VLのkernel 3.xパッチ] この記事がスレッドの最初です
3.2.9でも大丈夫です。
元は「v2-ARM-kirkwood-Add-support-for-Buffalo-LS-XHL.patch」です。
GPIO振り直しをし、使いやすいように改良してます。
スイッチはGPIOを監視するスクリプトで監視してください。

v3.2-ARM-kirkwood-Add-support-for-Buffalo-LS-VL.patch
-----
--- /dev/null 2012-01-26 13:36:46.440000000 +0900
+++ linux-3.2.1/arch/arm/mach-kirkwood/lsvl-setup.c 2012-01-26 11:54:47.196653884 +0900
@@ -0,0 +1,340 @@
+/*
+ * arch/arm/mach-kirkwood/lsvl-setup.c
+ *
+ * Buffalo LS-VL Series 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/mtd/partitions.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 lsvl_partitions[] = {
+ {
+ .name = "u-boot",
+ .size = 0x80000,
+ .offset = 0x00000,
+ //.mask_flags = MTD_WRITEABLE, /* force read-only */
+ }
+};
+
+static struct flash_platform_data lsvl_spi_slave_data = {
+ .type = "m25p40-nonjedec",
+ .parts = lsvl_partitions,
+ .nr_parts = ARRAY_SIZE(lsvl_partitions),
+};
+
+static struct spi_board_info __initdata lsvl_spi_slave_info[] = {
+ {
+ .modalias = "m25p80",
+ .platform_data = &lsvl_spi_slave_data,
+ .irq = -1,
+ .max_speed_hz = 20000000,
+ .bus_num = 0,
+ .chip_select = 0,
+ }
+};
+
+/*****************************************************************************
+ * Ethernet
+ ****************************************************************************/
+static struct mv643xx_eth_platform_data lsvl_ge00_data = {
+ .phy_addr = MV643XX_ETH_PHY_ADDR(0),
+};
+
+/*****************************************************************************
+ * SATA
+ ****************************************************************************/
+static struct mv_sata_platform_data lsvl_sata_data = {
+ .n_ports = 1,
+};
+
+/*****************************************************************************
+ * LEDs attached to GPIO
+ ****************************************************************************/
+#define LSVL_GPIO_LED_ALARM 36
+#define LSVL_GPIO_LED_FUNC_RED 37
+#define LSVL_GPIO_LED_INFO 38
+#define LSVL_GPIO_LED_FUNC_BLUE 39
+#define LSVL_GPIO_LED_PWR 40
+
+static struct gpio_led lsvl_led_pins[] = {
+ {
+ .name = "alarm:red",
+ .gpio = LSVL_GPIO_LED_ALARM,
+ },
+ {
+ .name = "func:red:bottom",
+ .gpio = LSVL_GPIO_LED_FUNC_RED,
+ },
+ {
+ .name = "info:amber",
+ .gpio = LSVL_GPIO_LED_INFO,
+ },
+ {
+ .name = "func:blue:bottom",
+ .gpio = LSVL_GPIO_LED_FUNC_BLUE,
+ },
+
+ {
+ .name = "power:blue",
+ .default_trigger = "default-on",
+ .gpio = LSVL_GPIO_LED_PWR,
+ .active_low = 1,
+ },
+};
+
+static struct gpio_led_platform_data lsvl_led_data = {
+ .leds = lsvl_led_pins,
+ .num_leds = ARRAY_SIZE(lsvl_led_pins),
+};
+
+static struct platform_device lsvl_leds = {
+ .name = "leds-gpio",
+ .id = -1,
+ .dev = {
+ .platform_data = &lsvl_led_data,
+ }
+};
+
+/*****************************************************************************
+ * General Setup
+ ****************************************************************************/
+#define LSVL_GPIO_HDD_POWER 8
+#define LSVL_GPIO_USB_POWER 12
+
+/*****************************************************************************
+ * GPIO Attached Keys
+ ****************************************************************************/
+/*#define LSVL_GPIO_KEY_FUNC 45
+#define LSVL_GPIO_KEY_POWER 46
+#define LSVL_GPIO_KEY_AUTOPOWER 47
+#define LSVL_SW_POWER 0x00
+#define LSVL_SW_AUTOPOWER 0x01
+#define LSVL_SW_FUNC 0x02
+
+static struct gpio_keys_button lsvl_buttons[] = {
+ {
+ .type = EV_SW,
+ .code = LSVL_SW_POWER,
+ .gpio = LSVL_GPIO_KEY_POWER,
+ .desc = "Power-on Switch",
+ .active_low = 1,
+ }, {
+ .type = EV_SW,
+ .code = LSVL_SW_AUTOPOWER,
+ .gpio = LSVL_GPIO_KEY_AUTOPOWER,
+ .desc = "Power-auto Switch",
+ .active_low = 1,
+ }, {
+ .type = EV_SW,
+ .code = LSVL_SW_FUNC,
+ .gpio = LSVL_GPIO_KEY_FUNC,
+ .desc = "Function Button",
+ .active_low = 1,
+ },
+};
+
+static struct gpio_keys_platform_data lsvl_button_data = {
+ .buttons = lsvl_buttons,
+ .nbuttons = ARRAY_SIZE(lsvl_buttons),
+};
+
+static struct platform_device lsvl_button_device = {
+ .name = "gpio-keys",
+ .id = -1,
+ .num_resources = 0,
+ .dev = {
+ .platform_data = &lsvl_button_data,
+ },
+};
+*/
+
+/*****************************************************************************
+ * GPIO Fan
+ ****************************************************************************/
+#define LSVL_GPIO_FAN_HIGH 16
+#define LSVL_GPIO_FAN_LOW 17
+#define LSVL_GPIO_FAN_LOCK 43
+
+static struct gpio_fan_alarm lsvl_alarm = {
+ .gpio = LSVL_GPIO_FAN_LOCK,
+};
+
+static struct gpio_fan_speed lsvl_speeds[] = {
+ {
+ .rpm = 0,
+ .ctrl_val = 3,
+ }, {
+ .rpm = 1500,
+ .ctrl_val = 1,
+ }, {
+ .rpm = 3250,
+ .ctrl_val = 2,
+ }, {
+ .rpm = 5000,
+ .ctrl_val = 0,
+ }
+};
+
+static int lsvl_gpio_list[] = {
+ LSVL_GPIO_FAN_HIGH, LSVL_GPIO_FAN_LOW,
+};
+
+static struct gpio_fan_platform_data lsvl_fan_data = {
+ .num_ctrl = ARRAY_SIZE(lsvl_gpio_list),
+ .ctrl = lsvl_gpio_list,
+ .alarm = &lsvl_alarm,
+ .num_speed = ARRAY_SIZE(lsvl_speeds),
+ .speed = lsvl_speeds,
+};
+
+static struct platform_device lsvl_fan_device = {
+ .name = "gpio-fan",
+ .id = -1,
+ .num_resources = 0,
+ .dev = {
+ .platform_data = &lsvl_fan_data,
+ },
+};
+
+/*****************************************************************************
+ * GPIO Data
+ ****************************************************************************/
+
+static unsigned int lsvl_mpp_config[] __initdata = {
+ MPP0_NF_IO2,
+ MPP1_NF_IO3,
+ MPP2_NF_IO4,
+ MPP3_NF_IO5,
+ MPP4_NF_IO6,
+ MPP5_NF_IO7,
+ MPP6_SYSRST_OUTn,
+ MPP7_SPI_SCn,
+ MPP8_GPIO, /* HDD Power */
+ MPP9_GPIO,
+ MPP10_UART0_TXD,
+ MPP11_UART0_RXD,
+ MPP12_GPO, /* USB VBUS EN */
+ MPP13_GPIO,
+ MPP14_GPIO,
+ MPP15_GPIO,
+ MPP16_GPIO, /* FAN HIGH: on:0, off:1 */
+ MPP17_GPIO, /* FAN LOW: on:0, off:1 */
+ MPP18_NF_IO0,
+ MPP19_NF_IO1,
+ MPP20_GPIO,
+ MPP21_GPIO,
+ MPP22_GPIO,
+ MPP23_GPIO,
+ MPP24_GPIO,
+ MPP25_GPIO,
+ MPP26_GPIO,
+ MPP27_GPIO,
+ MPP28_GPIO,
+ MPP29_GPIO,
+ MPP30_GPIO,
+ MPP31_GPIO,
+ MPP32_GPIO,
+ MPP33_GPO,
+ MPP34_GPIO,
+ MPP35_GPIO,
+ MPP36_GPIO, /* ALARM LED */
+ MPP37_GPIO, /* FUNC RED LED */
+ MPP38_GPIO, /* INFO LED */
+ MPP39_GPIO, /* FUNC LED */
+ MPP40_GPIO, /* POWER LED */
+ MPP41_GPIO,
+ MPP42_GPIO,
+ MPP43_GPIO, /* FAN LOCK */
+ MPP44_GPIO,
+ MPP45_GPIO, /* FUNC SW */
+ MPP46_GPIO, /* POWER SW */
+ MPP47_GPIO, /* POWER AUTO SW */
+ MPP48_GPIO, /* UART EN */
+ MPP49_GPIO,
+ 0
+};
+
+/*****************************************************************************
+ * LS-VL specific power off method: reboot
+ ****************************************************************************/
+/*
+ * On the LS-VL, 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 lsvl_power_off(void)
+{
+ arm_machine_restart('h', NULL);
+}
+
+static void __init lsvl_init(void)
+{
+ /*
+ * Basic setup. Needs to be called early.
+ */
+ kirkwood_init();
+ kirkwood_mpp_conf(lsvl_mpp_config);
+
+ /*
+ * Configure peripherals.
+ */
+ kirkwood_uart0_init();
+ kirkwood_ehci_init();
+ kirkwood_ge00_init(&lsvl_ge00_data);
+ kirkwood_sata_init(&lsvl_sata_data);
+ kirkwood_spi_init();
+
+ platform_device_register(&lsvl_leds);
+// platform_device_register(&lsvl_button_device);
+ platform_device_register(&lsvl_fan_device);
+
+ spi_register_board_info(lsvl_spi_slave_info,
+ ARRAY_SIZE(lsvl_spi_slave_info));
+
+ /* usb power on */
+ gpio_set_value(LSVL_GPIO_USB_POWER, 1);
+
+ /* register power-off method */
+ pm_power_off = lsvl_power_off;
+
+ pr_info("%s: finished\n", __func__);
+}
+
+MACHINE_START(LSVL, "Buffalo LS-VL Series")
+ .atag_offset = 0x100,
+ .init_machine = lsvl_init,
+ .map_io = kirkwood_map_io,
+ .init_early = kirkwood_init_early,
+ .init_irq = kirkwood_init_irq,
+ .timer = &kirkwood_timer,
+MACHINE_END
+
--- linux-3.0.4.org/arch/arm/mach-kirkwood/Kconfig 2011-08-30 05:56:30.000000000 +0900
+++ linux-3.0.4/arch/arm/mach-kirkwood/Kconfig 2011-09-03 12:01:26.636120337 +0900
@@ -130,6 +130,12 @@
Say 'Y' here if you want your kernel to support the
HP t5325 Thin Client.

+config MACH_LSVL
+ bool "Buffalo LS-VL Series"
+ help
+ Say 'Y' here if you want your kernel to support the
+ Buffalo LS-VL Series.
+
endmenu

endif
--- linux-3.0.4.org/arch/arm/mach-kirkwood/Makefile 2011-08-30 05:56:30.000000000 +0900
+++ linux-3.0.4/arch/arm/mach-kirkwood/Makefile 2011-09-03 12:01:26.636120337 +0900
@@ -18,5 +18,6 @@
obj-$(CONFIG_MACH_NET2BIG_V2) += netxbig_v2-setup.o lacie_v2-common.o
obj-$(CONFIG_MACH_NET5BIG_V2) += netxbig_v2-setup.o lacie_v2-common.o
obj-$(CONFIG_MACH_T5325) += t5325-setup.o
+obj-$(CONFIG_MACH_LSVL) += lsvl-setup.o

obj-$(CONFIG_CPU_IDLE) += cpuidle.o
--- linux-3.2.2.org/arch/arm/tools/mach-types 2012-01-26 14:26:13.443508762 +0900
+++ linux-3.2.2/arch/arm/tools/mach-types 2012-01-26 14:27:27.103483923 +0900
@@ -118,6 +118,7 @@
omap_osk MACH_OMAP_OSK OMAP_OSK 515
tosa MACH_TOSA TOSA 520
avila MACH_AVILA AVILA 526
+lsvl MACH_LSVL LSVL 527
edb9302 MACH_EDB9302 EDB9302 538
husky MACH_HUSKY HUSKY 543
shepherd MACH_SHEPHERD SHEPHERD 545

12/05/08(火) 21:09:13 投稿者[通りすがり] [No.5968]のスレッド内
【No.5992】 タイトル[LS-VLとLS-XHLのkernel 3.3.5のパッチ] 【No.5968】に対する返信
お借りします。本当に申し訳ありません。
xhlはdebian謹製の"uboot-envtools"が書き込みもできるようになりました。

----------
ls-xhl
----------
--- linux-3.0.4.org/arch/arm/mach-kirkwood/Kconfig 2011-08-30 05:56:30.000000000 +0900
+++ linux-3.0.4/arch/arm/mach-kirkwood/Kconfig 2011-09-03 10:51:22.000000000 +0900
@@ -130,6 +130,12 @@
Say 'Y' here if you want your kernel to support the
HP t5325 Thin Client.

+config MACH_LSXHL
+ bool "Buffalo LS-XHL Series"
+ help
+ Say 'Y' here if you want your kernel to support the
+ Buffalo LS-XHL Series.
+
endmenu

endif
--- linux-3.0.4.org/arch/arm/mach-kirkwood/Makefile 2011-08-30 05:56:30.000000000 +0900
+++ linux-3.0.4/arch/arm/mach-kirkwood/Makefile 2011-09-03 10:51:22.000000000 +0900
@@ -18,5 +18,6 @@
obj-$(CONFIG_MACH_NET2BIG_V2) += netxbig_v2-setup.o lacie_v2-common.o
obj-$(CONFIG_MACH_NET5BIG_V2) += netxbig_v2-setup.o lacie_v2-common.o
obj-$(CONFIG_MACH_T5325) += t5325-setup.o
+obj-$(CONFIG_MACH_LSXHL) += lsxhl-setup.o

obj-$(CONFIG_CPU_IDLE) += cpuidle.o
--- linux-3.2.2.org/arch/arm/tools/mach-types 2012-01-26 09:39:32.000000000 +0900
+++ linux-3.2.2/arch/arm/tools/mach-types 2012-01-26 14:37:31.557136977 +0900
@@ -118,6 +118,7 @@
omap_osk MACH_OMAP_OSK OMAP_OSK 515
tosa MACH_TOSA TOSA 520
avila MACH_AVILA AVILA 526
+lsxhl MACH_LSXHL LSXHL 527
edb9302 MACH_EDB9302 EDB9302 538
husky MACH_HUSKY HUSKY 543
shepherd MACH_SHEPHERD SHEPHERD 545
--- /dev/null 2012-04-30 01:38:25.570000000 +0900
+++ linux-3.3.4/arch/arm/mach-kirkwood/lsxhl-setup.c 2012-04-30 01:07:21.167362071 +0900
@@ -0,0 +1,312 @@
+/*
+ * arch/arm/mach-kirkwood/lsxhl-setup.c
+ *
+ * Buffalo LS-XHL Series 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/mtd/physmap.h>
+#include <linux/spi/flash.h>
+#include <linux/spi/spi.h>
+#include <linux/platform_device.h>
+#include <linux/ata_platform.h>
+#include <linux/mv643xx_eth.h>
+#include <linux/gpio.h>
+#include <linux/leds.h>
+#include <linux/gpio_keys.h>
+#include <linux/gpio-fan.h>
+#include <linux/input.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 lsxhl_partitions[] = {
+ {
+ .name = "u-boot",
+ .size = MTDPART_SIZ_FULL,
+ .offset = 0,
+ // mask_flags = MTD_WRITEABLE, /* force read-only */
+ },
+};
+
+static struct flash_platform_data lsxhl_spi_slave_data = {
+ .type = "m25p40",
+ .name = "spi_flash",
+ .parts = lsxhl_partitions,
+ .nr_parts = ARRAY_SIZE(lsxhl_partitions),
+};
+
+static struct spi_board_info __initdata lsxhl_spi_slave_info[] = {
+ {
+ .modalias = "m25p80",
+ .platform_data = &lsxhl_spi_slave_data,
+ .irq = -1,
+ .max_speed_hz = 20000000,
+ .bus_num = 0,
+ .chip_select = 0,
+ }
+};
+
+/*****************************************************************************
+ * Ethernet
+ ****************************************************************************/
+static struct mv643xx_eth_platform_data lsxhl_ge00_data = {
+ .phy_addr = MV643XX_ETH_PHY_ADDR(0),
+};
+
+static struct mv643xx_eth_platform_data lsxhl_ge01_data = {
+ .phy_addr = MV643XX_ETH_PHY_ADDR(8),
+};
+
+/*****************************************************************************
+ * SATA
+ ****************************************************************************/
+static struct mv_sata_platform_data lsxhl_sata_data = {
+ .n_ports = 1,
+};
+
+/*****************************************************************************
+ * LEDs attached to GPIO
+ ****************************************************************************/
+#define LSXHL_GPIO_LED_ALARM 37
+#define LSXHL_GPIO_LED_INFO 38
+#define LSXHL_GPIO_LED_PWR 39
+#define LSXHL_GPIO_LED_FUNC_BLUE 36
+#define LSXHL_GPIO_LED_FUNC_RED 48
+
+static struct gpio_led lsxhl_led_pins[] = {
+ {
+ .name = "alarm:red",
+ .gpio = LSXHL_GPIO_LED_ALARM,
+ .active_low = 1,
+ },
+ {
+ .name = "info:amber",
+ .gpio = LSXHL_GPIO_LED_INFO,
+ .active_low = 1,
+ },
+ {
+ .name = "power:blue",
+ .default_trigger = "default-on",
+ .gpio = LSXHL_GPIO_LED_PWR,
+ .active_low = 1,
+ },
+ {
+ .name = "func:blue:bottom",
+ .gpio = LSXHL_GPIO_LED_FUNC_BLUE,
+ .active_low = 1,
+ },
+ {
+ .name = "func:red:bottom",
+ .gpio = LSXHL_GPIO_LED_FUNC_RED,
+ .active_low = 1,
+ },
+};
+
+static struct gpio_led_platform_data lsxhl_led_data = {
+ .leds = lsxhl_led_pins,
+ .num_leds = ARRAY_SIZE(lsxhl_led_pins),
+};
+
+static struct platform_device lsxhl_leds = {
+ .name = "leds-gpio",
+ .id = -1,
+ .dev = {
+ .platform_data = &lsxhl_led_data,
+ }
+};
+
+/*****************************************************************************
+ * General Setup
+ ****************************************************************************/
+#define LSXHL_GPIO_HDD_POWER 10
+#define LSXHL_GPIO_USB_POWER 11
+
+/*****************************************************************************
+ * GPIO Attached Keys
+ ****************************************************************************/
+/*
+#define LSXHL_GPIO_KEY_FUNC 41
+#define LSXHL_GPIO_KEY_AUTOPOWER 42
+#define LSXHL_GPIO_KEY_POWER 43
+#define LSXHL_SW_POWER 0x00
+#define LSXHL_SW_AUTOPOWER 0x01
+#define LSXHL_SW_FUNC 0x02
+
+static struct gpio_keys_button lsxhl_buttons[] = {
+ {
+ .type = EV_SW,
+ .code = LSXHL_SW_POWER,
+ .gpio = LSXHL_GPIO_KEY_POWER,
+ .desc = "Power-on Switch",
+ .active_low = 1,
+ }, {
+ .type = EV_SW,
+ .code = LSXHL_SW_AUTOPOWER,
+ .gpio = LSXHL_GPIO_KEY_AUTOPOWER,
+ .desc = "Power-auto Switch",
+ .active_low = 1,
+ }, {
+ .type = EV_SW,
+ .code = LSXHL_SW_FUNC,
+ .gpio = LSXHL_GPIO_KEY_FUNC,
+ .desc = "Function Button",
+ .active_low = 1,
+ },
+};
+
+static struct gpio_keys_platform_data lsxhl_button_data = {
+ .buttons = lsxhl_buttons,
+ .nbuttons = ARRAY_SIZE(lsxhl_buttons),
+};
+
+static struct platform_device lsxhl_button_device = {
+ .name = "gpio-keys",
+ .id = -1,
+ .num_resources = 0,
+ .dev = {
+ .platform_data = &lsxhl_button_data,
+ },
+};
+*/
+
+/*****************************************************************************
+ * GPIO Fan
+ ****************************************************************************/
+#define LSXHL_GPIO_FAN_HIGH 18
+#define LSXHL_GPIO_FAN_LOW 19
+#define LSXHL_GPIO_FAN_LOCK 40
+
+static struct gpio_fan_alarm lsxhl_alarm = {
+ .gpio = LSXHL_GPIO_FAN_LOCK,
+};
+
+static struct gpio_fan_speed lsxhl_speeds[] = {
+ {
+ .rpm = 0,
+ .ctrl_val = 3,
+ }, {
+ .rpm = 1500,
+ .ctrl_val = 1,
+ }, {
+ .rpm = 3250,
+ .ctrl_val = 2,
+ }, {
+ .rpm = 5000,
+ .ctrl_val = 0,
+ }
+};
+
+static int lsxhl_gpio_list[] = {
+ LSXHL_GPIO_FAN_HIGH, LSXHL_GPIO_FAN_LOW,
+};
+
+static struct gpio_fan_platform_data lsxhl_fan_data = {
+ .num_ctrl = ARRAY_SIZE(lsxhl_gpio_list),
+ .ctrl = lsxhl_gpio_list,
+ .alarm = &lsxhl_alarm,
+ .num_speed = ARRAY_SIZE(lsxhl_speeds),
+ .speed = lsxhl_speeds,
+};
+
+static struct platform_device lsxhl_fan_device = {
+ .name = "gpio-fan",
+ .id = -1,
+ .num_resources = 0,
+ .dev = {
+ .platform_data = &lsxhl_fan_data,
+ },
+};
+
+/*****************************************************************************
+ * GPIO Data
+ ****************************************************************************/
+
+static unsigned int lsxhl_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-XHL specific power off method: reboot
+ ****************************************************************************/
+/*
+ * On the LS-XHL, 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 lsxhl_power_off(void)
+{
+ kirkwood_restart('h', NULL);
+}
+
+static void __init lsxhl_init(void)
+{
+ /*
+ * Basic setup. Needs to be called early.
+ */
+ kirkwood_init();
+ kirkwood_mpp_conf(lsxhl_mpp_config);
+
+ /*
+ * Configure peripherals.
+ */
+ kirkwood_uart0_init();
+ kirkwood_ehci_init();
+ kirkwood_ge00_init(&lsxhl_ge00_data);
+ kirkwood_ge01_init(&lsxhl_ge01_data);
+ kirkwood_sata_init(&lsxhl_sata_data);
+ kirkwood_spi_init();
+
+ platform_device_register(&lsxhl_leds);
+// platform_device_register(&lsxhl_button_device);
+ platform_device_register(&lsxhl_fan_device);
+
+ spi_register_board_info(lsxhl_spi_slave_info,
+ ARRAY_SIZE(lsxhl_spi_slave_info));
+
+ /* usb power on */
+ gpio_set_value(LSXHL_GPIO_USB_POWER, 1);
+
+ /* register power-off method */
+ pm_power_off = lsxhl_power_off;
+
+ pr_info("%s: finished\n", __func__);
+}
+
+MACHINE_START(LSXHL, "Buffalo LS-XHL Series")
+ .atag_offset = 0x100,
+ .init_machine = lsxhl_init,
+ .map_io = kirkwood_map_io,
+ .init_early = kirkwood_init_early,
+ .init_irq = kirkwood_init_irq,
+ .timer = &kirkwood_timer,
+ .restart = kirkwood_restart,
+MACHINE_END

----------
ls-vl
----------
--- linux-3.0.4.org/arch/arm/mach-kirkwood/Kconfig 2011-08-30 05:56:30.000000000 +0900
+++ linux-3.0.4/arch/arm/mach-kirkwood/Kconfig 2011-09-03 12:01:26.636120337 +0900
@@ -130,6 +130,12 @@
Say 'Y' here if you want your kernel to support the
HP t5325 Thin Client.

+config MACH_LSVL
+ bool "Buffalo LS-VL Series"
+ help
+ Say 'Y' here if you want your kernel to support the
+ Buffalo LS-VL Series.
+
endmenu

endif
--- linux-3.0.4.org/arch/arm/mach-kirkwood/Makefile 2011-08-30 05:56:30.000000000 +0900
+++ linux-3.0.4/arch/arm/mach-kirkwood/Makefile 2011-09-03 12:01:26.636120337 +0900
@@ -18,5 +18,6 @@
obj-$(CONFIG_MACH_NET2BIG_V2) += netxbig_v2-setup.o lacie_v2-common.o
obj-$(CONFIG_MACH_NET5BIG_V2) += netxbig_v2-setup.o lacie_v2-common.o
obj-$(CONFIG_MACH_T5325) += t5325-setup.o
+obj-$(CONFIG_MACH_LSVL) += lsvl-setup.o

obj-$(CONFIG_CPU_IDLE) += cpuidle.o
--- linux-3.2.2.org/arch/arm/tools/mach-types 2012-01-26 14:26:13.443508762 +0900
+++ linux-3.2.2/arch/arm/tools/mach-types 2012-01-26 14:27:27.103483923 +0900
@@ -118,6 +118,7 @@
omap_osk MACH_OMAP_OSK OMAP_OSK 515
tosa MACH_TOSA TOSA 520
avila MACH_AVILA AVILA 526
+lsvl MACH_LSVL LSVL 527
edb9302 MACH_EDB9302 EDB9302 538
husky MACH_HUSKY HUSKY 543
shepherd MACH_SHEPHERD SHEPHERD 545
--- /dev/null 2012-04-30 01:38:28.500000000 +0900
+++ linux-3.3.4/arch/arm/mach-kirkwood/lsvl-setup.c 2012-04-30 01:06:49.288062466 +0900
@@ -0,0 +1,340 @@
+/*
+ * arch/arm/mach-kirkwood/lsvl-setup.c
+ *
+ * Buffalo LS-VL Series 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/mtd/physmap.h>
+#include <linux/spi/flash.h>
+#include <linux/spi/spi.h>
+#include <linux/platform_device.h>
+#include <linux/ata_platform.h>
+#include <linux/mv643xx_eth.h>
+#include <linux/gpio.h>
+#include <linux/leds.h>
+#include <linux/gpio_keys.h>
+#include <linux/gpio-fan.h>
+#include <linux/input.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 lsvl_partitions[] = {
+ {
+ .name = "u-boot",
+ .size = MTDPART_SIZ_FULL,
+ .offset = 0,
+ //.mask_flags = MTD_WRITEABLE, /* force read-only */
+ }
+};
+
+static struct flash_platform_data lsvl_spi_slave_data = {
+ .type = "m25p40-nonjedec",
+ .name = "spi_flash",
+ .parts = lsvl_partitions,
+ .nr_parts = ARRAY_SIZE(lsvl_partitions),
+};
+
+static struct spi_board_info __initdata lsvl_spi_slave_info[] = {
+ {
+ .modalias = "m25p80-nonjedec",
+ .platform_data = &lsvl_spi_slave_data,
+ .irq = -1,
+ .max_speed_hz = 20000000,
+ .bus_num = 0,
+ .chip_select = 0,
+ }
+};
+
+/*****************************************************************************
+ * Ethernet
+ ****************************************************************************/
+static struct mv643xx_eth_platform_data lsvl_ge00_data = {
+ .phy_addr = MV643XX_ETH_PHY_ADDR(0),
+};
+
+/*****************************************************************************
+ * SATA
+ ****************************************************************************/
+static struct mv_sata_platform_data lsvl_sata_data = {
+ .n_ports = 1,
+};
+
+/*****************************************************************************
+ * LEDs attached to GPIO
+ ****************************************************************************/
+#define LSVL_GPIO_LED_ALARM 36
+#define LSVL_GPIO_LED_FUNC_RED 37
+#define LSVL_GPIO_LED_INFO 38
+#define LSVL_GPIO_LED_FUNC_BLUE 39
+#define LSVL_GPIO_LED_PWR 40
+
+static struct gpio_led lsvl_led_pins[] = {
+ {
+ .name = "alarm:red",
+ .gpio = LSVL_GPIO_LED_ALARM,
+ },
+ {
+ .name = "func:red:bottom",
+ .gpio = LSVL_GPIO_LED_FUNC_RED,
+ },
+ {
+ .name = "info:amber",
+ .gpio = LSVL_GPIO_LED_INFO,
+ },
+ {
+ .name = "func:blue:bottom",
+ .gpio = LSVL_GPIO_LED_FUNC_BLUE,
+ },
+
+ {
+ .name = "power:blue",
+ .default_trigger = "default-on",
+ .gpio = LSVL_GPIO_LED_PWR,
+ .active_low = 1,
+ },
+};
+
+static struct gpio_led_platform_data lsvl_led_data = {
+ .leds = lsvl_led_pins,
+ .num_leds = ARRAY_SIZE(lsvl_led_pins),
+};
+
+static struct platform_device lsvl_leds = {
+ .name = "leds-gpio",
+ .id = -1,
+ .dev = {
+ .platform_data = &lsvl_led_data,
+ }
+};
+
+/*****************************************************************************
+ * General Setup
+ ****************************************************************************/
+#define LSVL_GPIO_HDD_POWER 8
+#define LSVL_GPIO_USB_POWER 12
+
+/*****************************************************************************
+ * GPIO Attached Keys
+ ****************************************************************************/
+/*#define LSVL_GPIO_KEY_FUNC 45
+#define LSVL_GPIO_KEY_POWER 46
+#define LSVL_GPIO_KEY_AUTOPOWER 47
+#define LSVL_SW_POWER 0x00
+#define LSVL_SW_AUTOPOWER 0x01
+#define LSVL_SW_FUNC 0x02
+
+static struct gpio_keys_button lsvl_buttons[] = {
+ {
+ .type = EV_SW,
+ .code = LSVL_SW_POWER,
+ .gpio = LSVL_GPIO_KEY_POWER,
+ .desc = "Power-on Switch",
+ .active_low = 1,
+ }, {
+ .type = EV_SW,
+ .code = LSVL_SW_AUTOPOWER,
+ .gpio = LSVL_GPIO_KEY_AUTOPOWER,
+ .desc = "Power-auto Switch",
+ .active_low = 1,
+ }, {
+ .type = EV_SW,
+ .code = LSVL_SW_FUNC,
+ .gpio = LSVL_GPIO_KEY_FUNC,
+ .desc = "Function Button",
+ .active_low = 1,
+ },
+};
+
+static struct gpio_keys_platform_data lsvl_button_data = {
+ .buttons = lsvl_buttons,
+ .nbuttons = ARRAY_SIZE(lsvl_buttons),
+};
+
+static struct platform_device lsvl_button_device = {
+ .name = "gpio-keys",
+ .id = -1,
+ .num_resources = 0,
+ .dev = {
+ .platform_data = &lsvl_button_data,
+ },
+};
+*/
+
+/*****************************************************************************
+ * GPIO Fan
+ ****************************************************************************/
+#define LSVL_GPIO_FAN_HIGH 16
+#define LSVL_GPIO_FAN_LOW 17
+#define LSVL_GPIO_FAN_LOCK 43
+
+static struct gpio_fan_alarm lsvl_alarm = {
+ .gpio = LSVL_GPIO_FAN_LOCK,
+};
+
+static struct gpio_fan_speed lsvl_speeds[] = {
+ {
+ .rpm = 0,
+ .ctrl_val = 3,
+ }, {
+ .rpm = 1500,
+ .ctrl_val = 1,
+ }, {
+ .rpm = 3250,
+ .ctrl_val = 2,
+ }, {
+ .rpm = 5000,
+ .ctrl_val = 0,
+ }
+};
+
+static int lsvl_gpio_list[] = {
+ LSVL_GPIO_FAN_HIGH, LSVL_GPIO_FAN_LOW,
+};
+
+static struct gpio_fan_platform_data lsvl_fan_data = {
+ .num_ctrl = ARRAY_SIZE(lsvl_gpio_list),
+ .ctrl = lsvl_gpio_list,
+ .alarm = &lsvl_alarm,
+ .num_speed = ARRAY_SIZE(lsvl_speeds),
+ .speed = lsvl_speeds,
+};
+
+static struct platform_device lsvl_fan_device = {
+ .name = "gpio-fan",
+ .id = -1,
+ .num_resources = 0,
+ .dev = {
+ .platform_data = &lsvl_fan_data,
+ },
+};
+
+/*****************************************************************************
+ * GPIO Data
+ ****************************************************************************/
+
+static unsigned int lsvl_mpp_config[] __initdata = {
+ MPP0_NF_IO2,
+ MPP1_NF_IO3,
+ MPP2_NF_IO4,
+ MPP3_NF_IO5,
+ MPP4_NF_IO6,
+ MPP5_NF_IO7,
+ MPP6_SYSRST_OUTn,
+ MPP7_SPI_SCn,
+ MPP8_GPIO, /* HDD Power */
+ MPP9_GPIO,
+ MPP10_UART0_TXD,
+ MPP11_UART0_RXD,
+ MPP12_GPO, /* USB VBUS EN */
+ MPP13_GPIO,
+ MPP14_GPIO,
+ MPP15_GPIO,
+ MPP16_GPIO, /* FAN HIGH: on:0, off:1 */
+ MPP17_GPIO, /* FAN LOW: on:0, off:1 */
+ MPP18_NF_IO0,
+ MPP19_NF_IO1,
+ MPP20_GPIO,
+ MPP21_GPIO,
+ MPP22_GPIO,
+ MPP23_GPIO,
+ MPP24_GPIO,
+ MPP25_GPIO,
+ MPP26_GPIO,
+ MPP27_GPIO,
+ MPP28_GPIO,
+ MPP29_GPIO,
+ MPP30_GPIO,
+ MPP31_GPIO,
+ MPP32_GPIO,
+ MPP33_GPO,
+ MPP34_GPIO,
+ MPP35_GPIO,
+ MPP36_GPIO, /* ALARM LED */
+ MPP37_GPIO, /* FUNC RED LED */
+ MPP38_GPIO, /* INFO LED */
+ MPP39_GPIO, /* FUNC LED */
+ MPP40_GPIO, /* POWER LED */
+ MPP41_GPIO,
+ MPP42_GPIO,
+ MPP43_GPIO, /* FAN LOCK */
+ MPP44_GPIO,
+ MPP45_GPIO, /* FUNC SW */
+ MPP46_GPIO, /* POWER SW */
+ MPP47_GPIO, /* POWER AUTO SW */
+ MPP48_GPIO, /* UART EN */
+ MPP49_GPIO,
+ 0
+};
+
+/*****************************************************************************
+ * LS-VL specific power off method: reboot
+ ****************************************************************************/
+/*
+ * On the LS-VL, 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 lsvl_power_off(void)
+{
+ kirkwood_restart('h', NULL);
+}
+
+static void __init lsvl_init(void)
+{
+ /*
+ * Basic setup. Needs to be called early.
+ */
+ kirkwood_init();
+ kirkwood_mpp_conf(lsvl_mpp_config);
+
+ /*
+ * Configure peripherals.
+ */
+ kirkwood_uart0_init();
+ kirkwood_ehci_init();
+ kirkwood_ge00_init(&lsvl_ge00_data);
+ kirkwood_sata_init(&lsvl_sata_data);
+ kirkwood_spi_init();
+
+ platform_device_register(&lsvl_leds);
+// platform_device_register(&lsvl_button_device);
+ platform_device_register(&lsvl_fan_device);
+
+ spi_register_board_info(lsvl_spi_slave_info,
+ ARRAY_SIZE(lsvl_spi_slave_info));
+
+ /* usb power on */
+ gpio_set_value(LSVL_GPIO_USB_POWER, 1);
+
+ /* register power-off method */
+ pm_power_off = lsvl_power_off;
+
+ pr_info("%s: finished\n", __func__);
+}
+
+MACHINE_START(LSVL, "Buffalo LS-VL Series")
+ .atag_offset = 0x100,
+ .init_machine = lsvl_init,
+ .map_io = kirkwood_map_io,
+ .init_early = kirkwood_init_early,
+ .init_irq = kirkwood_init_irq,
+ .timer = &kirkwood_timer,
+ .restart = kirkwood_restart,
+MACHINE_END

12/04/14(土) 20:52:19 投稿者[通りすがり] [No.5968]のスレッド内
【No.5990】 タイトル[Re: LS-VLのkernel 3.xパッチ] 【No.5968】に対する返信
ごめんなさい。また書き込ませてください。
xhlもvlも3.3.2 からは、uImageにdevioの情報を貼り付けないと起動できません。

$ make zImage modules_install
$ devio > foo 'wl 0xe3a01c0a,4' 'wl 0xe3811067,4'
$ cat foo arch/arm/boot/zImage > zImage.new
$ mkimage -A arm -O linux -T kernel -C none -a 0x00008000 -e 0x00008000 -n 'linux' -d zImage.new uImage.new

12/04/03(火) 13:34:58 投稿者[通りすがり] [No.5968]のスレッド内
【No.5986】 タイトル[Re: LS-VLのkernel 3.xパッチ] 【No.5968】に対する返信
menuconfigで3.3.1から、「EFI GUID Partition support」がFile systemsから外れて、
Enable the block layer --->Partition Types --->EFI GUID Partition support
です。

lsxhl-setup.c の「arm_machine_restart」は「kirkwood_restart」に変えます。


12/03/13(火) 01:45:54 投稿者[山下康成] [No.5968]のスレッド内
【No.5970】 タイトル[Re: LS-VLのkernel 3.xパッチ] 【No.5968】に対する返信
>3.2.9でも大丈夫です。
>元は「v2-ARM-kirkwood-Add-support-for-Buffalo-LS-XHL.patch」です。

ありがとうございます。さすが、餅は餅屋ですね。
追試をしてみます。


>GPIO振り直しをし、使いやすいように改良してます。
>スイッチはGPIOを監視するスクリプトで監視してください。

このあたり、もう少し解説をいただけましたら幸いです。
他機種への移植の参考にもなりますし。

よろしくおねがいします

12/03/14(水) 19:40:36 投稿者[通りすがり] [No.5968]のスレッド内
【No.5974】 タイトル[Re: LS-VLのkernel 3.xパッチ] 【No.5970】に対する返信
オリジナルのカーネルのパッチでコメントアウトしている「GPIO Attached Keys」を有効にすると、スイッチは /dev/input/event0 の イベントを監視します。
OFFの位置にしたとき、何もイベントが発生していないので使わなくしました。

-----
Input driver version is 1.0.1
Input device ID: bus 0x19 vendor 0x1 product 0x1 version 0x100
Input device name: "gpio-keys"
Supported events:
Event type 0 (Sync)
Event type 5 (Switches)
Event code 0 (?)
Event code 1 (?)
Event code 2 (?)

[OFF]
Event: time 1315414416.667136, type 5 (Switches), code 0 (?), value 0
[ON←OFF]
Event: time 1315414421.675216, type 5 (Switches), code 0 (?), value 1
[AUTO←ON]
Event: time 1315414425.793023, type 5 (Switches), code 1 (?), value 1

[FUNCTION DOWN]
Event: time 1315414453.072995, type 5 (Switches), code 2 (?), value 1

[FUNCTION UP]
Event: time 1315414454.890553, type 5 (Switches), code 2 (?), value 0

12/03/14(水) 19:22:27 投稿者[通りすがり] [No.5968]のスレッド内
【No.5973】 タイトル[Re: LS-VLのkernel 3.xパッチ] 【No.5970】に対する返信
素人で餅屋ではありませんが...w

例えば、
$ echo in > /sys/class/gpio/gpio46/direction
で /sys/class/gpio/gpio46/value ができます。
それを $ cat して値が 0 だと スイッチ の場所がPower switch の場所です。

GPIO は 下にディレクトリに割り当てられています。
/sys/class/gpio/gpio45 → Function switch
/sys/class/gpio/gpio46 → Power switch
/sys/class/gpio/gpio47 → Auto-Power switch
/sys/class/gpio/gpio16 → Fan high speed
/sys/class/gpio/gpio17 → Fan low speed
/sys/class/gpio/gpio43 → Fan status

ですので、自分は どこでいただいたか忘れましたが、(NAS-Central Buffalo のblstools-0.2.0.tar.gz とはちょっと違います)/etc/init.d/lsmonitor としてdaemonにしています。

----------
#!/bin/bash

### BEGIN INIT INFO
# Provides: lsmonitor
# Required-Start: $syslog
# Required-Stop: $syslog
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Monitor Linkstation LS-WXL
# Description: Enable service provided by daemon.
### END INIT INFO

#
# lsmonitor:
# - handle ls complete power-on
# - monitor power switch
# - monitor hdd temperature & control fan speed
# - monitor function button (todo)
#
# blstools - Tools for Buffalo Linkstation
# Copyright (C) 2010 Michele Manzato
#
# Credits:
# Thanks to archonfx on Buffalo NAS Central forum for HDD
# temperature monitoring command.
#
# Changelog:
# Modified to work with a Debian kernel on an LS-WXL
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License along
# with this program; if not, write to the Free Software Foundation, Inc.,
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
#

NAME=${0#/*init.d/}

## Location of pid file
PIDFILE=/var/run/${NAME}.pid

## Log
LOGTXT=/var/log/local.log
log_func ()
{
export LC_TIME=C
LOGFORM=$(date '+%b %d %H:%M:%S')
unset LC_TIME
}

## GPIO's for LS-VL
GPIO_FUNC_SW=45 # Function switch
GPIO_PWR_SW=46 # Power switch
GPIO_AUT_SW=47 # Auto-Power switch
GPIO_FAN_HI=16 # Fan high speed enable
GPIO_FAN_LO=17 # Fan low speed enable
GPIO_FAN_STAT=43 # Fan status

gpio_config()
{
if [ $1 == "enable" ]; then
[ -d /sys/class/gpio/gpio$2 ] || echo $2 > /sys/class/gpio/export
if [ $3 == "output" ]; then
[ -f /sys/class/gpio/gpio$2/direction ] && \
echo out > /sys/class/gpio/gpio$2/direction
else
[ -f /sys/class/gpio/gpio$2/direction ] && \
echo in > /sys/class/gpio/gpio$2/direction
fi
else
echo $2 > /sys/class/gpio/unexport
fi
}

enable_gpio()
{
gpio_config enable ${GPIO_FUNC_SW} input
gpio_config enable ${GPIO_PWR_SW} input
gpio_config enable ${GPIO_AUT_SW} input
gpio_config enable ${GPIO_FAN_STAT} input
gpio_config enable ${GPIO_FAN_LO} output
gpio_config enable ${GPIO_FAN_HI} output
}

disable_gpio()
{
gpio_config disable ${GPIO_FUNC_SW}
gpio_config disable ${GPIO_PWR_SW}
gpio_config disable ${GPIO_AUT_SW}
gpio_config disable ${GPIO_FAN_STAT}
gpio_config disable ${GPIO_FAN_LO}
gpio_config disable ${GPIO_FAN_HI}
}

## monitor function button
monitor_functionbutton()
{
FUNC_SW=`cat /sys/class/gpio/gpio${GPIO_FUNC_SW}/value`
if [ "${FUNC_SW}" -ne 1 ]; then
log_func;echo "${LOGFORM} ${HOSTNAME} ${NAME}[$$]: ファンクションボタンが押されました" >>${LOGTXT}
【ファンクション押したときののコマンド】
fi
}

## Control LS switch status to power down the unit
lsmonitor_daemon()
{
while [ true ] ; do

## Check switch status
PWR_SW=`cat /sys/class/gpio/gpio${GPIO_PWR_SW}/value`
AUT_SW=`cat /sys/class/gpio/gpio${GPIO_AUT_SW}/value`
if [ "${PWR_SW}" -eq 1 ]; then

## Terminate when in OFF state
if [ "${AUT_SW}" -eq 1 ] ; then
log_func;echo "${LOGFORM} ${HOSTNAME} ${NAME}[$$]: POWERスイッチをOFFにしました" >>${LOGTXT}
break

## Terminate when in AUTO-SWITCH state
else
【オートスイッチにしたときののコマンド】
fi

sleep 1
fi

## Terminate when in Function Button state
monitor_functionbutton

sleep 1
done

## Run the fan at low speed while halting, just in case halt hangs the unit
echo 0 > /sys/class/gpio/gpio${GPIO_FAN_LO}/value
echo 1 > /sys/class/gpio/gpio${GPIO_FAN_HI}/value

## blink power led
echo timer > /sys/devices/platform/leds-gpio/leds/power\:blue/trigger
echo 100 > /sys/devices/platform/leds-gpio/leds/power\:blue/delay_on
echo 100 > /sys/devices/platform/leds-gpio/leds/power\:blue/delay_off

## Initiate unit shutdown
halt
}

## Kill the lsmonitor daemon
kill_lsmonitor_daemon()
{
PID=`cat $PIDFILE`
if [ "$PID" != "" ] ; then
kill $PID
rm $PIDFILE
fi
}

case $1 in
start)
## Enable the corresponding GPIO's
enable_gpio

## Start the lsmonitor daemon
lsmonitor_daemon &
echo $! > $PIDFILE

## Monitor HDD temperature & control fan speed
[ -f /usr/local/sbin/FANCTL ] && /usr/local/sbin/FANCTL -d &
;;

stop)
## Kill HDD temperature control fan speed daemon
[ -f /usr/local/sbin/FANCTL ] && /usr/local/sbin/FANCTL -q &

## Kill the lsmonitor daemon
kill_lsmonitor_daemon

## Disable the corresponding GPIO's
disable_gpio
;;

restart|force-reload)
$0 stop && sleep 2 && $0 start
;;

*)
echo "Usage: $0 {start|stop|restart|force-reload}"
exit 2
;;
esac
----------

ファン制御は別にしちゃったので下記に載せます。(上の「/usr/local/sbin/FANCTL」がそうです。)
----------
#!/bin/bash
PATH=/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/bin
export LANG=ja_JP.UTF-8

## Load settings
. /etc/default/lsmonitor

## GPIO's for LS-VL
GPIO_FAN_LO=17 # Fan low speed enable
GPIO_FAN_HI=16 # Fan high speed enable

LO_STAT="/sys/class/gpio/gpio${GPIO_FAN_LO}/value"
HI_STAT="/sys/class/gpio/gpio${GPIO_FAN_HI}/value"

## service
INTERVAL=300

NAME=${0#/*bin/}
PIDFILE=/var/run/${NAME}.pid
kill_daemon()
{
PID=$(cat ${PIDFILE})
if [ "${PID}" != "" ] ; then
kill ${PID}
rm ${PIDFILE}
fi
}

## log
#LOGTXT=/var/log/local.log
#log_func ()
#{
# export LC_TIME=C
# LOGFORM=$(date '+%b %d %H:%M:%S')
# unset LC_TIME
#}

## Monitor HDD temperature & control fan speed
monitor_temperature()
{
## Retrieve HDD temp
HDDTEMP=$(smartctl -A /dev/sda |awk '/^194/ {print $10}')
OLDSTAT=(`cat ${LO_STAT}` `cat ${HI_STAT}`)

## Change fan speed accordingly
if [ $HDDTEMP -le $HDDTEMP0 ]; then
### off
NEWSTAT=(1 1 "stop")
elif [ $HDDTEMP -le $HDDTEMP1 ]; then
### slow
NEWSTAT=(0 1 "slow")
elif [ $HDDTEMP -le $HDDTEMP2 ]; then
### medium
NEWSTAT=(1 0 "fast")
else
### fast
NEWSTAT=(0 0 "full")
fi

if [ "${OLDSTAT[0]}" != "${NEWSTAT[0]}" -o "${OLDSTAT[1]}" != "${NEWSTAT[1]}" ]; then
echo ${NEWSTAT[0]} >${LO_STAT}
echo ${NEWSTAT[1]} >${HI_STAT}
#log_func;echo "${LOGFORM} ${HOSTNAME} ${NAME}[$$]: ${HDDTEMP}C ファンの回転は ${NEWSTAT[2]}" >>${LOGTXT}
fi

}

case $1 in
-d | --deamon )
if ! [ -f ${PIDFILE} ]; then
echo -n $$ >${PIDFILE}
while :
do
monitor_temperature
sleep ${INTERVAL}
done
else
echo "${NAME} は起動中です"
exit 0
fi
;;

-x | -q | -k | --exit | --quit | --exit )
kill_daemon
;;

* )
monitor_temperature
echo "${HDDTEMP}C ファンの回転は ${NEWSTAT[2]}"
exit 0
;;
esac