blob: 75fb96ca61db7ef6652722640a8d452cbc125d55 [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>
Linus Walleijb2e63552017-09-10 01:30:46 +020014#include <linux/gpio/machine.h>
Wolfram Sangb6480fa2017-05-21 23:57:26 +020015#include <linux/platform_data/pcf857x.h>
Gabor Juhos0cde7222011-01-04 21:28:17 +010016
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 Juhos68a1d312011-01-04 21:28:23 +010020#include "dev-spi.h"
Gabor Juhos7e98aa42011-06-05 23:38:46 +020021#include "dev-usb.h"
Gabor Juhos1f3a92d2012-03-14 10:36:13 +010022#include "pci.h"
Gabor Juhos0cde7222011-01-04 21:28:17 +010023
24#define PB44_GPIO_I2C_SCL 0
25#define PB44_GPIO_I2C_SDA 1
26
27#define PB44_GPIO_EXP_BASE 16
Gabor Juhos3f348c52011-01-04 21:28:21 +010028#define PB44_GPIO_SW_RESET (PB44_GPIO_EXP_BASE + 6)
29#define PB44_GPIO_SW_JUMP (PB44_GPIO_EXP_BASE + 8)
Gabor Juhosd8fec1f2011-01-04 21:28:18 +010030#define PB44_GPIO_LED_JUMP1 (PB44_GPIO_EXP_BASE + 9)
31#define PB44_GPIO_LED_JUMP2 (PB44_GPIO_EXP_BASE + 10)
Gabor Juhos0cde7222011-01-04 21:28:17 +010032
Gabor Juhos3f348c52011-01-04 21:28:21 +010033#define PB44_KEYS_POLL_INTERVAL 20 /* msecs */
34#define PB44_KEYS_DEBOUNCE_INTERVAL (3 * PB44_KEYS_POLL_INTERVAL)
35
Linus Walleijb2e63552017-09-10 01:30:46 +020036static struct gpiod_lookup_table pb44_i2c_gpiod_table = {
Linus Walleij326345f2018-05-26 19:12:51 +020037 .dev_id = "i2c-gpio.0",
Linus Walleijb2e63552017-09-10 01:30:46 +020038 .table = {
39 GPIO_LOOKUP_IDX("ath79-gpio", PB44_GPIO_I2C_SDA,
Linus Walleij4d0ce622017-09-10 23:03:32 +020040 NULL, 0, GPIO_ACTIVE_HIGH | GPIO_OPEN_DRAIN),
Linus Walleijb2e63552017-09-10 01:30:46 +020041 GPIO_LOOKUP_IDX("ath79-gpio", PB44_GPIO_I2C_SCL,
Linus Walleij4d0ce622017-09-10 23:03:32 +020042 NULL, 1, GPIO_ACTIVE_HIGH | GPIO_OPEN_DRAIN),
Linus Walleijb2e63552017-09-10 01:30:46 +020043 },
Gabor Juhos0cde7222011-01-04 21:28:17 +010044};
45
46static struct platform_device pb44_i2c_gpio_device = {
47 .name = "i2c-gpio",
48 .id = 0,
49 .dev = {
Linus Walleijb2e63552017-09-10 01:30:46 +020050 .platform_data = NULL,
Gabor Juhos0cde7222011-01-04 21:28:17 +010051 }
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),
Ralf Baechle70342282013-01-22 12:59:30 +010061 .platform_data = &pb44_pcf857x_data,
Gabor Juhos0cde7222011-01-04 21:28:17 +010062 },
63};
64
Gabor Juhosd8fec1f2011-01-04 21:28:18 +010065static 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
Gabor Juhos3f348c52011-01-04 21:28:21 +010077static 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
Gabor Juhos68a1d312011-01-04 21:28:23 +010095static 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
Gabor Juhos0cde7222011-01-04 21:28:17 +0100109static void __init pb44_init(void)
110{
Linus Walleijb2e63552017-09-10 01:30:46 +0200111 gpiod_add_lookup_table(&pb44_i2c_gpiod_table);
Gabor Juhos0cde7222011-01-04 21:28:17 +0100112 i2c_register_board_info(0, pb44_i2c_board_info,
113 ARRAY_SIZE(pb44_i2c_board_info));
114 platform_device_register(&pb44_i2c_gpio_device);
Gabor Juhosd8fec1f2011-01-04 21:28:18 +0100115
116 ath79_register_leds_gpio(-1, ARRAY_SIZE(pb44_leds_gpio),
117 pb44_leds_gpio);
Gabor Juhos3f348c52011-01-04 21:28:21 +0100118 ath79_register_gpio_keys_polled(-1, PB44_KEYS_POLL_INTERVAL,
119 ARRAY_SIZE(pb44_gpio_keys),
120 pb44_gpio_keys);
Gabor Juhos68a1d312011-01-04 21:28:23 +0100121 ath79_register_spi(&pb44_spi_data, pb44_spi_info,
122 ARRAY_SIZE(pb44_spi_info));
Gabor Juhos7e98aa42011-06-05 23:38:46 +0200123 ath79_register_usb();
Gabor Juhos1f3a92d2012-03-14 10:36:13 +0100124 ath79_register_pci();
Gabor Juhos0cde7222011-01-04 21:28:17 +0100125}
126
127MIPS_MACHINE(ATH79_MACH_PB44, "PB44", "Atheros PB44 reference board",
128 pb44_init);