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>
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 DIR_645_GPIO_LED_INET 0
28 #define DIR_645_GPIO_LED_WPS 26
30 #define DIR_645_GPIO_BUTTON_RESET 9
31 #define DIR_645_GPIO_BUTTON_WPS 14
33 #define DIR_645_GPIO_USB_POWER 30
35 #define DIR_645_GPIO_RTL8367_SCK 2
36 #define DIR_645_GPIO_RTL8367_SDA 1
38 #define DIR_645_KEYS_POLL_INTERVAL 20
39 #define DIR_645_KEYS_DEBOUNCE_INTERVAL (3 * DIR_645_KEYS_POLL_INTERVAL)
41 static struct gpio_led dir_645_leds_gpio[] __initdata = {
43 .name = "d-link:green:inet",
44 .gpio = DIR_645_GPIO_LED_INET,
48 .name = "d-link:green:wps",
49 .gpio = DIR_645_GPIO_LED_WPS,
54 static struct gpio_keys_button dir_645_gpio_buttons[] __initdata = {
59 .debounce_interval = DIR_645_KEYS_DEBOUNCE_INTERVAL,
60 .gpio = DIR_645_GPIO_BUTTON_RESET,
66 .code = KEY_WPS_BUTTON,
67 .debounce_interval = DIR_645_KEYS_DEBOUNCE_INTERVAL,
68 .gpio = DIR_645_GPIO_BUTTON_WPS,
73 static struct rtl8367_extif_config dir_645_rtl8367_extif1_cfg = {
76 .mode = RTL8367_EXTIF_MODE_RGMII,
83 .speed = RTL8367_PORT_SPEED_1000,
87 static struct rtl8367_platform_data dir_645_rtl8367_data = {
88 .gpio_sda = DIR_645_GPIO_RTL8367_SDA,
89 .gpio_sck = DIR_645_GPIO_RTL8367_SCK,
90 .extif1_cfg = &dir_645_rtl8367_extif1_cfg,
93 static struct platform_device dir_645_rtl8367_device = {
94 .name = RTL8367B_DRIVER_NAME,
97 .platform_data = &dir_645_rtl8367_data,
101 static struct spi_board_info dir_645_spi_info[] = {
105 .max_speed_hz = 25000000,
106 .modalias = "m25p80",
110 static void __init dir_645_gpio_init(void)
112 rt3883_gpio_init(RT3883_GPIO_MODE_I2C |
113 RT3883_GPIO_MODE_UART0(RT3883_GPIO_MODE_GPIO) |
114 RT3883_GPIO_MODE_JTAG |
115 RT3883_GPIO_MODE_PCI(RT3883_GPIO_MODE_PCI_FNC));
118 static void __init dir_645_init(void)
122 rt3883_register_spi(dir_645_spi_info,
123 ARRAY_SIZE(dir_645_spi_info));
125 ramips_register_gpio_leds(-1, ARRAY_SIZE(dir_645_leds_gpio),
128 ramips_register_gpio_buttons(-1, DIR_645_KEYS_POLL_INTERVAL,
129 ARRAY_SIZE(dir_645_gpio_buttons),
130 dir_645_gpio_buttons);
132 platform_device_register(&dir_645_rtl8367_device);
134 rt3883_wlan_data.disable_5ghz = 1;
135 rt3883_register_wlan();
137 rt3883_eth_data.speed = SPEED_1000;
138 rt3883_eth_data.duplex = DUPLEX_FULL;
139 rt3883_eth_data.tx_fc = 1;
140 rt3883_eth_data.rx_fc = 1;
141 rt3883_register_ethernet();
143 rt3883_register_wdt(false);
144 rt3883_register_usbhost();
147 MIPS_MACHINE(RAMIPS_MACH_DIR_645, "DIR-645", "D-Link DIR-645", dir_645_init);