aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJonas Gorski <jogo@openwrt.org>2015-10-12 06:24:22 -0400
committerMark Brown <broonie@kernel.org>2015-10-12 12:24:33 -0400
commitf13a5e8a856cda0626da316d853a71952f14b1d7 (patch)
treecb441fbc4ed4f4dac1feaf071fee66084c01a0c8
parent682b5280bf00c0618606ecb26cf4a9342d5e282e (diff)
spi/bcm63xx: move message control word description to register offsets
Make the message control word parameters part of the register offsets array so we have them all in one struct. Signed-off-by: Jonas Gorski <jogo@openwrt.org> Signed-off-by: Mark Brown <broonie@kernel.org>
-rw-r--r--arch/mips/bcm63xx/dev-spi.c20
-rw-r--r--arch/mips/include/asm/mach-bcm63xx/bcm63xx_dev_spi.h16
-rw-r--r--drivers/spi/spi-bcm63xx.c7
3 files changed, 12 insertions, 31 deletions
diff --git a/arch/mips/bcm63xx/dev-spi.c b/arch/mips/bcm63xx/dev-spi.c
index ad448e41e3bd..b21225647e03 100644
--- a/arch/mips/bcm63xx/dev-spi.c
+++ b/arch/mips/bcm63xx/dev-spi.c
@@ -53,19 +53,11 @@ static struct resource spi_resources[] = {
53 }, 53 },
54}; 54};
55 55
56static struct bcm63xx_spi_pdata spi_pdata = {
57 .bus_num = 0,
58 .num_chipselect = 8,
59};
60
61static struct platform_device bcm63xx_spi_device = { 56static struct platform_device bcm63xx_spi_device = {
62 .name = "bcm63xx-spi", 57 .name = "bcm63xx-spi",
63 .id = -1, 58 .id = -1,
64 .num_resources = ARRAY_SIZE(spi_resources), 59 .num_resources = ARRAY_SIZE(spi_resources),
65 .resource = spi_resources, 60 .resource = spi_resources,
66 .dev = {
67 .platform_data = &spi_pdata,
68 },
69}; 61};
70 62
71int __init bcm63xx_spi_register(void) 63int __init bcm63xx_spi_register(void)
@@ -77,20 +69,12 @@ int __init bcm63xx_spi_register(void)
77 spi_resources[0].end = spi_resources[0].start; 69 spi_resources[0].end = spi_resources[0].start;
78 spi_resources[1].start = bcm63xx_get_irq_number(IRQ_SPI); 70 spi_resources[1].start = bcm63xx_get_irq_number(IRQ_SPI);
79 71
80 if (BCMCPU_IS_6338() || BCMCPU_IS_6348()) { 72 if (BCMCPU_IS_6338() || BCMCPU_IS_6348())
81 spi_resources[0].end += BCM_6348_RSET_SPI_SIZE - 1; 73 spi_resources[0].end += BCM_6348_RSET_SPI_SIZE - 1;
82 spi_pdata.fifo_size = SPI_6348_MSG_DATA_SIZE;
83 spi_pdata.msg_type_shift = SPI_6348_MSG_TYPE_SHIFT;
84 spi_pdata.msg_ctl_width = SPI_6348_MSG_CTL_WIDTH;
85 }
86 74
87 if (BCMCPU_IS_3368() || BCMCPU_IS_6358() || BCMCPU_IS_6362() || 75 if (BCMCPU_IS_3368() || BCMCPU_IS_6358() || BCMCPU_IS_6362() ||
88 BCMCPU_IS_6368()) { 76 BCMCPU_IS_6368())
89 spi_resources[0].end += BCM_6358_RSET_SPI_SIZE - 1; 77 spi_resources[0].end += BCM_6358_RSET_SPI_SIZE - 1;
90 spi_pdata.fifo_size = SPI_6358_MSG_DATA_SIZE;
91 spi_pdata.msg_type_shift = SPI_6358_MSG_TYPE_SHIFT;
92 spi_pdata.msg_ctl_width = SPI_6358_MSG_CTL_WIDTH;
93 }
94 78
95 bcm63xx_spi_regs_init(); 79 bcm63xx_spi_regs_init();
96 80
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 25737655d141..1d121fd5b6f5 100644
--- a/arch/mips/include/asm/mach-bcm63xx/bcm63xx_dev_spi.h
+++ b/arch/mips/include/asm/mach-bcm63xx/bcm63xx_dev_spi.h
@@ -7,14 +7,6 @@
7 7
8int __init bcm63xx_spi_register(void); 8int __init bcm63xx_spi_register(void);
9 9
10struct bcm63xx_spi_pdata {
11 unsigned int fifo_size;
12 unsigned int msg_type_shift;
13 unsigned int msg_ctl_width;
14 int bus_num;
15 int num_chipselect;
16};
17
18enum bcm63xx_regs_spi { 10enum bcm63xx_regs_spi {
19 SPI_CMD, 11 SPI_CMD,
20 SPI_INT_STATUS, 12 SPI_INT_STATUS,
@@ -28,6 +20,9 @@ enum bcm63xx_regs_spi {
28 SPI_MSG_CTL, 20 SPI_MSG_CTL,
29 SPI_MSG_DATA, 21 SPI_MSG_DATA,
30 SPI_RX_DATA, 22 SPI_RX_DATA,
23 SPI_MSG_TYPE_SHIFT,
24 SPI_MSG_CTL_WIDTH,
25 SPI_MSG_DATA_SIZE,
31}; 26};
32 27
33#define __GEN_SPI_REGS_TABLE(__cpu) \ 28#define __GEN_SPI_REGS_TABLE(__cpu) \
@@ -42,7 +37,10 @@ enum bcm63xx_regs_spi {
42 [SPI_RX_TAIL] = SPI_## __cpu ##_RX_TAIL, \ 37 [SPI_RX_TAIL] = SPI_## __cpu ##_RX_TAIL, \
43 [SPI_MSG_CTL] = SPI_## __cpu ##_MSG_CTL, \ 38 [SPI_MSG_CTL] = SPI_## __cpu ##_MSG_CTL, \
44 [SPI_MSG_DATA] = SPI_## __cpu ##_MSG_DATA, \ 39 [SPI_MSG_DATA] = SPI_## __cpu ##_MSG_DATA, \
45 [SPI_RX_DATA] = SPI_## __cpu ##_RX_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,
46 44
47static inline unsigned long bcm63xx_spireg(enum bcm63xx_regs_spi reg) 45static inline unsigned long bcm63xx_spireg(enum bcm63xx_regs_spi reg)
48{ 46{
diff --git a/drivers/spi/spi-bcm63xx.c b/drivers/spi/spi-bcm63xx.c
index 461891fbc198..b3da04494fa9 100644
--- a/drivers/spi/spi-bcm63xx.c
+++ b/drivers/spi/spi-bcm63xx.c
@@ -329,7 +329,6 @@ static int bcm63xx_spi_probe(struct platform_device *pdev)
329{ 329{
330 struct resource *r; 330 struct resource *r;
331 struct device *dev = &pdev->dev; 331 struct device *dev = &pdev->dev;
332 struct bcm63xx_spi_pdata *pdata = dev_get_platdata(&pdev->dev);
333 int irq; 332 int irq;
334 struct spi_master *master; 333 struct spi_master *master;
335 struct clk *clk; 334 struct clk *clk;
@@ -369,7 +368,7 @@ static int bcm63xx_spi_probe(struct platform_device *pdev)
369 368
370 bs->irq = irq; 369 bs->irq = irq;
371 bs->clk = clk; 370 bs->clk = clk;
372 bs->fifo_size = pdata->fifo_size; 371 bs->fifo_size = bcm63xx_spireg(SPI_MSG_DATA_SIZE);
373 372
374 ret = devm_request_irq(&pdev->dev, irq, bcm63xx_spi_interrupt, 0, 373 ret = devm_request_irq(&pdev->dev, irq, bcm63xx_spi_interrupt, 0,
375 pdev->name, master); 374 pdev->name, master);
@@ -384,8 +383,8 @@ static int bcm63xx_spi_probe(struct platform_device *pdev)
384 master->mode_bits = MODEBITS; 383 master->mode_bits = MODEBITS;
385 master->bits_per_word_mask = SPI_BPW_MASK(8); 384 master->bits_per_word_mask = SPI_BPW_MASK(8);
386 master->auto_runtime_pm = true; 385 master->auto_runtime_pm = true;
387 bs->msg_type_shift = pdata->msg_type_shift; 386 bs->msg_type_shift = bcm63xx_spireg(SPI_MSG_TYPE_SHIFT);
388 bs->msg_ctl_width = pdata->msg_ctl_width; 387 bs->msg_ctl_width = bcm63xx_spireg(SPI_MSG_CTL_WIDTH);
389 bs->tx_io = (u8 *)(bs->regs + bcm63xx_spireg(SPI_MSG_DATA)); 388 bs->tx_io = (u8 *)(bs->regs + bcm63xx_spireg(SPI_MSG_DATA));
390 bs->rx_io = (const u8 *)(bs->regs + bcm63xx_spireg(SPI_RX_DATA)); 389 bs->rx_io = (const u8 *)(bs->regs + bcm63xx_spireg(SPI_RX_DATA));
391 390