2 * Omnima EMB HPM board support
4 * Copyright (C) 2012 Gabor Juhos <juhosg@openwrt.org>
6 * This program is free software; you can redistribute it and/or modify it
7 * under the terms of the GNU General Public License version 2 as published
8 * by the Free Software Foundation.
11 #include <linux/init.h>
12 #include <linux/platform_device.h>
13 #include <linux/ethtool.h>
14 #include <linux/gpio.h>
15 #include <linux/rt2x00_platform.h>
16 #include <linux/spi/spi.h>
18 #include <asm/mach-ralink/machine.h>
19 #include <asm/mach-ralink/dev-gpio-buttons.h>
20 #include <asm/mach-ralink/dev-gpio-leds.h>
21 #include <asm/mach-ralink/rt3883.h>
22 #include <asm/mach-ralink/rt3883_regs.h>
23 #include <asm/mach-ralink/ramips_eth_platform.h>
27 #define OMNI_EMB_HPM_GPIO_LED_POWER 7
28 #define OMNI_EMB_HPM_GPIO_LED_ETH_GREEN 20
29 #define OMNI_EMB_HPM_GPIO_LED_ETH_RED 18
30 #define OMNI_EMB_HPM_GPIO_LED_STATUS 21
31 #define OMNI_EMB_HPM_GPIO_LED_WIFI_GREEN 17
32 #define OMNI_EMB_HPM_GPIO_LED_WIFI_RED 19
34 #define OMNI_EMB_HPM_GPIO_BUTTON_RESET 14
36 #define OMNI_EMB_HPM_GPIO_USB0_ENABLE 2
37 #define OMNI_EMB_HPM_GPIO_USB1_ENABLE 1
38 #define OMNI_EMB_HPM_GPIO_USB0_OC 12
39 #define OMNI_EMB_HPM_GPIO_USB1_OC 13
41 #define OMNI_EMB_HPM_KEYS_POLL_INTERVAL 20
42 #define OMNI_EMB_HPM_KEYS_DEBOUNCE_INTERVAL (3 * OMNI_EMB_HPM_KEYS_POLL_INTERVAL)
44 static struct gpio_led omni_emb_hpm_leds_gpio[] __initdata = {
46 .name = "emb:orange:power",
47 .gpio = OMNI_EMB_HPM_GPIO_LED_POWER,
51 .name = "emb:green:status",
52 .gpio = OMNI_EMB_HPM_GPIO_LED_STATUS,
55 .name = "emb:green:eth",
56 .gpio = OMNI_EMB_HPM_GPIO_LED_ETH_GREEN,
60 .name = "emb:red:eth",
61 .gpio = OMNI_EMB_HPM_GPIO_LED_ETH_RED,
65 .name = "emb:green:wifi",
66 .gpio = OMNI_EMB_HPM_GPIO_LED_WIFI_GREEN,
70 .name = "emb:red:wifi",
71 .gpio = OMNI_EMB_HPM_GPIO_LED_WIFI_RED,
76 static struct gpio_keys_button omni_emb_hpm_gpio_buttons[] __initdata = {
81 .debounce_interval = OMNI_EMB_HPM_KEYS_DEBOUNCE_INTERVAL,
82 .gpio = OMNI_EMB_HPM_GPIO_BUTTON_RESET,
87 static struct spi_board_info omni_emb_hpm_spi_info[] = {
91 .max_speed_hz = 25000000,
97 static void __init omni_emb_hpm_gpio_request(unsigned int gpio,
104 err = gpio_request_one(gpio, flags, label);
106 pr_err("EMB_HPM: can't setup GPIO%u (%s), err=%d\n",
115 static void __init omni_emb_hpm_gpio_init(void)
117 rt3883_gpio_init(RT3883_GPIO_MODE_I2C |
118 RT3883_GPIO_MODE_UART0(RT3883_GPIO_MODE_GPIO) |
119 RT3883_GPIO_MODE_JTAG);
121 omni_emb_hpm_gpio_request(OMNI_EMB_HPM_GPIO_USB0_ENABLE,
124 omni_emb_hpm_gpio_request(OMNI_EMB_HPM_GPIO_USB1_ENABLE,
127 omni_emb_hpm_gpio_request(OMNI_EMB_HPM_GPIO_USB0_OC,
128 GPIOF_IN, "USB0 OC", false);
129 omni_emb_hpm_gpio_request(OMNI_EMB_HPM_GPIO_USB1_OC,
130 GPIOF_IN, "USB1 OC", false);
133 static void __init omni_emb_hpm_init(void)
135 omni_emb_hpm_gpio_init();
137 ramips_register_gpio_leds(-1, ARRAY_SIZE(omni_emb_hpm_leds_gpio),
138 omni_emb_hpm_leds_gpio);
140 ramips_register_gpio_buttons(-1, OMNI_EMB_HPM_KEYS_POLL_INTERVAL,
141 ARRAY_SIZE(omni_emb_hpm_gpio_buttons),
142 omni_emb_hpm_gpio_buttons);
144 rt3883_register_spi(omni_emb_hpm_spi_info,
145 ARRAY_SIZE(omni_emb_hpm_spi_info));
147 rt3883_register_wlan();
149 rt3883_eth_data.phy_mask = BIT(4);
150 rt3883_register_ethernet();
152 rt3883_register_wdt(false);
153 rt3883_register_usbhost();
156 MIPS_MACHINE(RAMIPS_MACH_OMNI_EMB_HPM, "OMNI-EMB-HPM", "Omnima EMB HPM",