2 * D-Link DIR-645 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/rtl8367.h>
14 #include <linux/ethtool.h>
15 #include <linux/rt2x00_platform.h>
16 #include <linux/spi/spi.h>
17 #include <linux/gpio.h>
19 #include <asm/mach-ralink/machine.h>
20 #include <asm/mach-ralink/dev-gpio-buttons.h>
21 #include <asm/mach-ralink/dev-gpio-leds.h>
22 #include <asm/mach-ralink/rt3883.h>
23 #include <asm/mach-ralink/rt3883_regs.h>
24 #include <asm/mach-ralink/ramips_eth_platform.h>
28 #define DIR_645_GPIO_LED_INET 0
29 #define DIR_645_GPIO_LED_WPS 26
31 #define DIR_645_GPIO_BUTTON_RESET 9
32 #define DIR_645_GPIO_BUTTON_WPS 14
34 #define DIR_645_GPIO_USB_POWER 30
36 #define DIR_645_GPIO_RTL8367_SCK 2
37 #define DIR_645_GPIO_RTL8367_SDA 1
39 #define DIR_645_KEYS_POLL_INTERVAL 20
40 #define DIR_645_KEYS_DEBOUNCE_INTERVAL (3 * DIR_645_KEYS_POLL_INTERVAL)
42 static struct gpio_led dir_645_leds_gpio
[] __initdata
= {
44 .name
= "d-link:green:inet",
45 .gpio
= DIR_645_GPIO_LED_INET
,
49 .name
= "d-link:green:wps",
50 .gpio
= DIR_645_GPIO_LED_WPS
,
55 static struct gpio_keys_button dir_645_gpio_buttons
[] __initdata
= {
60 .debounce_interval
= DIR_645_KEYS_DEBOUNCE_INTERVAL
,
61 .gpio
= DIR_645_GPIO_BUTTON_RESET
,
67 .code
= KEY_WPS_BUTTON
,
68 .debounce_interval
= DIR_645_KEYS_DEBOUNCE_INTERVAL
,
69 .gpio
= DIR_645_GPIO_BUTTON_WPS
,
74 static struct rtl8367_extif_config dir_645_rtl8367_extif1_cfg
= {
77 .mode
= RTL8367_EXTIF_MODE_RGMII
,
84 .speed
= RTL8367_PORT_SPEED_1000
,
88 static struct rtl8367_platform_data dir_645_rtl8367_data
= {
89 .gpio_sda
= DIR_645_GPIO_RTL8367_SDA
,
90 .gpio_sck
= DIR_645_GPIO_RTL8367_SCK
,
91 .extif1_cfg
= &dir_645_rtl8367_extif1_cfg
,
94 static struct platform_device dir_645_rtl8367_device
= {
95 .name
= RTL8367B_DRIVER_NAME
,
98 .platform_data
= &dir_645_rtl8367_data
,
102 static struct spi_board_info dir_645_spi_info
[] = {
106 .max_speed_hz
= 25000000,
107 .modalias
= "m25p80",
111 static void __init
dir_645_gpio_init(void)
113 rt3883_gpio_init(RT3883_GPIO_MODE_I2C
|
114 RT3883_GPIO_MODE_UART0(RT3883_GPIO_MODE_GPIO
) |
115 RT3883_GPIO_MODE_JTAG
|
116 RT3883_GPIO_MODE_PCI(RT3883_GPIO_MODE_PCI_FNC
));
118 gpio_request_one(DIR_645_GPIO_USB_POWER
,
119 GPIOF_OUT_INIT_HIGH
| GPIOF_EXPORT_DIR_FIXED
,
123 static void __init
dir_645_init(void)
127 rt3883_register_spi(dir_645_spi_info
,
128 ARRAY_SIZE(dir_645_spi_info
));
130 ramips_register_gpio_leds(-1, ARRAY_SIZE(dir_645_leds_gpio
),
133 ramips_register_gpio_buttons(-1, DIR_645_KEYS_POLL_INTERVAL
,
134 ARRAY_SIZE(dir_645_gpio_buttons
),
135 dir_645_gpio_buttons
);
137 platform_device_register(&dir_645_rtl8367_device
);
139 rt3883_wlan_data
.disable_5ghz
= 1;
140 rt3883_register_wlan();
142 rt3883_eth_data
.speed
= SPEED_1000
;
143 rt3883_eth_data
.duplex
= DUPLEX_FULL
;
144 rt3883_eth_data
.tx_fc
= 1;
145 rt3883_eth_data
.rx_fc
= 1;
146 rt3883_register_ethernet();
148 rt3883_register_wdt(false);
149 rt3883_register_usbhost();
152 MIPS_MACHINE(RAMIPS_MACH_DIR_645
, "DIR-645", "D-Link DIR-645", dir_645_init
);