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/delay.h>
14 #include <linux/i2c.h>
15 #include <linux/i2c-algo-bit.h>
16 #include <linux/i2c-gpio.h>
17 #include <linux/mtd/mtd.h>
18 #include <linux/mtd/partitions.h>
19 #include <linux/platform_device.h>
20 #include <linux/rtl8366.h>
22 #include <asm/mach-ath79/ath79.h>
25 #include "dev-gpio-buttons.h"
26 #include "dev-leds-gpio.h"
27 #include "dev-m25p80.h"
29 #include "machtypes.h"
32 #define NBG460N_GPIO_LED_WPS 3
33 #define NBG460N_GPIO_LED_WAN 6
34 #define NBG460N_GPIO_LED_POWER 14
35 #define NBG460N_GPIO_LED_WLAN 15
38 #define NBG460N_GPIO_BTN_WPS 12
39 #define NBG460N_GPIO_BTN_RESET 21
41 #define NBG460N_KEYS_POLL_INTERVAL 20 /* msecs */
42 #define NBG460N_KEYS_DEBOUNCE_INTERVAL (3 * NBG460N_KEYS_POLL_INTERVAL)
44 /* RTC chip PCF8563 I2C interface */
45 #define NBG460N_GPIO_PCF8563_SDA 8
46 #define NBG460N_GPIO_PCF8563_SCK 7
48 /* Switch configuration I2C interface */
49 #define NBG460N_GPIO_RTL8366_SDA 16
50 #define NBG460N_GPIO_RTL8366_SCK 18
52 static struct mtd_partition nbg460n_partitions
[] = {
57 .mask_flags
= MTD_WRITEABLE
,
59 .name
= "U-Boot Config",
78 .mask_flags
= MTD_WRITEABLE
,
86 static struct flash_platform_data nbg460n_flash_data
= {
87 .parts
= nbg460n_partitions
,
88 .nr_parts
= ARRAY_SIZE(nbg460n_partitions
),
91 static struct gpio_led nbg460n_leds_gpio
[] __initdata
= {
93 .name
= "nbg460n:green:power",
94 .gpio
= NBG460N_GPIO_LED_POWER
,
96 .default_trigger
= "default-on",
98 .name
= "nbg460n:green:wps",
99 .gpio
= NBG460N_GPIO_LED_WPS
,
102 .name
= "nbg460n:green:wlan",
103 .gpio
= NBG460N_GPIO_LED_WLAN
,
106 /* Not really for controlling the LED,
107 when set low the LED blinks uncontrollable */
108 .name
= "nbg460n:green:wan",
109 .gpio
= NBG460N_GPIO_LED_WAN
,
114 static struct gpio_keys_button nbg460n_gpio_keys
[] __initdata
= {
119 .debounce_interval
= NBG460N_KEYS_DEBOUNCE_INTERVAL
,
120 .gpio
= NBG460N_GPIO_BTN_RESET
,
125 .code
= KEY_WPS_BUTTON
,
126 .debounce_interval
= NBG460N_KEYS_DEBOUNCE_INTERVAL
,
127 .gpio
= NBG460N_GPIO_BTN_WPS
,
132 static struct i2c_gpio_platform_data nbg460n_i2c_device_platdata
= {
133 .sda_pin
= NBG460N_GPIO_PCF8563_SDA
,
134 .scl_pin
= NBG460N_GPIO_PCF8563_SCK
,
138 static struct platform_device nbg460n_i2c_device
= {
144 .platform_data
= &nbg460n_i2c_device_platdata
,
148 static struct i2c_board_info nbg460n_i2c_devs
[] __initdata
= {
150 I2C_BOARD_INFO("pcf8563", 0x51),
154 static void __devinit
nbg460n_i2c_init(void)
156 /* The gpio interface */
157 platform_device_register(&nbg460n_i2c_device
);
159 i2c_register_board_info(0, nbg460n_i2c_devs
,
160 ARRAY_SIZE(nbg460n_i2c_devs
));
164 static struct rtl8366_platform_data nbg460n_rtl8366s_data
= {
165 .gpio_sda
= NBG460N_GPIO_RTL8366_SDA
,
166 .gpio_sck
= NBG460N_GPIO_RTL8366_SCK
,
169 static struct platform_device nbg460n_rtl8366s_device
= {
170 .name
= RTL8366S_DRIVER_NAME
,
173 .platform_data
= &nbg460n_rtl8366s_data
,
177 static void __init
nbg460n_setup(void)
179 /* end of bootloader sector contains mac address */
180 u8
*mac
= (u8
*) KSEG1ADDR(0x1fc0fff8);
181 /* last sector contains wlan calib data */
182 u8
*eeprom
= (u8
*) KSEG1ADDR(0x1fff1000);
185 ath79_init_mac(ath79_eth0_data
.mac_addr
, mac
, 0);
186 ath79_eth0_data
.mii_bus_dev
= &nbg460n_rtl8366s_device
.dev
;
187 ath79_eth0_data
.phy_if_mode
= PHY_INTERFACE_MODE_RGMII
;
188 ath79_eth0_data
.speed
= SPEED_1000
;
189 ath79_eth0_data
.duplex
= DUPLEX_FULL
;
192 ath79_init_mac(ath79_eth1_data
.mac_addr
, mac
, 1);
193 ath79_eth1_data
.mii_bus_dev
= &nbg460n_rtl8366s_device
.dev
;
194 ath79_eth1_data
.phy_if_mode
= PHY_INTERFACE_MODE_RGMII
;
195 ath79_eth1_data
.phy_mask
= 0x10;
197 ath79_register_eth(0);
198 ath79_register_eth(1);
200 /* register the switch phy */
201 platform_device_register(&nbg460n_rtl8366s_device
);
204 ath79_register_m25p80(&nbg460n_flash_data
);
206 ath79_register_wmac(eeprom
, mac
);
208 /* register RTC chip */
211 ath79_register_leds_gpio(-1, ARRAY_SIZE(nbg460n_leds_gpio
),
214 ath79_register_gpio_keys_polled(-1, NBG460N_KEYS_POLL_INTERVAL
,
215 ARRAY_SIZE(nbg460n_gpio_keys
),
219 MIPS_MACHINE(ATH79_MACH_NBG460N
, "NBG460N", "Zyxel NBG460N/550N/550NH",