aboutsummaryrefslogtreecommitdiffstats
path: root/arch/mips/ath79
diff options
context:
space:
mode:
authorGabor Juhos <juhosg@openwrt.org>2011-01-04 15:28:23 -0500
committerRalf Baechle <ralf@linux-mips.org>2011-01-18 13:30:27 -0500
commit68a1d3163678a42ad2d0a9013672083c4fb613be (patch)
treeac653355ea8030195c4edd606fa1b31c7f4a8a75 /arch/mips/ath79
parent8efaef4dc842a8a050d10aef30e26220b8995fc3 (diff)
MIPS: ath79: add common SPI controller device
Several boards are using the built-in SPI controller of the AR71XX/AR724X/AR913X SoCs. This patch adds common platform_device and helper code to register it. Additionally, the patch registers the SPI bus on the PB44 board. Signed-off-by: Gabor Juhos <juhosg@openwrt.org> Cc: linux-mips@linux-mips.org Cc: Imre Kaloz <kaloz@openwrt.org> Cc: Luis R. Rodriguez <lrodriguez@atheros.com> Cc: Cliff Holden <Cliff.Holden@Atheros.com> Cc: Kathy Giori <Kathy.Giori@Atheros.com> Patchwork: https://patchwork.linux-mips.org/patch/1956/ Signed-off-by: Ralf Baechle <ralf@linux-mips.org>
Diffstat (limited to 'arch/mips/ath79')
-rw-r--r--arch/mips/ath79/Kconfig4
-rw-r--r--arch/mips/ath79/Makefile1
-rw-r--r--arch/mips/ath79/dev-spi.c38
-rw-r--r--arch/mips/ath79/dev-spi.h22
-rw-r--r--arch/mips/ath79/mach-pb44.c17
5 files changed, 82 insertions, 0 deletions
diff --git a/arch/mips/ath79/Kconfig b/arch/mips/ath79/Kconfig
index 185a8d6c73de..cd6c738a916c 100644
--- a/arch/mips/ath79/Kconfig
+++ b/arch/mips/ath79/Kconfig
@@ -7,6 +7,7 @@ config ATH79_MACH_PB44
7 select SOC_AR71XX 7 select SOC_AR71XX
8 select ATH79_DEV_GPIO_BUTTONS 8 select ATH79_DEV_GPIO_BUTTONS
9 select ATH79_DEV_LEDS_GPIO 9 select ATH79_DEV_LEDS_GPIO
10 select ATH79_DEV_SPI
10 help 11 help
11 Say 'Y' here if you want your kernel to support the 12 Say 'Y' here if you want your kernel to support the
12 Atheros PB44 reference board. 13 Atheros PB44 reference board.
@@ -28,4 +29,7 @@ config ATH79_DEV_GPIO_BUTTONS
28config ATH79_DEV_LEDS_GPIO 29config ATH79_DEV_LEDS_GPIO
29 def_bool n 30 def_bool n
30 31
32config ATH79_DEV_SPI
33 def_bool n
34
31endif 35endif
diff --git a/arch/mips/ath79/Makefile b/arch/mips/ath79/Makefile
index 344e9ab1e106..42f4295e650a 100644
--- a/arch/mips/ath79/Makefile
+++ b/arch/mips/ath79/Makefile
@@ -18,6 +18,7 @@ obj-$(CONFIG_EARLY_PRINTK) += early_printk.o
18obj-y += dev-common.o 18obj-y += dev-common.o
19obj-$(CONFIG_ATH79_DEV_GPIO_BUTTONS) += dev-gpio-buttons.o 19obj-$(CONFIG_ATH79_DEV_GPIO_BUTTONS) += dev-gpio-buttons.o
20obj-$(CONFIG_ATH79_DEV_LEDS_GPIO) += dev-leds-gpio.o 20obj-$(CONFIG_ATH79_DEV_LEDS_GPIO) += dev-leds-gpio.o
21obj-$(CONFIG_ATH79_DEV_SPI) += dev-spi.o
21 22
22# 23#
23# Machines 24# Machines
diff --git a/arch/mips/ath79/dev-spi.c b/arch/mips/ath79/dev-spi.c
new file mode 100644
index 000000000000..aa30163efbfd
--- /dev/null
+++ b/arch/mips/ath79/dev-spi.c
@@ -0,0 +1,38 @@
1/*
2 * Atheros AR71XX/AR724X/AR913X SPI controller device
3 *
4 * Copyright (C) 2008-2010 Gabor Juhos <juhosg@openwrt.org>
5 * Copyright (C) 2008 Imre Kaloz <kaloz@openwrt.org>
6 *
7 * This program is free software; you can redistribute it and/or modify it
8 * under the terms of the GNU General Public License version 2 as published
9 * by the Free Software Foundation.
10 */
11
12#include <linux/platform_device.h>
13#include <asm/mach-ath79/ar71xx_regs.h>
14#include "dev-spi.h"
15
16static struct resource ath79_spi_resources[] = {
17 {
18 .start = AR71XX_SPI_BASE,
19 .end = AR71XX_SPI_BASE + AR71XX_SPI_SIZE - 1,
20 .flags = IORESOURCE_MEM,
21 },
22};
23
24static struct platform_device ath79_spi_device = {
25 .name = "ath79-spi",
26 .id = -1,
27 .resource = ath79_spi_resources,
28 .num_resources = ARRAY_SIZE(ath79_spi_resources),
29};
30
31void __init ath79_register_spi(struct ath79_spi_platform_data *pdata,
32 struct spi_board_info const *info,
33 unsigned n)
34{
35 spi_register_board_info(info, n);
36 ath79_spi_device.dev.platform_data = pdata;
37 platform_device_register(&ath79_spi_device);
38}
diff --git a/arch/mips/ath79/dev-spi.h b/arch/mips/ath79/dev-spi.h
new file mode 100644
index 000000000000..d732565ca736
--- /dev/null
+++ b/arch/mips/ath79/dev-spi.h
@@ -0,0 +1,22 @@
1/*
2 * Atheros AR71XX/AR724X/AR913X SPI controller device
3 *
4 * Copyright (C) 2008-2010 Gabor Juhos <juhosg@openwrt.org>
5 * Copyright (C) 2008 Imre Kaloz <kaloz@openwrt.org>
6 *
7 * This program is free software; you can redistribute it and/or modify it
8 * under the terms of the GNU General Public License version 2 as published
9 * by the Free Software Foundation.
10 */
11
12#ifndef _ATH79_DEV_SPI_H
13#define _ATH79_DEV_SPI_H
14
15#include <linux/spi/spi.h>
16#include <asm/mach-ath79/ath79_spi_platform.h>
17
18void ath79_register_spi(struct ath79_spi_platform_data *pdata,
19 struct spi_board_info const *info,
20 unsigned n);
21
22#endif /* _ATH79_DEV_SPI_H */
diff --git a/arch/mips/ath79/mach-pb44.c b/arch/mips/ath79/mach-pb44.c
index 3dc5080185cb..ec7b7a135d53 100644
--- a/arch/mips/ath79/mach-pb44.c
+++ b/arch/mips/ath79/mach-pb44.c
@@ -17,6 +17,7 @@
17#include "machtypes.h" 17#include "machtypes.h"
18#include "dev-gpio-buttons.h" 18#include "dev-gpio-buttons.h"
19#include "dev-leds-gpio.h" 19#include "dev-leds-gpio.h"
20#include "dev-spi.h"
20 21
21#define PB44_GPIO_I2C_SCL 0 22#define PB44_GPIO_I2C_SCL 0
22#define PB44_GPIO_I2C_SDA 1 23#define PB44_GPIO_I2C_SDA 1
@@ -84,6 +85,20 @@ static struct gpio_keys_button pb44_gpio_keys[] __initdata = {
84 } 85 }
85}; 86};
86 87
88static struct spi_board_info pb44_spi_info[] = {
89 {
90 .bus_num = 0,
91 .chip_select = 0,
92 .max_speed_hz = 25000000,
93 .modalias = "m25p64",
94 },
95};
96
97static struct ath79_spi_platform_data pb44_spi_data = {
98 .bus_num = 0,
99 .num_chipselect = 1,
100};
101
87static void __init pb44_init(void) 102static void __init pb44_init(void)
88{ 103{
89 i2c_register_board_info(0, pb44_i2c_board_info, 104 i2c_register_board_info(0, pb44_i2c_board_info,
@@ -95,6 +110,8 @@ static void __init pb44_init(void)
95 ath79_register_gpio_keys_polled(-1, PB44_KEYS_POLL_INTERVAL, 110 ath79_register_gpio_keys_polled(-1, PB44_KEYS_POLL_INTERVAL,
96 ARRAY_SIZE(pb44_gpio_keys), 111 ARRAY_SIZE(pb44_gpio_keys),
97 pb44_gpio_keys); 112 pb44_gpio_keys);
113 ath79_register_spi(&pb44_spi_data, pb44_spi_info,
114 ARRAY_SIZE(pb44_spi_info));
98} 115}
99 116
100MIPS_MACHINE(ATH79_MACH_PB44, "PB44", "Atheros PB44 reference board", 117MIPS_MACHINE(ATH79_MACH_PB44, "PB44", "Atheros PB44 reference board",