ramips: rt3883: add kernel support for the Omnima EMB HPM board
authorGabor Juhos <juhosg@openwrt.org>
Sat, 2 Feb 2013 17:21:01 +0000 (17:21 +0000)
committerGabor Juhos <juhosg@openwrt.org>
Sat, 2 Feb 2013 17:21:01 +0000 (17:21 +0000)
Signed-off-by: Gabor Juhos <juhosg@openwrt.org>
SVN-Revision: 35466

target/linux/ramips/files/arch/mips/include/asm/mach-ralink/machine.h
target/linux/ramips/files/arch/mips/ralink/rt3883/Kconfig
target/linux/ramips/files/arch/mips/ralink/rt3883/Makefile
target/linux/ramips/files/arch/mips/ralink/rt3883/mach-omni-emb-hpm.c [new file with mode: 0644]
target/linux/ramips/rt3883/config-3.7

index 238495d299248546671b70468c3b76e6d9133cb7..b3903fc2266d54a04edc89d06a948b904f6f65d3 100644 (file)
@@ -75,6 +75,7 @@ enum ramips_mach_type {
 
        /* RT3662 based machines */
        RAMIPS_MACH_DIR_645,            /* D-Link DIR-645 */
+       RAMIPS_MACH_OMNI_EMB_HPM,       /* Omnima EMB HPM */
        RAMIPS_MACH_RT_N56U,            /* Asus RT-N56U */
 
        /* RT3883 based machines */
index 507cdb38b4e2d504f888140e9d3abb58a47218b5..57823f0c6780f5a473af4ba8e0440e533f35be2f 100644 (file)
@@ -13,6 +13,11 @@ config RT3883_MACH_DIR_645
        select RALINK_DEV_GPIO_BUTTONS
        select RALINK_DEV_GPIO_LEDS
 
+config RT3883_MACH_OMNI_EMB_HPM
+       bool "Omnima EMB HPM board support"
+       select RALINK_DEV_GPIO_BUTTONS
+       select RALINK_DEV_GPIO_LEDS
+
 config RT3883_MACH_TEW_691GR
        bool "TRENDnet TEW-691GR support"
        select RALINK_DEV_GPIO_BUTTONS
index 125471af33f55ea07957a20dec462a3fcfe7ca97..e1ab61e814682d7464c33bf4f5d258ae975f222c 100644 (file)
@@ -12,6 +12,7 @@ obj-y := irq.o setup.o devices.o rt3883.o clock.o
 obj-$(CONFIG_EARLY_PRINTK)             += early_printk.o
 
 obj-$(CONFIG_RT3883_MACH_DIR_645)      += mach-dir-645.o
+obj-$(CONFIG_RT3883_MACH_OMNI_EMB_HPM) += mach-omni-emb-hpm.o
 obj-$(CONFIG_RT3883_MACH_RT_N56U)      += mach-rt-n56u.o
 obj-$(CONFIG_RT3883_MACH_TEW_691GR)    += mach-tew-691gr.o
 obj-$(CONFIG_RT3883_MACH_TEW_692GR)    += mach-tew-692gr.o
diff --git a/target/linux/ramips/files/arch/mips/ralink/rt3883/mach-omni-emb-hpm.c b/target/linux/ramips/files/arch/mips/ralink/rt3883/mach-omni-emb-hpm.c
new file mode 100644 (file)
index 0000000..77ccff6
--- /dev/null
@@ -0,0 +1,157 @@
+/*
+ *  Omnima EMB HPM board support
+ *
+ *  Copyright (C) 2012 Gabor Juhos <juhosg@openwrt.org>
+ *
+ *  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/init.h>
+#include <linux/platform_device.h>
+#include <linux/ethtool.h>
+#include <linux/gpio.h>
+#include <linux/rt2x00_platform.h>
+#include <linux/spi/spi.h>
+
+#include <asm/mach-ralink/machine.h>
+#include <asm/mach-ralink/dev-gpio-buttons.h>
+#include <asm/mach-ralink/dev-gpio-leds.h>
+#include <asm/mach-ralink/rt3883.h>
+#include <asm/mach-ralink/rt3883_regs.h>
+#include <asm/mach-ralink/ramips_eth_platform.h>
+
+#include "devices.h"
+
+#define OMNI_EMB_HPM_GPIO_LED_POWER            7
+#define OMNI_EMB_HPM_GPIO_LED_ETH_GREEN                20
+#define OMNI_EMB_HPM_GPIO_LED_ETH_RED          18
+#define OMNI_EMB_HPM_GPIO_LED_STATUS           21
+#define OMNI_EMB_HPM_GPIO_LED_WIFI_GREEN       17
+#define OMNI_EMB_HPM_GPIO_LED_WIFI_RED         19
+
+#define OMNI_EMB_HPM_GPIO_BUTTON_RESET         14
+
+#define OMNI_EMB_HPM_GPIO_USB0_ENABLE          2
+#define OMNI_EMB_HPM_GPIO_USB1_ENABLE          1
+#define OMNI_EMB_HPM_GPIO_USB0_OC              12
+#define OMNI_EMB_HPM_GPIO_USB1_OC              13
+
+#define OMNI_EMB_HPM_KEYS_POLL_INTERVAL        20
+#define OMNI_EMB_HPM_KEYS_DEBOUNCE_INTERVAL (3 * OMNI_EMB_HPM_KEYS_POLL_INTERVAL)
+
+static struct gpio_led omni_emb_hpm_leds_gpio[] __initdata = {
+       {
+               .name           = "emb:orange:power",
+               .gpio           = OMNI_EMB_HPM_GPIO_LED_POWER,
+               .active_low     = 1,
+       },
+       {
+               .name           = "emb:green:status",
+               .gpio           = OMNI_EMB_HPM_GPIO_LED_STATUS,
+       },
+       {
+               .name           = "emb:green:eth",
+               .gpio           = OMNI_EMB_HPM_GPIO_LED_ETH_GREEN,
+               .active_low     = 1,
+       },
+       {
+               .name           = "emb:red:eth",
+               .gpio           = OMNI_EMB_HPM_GPIO_LED_ETH_RED,
+               .active_low     = 1,
+       },
+       {
+               .name           = "emb:green:wifi",
+               .gpio           = OMNI_EMB_HPM_GPIO_LED_WIFI_GREEN,
+               .active_low     = 1,
+       },
+       {
+               .name           = "emb:red:wifi",
+               .gpio           = OMNI_EMB_HPM_GPIO_LED_WIFI_RED,
+               .active_low     = 1,
+       },
+};
+
+static struct gpio_keys_button omni_emb_hpm_gpio_buttons[] __initdata = {
+       {
+               .desc           = "reset",
+               .type           = EV_KEY,
+               .code           = KEY_RESTART,
+               .debounce_interval = OMNI_EMB_HPM_KEYS_DEBOUNCE_INTERVAL,
+               .gpio           = OMNI_EMB_HPM_GPIO_BUTTON_RESET,
+               .active_low     = 1,
+       },
+};
+
+static struct spi_board_info omni_emb_hpm_spi_info[] = {
+       {
+               .bus_num        = 0,
+               .chip_select    = 0,
+               .max_speed_hz   = 25000000,
+               .modalias       = "m25p80",
+       }
+};
+
+
+static void __init omni_emb_hpm_gpio_request(unsigned int gpio,
+                                            unsigned long flags,
+                                            const char *label,
+                                            bool free)
+{
+       int err;
+
+       err = gpio_request_one(gpio, flags, label);
+       if (err) {
+               pr_err("EMB_HPM: can't setup GPIO%u (%s), err=%d\n",
+                       gpio, label, err);
+               return;
+       }
+
+       if (free)
+               gpio_free(gpio);
+}
+
+static void __init omni_emb_hpm_gpio_init(void)
+{
+       rt3883_gpio_init(RT3883_GPIO_MODE_I2C |
+                        RT3883_GPIO_MODE_UART0(RT3883_GPIO_MODE_GPIO) |
+                        RT3883_GPIO_MODE_JTAG);
+
+       omni_emb_hpm_gpio_request(OMNI_EMB_HPM_GPIO_USB0_ENABLE,
+                                 GPIOF_OUT_INIT_HIGH,
+                                 "USB0 power", true);
+       omni_emb_hpm_gpio_request(OMNI_EMB_HPM_GPIO_USB1_ENABLE,
+                                 GPIOF_OUT_INIT_HIGH,
+                                 "USB1 power", true);
+       omni_emb_hpm_gpio_request(OMNI_EMB_HPM_GPIO_USB0_OC,
+                                 GPIOF_IN, "USB0 OC", false);
+       omni_emb_hpm_gpio_request(OMNI_EMB_HPM_GPIO_USB1_OC,
+                                 GPIOF_IN, "USB1 OC", false);
+}
+
+static void __init omni_emb_hpm_init(void)
+{
+       omni_emb_hpm_gpio_init();
+
+       ramips_register_gpio_leds(-1, ARRAY_SIZE(omni_emb_hpm_leds_gpio),
+                                 omni_emb_hpm_leds_gpio);
+
+       ramips_register_gpio_buttons(-1, OMNI_EMB_HPM_KEYS_POLL_INTERVAL,
+                                    ARRAY_SIZE(omni_emb_hpm_gpio_buttons),
+                                    omni_emb_hpm_gpio_buttons);
+
+       rt3883_register_spi(omni_emb_hpm_spi_info,
+                           ARRAY_SIZE(omni_emb_hpm_spi_info));
+
+       rt3883_register_wlan();
+
+       rt3883_eth_data.phy_mask = BIT(4);
+       rt3883_register_ethernet();
+
+       rt3883_register_wdt(false);
+       rt3883_register_usbhost();
+}
+
+MIPS_MACHINE(RAMIPS_MACH_OMNI_EMB_HPM, "OMNI-EMB-HPM", "Omnima EMB HPM",
+            omni_emb_hpm_init);
index f9b195ab93e38273b1c6035db4ea0d7e97da5141..80763978902445a07601ba3ac55e47899630b006 100644 (file)
@@ -110,6 +110,7 @@ CONFIG_RALINK_DEV_GPIO_LEDS=y
 CONFIG_RALINK_RT3883=y
 CONFIG_RAMIPS_WDT=y
 CONFIG_RT3883_MACH_DIR_645=y
+CONFIG_RT3883_MACH_OMNI_EMB_HPM=y
 CONFIG_RT3883_MACH_RT_N56U=y
 CONFIG_RT3883_MACH_TEW_691GR=y
 CONFIG_RT3883_MACH_TEW_692GR=y