[ar71xx] register a I2C GPIO expander on the PB44 board
[openwrt/svn-archive/archive.git] / target / linux / ar71xx / files / arch / mips / ar71xx / mach-pb44.c
1 /*
2 * Atheros PB44 board support
3 *
4 * Copyright (C) 2009 Gabor Juhos <juhosg@openwrt.org>
5 *
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.
9 */
10
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>
20
21 #include <asm/mips_machine.h>
22 #include <asm/mach-ar71xx/ar71xx.h>
23 #include <asm/mach-ar71xx/pci.h>
24
25 #include "devices.h"
26
27 #define PB44_GPIO_I2C_SCL 0
28 #define PB44_GPIO_I2C_SDA 1
29
30 #define PB44_GPIO_EXP_BASE 16
31
32 static struct spi_board_info pb44_spi_info[] = {
33 {
34 .bus_num = 0,
35 .chip_select = 0,
36 .max_speed_hz = 25000000,
37 .modalias = "m25p80",
38 }
39 };
40
41 static struct ar71xx_pci_irq pb44_pci_irqs[] __initdata = {
42 {
43 .slot = 0,
44 .pin = 1,
45 .irq = AR71XX_PCI_IRQ_DEV0,
46 }, {
47 .slot = 1,
48 .pin = 1,
49 .irq = AR71XX_PCI_IRQ_DEV1,
50 }, {
51 .slot = 2,
52 .pin = 1,
53 .irq = AR71XX_PCI_IRQ_DEV2,
54 }
55 };
56
57 static struct i2c_gpio_platform_data pb44_i2c_gpio_data = {
58 .sda_pin = PB44_GPIO_I2C_SDA,
59 .scl_pin = PB44_GPIO_I2C_SCL,
60 };
61
62 static struct platform_device pb44_i2c_gpio_device = {
63 .name = "i2c-gpio",
64 .id = 0,
65 .dev = {
66 .platform_data = &pb44_i2c_gpio_data,
67 }
68 };
69
70 static struct pcf857x_platform_data pb44_pcf857x_data = {
71 .gpio_base = PB44_GPIO_EXP_BASE,
72 };
73
74 static struct i2c_board_info pb44_i2c_board_info[] __initdata = {
75 {
76 I2C_BOARD_INFO("pcf8575", 0x20),
77 .platform_data = &pb44_pcf857x_data,
78 },
79 };
80
81 #define PB44_WAN_PHYMASK BIT(0)
82 #define PB44_LAN_PHYMASK 0
83 #define PB44_MDIO_PHYMASK (PB44_LAN_PHYMASK | PB44_WAN_PHYMASK)
84
85 static void __init pb44_init(void)
86 {
87 ar71xx_add_device_spi(NULL, pb44_spi_info,
88 ARRAY_SIZE(pb44_spi_info));
89
90 ar71xx_add_device_mdio(~PB44_MDIO_PHYMASK);
91
92 ar71xx_eth0_data.phy_if_mode = PHY_INTERFACE_MODE_RGMII;
93 ar71xx_eth0_data.phy_mask = PB44_WAN_PHYMASK;
94
95 ar71xx_add_device_eth(0);
96
97 ar71xx_eth1_data.phy_if_mode = PHY_INTERFACE_MODE_RGMII;
98 ar71xx_eth1_data.phy_mask = PB44_LAN_PHYMASK;
99 ar71xx_eth1_data.speed = SPEED_1000;
100 ar71xx_eth1_data.duplex = DUPLEX_FULL;
101
102 ar71xx_add_device_eth(1);
103
104 ar71xx_add_device_usb();
105
106 ar71xx_pci_init(ARRAY_SIZE(pb44_pci_irqs), pb44_pci_irqs);
107
108 i2c_register_board_info(0, pb44_i2c_board_info,
109 ARRAY_SIZE(pb44_i2c_board_info));
110
111 platform_device_register(&pb44_i2c_gpio_device);
112
113 /* TODO: GPIO LEDs & buttons */
114 }
115
116 MIPS_MACHINE(AR71XX_MACH_PB44, "Atheros PB44", pb44_init);