correct NSA310 setup.c

This commit is contained in:
Jason Plum 2013-05-17 19:48:23 -04:00
parent c47313e6e8
commit 39872415a1
2 changed files with 309 additions and 251 deletions

View file

@ -10,7 +10,7 @@ pkgname=('linux' 'linux-headers')
_kernelname=${pkgname#linux}
_basekernel=3.1
pkgver=${_basekernel}.10
pkgrel=19
pkgrel=20
cryptover=1.6
bfqver=v6
arch=('arm')
@ -39,7 +39,7 @@ source=("ftp://ftp.kernel.org/pub/linux/kernel/v3.x/linux-${_basekernel}.tar.bz2
md5sums=('8d43453f8159b2332ad410b19d86a931'
'a8e1c25a93a685ec2a1c3a808715fe9d'
'ee2f814b8e7aded2c3eb0c04003d13ae'
'bb33e83edfdfa267e47a7b56d4f47e62'
'61dbbcdb0f35032ea7f82c5b1ef7c769'
'f5d3635da03cb45904bedd69b47133de'
'3f64ed9d71499fe9293dc671f4e4087e'

View file

@ -6862,11 +6862,11 @@ diff -rupN a/arch/arm/mach-kirkwood/Makefile b/arch/arm/mach-kirkwood/Makefile
diff -rupN a/arch/arm/mach-kirkwood/nsa310-setup.c b/arch/arm/mach-kirkwood/nsa310-setup.c
--- a/arch/arm/mach-kirkwood/nsa310-setup.c 1969-12-31 19:00:00.000000000 -0500
+++ b/arch/arm/mach-kirkwood/nsa310-setup.c 2012-08-20 00:08:42.280823844 -0400
@@ -0,0 +1,299 @@
@@ -0,0 +1,357 @@
+/*
+ * arch/arm/mach-kirkwood/nsa310-setup.c
+ *
+ * ZyXEL NSA310 1-Bay Power Media Server Setup
+ * Zyxel NSA-310 Setup, by AA666 and Peeter123
+ *
+ * This file is licensed under the terms of the GNU General Public
+ * License version 2. This program is licensed "as is" without any
@ -6875,292 +6875,350 @@ diff -rupN a/arch/arm/mach-kirkwood/nsa310-setup.c b/arch/arm/mach-kirkwood/nsa3
+
+#include <linux/kernel.h>
+#include <linux/init.h>
+#include <linux/input.h>
+#include <linux/delay.h>
+#include <linux/platform_device.h>
+#include <linux/mtd/nand.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/ethtool.h> /* for SPEED_1000, DUPLEX_FULL */
+#include <linux/i2c.h>
+#include <linux/mv643xx_i2c.h>
+#include <linux/ethtool.h>
+#include <linux/gpio.h>
+#include <linux/gpio_keys.h>
+#include <linux/leds.h>
+#include <linux/input.h>
+#include <linux/nsa3xx-hwmon.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 = SZ_1M,
+ .mask_flags = MTD_WRITEABLE
+ }, {
+ .name = "uboot_env",
+ .offset = MTDPART_OFS_NXTBLK,
+ .size = SZ_512K
+ }, {
+ .name = "key_store",
+ .offset = MTDPART_OFS_NXTBLK,
+ .size = SZ_512K
+ }, {
+ .name = "info",
+ .offset = MTDPART_OFS_NXTBLK,
+ .size = SZ_512K
+ }, {
+ .name = "etc",
+ .offset = MTDPART_OFS_NXTBLK,
+ .size = 10 * SZ_1M
+ }, {
+ .name = "kernel_1",
+ .offset = MTDPART_OFS_NXTBLK,
+ .size = 10 * SZ_1M
+ }, {
+ .name = "rootfs1",
+ .offset = MTDPART_OFS_NXTBLK,
+ .size = 48 * SZ_1M - SZ_256K
+ }, {
+ .name = "kernel_2",
+ .offset = MTDPART_OFS_NXTBLK,
+ .size = 10 * SZ_1M
+ }, {
+ .name = "rootfs2",
+ .offset = MTDPART_OFS_NXTBLK,
+ .size = 48 * SZ_1M - SZ_256K
+ },
+ {
+ .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_rtc = {
+ I2C_BOARD_INFO("pcf8563", 0x51),
+};
+
+static struct mv643xx_eth_platform_data nsa310_ge00_data = {
+ .phy_addr = MV643XX_ETH_PHY_ADDR(0),
+ .speed = SPEED_1000,
+ .duplex = DUPLEX_FULL,
+};
+
+static struct mv_sata_platform_data nsa310_sata_data = {
+ .n_ports = 2,
+};
+
+static struct gpio_keys_button nsa310_button_pins[] = {
+ {
+ .code = KEY_RESTART,
+ .gpio = 36,
+ .desc = "Reset",
+ .active_low = 1,
+ }, {
+ .code = KEY_COPY,
+ .gpio = 37,
+ .desc = "Copy",
+ .active_low = 1,
+ }, {
+ .code = KEY_POWER,
+ .gpio = 46,
+ .desc = "Power",
+ .active_low = 0,
+ },
+};
+
+static struct gpio_keys_platform_data nsa310_button_data = {
+ .buttons = nsa310_button_pins,
+ .nbuttons = ARRAY_SIZE(nsa310_button_pins),
+};
+
+static struct platform_device nsa310_buttons = {
+ .name = "gpio-keys",
+ .id = -1,
+ .num_resources = 0,
+ .dev = {
+ .platform_data = &nsa310_button_data,
+ },
+};
+
+static struct gpio_led nsa310_led_pins[] = {
+ {
+ .name = "nsa310:green:hdd2",
+ .default_trigger = "default-off",
+ .gpio = 12,
+ .active_low = 0,
+ }, {
+ .name = "nsa310:red:hdd2",
+ .default_trigger = "default-off",
+ .gpio = 13,
+ .active_low = 0,
+ }, {
+ .name = "nsa310:green:usb",
+ .default_trigger = "default-off",
+ .gpio = 15,
+ .active_low = 0,
+ }, {
+ .name = "nsa310:green:sys",
+ .default_trigger = "default-off",
+ .gpio = 28,
+ .active_low = 0,
+ }, {
+ .name = "nsa310:orange:sys",
+ .default_trigger = "default-on",
+ .gpio = 29,
+ .active_low = 0,
+ }, {
+ .name = "nsa310:green:copy",
+ .default_trigger = "default-off",
+ .gpio = 39,
+ .active_low = 0,
+ }, {
+ .name = "nsa310:red:copy",
+ .default_trigger = "default-off",
+ .gpio = 40,
+ .active_low = 0,
+ }, {
+ .name = "nsa310:green:hdd1",
+ .default_trigger = "default-off",
+ .gpio = 41,
+ .active_low = 0,
+ }, {
+ .name = "nsa310:red:hdd1",
+ .default_trigger = "default-off",
+ .gpio = 42,
+ .active_low = 0,
+ },
+};
+
+static struct gpio_led_platform_data nsa310_led_data = {
+ .leds = nsa310_led_pins,
+ .num_leds = ARRAY_SIZE(nsa310_led_pins),
+};
+
+static struct platform_device nsa310_leds = {
+ .name = "leds-gpio",
+ .id = -1,
+ .dev = {
+ .platform_data = &nsa310_led_data,
+ },
+};
+
+static struct nsa3xx_hwmon_platform_data nsa310_hwmon_data = {
+ /* GPIOs connected to Holtek HT46R065 MCU */
+ .act_pin = 17,
+ .clk_pin = 16,
+ .data_pin = 14,
+};
+
+static struct platform_device nsa310_hwmon = {
+ .name = "nsa3xx-hwmon",
+ .id = -1,
+ .num_resources = 0,
+ .dev = {
+ .platform_data = &nsa310_hwmon_data,
+ },
+ .n_ports = 2,
+};
+
+static unsigned int nsa310_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_GPO,
+ MPP8_TW0_SDA, /* PCF8563 RTC chip */
+ MPP9_TW0_SCK, /* connected to TWSI */
+ MPP10_UART0_TXD,
+ MPP11_UART0_RXD,
+ MPP12_GPO, /* HDD2 LED (green) */
+ MPP13_GPIO, /* HDD2 LED (red) */
+ MPP14_GPIO, /* MCU DATA pin (in) */
+ MPP15_GPIO, /* USB LED (green) */
+ MPP16_GPIO, /* MCU CLK pin (out) */
+ MPP17_GPIO, /* MCU ACT pin (out) */
+ MPP18_NF_IO0,
+ MPP19_NF_IO1,
+ MPP20_GPIO,
+ MPP21_GPIO, /* USB power */
+ MPP22_GPIO,
+ MPP23_GPIO,
+ MPP24_GPIO,
+ MPP25_GPIO,
+ MPP26_GPIO,
+ MPP27_GPIO,
+ MPP28_GPIO, /* SYS LED (green) */
+ MPP29_GPIO, /* SYS LED (orange) */
+ MPP30_GPIO,
+ MPP31_GPIO,
+ MPP32_GPIO,
+ MPP33_GPO,
+ MPP34_GPIO,
+ MPP35_GPIO,
+ MPP36_GPIO, /* reset button */
+ MPP37_GPIO, /* copy button */
+ MPP38_GPIO, /* VID B0 */
+ MPP39_GPIO, /* COPY LED (green) */
+ MPP40_GPIO, /* COPY LED (red) */
+ MPP41_GPIO, /* HDD1 LED (green) */
+ MPP42_GPIO, /* HDD1 LED (red) */
+ MPP43_GPIO, /* HTP pin */
+ MPP44_GPIO, /* buzzer */
+ MPP45_GPIO, /* VID B1 */
+ MPP46_GPIO, /* power button */
+ MPP47_GPIO, /* power resume data */
+ MPP48_GPIO, /* power off */
+ MPP49_GPIO, /* power resume clock */
+ 0
+ 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
+};
+
+#define NSA310_GPIO_USB_POWER 21
+#define NSA310_GPIO_POWER_OFF 48
+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 = "none",
+ .gpio = 41,
+ .active_low = 0,
+ },
+ {
+ .name = "nsa310:red:SATA1",
+ .default_trigger = "sata-disk",
+ .gpio = 42,
+ .active_low = 0,
+ },
+ {
+ .name = "nsa310:green:SATA2",
+ .default_trigger = "none",
+ .gpio = 12,
+ .active_low = 0,
+ },
+ {
+ .name = "nsa310:red:SATA2",
+ .default_trigger = "none",
+ .gpio = 13,
+ .active_low = 0,
+ },
+ {
+ .name = "nsa310:green:USB",
+ .default_trigger = "none",
+ .gpio = 15,
+ .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)
+{
+ gpio_set_value(NSA310_GPIO_POWER_OFF, 1);
+//
+//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 int __initdata usb_power = 1; /* default "on" */
+
+static int __init nsa310_usb_power(char *str)
+static void nsa310_timerfunc(unsigned long data)
+{
+ usb_power = strncmp(str, "off", 3) ? 1 : 0;
+ return 1;
+// 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);
+}
+/* Parse boot_command_line string nsa310_usb_power=on|off */
+__setup("nsa310_usb_power=", nsa310_usb_power);
+
+static void __init nsa310_init(void)
+{
+ /*
+ * Basic setup. Needs to be called early.
+ */
+ kirkwood_init();
+ kirkwood_mpp_conf(nsa310_mpp_config);
+ u32 dev, rev;
+
+ kirkwood_uart0_init();
+ kirkwood_nand_init(ARRAY_AND_SIZE(nsa310_nand_parts), 40);
+ kirkwood_init();
+
+ kirkwood_i2c_init();
+ kirkwood_mpp_conf(nsa310_mpp_config);
+ kirkwood_nand_init(ARRAY_AND_SIZE(nsa310_nand_parts), 25);
+ kirkwood_ge00_init(&nsa310_ge00_data);
+ kirkwood_pcie_id(&dev, &rev);
+
+ if (gpio_request(NSA310_GPIO_USB_POWER, "USB Power Enable") ||
+ gpio_direction_output(NSA310_GPIO_USB_POWER, usb_power))
+ pr_err("nsa310: failed to configure USB power enable GPIO)\n");
+ gpio_free(NSA310_GPIO_USB_POWER);
+ kirkwood_sata_init(&nsa310_sata_data);
+ kirkwood_uart0_init();
+ kirkwood_i2c_init();
+ i2c_register_board_info(0, &nsa310_i2c_rtc, 1);
+
+ kirkwood_ehci_init();
+ kirkwood_sata_init(&nsa310_sata_data);
+ platform_device_register(&nsa310_leds);
+ platform_device_register(&nsa310_buttons);
+ platform_device_register(&nsa310_hwmon);
+ 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);
+
+ if (gpio_request(NSA310_GPIO_POWER_OFF, "power-off") ||
+ gpio_direction_output(NSA310_GPIO_POWER_OFF, 0))
+ pr_err("nsa310: failed to configure power-off GPIO\n");
+ else
+ pm_power_off = nsa310_power_off;
+
+/* 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;
+}
+
+MACHINE_START(NSA310, "ZyXEL NSA310 1-Bay Power Media Server")
+ /* Maintainer: Peter Oostewechel <peter_oostewechel@hotmail.com> */
+ .boot_params = 0x00000100,
+ .init_machine = nsa310_init,
+ .map_io = kirkwood_map_io,
+ .init_early = kirkwood_init_early,
+ .init_irq = kirkwood_init_irq,
+ .timer = &kirkwood_timer,
+// .restart = kirkwood_restart,
+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 -rupN a/arch/arm/mach-kirkwood/nsa320-setup.c b/arch/arm/mach-kirkwood/nsa320-setup.c
--- a/arch/arm/mach-kirkwood/nsa320-setup.c 1969-12-31 19:00:00.000000000 -0500