1
0
mirror of git://projects.qi-hardware.com/openwrt-xburst.git synced 2025-04-21 12:27:27 +03:00

[brcm63xx] prepare for SPI controller driver

git-svn-id: svn://svn.openwrt.org/openwrt/trunk@14755 3c298f89-4303-0410-b956-a3cf2f4a3e73
This commit is contained in:
florian
2009-03-06 01:15:00 +00:00
parent 493a9bf37a
commit 8bd259b281
5 changed files with 252 additions and 0 deletions

View File

@@ -289,6 +289,120 @@ static inline unsigned long bcm63xx_regset_address(enum bcm63xx_regs_set set)
return 0;
}
/*
* SPI register layout is not compatible
* accross CPU versions but it is software
* compatible
*/
enum bcm63xx_regs_spi {
SPI_CMD,
SPI_INT_STATUS,
SPI_INT_MASK_ST,
SPI_INT_MASK,
SPI_ST,
SPI_CLK_CFG,
SPI_FILL_BYTE,
SPI_MSG_TAIL,
SPI_RX_TAIL,
SPI_MSG_CTL,
SPI_MSG_DATA,
SPI_RX_DATA,
};
extern const unsigned long *bcm63xx_regs_spi;
static inline unsigned long bcm63xx_spireg(enum bcm63xx_regs_spi reg)
{
#ifdef BCMCPU_RUNTIME_DETECT
return bcm63xx_regs_spi[reg];
#else
#ifdef CONFIG_BCM63XX_CPU_6338
switch (reg) {
case SPI_CMD:
return SPI_BCM_6338_SPI_CMD;
case SPI_INT_STATUS:
return SPI_BCM_6338_SPI_INT_STATUS;
case SPI_INT_MASK_ST:
return SPI_BCM_6338_SPI_MASK_INT_ST;
case SPI_INT_MASK:
return SPI_BCM_6338_SPI_INT_MASK;
case SPI_ST:
return SPI_BCM_6338_SPI_ST;
case SPI_CLK_CFG:
return SPI_BCM_6338_SPI_CLK_CFG;
case SPI_FILL_BYTE:
return SPI_BCM_6338_SPI_FILL_BYTE;
case SPI_MSG_TAIL:
return SPI_BCM_6338_SPI_MSG_TAIL;
case SPI_RX_TAIL:
return SPI_BCM_6338_SPI_RX_TAIL;
case SPI_MSG_CTL:
return SPI_BCM_6338_SPI_MSG_CTL;
case SPI_MSG_DATA:
return SPI_BCM_6338_SPI_MSG_DATA;
case SPI_RX_DATA:
return SPI_BCM_6338_SPI_RX_DATA;
}
#endif
#ifdef CONFIG_BCM63XX_CPU_6348
switch (reg) {
case SPI_CMD:
return SPI_BCM_6348_SPI_CMD;
case SPI_INT_MASK_ST:
return SPI_BCM_6348_SPI_MASK_INT_ST;
case SPI_INT_STATUS:
return SPI_BCM_6348_SPI_INT_STATUS;
case SPI_ST:
return SPI_BCM_6348_SPI_ST;
case SPI_CLK_CFG:
return SPI_BCM_6348_SPI_CLK_CFG;
case SPI_FILL_BYTE:
return SPI_BCM_6348_SPI_FILL_BYTE;
case SPI_MSG_TAIL:
return SPI_BCM_6348_SPI_MSG_TAIL;
case SPI_RX_TAIL:
return SPI_BCM_6348_SPI_RX_TAIL;
case SPI_MSG_CTL:
return SPI_BCM_6348_SPI_MSG_CTL;
case SPI_MSG_DATA:
return SPI_BCM_6348_SPI_MSG_DATA;
case SPI_BCM_6348_SPI_RX_DATA:
return SPI_BCM_6348_SPI_RX_DATA;
}
#endif
#ifdef CONFIG_BCM63XX_CPU_6358
switch (reg) {
case SPI_CMD:
return SPI_BCM_6358_SPI_CMD;
case SPI_INT_STATUS:
return SPI_BCM_6358_SPI_INT_STATUS;
case SPI_INT_MASK_ST:
return SPI_BCM_6358_SPI_MASK_INT_ST;
case SPI_INT_MASK:
return SPI_BCM_6358_SPI_INT_MASK;
case SPI_ST:
return SPI_BCM_6358_SPI_STATUS;
case SPI_CLK_CFG:
return SPI_BCM_6358_SPI_CLK_CFG;
case SPI_FILL_BYTE:
return SPI_BCM_6358_SPI_FILL_BYTE;
case SPI_MSG_TAIL:
return SPI_BCM_6358_SPI_MSG_TAIL;
case SPI_RX_TAIL:
return SPI_BCM_6358_SPI_RX_TAIL;
case SPI_MSG_CTL:
return SPI_BCM_6358_MSG_CTL;
case SPI_MSG_DATA:
return SPI_BCM_6358_SPI_MSG_DATA;
case SPI_RX_DATA:
return SPI_BCM_6358_SPI_RX_FIFO;
}
#endif
#endif
return 0;
}
/*
* IRQ number changes across CPU too
*/

View File

@@ -0,0 +1,16 @@
#ifndef BCM63XX_DEV_SPI_H
#define BCM63XX_DEV_SPI_H
#include <linux/types.h>
int bcm63xx_spi_register(void);
struct bcm63xx_spi_pdata {
unsigned int msg_fifo_size;
unsigned int rx_fifo_size;
int bus_num;
int num_chipselect;
u32 speed_hz;
};
#endif /* BCM63XX_DEV_SPI_H */

View File

@@ -65,6 +65,12 @@
bcm63xx_regset_address(s) + (o))
#define bcm_rset_writel(s,v,o) bcm_writel((v), \
bcm63xx_regset_address(s) + (o))
#define bcm_reg_spi_readb(s,o) bcm_readb(bcm63xx_spireg(s) + (o))
#define bcm_reg_spi_readw(s,o) bcm_readw(bcm63xx_spireg(s) + (o))
#define bcm_reg_spi_writeb(s,v,o) bcm_writeb((v), \
bcm63xx_spireg(s) + (o))
#define bcm_reg_spi_writew(s,v,o) bcm_writew((v), \
bcm63xx_spireg(s) + (o))
/*
* helpers for frequently used register sets
@@ -89,5 +95,9 @@
#define bcm_memc_writel(v,o) bcm_rset_writel(RSET_MEMC, (v), (o))
#define bcm_ddr_readl(o) bcm_rset_readl(RSET_DDR, (o))
#define bcm_ddr_writel(v,o) bcm_rset_writel(RSET_DDR, (v), (o))
#define bcm_spi_readb(o) bcm_reg_spi_readb(RSET_SPI, (o))
#define bcm_spi_readw(o) bcm_reg_spi_readw(RSET_SPI, (o))
#define bcm_spi_writeb(v,o) bcm_reg_spi_writeb(RSET_SPI, (v), (o))
#define bcm_spi_writew(v,o) bcm_reg_spi_writew(RSET_SPI, (v), (o))
#endif /* ! BCM63XX_IO_H_ */