Commit 68a1d3163678a42ad2d0a9013672083c4fb613be

Authored by Gabor Juhos
Committed by Ralf Baechle
1 parent 8efaef4dc8

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>

Showing 6 changed files with 84 additions and 0 deletions Side-by-side Diff

arch/mips/ath79/Kconfig
... ... @@ -7,6 +7,7 @@
7 7 select SOC_AR71XX
8 8 select ATH79_DEV_GPIO_BUTTONS
9 9 select ATH79_DEV_LEDS_GPIO
  10 + select ATH79_DEV_SPI
10 11 help
11 12 Say 'Y' here if you want your kernel to support the
12 13 Atheros PB44 reference board.
... ... @@ -26,6 +27,9 @@
26 27 def_bool n
27 28  
28 29 config ATH79_DEV_LEDS_GPIO
  30 + def_bool n
  31 +
  32 +config ATH79_DEV_SPI
29 33 def_bool n
30 34  
31 35 endif
arch/mips/ath79/Makefile
... ... @@ -18,6 +18,7 @@
18 18 obj-y += dev-common.o
19 19 obj-$(CONFIG_ATH79_DEV_GPIO_BUTTONS) += dev-gpio-buttons.o
20 20 obj-$(CONFIG_ATH79_DEV_LEDS_GPIO) += dev-leds-gpio.o
  21 +obj-$(CONFIG_ATH79_DEV_SPI) += dev-spi.o
21 22  
22 23 #
23 24 # Machines
arch/mips/ath79/dev-spi.c
  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 +
  16 +static 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 +
  24 +static 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 +
  31 +void __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 +}
arch/mips/ath79/dev-spi.h
  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 +
  18 +void 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 */
arch/mips/ath79/mach-pb44.c
... ... @@ -17,6 +17,7 @@
17 17 #include "machtypes.h"
18 18 #include "dev-gpio-buttons.h"
19 19 #include "dev-leds-gpio.h"
  20 +#include "dev-spi.h"
20 21  
21 22 #define PB44_GPIO_I2C_SCL 0
22 23 #define PB44_GPIO_I2C_SDA 1
... ... @@ -84,6 +85,20 @@
84 85 }
85 86 };
86 87  
  88 +static 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 +
  97 +static struct ath79_spi_platform_data pb44_spi_data = {
  98 + .bus_num = 0,
  99 + .num_chipselect = 1,
  100 +};
  101 +
87 102 static void __init pb44_init(void)
88 103 {
89 104 i2c_register_board_info(0, pb44_i2c_board_info,
... ... @@ -95,6 +110,8 @@
95 110 ath79_register_gpio_keys_polled(-1, PB44_KEYS_POLL_INTERVAL,
96 111 ARRAY_SIZE(pb44_gpio_keys),
97 112 pb44_gpio_keys);
  113 + ath79_register_spi(&pb44_spi_data, pb44_spi_info,
  114 + ARRAY_SIZE(pb44_spi_info));
98 115 }
99 116  
100 117 MIPS_MACHINE(ATH79_MACH_PB44, "PB44", "Atheros PB44 reference board",
arch/mips/include/asm/mach-ath79/ar71xx_regs.h
... ... @@ -20,6 +20,8 @@
20 20 #include <linux/bitops.h>
21 21  
22 22 #define AR71XX_APB_BASE 0x18000000
  23 +#define AR71XX_SPI_BASE 0x1f000000
  24 +#define AR71XX_SPI_SIZE 0x01000000
23 25  
24 26 #define AR71XX_DDR_CTRL_BASE (AR71XX_APB_BASE + 0x00000000)
25 27 #define AR71XX_DDR_CTRL_SIZE 0x100