kernel: add md5sum for 3.9 final
[openwrt/staging/chunkeey.git] / target / linux / brcm63xx / patches-3.7 / 425-MIPS-BCM63XX-add-HS-SPI-platform-device-and-register.patch
1 From 261ee140e75615351128eee497e6bbd76686784b Mon Sep 17 00:00:00 2001
2 From: Jonas Gorski <jonas.gorski@gmail.com>
3 Date: Sat, 12 Nov 2011 12:18:26 +0100
4 Subject: [PATCH 51/72] MIPS: BCM63XX: add HS SPI platform device and register
5 it
6
7 Signed-off-by: Jonas Gorski <jonas.gorski@gmail.com>
8 ---
9 arch/mips/bcm63xx/Makefile | 4 +-
10 arch/mips/bcm63xx/boards/board_bcm963xx.c | 2 +
11 arch/mips/bcm63xx/dev-hsspi.c | 57 ++++++++++++++++++++
12 .../include/asm/mach-bcm63xx/bcm63xx_dev_hsspi.h | 20 +++++++
13 4 files changed, 81 insertions(+), 2 deletions(-)
14 create mode 100644 arch/mips/bcm63xx/dev-hsspi.c
15 create mode 100644 arch/mips/include/asm/mach-bcm63xx/bcm63xx_dev_hsspi.h
16
17 --- a/arch/mips/bcm63xx/Makefile
18 +++ b/arch/mips/bcm63xx/Makefile
19 @@ -1,7 +1,7 @@
20 obj-y += clk.o cpu.o cs.o gpio.o irq.o nvram.o prom.o reset.o \
21 setup.o timer.o dev-dsp.o dev-enet.o dev-flash.o \
22 - dev-pcmcia.o dev-rng.o dev-spi.o dev-uart.o dev-wdt.o \
23 - dev-usb-ehci.o dev-usb-ohci.o dev-usb-usbd.o
24 + dev-hsspi.o dev-pcmcia.o dev-rng.o dev-spi.o dev-uart.o \
25 + dev-wdt.o dev-usb-ehci.o dev-usb-ohci.o dev-usb-usbd.o
26 obj-$(CONFIG_EARLY_PRINTK) += early_printk.o
27
28 obj-y += boards/
29 --- a/arch/mips/bcm63xx/boards/board_bcm963xx.c
30 +++ b/arch/mips/bcm63xx/boards/board_bcm963xx.c
31 @@ -26,6 +26,7 @@
32 #include <bcm63xx_dev_enet.h>
33 #include <bcm63xx_dev_dsp.h>
34 #include <bcm63xx_dev_flash.h>
35 +#include <bcm63xx_dev_hsspi.h>
36 #include <bcm63xx_dev_pcmcia.h>
37 #include <bcm63xx_dev_spi.h>
38 #include <bcm63xx_dev_usb_ohci.h>
39 @@ -952,6 +953,7 @@ int __init board_register_devices(void)
40 pr_err(PFX "failed to register fallback SPROM\n");
41 }
42 #endif
43 + bcm63xx_hsspi_register();
44
45 bcm63xx_spi_register();
46
47 --- /dev/null
48 +++ b/arch/mips/bcm63xx/dev-hsspi.c
49 @@ -0,0 +1,57 @@
50 +/*
51 + * This file is subject to the terms and conditions of the GNU General Public
52 + * License. See the file "COPYING" in the main directory of this archive
53 + * for more details.
54 + *
55 + * Copyright (C) 2012 Jonas Gorski <jonas.gorski@gmail.com>
56 + */
57 +
58 +#include <linux/init.h>
59 +#include <linux/kernel.h>
60 +#include <linux/platform_device.h>
61 +
62 +#include <bcm63xx_cpu.h>
63 +#include <bcm63xx_dev_hsspi.h>
64 +#include <bcm63xx_regs.h>
65 +
66 +static struct resource spi_resources[] = {
67 + {
68 + .start = -1, /* filled at runtime */
69 + .end = -1, /* filled at runtime */
70 + .flags = IORESOURCE_MEM,
71 + },
72 + {
73 + .start = -1, /* filled at runtime */
74 + .flags = IORESOURCE_IRQ,
75 + },
76 +};
77 +
78 +static struct bcm63xx_hsspi_pdata spi_pdata = {
79 + .bus_num = 0,
80 +};
81 +
82 +static struct platform_device bcm63xx_hsspi_device = {
83 + .name = "bcm63xx-hsspi",
84 + .id = 0,
85 + .num_resources = ARRAY_SIZE(spi_resources),
86 + .resource = spi_resources,
87 + .dev = {
88 + .platform_data = &spi_pdata,
89 + },
90 +};
91 +
92 +int __init bcm63xx_hsspi_register(void)
93 +{
94 +
95 + if (!BCMCPU_IS_6328())
96 + return -ENODEV;
97 +
98 + spi_resources[0].start = bcm63xx_regset_address(RSET_HSSPI);
99 + spi_resources[0].end = spi_resources[0].start;
100 + spi_resources[0].end += RSET_HSSPI_SIZE - 1;
101 + spi_resources[1].start = bcm63xx_get_irq_number(IRQ_HSSPI);
102 +
103 + spi_pdata.speed_hz = HSSPI_PLL_HZ_6328;
104 +
105 + return platform_device_register(&bcm63xx_hsspi_device);
106 +}
107 --- /dev/null
108 +++ b/arch/mips/include/asm/mach-bcm63xx/bcm63xx_dev_hsspi.h
109 @@ -0,0 +1,20 @@
110 +#ifndef BCM63XX_DEV_HSSPI_H
111 +#define BCM63XX_DEV_HSSPI_H
112 +
113 +#include <linux/types.h>
114 +#include <bcm63xx_io.h>
115 +#include <bcm63xx_regs.h>
116 +
117 +int __init bcm63xx_hsspi_register(void);
118 +
119 +struct bcm63xx_hsspi_pdata {
120 + int bus_num;
121 + u32 speed_hz;
122 +};
123 +
124 +#define bcm_hsspi_readl(o) bcm_rset_readl(RSET_HSSPI, (o))
125 +#define bcm_hsspi_writel(v, o) bcm_rset_writel(RSET_HSSPI, (v), (o))
126 +
127 +#define HSSPI_PLL_HZ_6328 133333333
128 +
129 +#endif /* BCM63XX_DEV_HSSPI_H */