1 #ifndef BCM63XX_DEV_SPI_H 2 #define BCM63XX_DEV_SPI_H 3 4 #include <linux/types.h> 5 #include <bcm63xx_io.h> 6 #include <bcm63xx_regs.h> 7 8 int __init bcm63xx_spi_register(void); 9 10 struct 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 18 enum bcm63xx_regs_spi { 19 SPI_CMD, 20 SPI_INT_STATUS, 21 SPI_INT_MASK_ST, 22 SPI_INT_MASK, 23 SPI_ST, 24 SPI_CLK_CFG, 25 SPI_FILL_BYTE, 26 SPI_MSG_TAIL, 27 SPI_RX_TAIL, 28 SPI_MSG_CTL, 29 SPI_MSG_DATA, 30 SPI_RX_DATA, 31 }; 32 33 #define __GEN_SPI_RSET_BASE(__cpu, __rset) \ 34 case SPI_## __rset: \ 35 return SPI_## __cpu ##_## __rset; 36 37 #define __GEN_SPI_RSET(__cpu) \ 38 switch (reg) { \ 39 __GEN_SPI_RSET_BASE(__cpu, CMD) \ 40 __GEN_SPI_RSET_BASE(__cpu, INT_STATUS) \ 41 __GEN_SPI_RSET_BASE(__cpu, INT_MASK_ST) \ 42 __GEN_SPI_RSET_BASE(__cpu, INT_MASK) \ 43 __GEN_SPI_RSET_BASE(__cpu, ST) \ 44 __GEN_SPI_RSET_BASE(__cpu, CLK_CFG) \ 45 __GEN_SPI_RSET_BASE(__cpu, FILL_BYTE) \ 46 __GEN_SPI_RSET_BASE(__cpu, MSG_TAIL) \ 47 __GEN_SPI_RSET_BASE(__cpu, RX_TAIL) \ 48 __GEN_SPI_RSET_BASE(__cpu, MSG_CTL) \ 49 __GEN_SPI_RSET_BASE(__cpu, MSG_DATA) \ 50 __GEN_SPI_RSET_BASE(__cpu, RX_DATA) \ 51 } 52 53 #define __GEN_SPI_REGS_TABLE(__cpu) \ 54 [SPI_CMD] = SPI_## __cpu ##_CMD, \ 55 [SPI_INT_STATUS] = SPI_## __cpu ##_INT_STATUS, \ 56 [SPI_INT_MASK_ST] = SPI_## __cpu ##_INT_MASK_ST, \ 57 [SPI_INT_MASK] = SPI_## __cpu ##_INT_MASK, \ 58 [SPI_ST] = SPI_## __cpu ##_ST, \ 59 [SPI_CLK_CFG] = SPI_## __cpu ##_CLK_CFG, \ 60 [SPI_FILL_BYTE] = SPI_## __cpu ##_FILL_BYTE, \ 61 [SPI_MSG_TAIL] = SPI_## __cpu ##_MSG_TAIL, \ 62 [SPI_RX_TAIL] = SPI_## __cpu ##_RX_TAIL, \ 63 [SPI_MSG_CTL] = SPI_## __cpu ##_MSG_CTL, \ 64 [SPI_MSG_DATA] = SPI_## __cpu ##_MSG_DATA, \ 65 [SPI_RX_DATA] = SPI_## __cpu ##_RX_DATA, 66 67 static inline unsigned long bcm63xx_spireg(enum bcm63xx_regs_spi reg) 68 { 69 #ifdef BCMCPU_RUNTIME_DETECT 70 extern const unsigned long *bcm63xx_regs_spi; 71 72 return bcm63xx_regs_spi[reg]; 73 #else 74 #if defined(CONFIG_BCM63XX_CPU_6338) || defined(CONFIG_BCM63XX_CPU_6348) 75 __GEN_SPI_RSET(6348) 76 #endif 77 #if defined(CONFIG_BCM63XX_CPU_6358) || defined(CONFIG_BCM63XX_CPU_6362) || \ 78 defined(CONFIG_BCM63XX_CPU_6368) 79 __GEN_SPI_RSET(6358) 80 #endif 81 #endif 82 return 0; 83 } 84 85 #endif /* BCM63XX_DEV_SPI_H */ 86