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/rtl8366s.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-ar913x-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
41 #define NBG460N_BUTTONS_POLL_INTERVAL 20
43 /* RTC chip PCF8563 I2C interface */
44 #define NBG460N_GPIO_PCF8563_SDA 8
45 #define NBG460N_GPIO_PCF8563_SCK 7
47 /* Switch configuration I2C interface */
48 #define NBG460N_GPIO_RTL8366_SDA 16
49 #define NBG460N_GPIO_RTL8366_SCK 18
51 #ifdef CONFIG_MTD_PARTITIONS
52 static struct mtd_partition nbg460n_partitions[] = {
57 .mask_flags = MTD_WRITEABLE,
59 .name = "U-Boot Config",
78 .mask_flags = MTD_WRITEABLE,
85 #endif /* CONFIG_MTD_PARTITIONS */
87 static struct flash_platform_data nbg460n_flash_data = {
88 #ifdef CONFIG_MTD_PARTITIONS
89 .parts = nbg460n_partitions,
90 .nr_parts = ARRAY_SIZE(nbg460n_partitions),
94 static struct gpio_led nbg460n_leds_gpio[] __initdata = {
96 .name = "nbg460n:green:power",
97 .gpio = NBG460N_GPIO_LED_POWER,
99 .default_trigger = "default-on",
101 .name = "nbg460n:green:wps",
102 .gpio = NBG460N_GPIO_LED_WPS,
105 .name = "nbg460n:green:wlan",
106 .gpio = NBG460N_GPIO_LED_WLAN,
109 /* Not really for controlling the LED,
110 when set low the LED blinks uncontrollable */
111 .name = "nbg460n:green:wan",
112 .gpio = NBG460N_GPIO_LED_WAN,
117 static struct gpio_button nbg460n_gpio_buttons[] __initdata = {
123 .gpio = NBG460N_GPIO_BTN_RESET,
128 .code = KEY_WPS_BUTTON,
130 .gpio = NBG460N_GPIO_BTN_WPS,
135 static struct i2c_gpio_platform_data nbg460n_i2c_device_platdata = {
136 .sda_pin = NBG460N_GPIO_PCF8563_SDA,
137 .scl_pin = NBG460N_GPIO_PCF8563_SCK,
141 static struct platform_device nbg460n_i2c_device = {
147 .platform_data = &nbg460n_i2c_device_platdata,
151 static struct i2c_board_info nbg460n_i2c_devs[] __initdata = {
153 I2C_BOARD_INFO("pcf8563", 0x51),
157 static void __devinit nbg460n_i2c_init(void)
159 /* The gpio interface */
160 platform_device_register(&nbg460n_i2c_device);
162 i2c_register_board_info(0, nbg460n_i2c_devs,
163 ARRAY_SIZE(nbg460n_i2c_devs));
167 static struct rtl8366s_platform_data nbg460n_rtl8366s_data = {
168 .gpio_sda = NBG460N_GPIO_RTL8366_SDA,
169 .gpio_sck = NBG460N_GPIO_RTL8366_SCK,
172 static struct platform_device nbg460n_rtl8366s_device = {
173 .name = RTL8366S_DRIVER_NAME,
176 .platform_data = &nbg460n_rtl8366s_data,
180 static void __init nbg460n_setup(void)
182 /* end of bootloader sector contains mac address */
183 u8 *mac = (u8 *) KSEG1ADDR(0x1fc0fff8);
184 /* last sector contains wlan calib data */
185 u8 *eeprom = (u8 *) KSEG1ADDR(0x1fff1000);
188 ar71xx_init_mac(ar71xx_eth0_data.mac_addr, mac, 0);
189 ar71xx_eth0_data.mii_bus_dev = &nbg460n_rtl8366s_device.dev;
190 ar71xx_eth0_data.phy_if_mode = PHY_INTERFACE_MODE_RGMII;
191 ar71xx_eth0_data.speed = SPEED_1000;
192 ar71xx_eth0_data.duplex = DUPLEX_FULL;
195 ar71xx_init_mac(ar71xx_eth1_data.mac_addr, mac, 1);
196 ar71xx_eth1_data.mii_bus_dev = &nbg460n_rtl8366s_device.dev;
197 ar71xx_eth1_data.phy_if_mode = PHY_INTERFACE_MODE_RGMII;
198 ar71xx_eth1_data.phy_mask = 0x10;
200 ar71xx_add_device_eth(0);
201 ar71xx_add_device_eth(1);
203 /* register the switch phy */
204 platform_device_register(&nbg460n_rtl8366s_device);
207 ar71xx_add_device_m25p80(&nbg460n_flash_data);
209 ar913x_add_device_wmac(eeprom, mac);
211 /* register RTC chip */
214 ar71xx_add_device_leds_gpio(-1, ARRAY_SIZE(nbg460n_leds_gpio),
217 ar71xx_add_device_gpio_buttons(-1, NBG460N_BUTTONS_POLL_INTERVAL,
218 ARRAY_SIZE(nbg460n_gpio_buttons),
219 nbg460n_gpio_buttons);
222 MIPS_MACHINE(AR71XX_MACH_NBG460N, "NBG460N", "Zyxel NBG460N/550N/550NH", nbg460n_setup);