Root/target/linux/brcm63xx/patches-3.6/425-MIPS-BCM63XX-add-HS-SPI-platform-device-and-register.patch

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

Archive Download this file



interactive