2 * Atheros PB44 board support
4 * Copyright (C) 2009 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/bitops.h>
13 #include <linux/input.h>
14 #include <linux/platform_device.h>
15 #include <linux/spi/spi.h>
16 #include <linux/spi/flash.h>
17 #include <linux/i2c.h>
18 #include <linux/i2c-gpio.h>
19 #include <linux/i2c/pcf857x.h>
21 #include <asm/mips_machine.h>
22 #include <asm/mach-ar71xx/ar71xx.h>
23 #include <asm/mach-ar71xx/pci.h>
27 #define PB44_PCF8757_VSC7385_CS 0
28 #define PB44_PCF8757_STEREO_CS 1
29 #define PB44_PCF8757_SLIC_CS0 2
30 #define PB44_PCF8757_SLIC_TEST 3
31 #define PB44_PCF8757_SLIC_INT0 4
32 #define PB44_PCF8757_SLIC_INT1 5
33 #define PB44_PCF8757_SW_RESET 6
34 #define PB44_PCF8757_SW_JUMP 8
35 #define PB44_PCF8757_LED_JUMP1 9
36 #define PB44_PCF8757_LED_JUMP2 10
37 #define PB44_PCF8757_TP24 11
38 #define PB44_PCF8757_TP25 12
39 #define PB44_PCF8757_TP26 13
40 #define PB44_PCF8757_TP27 14
41 #define PB44_PCF8757_TP28 15
43 #define PB44_GPIO_I2C_SCL 0
44 #define PB44_GPIO_I2C_SDA 1
46 #define PB44_GPIO_EXP_BASE 16
47 #define PB44_GPIO_SW_RESET (PB44_GPIO_EXP_BASE + PB44_PCF8757_SW_RESET)
48 #define PB44_GPIO_SW_JUMP (PB44_GPIO_EXP_BASE + PB44_PCF8757_SW_JUMP)
49 #define PB44_GPIO_LED_JUMP1 (PB44_GPIO_EXP_BASE + PB44_PCF8757_LED_JUMP1)
50 #define PB44_GPIO_LED_JUMP2 (PB44_GPIO_EXP_BASE + PB44_PCF8757_LED_JUMP2)
52 static struct spi_board_info pb44_spi_info
[] = {
56 .max_speed_hz
= 25000000,
61 static struct ar71xx_pci_irq pb44_pci_irqs
[] __initdata
= {
65 .irq
= AR71XX_PCI_IRQ_DEV0
,
69 .irq
= AR71XX_PCI_IRQ_DEV1
,
73 .irq
= AR71XX_PCI_IRQ_DEV2
,
77 static struct i2c_gpio_platform_data pb44_i2c_gpio_data
= {
78 .sda_pin
= PB44_GPIO_I2C_SDA
,
79 .scl_pin
= PB44_GPIO_I2C_SCL
,
82 static struct platform_device pb44_i2c_gpio_device
= {
86 .platform_data
= &pb44_i2c_gpio_data
,
90 static struct pcf857x_platform_data pb44_pcf857x_data
= {
91 .gpio_base
= PB44_GPIO_EXP_BASE
,
94 static struct i2c_board_info pb44_i2c_board_info
[] __initdata
= {
96 I2C_BOARD_INFO("pcf8575", 0x20),
97 .platform_data
= &pb44_pcf857x_data
,
101 static struct gpio_led pb44_leds_gpio
[] __initdata
= {
103 .name
= "pb44:amber:jump1",
104 .gpio
= PB44_GPIO_LED_JUMP1
,
107 .name
= "pb44:green:jump2",
108 .gpio
= PB44_GPIO_LED_JUMP2
,
113 static struct gpio_button pb44_gpio_buttons
[] __initdata
= {
115 .desc
= "soft_reset",
119 .gpio
= PB44_GPIO_SW_RESET
,
126 .gpio
= PB44_GPIO_SW_JUMP
,
131 #define PB44_WAN_PHYMASK BIT(0)
132 #define PB44_LAN_PHYMASK 0
133 #define PB44_MDIO_PHYMASK (PB44_LAN_PHYMASK | PB44_WAN_PHYMASK)
135 static void __init
pb44_init(void)
137 ar71xx_add_device_spi(NULL
, pb44_spi_info
,
138 ARRAY_SIZE(pb44_spi_info
));
140 ar71xx_add_device_mdio(~PB44_MDIO_PHYMASK
);
142 ar71xx_eth0_data
.phy_if_mode
= PHY_INTERFACE_MODE_RGMII
;
143 ar71xx_eth0_data
.phy_mask
= PB44_WAN_PHYMASK
;
145 ar71xx_add_device_eth(0);
147 ar71xx_eth1_data
.phy_if_mode
= PHY_INTERFACE_MODE_RGMII
;
148 ar71xx_eth1_data
.phy_mask
= PB44_LAN_PHYMASK
;
149 ar71xx_eth1_data
.speed
= SPEED_1000
;
150 ar71xx_eth1_data
.duplex
= DUPLEX_FULL
;
152 ar71xx_add_device_eth(1);
154 ar71xx_add_device_usb();
156 ar71xx_pci_init(ARRAY_SIZE(pb44_pci_irqs
), pb44_pci_irqs
);
158 i2c_register_board_info(0, pb44_i2c_board_info
,
159 ARRAY_SIZE(pb44_i2c_board_info
));
161 platform_device_register(&pb44_i2c_gpio_device
);
163 ar71xx_add_device_leds_gpio(-1, ARRAY_SIZE(pb44_leds_gpio
),
166 ar71xx_add_device_gpio_buttons(-1, 20, ARRAY_SIZE(pb44_gpio_buttons
),
170 MIPS_MACHINE(AR71XX_MACH_PB44
, "Atheros PB44", pb44_init
);