ar71xx: add missing files for the JA76PF board
[openwrt/svn-archive/archive.git] / target / linux / ar71xx / files / arch / mips / ar71xx / mach-ja76pf.c
1 /*
2 * jjPlus JA76PF board support
3 */
4
5 #include <asm/mach-ar71xx/ar71xx.h>
6 #include <linux/platform_device.h>
7 #include <linux/i2c.h>
8 #include <linux/i2c-gpio.h>
9
10 #include "machtype.h"
11 #include "devices.h"
12 #include "dev-m25p80.h"
13 #include "dev-gpio-buttons.h"
14 #include "dev-pb42-pci.h"
15 #include "dev-usb.h"
16 #include "dev-leds-gpio.h"
17
18 #define JA76PF_BUTTONS_POLL_INTERVAL 20
19
20 #define JA76PF_GPIO_I2C_SCL 0
21 #define JA76PF_GPIO_I2C_SDA 1
22 #define JA76PF_GPIO_LED_1 5
23 #define JA76PF_GPIO_LED_2 4
24 #define JA76PF_GPIO_BTN_RESET 11
25
26 static struct gpio_led ja76pf_leds_gpio[] __initdata = {
27 {
28 .name = "ja76pf:green:led1",
29 .gpio = JA76PF_GPIO_LED_1,
30 .active_low = 1,
31 }, {
32 .name = "ja76pf:green:led2",
33 .gpio = JA76PF_GPIO_LED_2,
34 .active_low = 1,
35 }
36 };
37
38 static struct gpio_button ja76pf_gpio_buttons[] __initdata = {
39 {
40 .desc = "reset",
41 .type = EV_KEY,
42 .code = KEY_RESTART,
43 .threshold = 3,
44 .gpio = JA76PF_GPIO_BTN_RESET,
45 .active_low = 1,
46 }
47 };
48
49 static struct i2c_gpio_platform_data ja76pf_i2c_gpio_data = {
50 .sda_pin = JA76PF_GPIO_I2C_SDA,
51 .scl_pin = JA76PF_GPIO_I2C_SCL,
52 };
53
54 static struct platform_device ja76pf_i2c_gpio_device = {
55 .name = "i2c-gpio",
56 .id = 0,
57 .dev = {
58 .platform_data = &ja76pf_i2c_gpio_data,
59 }
60 };
61
62 #define JA76PF_WAN_PHYMASK (1 << 4)
63 #define JA76PF_LAN_PHYMASK ((1 << 0) | (1 << 1) | (1 << 2) | (1 < 3))
64 #define JA76PF_MDIO_PHYMASK (JA76PF_LAN_PHYMASK | JA76PF_WAN_PHYMASK)
65
66 static void __init ja76pf_init(void)
67 {
68 ar71xx_add_device_m25p80(NULL);
69
70 ar71xx_add_device_mdio(~JA76PF_MDIO_PHYMASK);
71
72 ar71xx_eth0_data.phy_if_mode = PHY_INTERFACE_MODE_RGMII;
73 ar71xx_eth0_data.phy_mask = JA76PF_LAN_PHYMASK;
74
75 ar71xx_eth1_data.phy_if_mode = PHY_INTERFACE_MODE_RGMII;
76 ar71xx_eth1_data.phy_mask = JA76PF_WAN_PHYMASK;
77 ar71xx_eth1_data.speed = SPEED_1000;
78 ar71xx_eth1_data.duplex = DUPLEX_FULL;
79
80 ar71xx_add_device_eth(0);
81 ar71xx_add_device_eth(1);
82
83 platform_device_register(&ja76pf_i2c_gpio_device);
84
85 ar71xx_add_device_leds_gpio(-1, ARRAY_SIZE(ja76pf_leds_gpio),
86 ja76pf_leds_gpio);
87
88 ar71xx_add_device_gpio_buttons(-1, JA76PF_BUTTONS_POLL_INTERVAL,
89 ARRAY_SIZE(ja76pf_gpio_buttons),
90 ja76pf_gpio_buttons);
91
92 ar71xx_add_device_usb();
93 pb42_pci_init();
94 }
95
96 MIPS_MACHINE(AR71XX_MACH_JA76PF, "JA76PF", "jjPlus JA76PF", ja76pf_init);