Loading...
1/*
2 * Atheros PB44 reference board support
3 *
4 * Copyright (C) 2009-2010 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/platform_device.h>
13#include <linux/i2c.h>
14#include <linux/i2c-gpio.h>
15#include <linux/i2c/pcf857x.h>
16
17#include "machtypes.h"
18#include "dev-gpio-buttons.h"
19#include "dev-leds-gpio.h"
20#include "dev-spi.h"
21#include "dev-usb.h"
22#include "pci.h"
23
24#define PB44_GPIO_I2C_SCL 0
25#define PB44_GPIO_I2C_SDA 1
26
27#define PB44_GPIO_EXP_BASE 16
28#define PB44_GPIO_SW_RESET (PB44_GPIO_EXP_BASE + 6)
29#define PB44_GPIO_SW_JUMP (PB44_GPIO_EXP_BASE + 8)
30#define PB44_GPIO_LED_JUMP1 (PB44_GPIO_EXP_BASE + 9)
31#define PB44_GPIO_LED_JUMP2 (PB44_GPIO_EXP_BASE + 10)
32
33#define PB44_KEYS_POLL_INTERVAL 20 /* msecs */
34#define PB44_KEYS_DEBOUNCE_INTERVAL (3 * PB44_KEYS_POLL_INTERVAL)
35
36static struct i2c_gpio_platform_data pb44_i2c_gpio_data = {
37 .sda_pin = PB44_GPIO_I2C_SDA,
38 .scl_pin = PB44_GPIO_I2C_SCL,
39};
40
41static struct platform_device pb44_i2c_gpio_device = {
42 .name = "i2c-gpio",
43 .id = 0,
44 .dev = {
45 .platform_data = &pb44_i2c_gpio_data,
46 }
47};
48
49static struct pcf857x_platform_data pb44_pcf857x_data = {
50 .gpio_base = PB44_GPIO_EXP_BASE,
51};
52
53static struct i2c_board_info pb44_i2c_board_info[] __initdata = {
54 {
55 I2C_BOARD_INFO("pcf8575", 0x20),
56 .platform_data = &pb44_pcf857x_data,
57 },
58};
59
60static struct gpio_led pb44_leds_gpio[] __initdata = {
61 {
62 .name = "pb44:amber:jump1",
63 .gpio = PB44_GPIO_LED_JUMP1,
64 .active_low = 1,
65 }, {
66 .name = "pb44:green:jump2",
67 .gpio = PB44_GPIO_LED_JUMP2,
68 .active_low = 1,
69 },
70};
71
72static struct gpio_keys_button pb44_gpio_keys[] __initdata = {
73 {
74 .desc = "soft_reset",
75 .type = EV_KEY,
76 .code = KEY_RESTART,
77 .debounce_interval = PB44_KEYS_DEBOUNCE_INTERVAL,
78 .gpio = PB44_GPIO_SW_RESET,
79 .active_low = 1,
80 } , {
81 .desc = "jumpstart",
82 .type = EV_KEY,
83 .code = KEY_WPS_BUTTON,
84 .debounce_interval = PB44_KEYS_DEBOUNCE_INTERVAL,
85 .gpio = PB44_GPIO_SW_JUMP,
86 .active_low = 1,
87 }
88};
89
90static struct spi_board_info pb44_spi_info[] = {
91 {
92 .bus_num = 0,
93 .chip_select = 0,
94 .max_speed_hz = 25000000,
95 .modalias = "m25p64",
96 },
97};
98
99static struct ath79_spi_platform_data pb44_spi_data = {
100 .bus_num = 0,
101 .num_chipselect = 1,
102};
103
104static void __init pb44_init(void)
105{
106 i2c_register_board_info(0, pb44_i2c_board_info,
107 ARRAY_SIZE(pb44_i2c_board_info));
108 platform_device_register(&pb44_i2c_gpio_device);
109
110 ath79_register_leds_gpio(-1, ARRAY_SIZE(pb44_leds_gpio),
111 pb44_leds_gpio);
112 ath79_register_gpio_keys_polled(-1, PB44_KEYS_POLL_INTERVAL,
113 ARRAY_SIZE(pb44_gpio_keys),
114 pb44_gpio_keys);
115 ath79_register_spi(&pb44_spi_data, pb44_spi_info,
116 ARRAY_SIZE(pb44_spi_info));
117 ath79_register_usb();
118 ath79_register_pci();
119}
120
121MIPS_MACHINE(ATH79_MACH_PB44, "PB44", "Atheros PB44 reference board",
122 pb44_init);
1/*
2 * Atheros PB44 reference board support
3 *
4 * Copyright (C) 2009-2010 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/platform_device.h>
13#include <linux/i2c.h>
14#include <linux/gpio/machine.h>
15#include <linux/platform_data/pcf857x.h>
16
17#include "machtypes.h"
18#include "dev-gpio-buttons.h"
19#include "dev-leds-gpio.h"
20#include "dev-spi.h"
21#include "dev-usb.h"
22#include "pci.h"
23
24#define PB44_GPIO_I2C_SCL 0
25#define PB44_GPIO_I2C_SDA 1
26
27#define PB44_GPIO_EXP_BASE 16
28#define PB44_GPIO_SW_RESET (PB44_GPIO_EXP_BASE + 6)
29#define PB44_GPIO_SW_JUMP (PB44_GPIO_EXP_BASE + 8)
30#define PB44_GPIO_LED_JUMP1 (PB44_GPIO_EXP_BASE + 9)
31#define PB44_GPIO_LED_JUMP2 (PB44_GPIO_EXP_BASE + 10)
32
33#define PB44_KEYS_POLL_INTERVAL 20 /* msecs */
34#define PB44_KEYS_DEBOUNCE_INTERVAL (3 * PB44_KEYS_POLL_INTERVAL)
35
36static struct gpiod_lookup_table pb44_i2c_gpiod_table = {
37 .dev_id = "i2c-gpio",
38 .table = {
39 GPIO_LOOKUP_IDX("ath79-gpio", PB44_GPIO_I2C_SDA,
40 NULL, 0, GPIO_ACTIVE_HIGH | GPIO_OPEN_DRAIN),
41 GPIO_LOOKUP_IDX("ath79-gpio", PB44_GPIO_I2C_SCL,
42 NULL, 1, GPIO_ACTIVE_HIGH | GPIO_OPEN_DRAIN),
43 },
44};
45
46static struct platform_device pb44_i2c_gpio_device = {
47 .name = "i2c-gpio",
48 .id = 0,
49 .dev = {
50 .platform_data = NULL,
51 }
52};
53
54static struct pcf857x_platform_data pb44_pcf857x_data = {
55 .gpio_base = PB44_GPIO_EXP_BASE,
56};
57
58static struct i2c_board_info pb44_i2c_board_info[] __initdata = {
59 {
60 I2C_BOARD_INFO("pcf8575", 0x20),
61 .platform_data = &pb44_pcf857x_data,
62 },
63};
64
65static struct gpio_led pb44_leds_gpio[] __initdata = {
66 {
67 .name = "pb44:amber:jump1",
68 .gpio = PB44_GPIO_LED_JUMP1,
69 .active_low = 1,
70 }, {
71 .name = "pb44:green:jump2",
72 .gpio = PB44_GPIO_LED_JUMP2,
73 .active_low = 1,
74 },
75};
76
77static struct gpio_keys_button pb44_gpio_keys[] __initdata = {
78 {
79 .desc = "soft_reset",
80 .type = EV_KEY,
81 .code = KEY_RESTART,
82 .debounce_interval = PB44_KEYS_DEBOUNCE_INTERVAL,
83 .gpio = PB44_GPIO_SW_RESET,
84 .active_low = 1,
85 } , {
86 .desc = "jumpstart",
87 .type = EV_KEY,
88 .code = KEY_WPS_BUTTON,
89 .debounce_interval = PB44_KEYS_DEBOUNCE_INTERVAL,
90 .gpio = PB44_GPIO_SW_JUMP,
91 .active_low = 1,
92 }
93};
94
95static struct spi_board_info pb44_spi_info[] = {
96 {
97 .bus_num = 0,
98 .chip_select = 0,
99 .max_speed_hz = 25000000,
100 .modalias = "m25p64",
101 },
102};
103
104static struct ath79_spi_platform_data pb44_spi_data = {
105 .bus_num = 0,
106 .num_chipselect = 1,
107};
108
109static void __init pb44_init(void)
110{
111 gpiod_add_lookup_table(&pb44_i2c_gpiod_table);
112 i2c_register_board_info(0, pb44_i2c_board_info,
113 ARRAY_SIZE(pb44_i2c_board_info));
114 platform_device_register(&pb44_i2c_gpio_device);
115
116 ath79_register_leds_gpio(-1, ARRAY_SIZE(pb44_leds_gpio),
117 pb44_leds_gpio);
118 ath79_register_gpio_keys_polled(-1, PB44_KEYS_POLL_INTERVAL,
119 ARRAY_SIZE(pb44_gpio_keys),
120 pb44_gpio_keys);
121 ath79_register_spi(&pb44_spi_data, pb44_spi_info,
122 ARRAY_SIZE(pb44_spi_info));
123 ath79_register_usb();
124 ath79_register_pci();
125}
126
127MIPS_MACHINE(ATH79_MACH_PB44, "PB44", "Atheros PB44 reference board",
128 pb44_init);