Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- diff -Nur a/arch/arm/mach-kirkwood/Kconfig b/arch/arm/mach-kirkwood/Kconfig
- --- a/arch/arm/mach-kirkwood/Kconfig 2012-02-09 04:21:53.000000000 +0100
- +++ b/arch/arm/mach-kirkwood/Kconfig 2012-02-16 18:29:22.760888482 +0100
- @@ -130,6 +130,18 @@
- Say 'Y' here if you want your kernel to support the
- HP t5325 Thin Client.
- +config MACH_NSA310
- + bool "Zyxel NSA-310"
- + help
- + Say 'Y' here if you want your kernel to support the
- + Zyxel NSA-310 NAS.
- +
- +config MACH_NSA320
- + bool "Zyxel NSA-320"
- + help
- + Say 'Y' here if you want your kernel to support the
- + Zyxel NSA-320 NAS.
- +
- endmenu
- endif
- diff -Nur a/arch/arm/mach-kirkwood/Makefile b/arch/arm/mach-kirkwood/Makefile
- --- a/arch/arm/mach-kirkwood/Makefile 2012-02-09 04:21:53.000000000 +0100
- +++ b/arch/arm/mach-kirkwood/Makefile 2012-02-16 18:29:22.824888479 +0100
- @@ -18,5 +18,7 @@
- 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_NSA310) += nsa310-setup.o
- +obj-$(CONFIG_MACH_NSA320) += nsa320-setup.o mcu.o
- obj-$(CONFIG_CPU_IDLE) += cpuidle.o
- diff -Nur a/arch/arm/mach-kirkwood/mcu.c b/arch/arm/mach-kirkwood/mcu.c
- --- a/arch/arm/mach-kirkwood/mcu.c 1970-01-01 01:00:00.000000000 +0100
- +++ b/arch/arm/mach-kirkwood/mcu.c 2012-02-16 18:29:23.196888477 +0100
- @@ -0,0 +1,125 @@
- +#include <linux/module.h>
- +#include <linux/init.h>
- +#include <asm/irq.h>
- +#include <asm/delay.h>
- +#include <linux/delay.h>
- +#include <linux/interrupt.h>
- +#include <linux/workqueue.h>
- +#include <linux/timer.h>
- +#include <linux/syscalls.h>
- +#include <linux/kmod.h>
- +#include <linux/syscalls.h>
- +#include <linux/fs.h>
- +#include <asm/fcntl.h>
- +#include <asm/hardirq.h>
- +#include <linux/ioctl.h>
- +#include <linux/cdev.h>
- +#include <linux/sched.h>
- +#include <linux/mm.h>
- +#include <asm/io.h>
- +#include <linux/spinlock.h>
- +#include <mach/hardware.h>
- +#include <asm/uaccess.h>
- +#include <linux/syscalls.h>
- +#include <asm/atomic.h>
- +#include <linux/proc_fs.h>
- +#include <asm/uaccess.h>
- +#include <linux/kernel.h>
- +
- +#include <mach/kirkwood.h>
- +#include <plat/gpio.h>
- +#include <linux/gpio.h>
- +#include "common.h"
- +#include "mpp.h"
- +
- +
- +
- +#define MCU_DATA_PIN 14
- +#define MCU_CLK_PIN 16
- +#define MCU_ACT_PIN 17
- +
- +MODULE_LICENSE("GPL v2");
- +#define MODULE_NAME "mcu"
- +
- +unsigned long mcu_data = 0;
- +unsigned long mcu_counter = 0;
- +
- +static struct proc_dir_entry *mcu_proc;
- +
- +static int mcu_status_read_fn(char *buf, char **start, off_t offset,
- + int count, int *eof, void *data)
- +{
- + unsigned long len, i;
- +
- + mcu_data = 0;
- +
- + gpio_request(14, "MCU_DATA");
- + gpio_request(16, "MCU_CLK");
- + gpio_request(17, "MCU_ACT");
- +
- + gpio_direction_output(MCU_ACT_PIN, 0);
- + msleep(100);
- + gpio_direction_input(MCU_DATA_PIN);
- + gpio_direction_output(MCU_CLK_PIN, 0);
- + udelay(100);
- +
- + for(i = 0 ; i < 32 ; i++)
- + {
- + mcu_data <<= 1;
- + gpio_set_value(MCU_CLK_PIN,1);
- +
- + mcu_data |= gpio_get_value(MCU_DATA_PIN)?0x1:0;
- +
- + udelay(100);
- +
- + gpio_set_value(MCU_CLK_PIN,0);
- +
- + udelay(100);
- + }
- +
- +
- + gpio_set_value(MCU_CLK_PIN,1);
- + gpio_set_value(MCU_ACT_PIN,1);
- +
- +
- + gpio_free(14);
- + gpio_free(16);
- + gpio_free(17);
- +
- + len = sprintf(buf, "MagicNum:%u\nRpss:%u\nTemperature:%u\n",(unsigned int)((mcu_data & 0xff000000) >> 24),
- + (unsigned int)((mcu_data & 0xff0000) >> 16),
- + (unsigned int)((mcu_data & 0xffff)));
- + *eof = 1;
- +
- + return len;
- +}
- +
- +static int mcu_status_write_fn(struct file *file, const char __user *buffer,
- + unsigned long count, void *data)
- +{
- + return 0;
- +}
- +
- +
- +static int __init mcu_init(void)
- +{
- +
- + mcu_proc = create_proc_entry("mcu", 0644, NULL);
- + if(mcu_proc != NULL)
- + {
- + mcu_proc->read_proc = mcu_status_read_fn;
- + mcu_proc->write_proc = mcu_status_write_fn;
- + }
- +
- + return 0;
- +}
- +
- +static void __exit mcu_exit(void)
- +{
- + remove_proc_entry("mcu", NULL);
- +
- +}
- +
- +module_init(mcu_init);
- +module_exit(mcu_exit);
- +
- diff -Nur a/arch/arm/mach-kirkwood/nsa310-setup.c b/arch/arm/mach-kirkwood/nsa310-setup.c
- --- a/arch/arm/mach-kirkwood/nsa310-setup.c 1970-01-01 01:00:00.000000000 +0100
- +++ b/arch/arm/mach-kirkwood/nsa310-setup.c 2012-02-16 18:29:23.584888469 +0100
- @@ -0,0 +1,351 @@
- +/*
- + * arch/arm/mach-kirkwood/nsa310-setup.c
- + *
- + * Zyxel NSA-310 Setup, by AA666, Peeter123 and Piotr Gozdur
- + *
- + * 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/input.h>
- +#include <linux/delay.h>
- +#include <linux/platform_device.h>
- +#include <linux/i2c.h>
- +#include <linux/irq.h>
- +#include <linux/mtd/partitions.h>
- +#include <mtd/mtd-abi.h>
- +#include <linux/ata_platform.h>
- +#include <linux/ethtool.h>
- +#include <linux/gpio.h>
- +#include <linux/gpio_keys.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"
- +#include <linux/timer.h>
- +#include <linux/jiffies.h>
- +
- +static void nsa310_timerfunc(unsigned long data);
- +static DEFINE_TIMER(timer, nsa310_timerfunc, 0, 0);
- +
- +static struct mtd_partition nsa310_nand_parts[] = {
- + {
- + .name = "uboot",
- + .offset = 0,
- + .size = 0x100000,
- + .mask_flags = MTD_WRITEABLE
- + }, {
- + .name = "uboot_env",
- + .offset = MTDPART_OFS_NXTBLK,
- + .size = 0x80000
- + }, {
- + .name = "key_store",
- + .offset = MTDPART_OFS_NXTBLK,
- + .size = 0x80000
- + }, {
- + .name = "info",
- + .offset = MTDPART_OFS_NXTBLK,
- + .size = 0x80000
- + }, {
- + .name = "etc",
- + .offset = MTDPART_OFS_NXTBLK,
- + .size = 0xA00000
- + }, {
- + .name = "kernel_1",
- + .offset = MTDPART_OFS_NXTBLK,
- + .size = 0xA00000
- + }, {
- + .name = "rootfs1",
- + .offset = MTDPART_OFS_NXTBLK,
- + .size = 0x2FC0000
- + }, {
- + .name = "kernel_2",
- + .offset = MTDPART_OFS_NXTBLK,
- + .size = 0xA00000
- + }, {
- + .name = "rootfs2",
- + .offset = MTDPART_OFS_NXTBLK,
- + .size = 0x2FC0000
- + },
- +};
- +
- +static struct i2c_board_info __initdata nsa310_i2c = {
- + I2C_BOARD_INFO("lm85", 0x2E),
- +};
- +
- +static struct mv_sata_platform_data nsa310_sata_data = {
- + .n_ports = 2,
- +};
- +
- +static unsigned int nsa310_mpp_config[] __initdata = {
- + MPP36_GPIO, // Reset button
- + MPP37_GPIO, // Copy button
- + MPP46_GPIO, // Power button
- +
- + MPP48_GPIO, // Power Off
- + MPP21_GPIO, // USB Power Off
- +
- + MPP28_GPIO, // Sys LED Green
- + MPP29_GPIO, // Sys LED Yellow
- + MPP41_GPIO, // SATA1 LED Green
- + MPP42_GPIO, // SATA1 LED Red
- + MPP12_GPO, // SATA2 LED Green
- + MPP13_GPIO, // SATA2 LED Red
- + MPP39_GPIO, // Copy LED Green
- + MPP40_GPIO, // Copy LED Red
- + MPP15_GPIO, // USB LED Green
- + MPP16_GPIO, // USB LED Red
- +
- + MPP38_GPIO, // VID B0
- + MPP45_GPIO, // VID B1
- +
- + MPP44_GPIO, // Buzzer
- + MPP43_GPIO, // HTP
- +
- + MPP47_GPIO, // Power Resume Data
- + MPP49_GPIO, // Power Resume Clock
- +
- + 0
- +};
- +
- +static struct gpio_led nsa310_gpio_led[] = {
- + {
- + .name = "nsa310:green:System",
- + .default_trigger = "timer",
- + .gpio = 28,
- + .active_low = 0,
- +
- + },
- + {
- + .name = "nsa310:red:System",
- + .default_trigger = "none",
- + .gpio = 29,
- + .active_low = 0,
- + },
- + {
- + .name = "nsa310:green:SATA1",
- + .default_trigger = "sata1r-disk",
- + .gpio = 41,
- + .active_low = 0,
- + },
- + {
- + .name = "nsa310:red:SATA1",
- + .default_trigger = "sata1w-disk",
- + .gpio = 42,
- + .active_low = 0,
- + },
- + {
- + .name = "nsa310:green:SATA2",
- + .default_trigger = "sata2r-disk",
- + .gpio = 12,
- + .active_low = 0,
- + },
- + {
- + .name = "nsa310:red:SATA2",
- + .default_trigger = "sata2w-disk",
- + .gpio = 13,
- + .active_low = 0,
- + },
- + {
- + .name = "nsa310:green:USB",
- + .default_trigger = "none",
- + .gpio = 15,
- + .active_low = 0,
- + },
- + {
- + .name = "nsa310:red:USB",
- + .default_trigger = "none",
- + .gpio = 16,
- + .active_low = 0,
- + },
- + {
- + .name = "nsa310:green:Copy",
- + .default_trigger = "none",
- + .gpio = 39,
- + .active_low = 0,
- + },
- + {
- + .name = "nsa310:red:Copy",
- + .default_trigger = "none",
- + .gpio = 40,
- + .active_low = 0,
- + },
- +};
- +
- +
- +static int nsa310_gpio_blink_set(unsigned gpio, int state,
- + unsigned long *delay_on, unsigned long *delay_off)
- +{
- +
- +// Use hardware acceleration
- +// if (delay_on && delay_off && !*delay_on && !*delay_off)
- +// *delay_on = *delay_off = 100;
- +
- + switch(state) {
- + case GPIO_LED_NO_BLINK_LOW:
- + case GPIO_LED_NO_BLINK_HIGH:
- + orion_gpio_set_blink(gpio, 0);
- + gpio_set_value(gpio, state);
- + break;
- + case GPIO_LED_BLINK:
- + orion_gpio_set_blink(gpio, 1);
- + break;
- + }
- + return 0;
- +}
- +
- +
- +static struct gpio_led_platform_data nsa310_led_data = {
- + .leds = nsa310_gpio_led,
- + .num_leds = ARRAY_SIZE(nsa310_gpio_led),
- + .gpio_blink_set = nsa310_gpio_blink_set,
- +};
- +
- +static struct platform_device nsa310_leds = {
- + .name = "leds-gpio",
- + .id = -1,
- + .dev = { .platform_data = &nsa310_led_data, }
- +};
- +
- +static struct gpio_keys_button nsa310_gpio_keys_button[] = {
- + {
- + .code = KEY_POWER,
- + .type = EV_KEY,
- + .gpio = 46,
- + .desc = "Power Button",
- + .active_low = 0,
- + .debounce_interval = 1000,
- + },
- + {
- + .code = KEY_COPY,
- + .type = EV_KEY,
- + .gpio = 37,
- + .desc = "USB Copy",
- + .active_low = 1,
- + .debounce_interval = 1000,
- + },
- + {
- + .code = KEY_OPTION,
- + .type = EV_KEY,
- + .gpio = 36,
- + .desc = "Reset",
- + .active_low = 1,
- + .debounce_interval = 1000,
- + },
- +};
- +
- +static struct gpio_keys_platform_data nsa310_keys_data = {
- + .buttons = nsa310_gpio_keys_button,
- + .nbuttons = ARRAY_SIZE(nsa310_gpio_keys_button),
- +};
- +
- +
- +static struct platform_device nsa310_buttons = {
- + .name = "gpio-keys",
- + .id = -1,
- + .dev = { .platform_data = &nsa310_keys_data, }
- +};
- +
- +static void nsa310_power_off(void)
- +{
- +//
- +//don't work with sysfs
- + printk(KERN_INFO "Activating power off GPIO pin...\n");
- + gpio_set_value(48, 1);
- +
- +// If machine goes to restart, uncomment next lines for infinite loop
- +/* printk(KERN_INFO "System halted, please turn off power manually\n");
- + gpio_set_value(28, 0);
- + do {
- + mdelay(1000);
- + } while(1);
- +*/
- +}
- +
- +static void nsa310_timerfunc(unsigned long data)
- +{
- +// Activate USB Power
- + if (gpio_request(21, "USB Power") != 0 || gpio_direction_output(21, 1) != 0)
- + printk(KERN_ERR "failed to setup USB power GPIO\n");
- + else
- + printk(KERN_INFO "USB power enabled\n");
- + gpio_free(21);
- +}
- +
- +static void __init nsa310_init(void)
- +{
- + u32 dev, rev;
- +
- + kirkwood_init();
- +
- + kirkwood_mpp_conf(nsa310_mpp_config);
- + kirkwood_nand_init(ARRAY_AND_SIZE(nsa310_nand_parts), 40);
- + kirkwood_pcie_id(&dev, &rev);
- +
- + kirkwood_sata_init(&nsa310_sata_data);
- + kirkwood_uart0_init();
- + kirkwood_i2c_init();
- + i2c_register_board_info(0, &nsa310_i2c, 1);
- +
- + platform_device_register(&nsa310_leds);
- + platform_device_register(&nsa310_buttons);
- +
- + kirkwood_ehci_init();
- +// USB Power delay for 20 sec
- + timer.function = nsa310_timerfunc;
- + timer.data = 0;
- + timer.expires = jiffies + msecs_to_jiffies(20000);
- + add_timer(&timer);
- +
- +
- +/* Power resume control */
- + gpio_request(49, "Power-clk");
- + gpio_direction_output(49, 1);
- + gpio_request(47, "Power-data");
- +// Clear power resume
- +// gpio_direction_output(47, 0);
- +// Set power resume
- + gpio_direction_output(47, 1);
- + udelay(1000);
- +// gpio_direction_output(49, 0);
- + gpio_set_value(49, 0);
- +// release GPIO?
- +//test
- + gpio_free(47);
- + gpio_free(49);
- + printk(KERN_INFO "Power resume enabled\n");
- +
- +
- +// Activate Power-off GPIO
- + if (gpio_request(48, "Power-off") == 0 && gpio_direction_output(48, 0) == 0) {
- +// gpio_free(48);
- + pm_power_off = nsa310_power_off;
- + printk(KERN_INFO "Power-off GPIO enabled\n");
- + } else
- + printk(KERN_ERR "failed to configure Power-off GPIO\n");
- +
- +};
- +
- +static int __init nsa310_pci_init(void)
- +{
- + if (machine_is_nsa310())
- + kirkwood_pcie_init(KW_PCIE0);
- + return 0;
- +}
- +
- +subsys_initcall(nsa310_pci_init);
- +
- +MACHINE_START(NSA310, "Zyxel NSA-310")
- + .atag_offset = 0x100,
- + .init_machine = nsa310_init,
- + .map_io = kirkwood_map_io,
- + .init_early = kirkwood_init_early,
- + .init_irq = kirkwood_init_irq,
- + .timer = &kirkwood_timer,
- +MACHINE_END
- diff -Nur a/arch/arm/mach-kirkwood/nsa320-setup.c b/arch/arm/mach-kirkwood/nsa320-setup.c
- --- a/arch/arm/mach-kirkwood/nsa320-setup.c 1970-01-01 01:00:00.000000000 +0100
- +++ b/arch/arm/mach-kirkwood/nsa320-setup.c 2012-02-16 18:29:23.848888468 +0100
- @@ -0,0 +1,356 @@
- +/*
- + * arch/arm/mach-kirkwood/nsa320-setup.c
- + *
- + * Zyxel NSA-320 Setup, by AA666 and Piotr Gozdur
- + *
- + * 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/input.h>
- +#include <linux/delay.h>
- +#include <linux/platform_device.h>
- +#include <linux/i2c.h>
- +#include <linux/irq.h>
- +#include <linux/mtd/partitions.h>
- +#include <mtd/mtd-abi.h>
- +#include <linux/ata_platform.h>
- +#include <linux/mv643xx_eth.h>
- +#include <linux/mv643xx_i2c.h>
- +#include <linux/ethtool.h>
- +#include <linux/gpio.h>
- +#include <linux/gpio_keys.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"
- +#include <linux/timer.h>
- +#include <linux/jiffies.h>
- +
- +static void nsa320_timerfunc(unsigned long data);
- +static DEFINE_TIMER(timer, nsa320_timerfunc, 0, 0);
- +
- +static struct mtd_partition nsa320_nand_parts[] = {
- + {
- + .name = "uboot",
- + .offset = 0,
- + .size = 0x100000,
- + .mask_flags = MTD_WRITEABLE
- + }, {
- + .name = "uboot_env",
- + .offset = MTDPART_OFS_NXTBLK,
- + .size = 0x80000
- + }, {
- + .name = "key_store",
- + .offset = MTDPART_OFS_NXTBLK,
- + .size = 0x80000
- + }, {
- + .name = "info",
- + .offset = MTDPART_OFS_NXTBLK,
- + .size = 0x80000
- + }, {
- + .name = "etc",
- + .offset = MTDPART_OFS_NXTBLK,
- + .size = 0xA00000
- + }, {
- + .name = "kernel_1",
- + .offset = MTDPART_OFS_NXTBLK,
- + .size = 0xA00000
- + }, {
- + .name = "rootfs1",
- + .offset = MTDPART_OFS_NXTBLK,
- + .size = 0x2FC0000
- + }, {
- + .name = "kernel_2",
- + .offset = MTDPART_OFS_NXTBLK,
- + .size = 0xA00000
- + }, {
- + .name = "rootfs2",
- + .offset = MTDPART_OFS_NXTBLK,
- + .size = 0x2FC0000
- + },
- +};
- +
- +static struct i2c_board_info __initdata nsa320_i2c_rtc = {
- + I2C_BOARD_INFO("pcf8563", 0x51),
- +};
- +
- +static struct mv643xx_eth_platform_data nsa320_ge00_data = {
- + .phy_addr = MV643XX_ETH_PHY_ADDR(0),
- + .speed = SPEED_1000,
- + .duplex = DUPLEX_FULL,
- +};
- +
- +static struct mv_sata_platform_data nsa320_sata_data = {
- + .n_ports = 2,
- +};
- +
- +static unsigned int nsa320_mpp_config[] __initdata = {
- + MPP36_GPIO, // Reset button
- + MPP37_GPIO, // Copy button
- + MPP46_GPIO, // Power button
- +
- + MPP48_GPIO, // Power Off
- + MPP21_GPIO, // USB Power Off
- +
- + MPP28_GPIO, // Sys LED Green
- + MPP29_GPIO, // Sys LED Yellow
- + MPP41_GPIO, // SATA1 LED Green
- + MPP42_GPIO, // SATA1 LED Red
- + MPP12_GPO, // SATA2 LED Green
- + MPP13_GPIO, // SATA2 LED Red
- + MPP39_GPIO, // Copy LED Green
- + MPP40_GPIO, // Copy LED Red
- + MPP15_GPIO, // USB LED Green
- +
- + MPP14_GPIO, // MCU Data
- + MPP16_GPIO, // MCU Clk
- + MPP17_GPIO, // MCU Act
- +
- + MPP38_GPIO, // VID B0
- + MPP45_GPIO, // VID B1
- +
- + MPP44_GPIO, // Buzzer
- + MPP43_GPIO, // HTP
- +
- + MPP47_GPIO, // Power Resume Data
- + MPP49_GPIO, // Power Resume Clock
- +
- + 0
- +};
- +
- +static struct gpio_led nsa320_gpio_led[] = {
- + {
- + .name = "nsa320:green:System",
- + .default_trigger = "timer",
- + .gpio = 28,
- + .active_low = 0,
- +
- + },
- + {
- + .name = "nsa320:red:System",
- + .default_trigger = "none",
- + .gpio = 29,
- + .active_low = 0,
- + },
- + {
- + .name = "nsa320:green:SATA1",
- + .default_trigger = "sata1r-disk",
- + .gpio = 41,
- + .active_low = 0,
- + },
- + {
- + .name = "nsa320:red:SATA1",
- + .default_trigger = "sata1w-disk",
- + .gpio = 42,
- + .active_low = 0,
- + },
- + {
- + .name = "nsa320:green:SATA2",
- + .default_trigger = "sata2r-disk",
- + .gpio = 12,
- + .active_low = 0,
- + },
- + {
- + .name = "nsa320:red:SATA2",
- + .default_trigger = "sata2w-disk",
- + .gpio = 13,
- + .active_low = 0,
- + },
- + {
- + .name = "nsa320:green:USB",
- + .default_trigger = "none",
- + .gpio = 15,
- + .active_low = 0,
- + },
- + {
- + .name = "nsa320:green:Copy",
- + .default_trigger = "none",
- + .gpio = 39,
- + .active_low = 0,
- + },
- + {
- + .name = "nsa320:red:Copy",
- + .default_trigger = "none",
- + .gpio = 40,
- + .active_low = 0,
- + },
- +};
- +
- +
- +static int nsa320_gpio_blink_set(unsigned gpio, int state,
- + unsigned long *delay_on, unsigned long *delay_off)
- +{
- +
- +// Use hardware acceleration
- +// if (delay_on && delay_off && !*delay_on && !*delay_off)
- +// *delay_on = *delay_off = 100;
- +
- + switch(state) {
- + case GPIO_LED_NO_BLINK_LOW:
- + case GPIO_LED_NO_BLINK_HIGH:
- + orion_gpio_set_blink(gpio, 0);
- + gpio_set_value(gpio, state);
- + break;
- + case GPIO_LED_BLINK:
- + orion_gpio_set_blink(gpio, 1);
- + break;
- + }
- + return 0;
- +}
- +
- +
- +static struct gpio_led_platform_data nsa320_led_data = {
- + .leds = nsa320_gpio_led,
- + .num_leds = ARRAY_SIZE(nsa320_gpio_led),
- + .gpio_blink_set = nsa320_gpio_blink_set,
- +};
- +
- +static struct platform_device nsa320_leds = {
- + .name = "leds-gpio",
- + .id = -1,
- + .dev = { .platform_data = &nsa320_led_data, }
- +};
- +
- +static struct gpio_keys_button nsa320_gpio_keys_button[] = {
- + {
- + .code = KEY_POWER,
- + .type = EV_KEY,
- + .gpio = 46,
- + .desc = "Power Button",
- + .active_low = 0,
- + .debounce_interval = 1000,
- + },
- + {
- + .code = KEY_COPY,
- + .type = EV_KEY,
- + .gpio = 37,
- + .desc = "USB Copy",
- + .active_low = 1,
- + .debounce_interval = 1000,
- + },
- + {
- + .code = KEY_OPTION,
- + .type = EV_KEY,
- + .gpio = 36,
- + .desc = "Reset",
- + .active_low = 1,
- + .debounce_interval = 1000,
- + },
- +};
- +
- +static struct gpio_keys_platform_data nsa320_keys_data = {
- + .buttons = nsa320_gpio_keys_button,
- + .nbuttons = ARRAY_SIZE(nsa320_gpio_keys_button),
- +};
- +
- +static struct platform_device nsa320_buttons = {
- + .name = "gpio-keys",
- + .id = -1,
- + .dev = { .platform_data = &nsa320_keys_data, }
- +};
- +
- +static void nsa320_power_off(void)
- +{
- +//
- +//don't work with sysfs
- + printk(KERN_INFO "Activating power off GPIO pin...\n");
- + gpio_set_value(48, 1);
- +
- +// If machine goes to restart, uncomment next lines for infinite loop
- +/* printk(KERN_INFO "System halted, please turn off power manually\n");
- + gpio_set_value(28, 0);
- + do {
- + mdelay(1000);
- + } while(1);
- +*/
- +}
- +
- +static void nsa320_timerfunc(unsigned long data)
- +{
- +// Activate USB Power
- + if (gpio_request(21, "USB Power") != 0 || gpio_direction_output(21, 1) != 0)
- + printk(KERN_ERR "failed to setup USB power GPIO\n");
- + else
- + printk(KERN_INFO "USB power enabled\n");
- + gpio_free(21);
- +}
- +
- +static void __init nsa320_init(void)
- +{
- + u32 dev, rev;
- +
- + kirkwood_init();
- +
- + kirkwood_mpp_conf(nsa320_mpp_config);
- + kirkwood_nand_init(ARRAY_AND_SIZE(nsa320_nand_parts), 25);
- + kirkwood_ge00_init(&nsa320_ge00_data);
- + kirkwood_pcie_id(&dev, &rev);
- +
- + kirkwood_sata_init(&nsa320_sata_data);
- + kirkwood_uart0_init();
- + kirkwood_i2c_init();
- + i2c_register_board_info(0, &nsa320_i2c_rtc, 1);
- +
- + platform_device_register(&nsa320_leds);
- + platform_device_register(&nsa320_buttons);
- +
- + kirkwood_ehci_init();
- +// USB Power delay for 20 sec
- + timer.function = nsa320_timerfunc;
- + timer.data = 0;
- + timer.expires = jiffies + msecs_to_jiffies(20000);
- + add_timer(&timer);
- +
- +
- +/* Power resume control */
- + gpio_request(49, "Power-clk");
- + gpio_direction_output(49, 1);
- + gpio_request(47, "Power-data");
- +// Clear power resume
- +// gpio_direction_output(47, 0);
- +// Set power resume
- + gpio_direction_output(47, 1);
- + udelay(1000);
- +// gpio_direction_output(49, 0);
- + gpio_set_value(49, 0);
- +// release GPIO?
- +//test
- + gpio_free(47);
- + gpio_free(49);
- + printk(KERN_INFO "Power resume enabled\n");
- +
- +
- +// Activate Power-off GPIO
- + if (gpio_request(48, "Power-off") == 0 && gpio_direction_output(48, 0) == 0) {
- +// gpio_free(48);
- + pm_power_off = nsa320_power_off;
- + printk(KERN_INFO "Power-off GPIO enabled\n");
- + } else
- + printk(KERN_ERR "failed to configure Power-off GPIO\n");
- +
- +};
- +
- +static int __init nsa320_pci_init(void)
- +{
- + if (machine_is_nsa320())
- + kirkwood_pcie_init(KW_PCIE0);
- + return 0;
- +}
- +
- +subsys_initcall(nsa320_pci_init);
- +
- +MACHINE_START(NSA320, "Zyxel NSA-320")
- + .atag_offset = 0x100,
- + .init_machine = nsa320_init,
- + .map_io = kirkwood_map_io,
- + .init_early = kirkwood_init_early,
- + .init_irq = kirkwood_init_irq,
- + .timer = &kirkwood_timer,
- +MACHINE_END
- diff -Nur a/arch/arm/tools/mach-types b/arch/arm/tools/mach-types
- --- a/arch/arm/tools/mach-types 2012-02-09 04:21:53.000000000 +0100
- +++ b/arch/arm/tools/mach-types 2012-02-16 18:29:24.380888459 +0100
- @@ -1169,3 +1169,5 @@
- pov2 MACH_POV2 POV2 3889
- ipod_touch_2g MACH_IPOD_TOUCH_2G IPOD_TOUCH_2G 3890
- da850_pqab MACH_DA850_PQAB DA850_PQAB 3891
- +nsa320 MACH_NSA320 NSA320 3956
- +nsa310 MACH_NSA310 NSA310 4022
- diff -Nur a/drivers/ata/sata_mv.c b/drivers/ata/sata_mv.c
- --- a/drivers/ata/sata_mv.c 2012-02-09 04:21:53.000000000 +0100
- +++ b/drivers/ata/sata_mv.c 2012-02-16 18:29:24.384888459 +0100
- @@ -69,6 +69,7 @@
- #include <scsi/scsi_cmnd.h>
- #include <scsi/scsi_device.h>
- #include <linux/libata.h>
- +#include <linux/leds.h>
- #define DRV_NAME "sata_mv"
- #define DRV_VERSION "1.28"
- @@ -2306,6 +2307,7 @@
- struct mv_port_priv *pp = ap->private_data;
- u32 in_index;
- unsigned int port_irqs;
- + struct ata_taskfile *tf = &qc->tf;
- pp->pp_flags &= ~MV_PP_FLAG_FAKE_ATA_BUSY; /* paranoia */
- @@ -2318,6 +2320,8 @@
- }
- /* fall thru */
- case ATA_PROT_NCQ:
- + ledtrig_sata_activity(ap->port_no, tf->flags & ATA_TFLAG_WRITE);
- +
- mv_start_edma(ap, port_mmio, pp, qc->tf.protocol);
- pp->req_idx = (pp->req_idx + 1) & MV_MAX_Q_DEPTH_MASK;
- in_index = pp->req_idx << EDMA_REQ_Q_PTR_SHIFT;
- diff -Nur a/drivers/leds/Kconfig b/drivers/leds/Kconfig
- --- a/drivers/leds/Kconfig 2012-02-09 04:21:53.000000000 +0100
- +++ b/drivers/leds/Kconfig 2012-02-16 18:29:24.384888459 +0100
- @@ -439,6 +439,14 @@
- This allows LEDs to be controlled by IDE disk activity.
- If unsure, say Y.
- +config LEDS_TRIGGER_SATA_DISK
- + bool "LED SATA Disk Trigger"
- + depends on ATA
- + depends on LEDS_TRIGGERS
- + help
- + This allows LEDs to be controlled by IDE disk activity.
- + If unsure, say Y.
- +
- config LEDS_TRIGGER_HEARTBEAT
- tristate "LED Heartbeat Trigger"
- depends on LEDS_TRIGGERS
- diff -Nur a/drivers/leds/ledtrig-sata-disk.c b/drivers/leds/ledtrig-sata-disk.c
- --- a/drivers/leds/ledtrig-sata-disk.c 1970-01-01 01:00:00.000000000 +0100
- +++ b/drivers/leds/ledtrig-sata-disk.c 2012-02-16 18:29:24.384888459 +0100
- @@ -0,0 +1,109 @@
- +/*
- + * LED SATA-Disk Activity Trigger
- + *
- + * Author: Piotr Gozdur
- + *
- + * Based on "LED IDE-Disk Activity Trigger"
- + * by Richard Purdie <rpurdie@openedhand.com>
- + *
- + * This program is free software; you can redistribute it and/or modify
- + * it under the terms of the GNU General Public License version 2 as
- + * published by the Free Software Foundation.
- + *
- + */
- +
- +#include <linux/module.h>
- +#include <linux/jiffies.h>
- +#include <linux/kernel.h>
- +#include <linux/init.h>
- +#include <linux/timer.h>
- +#include <linux/leds.h>
- +
- +DEFINE_LED_TRIGGER(ledtrig1r_sata);
- +DEFINE_LED_TRIGGER(ledtrig1w_sata);
- +DEFINE_LED_TRIGGER(ledtrig2r_sata);
- +DEFINE_LED_TRIGGER(ledtrig2w_sata);
- +
- +static void ledtrig_sata_timerfunc(unsigned long data);
- +static DEFINE_TIMER(ledtrig_sata_timer, ledtrig_sata_timerfunc, 0, 0);
- +
- +static int sata_activity=0;
- +static int sata_lastactivity=0;
- +static unsigned char sata1_rd=0, sata2_rd=0, sata1_wr=0, sata2_wr=0;
- +
- +void ledtrig_sata_activity(int port, int wr)
- +{
- + if(port == 0){
- + if(wr) sata1_wr = 1;
- + else sata1_rd = 1;
- + }
- + if(port == 1){
- + if(wr) sata2_wr = 1;
- + else sata2_rd = 1;
- + }
- +
- + sata_activity++;
- + if (!timer_pending(&ledtrig_sata_timer))
- + mod_timer(&ledtrig_sata_timer, jiffies + msecs_to_jiffies(10));
- +}
- +EXPORT_SYMBOL(ledtrig_sata_activity);
- +
- +static void ledtrig_sata_timerfunc(unsigned long data)
- +{
- + if (sata_lastactivity != sata_activity) {
- + sata_lastactivity = sata_activity;
- +
- + if(sata1_rd){
- + sata1_rd = 0;
- + led_trigger_event(ledtrig1r_sata, INT_MAX);
- + }
- + else led_trigger_event(ledtrig1r_sata, LED_OFF);
- + if(sata1_wr){
- + sata1_wr = 0;
- + led_trigger_event(ledtrig1w_sata, INT_MAX);
- + }
- + else led_trigger_event(ledtrig1w_sata, LED_OFF);
- +
- + if(sata2_rd){
- + sata2_rd = 0;
- + led_trigger_event(ledtrig2r_sata, INT_MAX);
- + }
- + else led_trigger_event(ledtrig2r_sata, LED_OFF);
- + if(sata2_wr){
- + sata2_wr = 0;
- + led_trigger_event(ledtrig2w_sata, INT_MAX);
- + }
- + else led_trigger_event(ledtrig2w_sata, LED_OFF);
- +
- + mod_timer(&ledtrig_sata_timer, jiffies + msecs_to_jiffies(10));
- + } else {
- + led_trigger_event(ledtrig1r_sata, LED_OFF);
- + led_trigger_event(ledtrig1w_sata, LED_OFF);
- + led_trigger_event(ledtrig2r_sata, LED_OFF);
- + led_trigger_event(ledtrig2w_sata, LED_OFF);
- + }
- +}
- +
- +static int __init ledtrig_sata_init(void)
- +{
- + led_trigger_register_simple("sata1r-disk", &ledtrig1r_sata);
- + led_trigger_register_simple("sata1w-disk", &ledtrig1w_sata);
- + led_trigger_register_simple("sata2r-disk", &ledtrig2r_sata);
- + led_trigger_register_simple("sata2w-disk", &ledtrig2w_sata);
- + return 0;
- +}
- +
- +static void __exit ledtrig_sata_exit(void)
- +{
- + led_trigger_unregister_simple(ledtrig1r_sata);
- + led_trigger_unregister_simple(ledtrig1w_sata);
- + led_trigger_unregister_simple(ledtrig2r_sata);
- + led_trigger_unregister_simple(ledtrig2w_sata);
- +}
- +
- +module_init(ledtrig_sata_init);
- +module_exit(ledtrig_sata_exit);
- +
- +MODULE_AUTHOR("Piotr Gozdur");
- +MODULE_DESCRIPTION("LED SATA Disk Activity Trigger");
- +MODULE_LICENSE("GPL");
- diff -Nur a/drivers/leds/Makefile b/drivers/leds/Makefile
- --- a/drivers/leds/Makefile 2012-02-09 04:21:53.000000000 +0100
- +++ b/drivers/leds/Makefile 2012-02-16 18:29:24.388888460 +0100
- @@ -57,3 +57,4 @@
- obj-$(CONFIG_LEDS_TRIGGER_BACKLIGHT) += ledtrig-backlight.o
- obj-$(CONFIG_LEDS_TRIGGER_GPIO) += ledtrig-gpio.o
- obj-$(CONFIG_LEDS_TRIGGER_DEFAULT_ON) += ledtrig-default-on.o
- +obj-$(CONFIG_LEDS_TRIGGER_SATA_DISK) += ledtrig-sata-disk.o
- diff -Nur a/include/linux/leds.h b/include/linux/leds.h
- --- a/include/linux/leds.h 2012-02-09 04:21:53.000000000 +0100
- +++ b/include/linux/leds.h 2012-02-16 18:29:24.388888460 +0100
- @@ -167,6 +167,12 @@
- #define ledtrig_ide_activity() do {} while(0)
- #endif
- +#ifdef CONFIG_LEDS_TRIGGER_SATA_DISK
- +extern void ledtrig_sata_activity(int port, int wr);
- +#else
- +#define ledtrig_sata_activity() do {} while(0)
- +#endif
- +
- /*
- * Generic LED platform data for describing LED names and default triggers.
- */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement