2 * Zyxel NBG 460N/550N/550NH board support
4 * Copyright (C) 2010 Michael Kurz <michi.kurz@googlemail.com>
6 * based on mach-tl-wr1043nd.c
8 * This program is free software; you can redistribute it and/or modify it
9 * under the terms of the GNU General Public License version 2 as published
10 * by the Free Software Foundation.
13 #include <linux/platform_device.h>
14 #include <linux/mtd/mtd.h>
15 #include <linux/mtd/partitions.h>
16 #include <linux/delay.h>
17 #include <linux/rtl8366.h>
19 #include <linux/i2c.h>
20 #include <linux/i2c-algo-bit.h>
21 #include <linux/i2c-gpio.h>
23 #include <asm/mach-ar71xx/ar71xx.h>
27 #include "dev-m25p80.h"
28 #include "dev-ar9xxx-wmac.h"
29 #include "dev-gpio-buttons.h"
30 #include "dev-leds-gpio.h"
33 #define NBG460N_GPIO_LED_WPS 3
34 #define NBG460N_GPIO_LED_WAN 6
35 #define NBG460N_GPIO_LED_POWER 14
36 #define NBG460N_GPIO_LED_WLAN 15
39 #define NBG460N_GPIO_BTN_WPS 12
40 #define NBG460N_GPIO_BTN_RESET 21
42 #define NBG460N_KEYS_POLL_INTERVAL 20 /* msecs */
43 #define NBG460N_KEYS_DEBOUNCE_INTERVAL (3 * NBG460N_KEYS_POLL_INTERVAL)
45 /* RTC chip PCF8563 I2C interface */
46 #define NBG460N_GPIO_PCF8563_SDA 8
47 #define NBG460N_GPIO_PCF8563_SCK 7
49 /* Switch configuration I2C interface */
50 #define NBG460N_GPIO_RTL8366_SDA 16
51 #define NBG460N_GPIO_RTL8366_SCK 18
53 #ifdef CONFIG_MTD_PARTITIONS
54 static struct mtd_partition nbg460n_partitions[] = {
59 .mask_flags = MTD_WRITEABLE,
61 .name = "U-Boot Config",
80 .mask_flags = MTD_WRITEABLE,
87 #endif /* CONFIG_MTD_PARTITIONS */
89 static struct flash_platform_data nbg460n_flash_data = {
90 #ifdef CONFIG_MTD_PARTITIONS
91 .parts = nbg460n_partitions,
92 .nr_parts = ARRAY_SIZE(nbg460n_partitions),
96 static struct gpio_led nbg460n_leds_gpio[] __initdata = {
98 .name = "nbg460n:green:power",
99 .gpio = NBG460N_GPIO_LED_POWER,
101 .default_trigger = "default-on",
103 .name = "nbg460n:green:wps",
104 .gpio = NBG460N_GPIO_LED_WPS,
107 .name = "nbg460n:green:wlan",
108 .gpio = NBG460N_GPIO_LED_WLAN,
111 /* Not really for controlling the LED,
112 when set low the LED blinks uncontrollable */
113 .name = "nbg460n:green:wan",
114 .gpio = NBG460N_GPIO_LED_WAN,
119 static struct gpio_keys_button nbg460n_gpio_keys[] __initdata = {
124 .debounce_interval = NBG460N_KEYS_DEBOUNCE_INTERVAL,
125 .gpio = NBG460N_GPIO_BTN_RESET,
130 .code = KEY_WPS_BUTTON,
131 .debounce_interval = NBG460N_KEYS_DEBOUNCE_INTERVAL,
132 .gpio = NBG460N_GPIO_BTN_WPS,
137 static struct i2c_gpio_platform_data nbg460n_i2c_device_platdata = {
138 .sda_pin = NBG460N_GPIO_PCF8563_SDA,
139 .scl_pin = NBG460N_GPIO_PCF8563_SCK,
143 static struct platform_device nbg460n_i2c_device = {
149 .platform_data = &nbg460n_i2c_device_platdata,
153 static struct i2c_board_info nbg460n_i2c_devs[] __initdata = {
155 I2C_BOARD_INFO("pcf8563", 0x51),
159 static void __devinit nbg460n_i2c_init(void)
161 /* The gpio interface */
162 platform_device_register(&nbg460n_i2c_device);
164 i2c_register_board_info(0, nbg460n_i2c_devs,
165 ARRAY_SIZE(nbg460n_i2c_devs));
169 static struct rtl8366_platform_data nbg460n_rtl8366s_data = {
170 .gpio_sda = NBG460N_GPIO_RTL8366_SDA,
171 .gpio_sck = NBG460N_GPIO_RTL8366_SCK,
174 static struct platform_device nbg460n_rtl8366s_device = {
175 .name = RTL8366S_DRIVER_NAME,
178 .platform_data = &nbg460n_rtl8366s_data,
182 static void __init nbg460n_setup(void)
184 /* end of bootloader sector contains mac address */
185 u8 *mac = (u8 *) KSEG1ADDR(0x1fc0fff8);
186 /* last sector contains wlan calib data */
187 u8 *eeprom = (u8 *) KSEG1ADDR(0x1fff1000);
190 ar71xx_init_mac(ar71xx_eth0_data.mac_addr, mac, 0);
191 ar71xx_eth0_data.mii_bus_dev = &nbg460n_rtl8366s_device.dev;
192 ar71xx_eth0_data.phy_if_mode = PHY_INTERFACE_MODE_RGMII;
193 ar71xx_eth0_data.speed = SPEED_1000;
194 ar71xx_eth0_data.duplex = DUPLEX_FULL;
197 ar71xx_init_mac(ar71xx_eth1_data.mac_addr, mac, 1);
198 ar71xx_eth1_data.mii_bus_dev = &nbg460n_rtl8366s_device.dev;
199 ar71xx_eth1_data.phy_if_mode = PHY_INTERFACE_MODE_RGMII;
200 ar71xx_eth1_data.phy_mask = 0x10;
202 ar71xx_add_device_eth(0);
203 ar71xx_add_device_eth(1);
205 /* register the switch phy */
206 platform_device_register(&nbg460n_rtl8366s_device);
209 ar71xx_add_device_m25p80(&nbg460n_flash_data);
211 ar9xxx_add_device_wmac(eeprom, mac);
213 /* register RTC chip */
216 ar71xx_add_device_leds_gpio(-1, ARRAY_SIZE(nbg460n_leds_gpio),
219 ar71xx_register_gpio_keys_polled(-1, NBG460N_KEYS_POLL_INTERVAL,
220 ARRAY_SIZE(nbg460n_gpio_keys),
224 MIPS_MACHINE(AR71XX_MACH_NBG460N, "NBG460N", "Zyxel NBG460N/550N/550NH",