MIPS: BCM63XX: prepare for SPI support
v2 cover MIPS: BCM63XX: prepare for SPI support
This patchset adds the required infrastructure to register a Broadcom BCM63XX SPI controller platform device and driver.
Changes since v1:
- fixed typo in spi platform device stub
- folded patch 7 and 8 together
Florian Fainelli (8):
MIPS: BCM63XX: add IRQ_SPI and CPU specific SPI IRQ values
MIPS: BCM63XX: define BCM6358 SPI base address
MIPS: BCM63XX: add BCM6368 SPI clock mask
MIPS: BCM63XX: define RSET_SPI_SIZE
MIPS: BCM63XX: remove SPI2 register
MIPS: BCM63XX: define internal registers offsets of the SPI
controller
MIPS: BCM63XX: add stub to register the SPI platform driver
MIPS: BCM63XX: make board setup code register the spi platform device
arch/mips/bcm63xx/Makefile | 3 +- arch/mips/bcm63xx/boards/board_bcm963xx.c | 3 + arch/mips/bcm63xx/clk.c | 6 +- arch/mips/bcm63xx/dev-spi.c | 117 +++++++++++++++++++ arch/mips/include/asm/mach-bcm63xx/bcm63xx_cpu.h | 20 ++-- .../include/asm/mach-bcm63xx/bcm63xx_dev_spi.h | 89 +++++++++++++++ arch/mips/include/asm/mach-bcm63xx/bcm63xx_regs.h | 120 ++++++++++++++++++++ 7 files changed, 345 insertions(+), 13 deletions(-) create mode 100644 arch/mips/bcm63xx/dev-spi.c create mode 100644 arch/mips/include/asm/mach-bcm63xx/bcm63xx_dev_spi.h
Signature · 1 line
1.7.5.4
PATCH v2 1/8 MIPS: BCM63XX: add IRQ_SPI and CPU specific SPI IRQ values
---
No changes since v1
arch/mips/include/asm/mach-bcm63xx/bcm63xx_cpu.h | 7 +++++++ 1 files changed, 7 insertions(+), 0 deletions(-)
arch/mips/include/asm/mach-bcm63xx/bcm63xx_cpu.h +7 -0
@@ -478,6 +478,7 @@ static inline unsigned long bcm63xx_regset_address(enum bcm63xx_regs_set set)*/ enum bcm63xx_irq {IRQ_TIMER =0 , +IRQ_SPI ,IRQ_UART0 ,IRQ_UART1 ,IRQ_DSL ,
@@ -509,6 +510,7 @@ enum bcm63xx_irq {* 6338 irqs */ #define BCM_6338_TIMER_IRQ (IRQ_INTERNAL_BASE + 0) +#define BCM_6338_SPI_IRQ (IRQ_INTERNAL_BASE + 1)#define BCM_6338_UART0_IRQ (IRQ_INTERNAL_BASE + 2)#define BCM_6338_UART1_IRQ 0#define BCM_6338_DSL_IRQ (IRQ_INTERNAL_BASE + 5)
@@ -539,6 +541,7 @@ enum bcm63xx_irq {* 6345 irqs */ #define BCM_6345_TIMER_IRQ (IRQ_INTERNAL_BASE + 0) +#define BCM_6345_SPI_IRQ 0#define BCM_6345_UART0_IRQ (IRQ_INTERNAL_BASE + 2)#define BCM_6345_UART1_IRQ 0#define BCM_6345_DSL_IRQ (IRQ_INTERNAL_BASE + 3)
@@ -569,6 +572,7 @@ enum bcm63xx_irq {* 6348 irqs */ #define BCM_6348_TIMER_IRQ (IRQ_INTERNAL_BASE + 0) +#define BCM_6348_SPI_IRQ (IRQ_INTERNAL_BASE + 1)#define BCM_6348_UART0_IRQ (IRQ_INTERNAL_BASE + 2)#define BCM_6348_UART1_IRQ 0#define BCM_6348_DSL_IRQ (IRQ_INTERNAL_BASE + 4)
@@ -599,6 +603,7 @@ enum bcm63xx_irq {* 6358 irqs */ #define BCM_6358_TIMER_IRQ (IRQ_INTERNAL_BASE + 0) +#define BCM_6358_SPI_IRQ (IRQ_INTERNAL_BASE + 1)#define BCM_6358_UART0_IRQ (IRQ_INTERNAL_BASE + 2)#define BCM_6358_UART1_IRQ (IRQ_INTERNAL_BASE + 3)#define BCM_6358_DSL_IRQ (IRQ_INTERNAL_BASE + 29)
@@ -638,6 +643,7 @@ enum bcm63xx_irq {#define BCM_6368_HIGH_IRQ_BASE (IRQ_INTERNAL_BASE + 32)#define BCM_6368_TIMER_IRQ (IRQ_INTERNAL_BASE + 0) +#define BCM_6368_SPI_IRQ (IRQ_INTERNAL_BASE + 1)#define BCM_6368_UART0_IRQ (IRQ_INTERNAL_BASE + 2)#define BCM_6368_UART1_IRQ (IRQ_INTERNAL_BASE + 3)#define BCM_6368_DSL_IRQ (IRQ_INTERNAL_BASE + 4)
@@ -677,6 +683,7 @@ extern const int *bcm63xx_irqs;#define __GEN_CPU_IRQ_TABLE (__cpu) \ [IRQ_TIMER] = BCM_## __cpu ##_TIMER_IRQ, \ + [IRQ_SPI] = BCM_## __cpu ##_SPI_IRQ, \ [IRQ_UART0] = BCM_## __cpu ##_UART0_IRQ, \ [IRQ_UART1] = BCM_## __cpu ##_UART1_IRQ, \ [IRQ_DSL] = BCM_## __cpu ##_DSL_IRQ, \
Signature · 1 line
1.7.5.4
PATCH v2 2/8 MIPS: BCM63XX: define BCM6358 SPI base address
In reply to Florian Fainelli---
No changes since v1
arch/mips/include/asm/mach-bcm63xx/bcm63xx_cpu.h | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)
arch/mips/include/asm/mach-bcm63xx/bcm63xx_cpu.h +1 -1
@@ -289,7 +289,7 @@ enum bcm63xx_regs_set {#define BCM_6358_UART0_BASE (0xfffe0100)#define BCM_6358_UART1_BASE (0xfffe0120)#define BCM_6358_GPIO_BASE (0xfffe0080) -#define BCM_6358_SPI_BASE (0xdeadbeef) +#define BCM_6358_SPI_BASE (0xfffe0800)#define BCM_6358_SPI2_BASE (0xfffe0800)#define BCM_6358_UDC0_BASE (0xfffe0800)#define BCM_6358_OHCI0_BASE (0xfffe1400)
Signature · 1 line
1.7.5.4
PATCH v2 3/8 MIPS: BCM63XX: add BCM6368 SPI clock mask
In reply to Florian Fainelli---
No chances since v1
arch/mips/bcm63xx/clk.c | 6 ++++-- 1 files changed, 4 insertions(+), 2 deletions(-)
arch/mips/bcm63xx/clk.c +4 -2
@@ -181,9 +181,11 @@ static void spi_set(struct clk *clk, int enable) mask =CKCTL_6338_SPI_EN ; else if (BCMCPU_IS_6348()) mask =CKCTL_6348_SPI_EN ; - else -/* BCMCPU_IS_6358 */ + else if (BCMCPU_IS_6358()) mask =CKCTL_6358_SPI_EN ; + else +/* BCMCPU_IS_6368 */ + mask =CKCTL_6368_SPI_CLK_EN ;bcm_hwclock_set (mask, enable); }
Signature · 1 line
1.7.5.4
PATCH v2 4/8 MIPS: BCM63XX: define RSET_SPI_SIZE
In reply to Florian Fainelli---
No changes since v1
arch/mips/include/asm/mach-bcm63xx/bcm63xx_cpu.h | 1 + 1 files changed, 1 insertions(+), 0 deletions(-)
arch/mips/include/asm/mach-bcm63xx/bcm63xx_cpu.h +1 -0
@@ -135,6 +135,7 @@ enum bcm63xx_regs_set {#define RSET_DSL_LMEM_SIZE (64 * 1024 * 4)#define RSET_DSL_SIZE 4096#define RSET_WDT_SIZE 12 +#define RSET_SPI_SIZE 256#define RSET_ENET_SIZE 2048#define RSET_ENETDMA_SIZE 2048#define RSET_ENETSW_SIZE 65536
Signature · 1 line
1.7.5.4
PATCH v2 5/8 MIPS: BCM63XX: remove SPI2 register
In reply to Florian FainelliThis register was introduced with the support of the BCM6368 CPU in the idea that its internal layout was different from the other CPUs SPI controller. The controller is actually the same as the one present on BCM6358 so we can remove this register and use the usual SPI register instead.
---
No changes since v1
arch/mips/include/asm/mach-bcm63xx/bcm63xx_cpu.h | 10 +--------- 1 files changed, 1 insertions(+), 9 deletions(-)
arch/mips/include/asm/mach-bcm63xx/bcm63xx_cpu.h +1 -9
@@ -102,7 +102,6 @@ enum bcm63xx_regs_set {RSET_UART1 ,RSET_GPIO ,RSET_SPI , -RSET_SPI2 ,RSET_UDC0 ,RSET_OHCI0 , RSET_OHCI_PRIV,
@@ -163,7 +162,6 @@ enum bcm63xx_regs_set {#define BCM_6338_UART1_BASE (0xdeadbeef)#define BCM_6338_GPIO_BASE (0xfffe0400)#define BCM_6338_SPI_BASE (0xfffe0c00) -#define BCM_6338_SPI2_BASE (0xdeadbeef)#define BCM_6338_UDC0_BASE (0xdeadbeef)#define BCM_6338_USBDMA_BASE (0xfffe2400)#define BCM_6338_OHCI0_BASE (0xdeadbeef)
@@ -207,7 +205,6 @@ enum bcm63xx_regs_set {#define BCM_6345_UART1_BASE (0xdeadbeef)#define BCM_6345_GPIO_BASE (0xfffe0400)#define BCM_6345_SPI_BASE (0xdeadbeef) -#define BCM_6345_SPI2_BASE (0xdeadbeef)#define BCM_6345_UDC0_BASE (0xdeadbeef)#define BCM_6345_USBDMA_BASE (0xfffe2800)#define BCM_6345_ENET0_BASE (0xfffe1800)
@@ -250,7 +247,6 @@ enum bcm63xx_regs_set {#define BCM_6348_UART1_BASE (0xdeadbeef)#define BCM_6348_GPIO_BASE (0xfffe0400)#define BCM_6348_SPI_BASE (0xfffe0c00) -#define BCM_6348_SPI2_BASE (0xdeadbeef)#define BCM_6348_UDC0_BASE (0xfffe1000)#define BCM_6348_OHCI0_BASE (0xfffe1b00)#define BCM_6348_OHCI_PRIV_BASE (0xfffe1c00)
@@ -291,7 +287,6 @@ enum bcm63xx_regs_set {#define BCM_6358_UART1_BASE (0xfffe0120)#define BCM_6358_GPIO_BASE (0xfffe0080)#define BCM_6358_SPI_BASE (0xfffe0800) -#define BCM_6358_SPI2_BASE (0xfffe0800)#define BCM_6358_UDC0_BASE (0xfffe0800)#define BCM_6358_OHCI0_BASE (0xfffe1400)#define BCM_6358_OHCI_PRIV_BASE (0xdeadbeef)
@@ -332,8 +327,7 @@ enum bcm63xx_regs_set {#define BCM_6368_UART0_BASE (0xb0000100)#define BCM_6368_UART1_BASE (0xb0000120)#define BCM_6368_GPIO_BASE (0xb0000080) -#define BCM_6368_SPI_BASE (0xdeadbeef) -#define BCM_6368_SPI2_BASE (0xb0000800) +#define BCM_6368_SPI_BASE (0xb0000800)#define BCM_6368_UDC0_BASE (0xdeadbeef)#define BCM_6368_OHCI0_BASE (0xb0001600)#define BCM_6368_OHCI_PRIV_BASE (0xdeadbeef)
@@ -380,7 +374,6 @@ extern const unsigned long *bcm63xx_regs_base; __GEN_RSET_BASE(__cpu, UART1) \ __GEN_RSET_BASE(__cpu, GPIO) \ __GEN_RSET_BASE(__cpu, SPI) \ - __GEN_RSET_BASE(__cpu, SPI2) \ __GEN_RSET_BASE(__cpu, UDC0) \ __GEN_RSET_BASE(__cpu, OHCI0) \__GEN_RSET_BASE (__cpu,OHCI_PRIV ) \
@@ -419,7 +412,6 @@ extern const unsigned long *bcm63xx_regs_base; [RSET_UART1] = BCM_## __cpu ##_UART1_BASE, \ [RSET_GPIO] = BCM_## __cpu ##_GPIO_BASE, \ [RSET_SPI] = BCM_## __cpu ##_SPI_BASE, \ - [RSET_SPI2] = BCM_## __cpu ##_SPI2_BASE, \ [RSET_UDC0] = BCM_## __cpu ##_UDC0_BASE, \ [RSET_OHCI0] = BCM_## __cpu ##_OHCI0_BASE, \ [RSET_OHCI_PRIV] = BCM_## __cpu ##_OHCI_PRIV_BASE, \
Signature · 1 line
1.7.5.4
PATCH v2 6/8 MIPS: BCM63XX: define internal registers offsets of the SPI controller
In reply to Florian FainelliBCM6338, BCM6348, BCM6358 and BCM6368 basically use the same SPI controller though the internal registers are shuffled, which still allows a common driver to drive that IP block.
---
No changes since v1
arch/mips/include/asm/mach-bcm63xx/bcm63xx_regs.h | 120 +++++++++++++++++++++ 1 files changed, 120 insertions(+), 0 deletions(-)
arch/mips/include/asm/mach-bcm63xx/bcm63xx_regs.h +120 -0
@@ -973,4 +973,124 @@#define M2M_SRCID_REG (x) ((x) * 0x40 + 0x14)#define M2M_DSTID_REG (x) ((x) * 0x40 + 0x18) +/************************************************************************* +* _REG relative to RSET_SPI +*************************************************************************/ + +/* BCM 6338 SPI core */ +#define SPI_6338_CMD 0x00/* 16-bits register */ +#define SPI_6338_INT_STATUS 0x02 +#define SPI_6338_INT_MASK_ST 0x03 +#define SPI_6338_INT_MASK 0x04 +#define SPI_6338_ST 0x05 +#define SPI_6338_CLK_CFG 0x06 +#define SPI_6338_FILL_BYTE 0x07 +#define SPI_6338_MSG_TAIL 0x09 +#define SPI_6338_RX_TAIL 0x0b +#define SPI_6338_MSG_CTL 0x40 +#define SPI_6338_MSG_DATA 0x41 +#define SPI_6338_MSG_DATA_SIZE 0x3f +#define SPI_6338_RX_DATA 0x80 +#define SPI_6338_RX_DATA_SIZE 0x3f + +/* BCM 6348 SPI core */ +#define SPI_6348_CMD 0x00/* 16-bits register */ +#define SPI_6348_INT_STATUS 0x02 +#define SPI_6348_INT_MASK_ST 0x03 +#define SPI_6348_INT_MASK 0x04 +#define SPI_6348_ST 0x05 +#define SPI_6348_CLK_CFG 0x06 +#define SPI_6348_FILL_BYTE 0x07 +#define SPI_6348_MSG_TAIL 0x09 +#define SPI_6348_RX_TAIL 0x0b +#define SPI_6348_MSG_CTL 0x40 +#define SPI_6348_MSG_DATA 0x41 +#define SPI_6348_MSG_DATA_SIZE 0x3f +#define SPI_6348_RX_DATA 0x80 +#define SPI_6348_RX_DATA_SIZE 0x3f + +/* BCM 6358 SPI core */ +#define SPI_6358_MSG_CTL 0x00/* 16-bits register */ +#define SPI_6358_MSG_DATA 0x02 +#define SPI_6358_MSG_DATA_SIZE 0x21e +#define SPI_6358_RX_DATA 0x400 +#define SPI_6358_RX_DATA_SIZE 0x220 +#define SPI_6358_CMD 0x700/* 16-bits register */ +#define SPI_6358_INT_STATUS 0x702 +#define SPI_6358_INT_MASK_ST 0x703 +#define SPI_6358_INT_MASK 0x704 +#define SPI_6358_ST 0x705 +#define SPI_6358_CLK_CFG 0x706 +#define SPI_6358_FILL_BYTE 0x707 +#define SPI_6358_MSG_TAIL 0x709 +#define SPI_6358_RX_TAIL 0x70B + +/* BCM 6358 SPI core */ +#define SPI_6368_MSG_CTL 0x00/* 16-bits register */ +#define SPI_6368_MSG_DATA 0x02 +#define SPI_6368_MSG_DATA_SIZE 0x21e +#define SPI_6368_RX_DATA 0x400 +#define SPI_6368_RX_DATA_SIZE 0x220 +#define SPI_6368_CMD 0x700/* 16-bits register */ +#define SPI_6368_INT_STATUS 0x702 +#define SPI_6368_INT_MASK_ST 0x703 +#define SPI_6368_INT_MASK 0x704 +#define SPI_6368_ST 0x705 +#define SPI_6368_CLK_CFG 0x706 +#define SPI_6368_FILL_BYTE 0x707 +#define SPI_6368_MSG_TAIL 0x709 +#define SPI_6368_RX_TAIL 0x70B + +/* Shared SPI definitions */ + +/* Message configuration */ +#define SPI_FD_RW 0x00 +#define SPI_HD_W 0x01 +#define SPI_HD_R 0x02 +#define SPI_BYTE_CNT_SHIFT 0 +#define SPI_MSG_TYPE_SHIFT 14 + +/* Command */ +#define SPI_CMD_NOOP 0x00 +#define SPI_CMD_SOFT_RESET 0x01 +#define SPI_CMD_HARD_RESET 0x02 +#define SPI_CMD_START_IMMEDIATE 0x03 +#define SPI_CMD_COMMAND_SHIFT 0 +#define SPI_CMD_COMMAND_MASK 0x000f +#define SPI_CMD_DEVICE_ID_SHIFT 4 +#define SPI_CMD_PREPEND_BYTE_CNT_SHIFT 8 +#define SPI_CMD_ONE_BYTE_SHIFT 11 +#define SPI_CMD_ONE_WIRE_SHIFT 12 +#define SPI_DEV_ID_0 0 +#define SPI_DEV_ID_1 1 +#define SPI_DEV_ID_2 2 +#define SPI_DEV_ID_3 3 + +/* Interrupt mask */ +#define SPI_INTR_CMD_DONE 0x01 +#define SPI_INTR_RX_OVERFLOW 0x02 +#define SPI_INTR_TX_UNDERFLOW 0x04 +#define SPI_INTR_TX_OVERFLOW 0x08 +#define SPI_INTR_RX_UNDERFLOW 0x10 +#define SPI_INTR_CLEAR_ALL 0x1f + +/* Status */ +#define SPI_RX_EMPTY 0x02 +#define SPI_CMD_BUSY 0x04 +#define SPI_SERIAL_BUSY 0x08 + +/* Clock configuration */ +#define SPI_CLK_20MHZ 0x00 +#define SPI_CLK_0_391MHZ 0x01 +#define SPI_CLK_0_781MHZ 0x02/* default */ +#define SPI_CLK_1_563MHZ 0x03 +#define SPI_CLK_3_125MHZ 0x04 +#define SPI_CLK_6_250MHZ 0x05 +#define SPI_CLK_12_50MHZ 0x06 +#define SPI_CLK_25MHZ 0x07 +#define SPI_CLK_MASK 0x07 +#define SPI_SSOFFTIME_MASK 0x38 +#define SPI_SSOFFTIME_SHIFT 3 +#define SPI_BYTE_SWAP 0x80 +#endif /* BCM63XX_REGS_H_ */
Signature · 1 line
1.7.5.4
PATCH v2 7/8 MIPS: BCM63XX: add stub to register the SPI platform driver
In reply to Florian FainelliThis patch adds the necessary stub to register the SPI platform driver. Since the registers are shuffled between the 4 BCM63xx CPUs supported by this SPI driver we also need to generate the internal register layout and export this layout for the driver to use it properly.
---
Changes since v1:
- fixed typo in bcm63xx_spi_regs_init()
- folded patch 8 and 7 together
arch/mips/bcm63xx/Makefile | 3 +- arch/mips/bcm63xx/dev-spi.c | 117 ++++++++++++++++++++ .../include/asm/mach-bcm63xx/bcm63xx_dev_spi.h | 89 +++++++++++++++ 3 files changed, 208 insertions(+), 1 deletions(-) create mode 100644 arch/mips/bcm63xx/dev-spi.c create mode 100644 arch/mips/include/asm/mach-bcm63xx/bcm63xx_dev_spi.h
arch/mips/bcm63xx/Makefile +2 -1
@@ -1,5 +1,6 @@ obj-y += clk.o cpu.o cs.o gpio.o irq.o prom.o setup.o timer.o \ - dev-dsp.o dev-enet.o dev-pcmcia.o dev-uart.o dev-wdt.o + dev-dsp.o dev-enet.o dev-pcmcia.o dev-spi.o dev-uart.o \ + dev-wdt.o obj-$(CONFIG_EARLY_PRINTK) += early_printk.o obj-y += boards/
arch/mips/bcm63xx/dev-spi.c new file +117 -0
117 lines not on this page · raw message
arch/mips/include/asm/mach-bcm63xx/bcm63xx_dev_spi.h new file +89 -0
89 lines not on this page · raw message
Signature · 1 line
1.7.5.4
PATCH v2 8/8 MIPS: BCM63XX: make board setup code register the spi platform device
In reply to Florian Fainelli---
No changes since v1
arch/mips/bcm63xx/boards/board_bcm963xx.c | 3 +++ 1 files changed, 3 insertions(+), 0 deletions(-)
arch/mips/bcm63xx/boards/board_bcm963xx.c +3 -0
@@ -25,6 +25,7 @@#include <bcm63xx_dev_enet.h> #include <bcm63xx_dev_dsp.h> #include <bcm63xx_dev_pcmcia.h> +#include <bcm63xx_dev_spi.h> #include <board_bcm963xx.h> #define PFX "board_bcm963xx: "
@@ -887,6 +888,8 @@ int __init board_register_devices(void) }#endif +bcm63xx_spi_register (); +/* read base address of boot chip select (0) */ val =bcm_mpi_readl (MPI_CSBASE_REG (0 )); val &=MPI_CSBASE_BASE_MASK ;
Signature · 1 line
1.7.5.4