aboutsummaryrefslogtreecommitdiffstats
path: root/arch/mips
diff options
context:
space:
mode:
authorJonas Gorski <jogo@openwrt.org>2015-10-12 06:24:23 -0400
committerMark Brown <broonie@kernel.org>2015-10-22 12:19:58 -0400
commit44d8fb30941d85800fbde0a1e3454b1fb23c5ecd (patch)
treede2c3968229a73f8cf14fc258f142282a13402d6 /arch/mips
parentf13a5e8a856cda0626da316d853a71952f14b1d7 (diff)
spi/bcm63xx: move register definitions into the driver
Move all register definitions and structs into the driver. This allows us dropping the platform_data struct and drop any arch specific includes. Make use of different device names to identify the version of the block we have. Since we now have full control over the message width, we can drop the size check, which was broken anyway, since it never set ret to any error code. Also since we now have no arch depedendent resources, we can now allow compiling it for any arch, hidden behind COMPILE_TEST. Signed-off-by: Jonas Gorski <jogo@openwrt.org> Signed-off-by: Mark Brown <broonie@kernel.org>
Diffstat (limited to 'arch/mips')
-rw-r--r--arch/mips/bcm63xx/dev-spi.c34
-rw-r--r--arch/mips/include/asm/mach-bcm63xx/bcm63xx_dev_spi.h42
2 files changed, 6 insertions, 70 deletions
diff --git a/arch/mips/bcm63xx/dev-spi.c b/arch/mips/bcm63xx/dev-spi.c
index b21225647e03..232385441e46 100644
--- a/arch/mips/bcm63xx/dev-spi.c
+++ b/arch/mips/bcm63xx/dev-spi.c
@@ -18,29 +18,6 @@
18#include <bcm63xx_dev_spi.h> 18#include <bcm63xx_dev_spi.h>
19#include <bcm63xx_regs.h> 19#include <bcm63xx_regs.h>
20 20
21/*
22 * register offsets
23 */
24static const unsigned long bcm6348_regs_spi[] = {
25 __GEN_SPI_REGS_TABLE(6348)
26};
27
28static const unsigned long bcm6358_regs_spi[] = {
29 __GEN_SPI_REGS_TABLE(6358)
30};
31
32const unsigned long *bcm63xx_regs_spi;
33EXPORT_SYMBOL(bcm63xx_regs_spi);
34
35static __init void bcm63xx_spi_regs_init(void)
36{
37 if (BCMCPU_IS_6338() || BCMCPU_IS_6348())
38 bcm63xx_regs_spi = bcm6348_regs_spi;
39 if (BCMCPU_IS_3368() || BCMCPU_IS_6358() ||
40 BCMCPU_IS_6362() || BCMCPU_IS_6368())
41 bcm63xx_regs_spi = bcm6358_regs_spi;
42}
43
44static struct resource spi_resources[] = { 21static struct resource spi_resources[] = {
45 { 22 {
46 .start = -1, /* filled at runtime */ 23 .start = -1, /* filled at runtime */
@@ -54,7 +31,6 @@ static struct resource spi_resources[] = {
54}; 31};
55 32
56static struct platform_device bcm63xx_spi_device = { 33static struct platform_device bcm63xx_spi_device = {
57 .name = "bcm63xx-spi",
58 .id = -1, 34 .id = -1,
59 .num_resources = ARRAY_SIZE(spi_resources), 35 .num_resources = ARRAY_SIZE(spi_resources),
60 .resource = spi_resources, 36 .resource = spi_resources,
@@ -69,14 +45,16 @@ int __init bcm63xx_spi_register(void)
69 spi_resources[0].end = spi_resources[0].start; 45 spi_resources[0].end = spi_resources[0].start;
70 spi_resources[1].start = bcm63xx_get_irq_number(IRQ_SPI); 46 spi_resources[1].start = bcm63xx_get_irq_number(IRQ_SPI);
71 47
72 if (BCMCPU_IS_6338() || BCMCPU_IS_6348()) 48 if (BCMCPU_IS_6338() || BCMCPU_IS_6348()) {
49 bcm63xx_spi_device.name = "bcm6348-spi",
73 spi_resources[0].end += BCM_6348_RSET_SPI_SIZE - 1; 50 spi_resources[0].end += BCM_6348_RSET_SPI_SIZE - 1;
51 }
74 52
75 if (BCMCPU_IS_3368() || BCMCPU_IS_6358() || BCMCPU_IS_6362() || 53 if (BCMCPU_IS_3368() || BCMCPU_IS_6358() || BCMCPU_IS_6362() ||
76 BCMCPU_IS_6368()) 54 BCMCPU_IS_6368()) {
55 bcm63xx_spi_device.name = "bcm6358-spi",
77 spi_resources[0].end += BCM_6358_RSET_SPI_SIZE - 1; 56 spi_resources[0].end += BCM_6358_RSET_SPI_SIZE - 1;
78 57 }
79 bcm63xx_spi_regs_init();
80 58
81 return platform_device_register(&bcm63xx_spi_device); 59 return platform_device_register(&bcm63xx_spi_device);
82} 60}
diff --git a/arch/mips/include/asm/mach-bcm63xx/bcm63xx_dev_spi.h b/arch/mips/include/asm/mach-bcm63xx/bcm63xx_dev_spi.h
index 1d121fd5b6f5..dd299548860d 100644
--- a/arch/mips/include/asm/mach-bcm63xx/bcm63xx_dev_spi.h
+++ b/arch/mips/include/asm/mach-bcm63xx/bcm63xx_dev_spi.h
@@ -7,46 +7,4 @@
7 7
8int __init bcm63xx_spi_register(void); 8int __init bcm63xx_spi_register(void);
9 9
10enum bcm63xx_regs_spi {
11 SPI_CMD,
12 SPI_INT_STATUS,
13 SPI_INT_MASK_ST,
14 SPI_INT_MASK,
15 SPI_ST,
16 SPI_CLK_CFG,
17 SPI_FILL_BYTE,
18 SPI_MSG_TAIL,
19 SPI_RX_TAIL,
20 SPI_MSG_CTL,
21 SPI_MSG_DATA,
22 SPI_RX_DATA,
23 SPI_MSG_TYPE_SHIFT,
24 SPI_MSG_CTL_WIDTH,
25 SPI_MSG_DATA_SIZE,
26};
27
28#define __GEN_SPI_REGS_TABLE(__cpu) \
29 [SPI_CMD] = SPI_## __cpu ##_CMD, \
30 [SPI_INT_STATUS] = SPI_## __cpu ##_INT_STATUS, \
31 [SPI_INT_MASK_ST] = SPI_## __cpu ##_INT_MASK_ST, \
32 [SPI_INT_MASK] = SPI_## __cpu ##_INT_MASK, \
33 [SPI_ST] = SPI_## __cpu ##_ST, \
34 [SPI_CLK_CFG] = SPI_## __cpu ##_CLK_CFG, \
35 [SPI_FILL_BYTE] = SPI_## __cpu ##_FILL_BYTE, \
36 [SPI_MSG_TAIL] = SPI_## __cpu ##_MSG_TAIL, \
37 [SPI_RX_TAIL] = SPI_## __cpu ##_RX_TAIL, \
38 [SPI_MSG_CTL] = SPI_## __cpu ##_MSG_CTL, \
39 [SPI_MSG_DATA] = SPI_## __cpu ##_MSG_DATA, \
40 [SPI_RX_DATA] = SPI_## __cpu ##_RX_DATA, \
41 [SPI_MSG_TYPE_SHIFT] = SPI_## __cpu ##_MSG_TYPE_SHIFT, \
42 [SPI_MSG_CTL_WIDTH] = SPI_## __cpu ##_MSG_CTL_WIDTH, \
43 [SPI_MSG_DATA_SIZE] = SPI_## __cpu ##_MSG_DATA_SIZE,
44
45static inline unsigned long bcm63xx_spireg(enum bcm63xx_regs_spi reg)
46{
47 extern const unsigned long *bcm63xx_regs_spi;
48
49 return bcm63xx_regs_spi[reg];
50}
51
52#endif /* BCM63XX_DEV_SPI_H */ 10#endif /* BCM63XX_DEV_SPI_H */