blob: 3dc5080185cb3802a18ceb0ab6843ea46d9a8b8d [file] [log] [blame]
Gabor Juhos0cde7222011-01-04 21:28:17 +01001/*
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"
Gabor Juhos3f348c52011-01-04 21:28:21 +010018#include "dev-gpio-buttons.h"
Gabor Juhosd8fec1f2011-01-04 21:28:18 +010019#include "dev-leds-gpio.h"
Gabor Juhos0cde7222011-01-04 21:28:17 +010020
21#define PB44_GPIO_I2C_SCL 0
22#define PB44_GPIO_I2C_SDA 1
23
24#define PB44_GPIO_EXP_BASE 16
Gabor Juhos3f348c52011-01-04 21:28:21 +010025#define PB44_GPIO_SW_RESET (PB44_GPIO_EXP_BASE + 6)
26#define PB44_GPIO_SW_JUMP (PB44_GPIO_EXP_BASE + 8)
Gabor Juhosd8fec1f2011-01-04 21:28:18 +010027#define PB44_GPIO_LED_JUMP1 (PB44_GPIO_EXP_BASE + 9)
28#define PB44_GPIO_LED_JUMP2 (PB44_GPIO_EXP_BASE + 10)
Gabor Juhos0cde7222011-01-04 21:28:17 +010029
Gabor Juhos3f348c52011-01-04 21:28:21 +010030#define PB44_KEYS_POLL_INTERVAL 20 /* msecs */
31#define PB44_KEYS_DEBOUNCE_INTERVAL (3 * PB44_KEYS_POLL_INTERVAL)
32
Gabor Juhos0cde7222011-01-04 21:28:17 +010033static struct i2c_gpio_platform_data pb44_i2c_gpio_data = {
34 .sda_pin = PB44_GPIO_I2C_SDA,
35 .scl_pin = PB44_GPIO_I2C_SCL,
36};
37
38static struct platform_device pb44_i2c_gpio_device = {
39 .name = "i2c-gpio",
40 .id = 0,
41 .dev = {
42 .platform_data = &pb44_i2c_gpio_data,
43 }
44};
45
46static struct pcf857x_platform_data pb44_pcf857x_data = {
47 .gpio_base = PB44_GPIO_EXP_BASE,
48};
49
50static struct i2c_board_info pb44_i2c_board_info[] __initdata = {
51 {
52 I2C_BOARD_INFO("pcf8575", 0x20),
53 .platform_data = &pb44_pcf857x_data,
54 },
55};
56
Gabor Juhosd8fec1f2011-01-04 21:28:18 +010057static struct gpio_led pb44_leds_gpio[] __initdata = {
58 {
59 .name = "pb44:amber:jump1",
60 .gpio = PB44_GPIO_LED_JUMP1,
61 .active_low = 1,
62 }, {
63 .name = "pb44:green:jump2",
64 .gpio = PB44_GPIO_LED_JUMP2,
65 .active_low = 1,
66 },
67};
68
Gabor Juhos3f348c52011-01-04 21:28:21 +010069static struct gpio_keys_button pb44_gpio_keys[] __initdata = {
70 {
71 .desc = "soft_reset",
72 .type = EV_KEY,
73 .code = KEY_RESTART,
74 .debounce_interval = PB44_KEYS_DEBOUNCE_INTERVAL,
75 .gpio = PB44_GPIO_SW_RESET,
76 .active_low = 1,
77 } , {
78 .desc = "jumpstart",
79 .type = EV_KEY,
80 .code = KEY_WPS_BUTTON,
81 .debounce_interval = PB44_KEYS_DEBOUNCE_INTERVAL,
82 .gpio = PB44_GPIO_SW_JUMP,
83 .active_low = 1,
84 }
85};
86
Gabor Juhos0cde7222011-01-04 21:28:17 +010087static void __init pb44_init(void)
88{
89 i2c_register_board_info(0, pb44_i2c_board_info,
90 ARRAY_SIZE(pb44_i2c_board_info));
91 platform_device_register(&pb44_i2c_gpio_device);
Gabor Juhosd8fec1f2011-01-04 21:28:18 +010092
93 ath79_register_leds_gpio(-1, ARRAY_SIZE(pb44_leds_gpio),
94 pb44_leds_gpio);
Gabor Juhos3f348c52011-01-04 21:28:21 +010095 ath79_register_gpio_keys_polled(-1, PB44_KEYS_POLL_INTERVAL,
96 ARRAY_SIZE(pb44_gpio_keys),
97 pb44_gpio_keys);
Gabor Juhos0cde7222011-01-04 21:28:17 +010098}
99
100MIPS_MACHINE(ATH79_MACH_PB44, "PB44", "Atheros PB44 reference board",
101 pb44_init);