Skip to content

Commit 8a398d7

Browse files
KanjiMonsterralfbaechle
authored andcommitted
MIPS: BCM63XX: remove duplicate spi register definitions
BCM6338 and BCM6348, and BCM6358 and everything after that share the same register layout. To not have to redefine them for each new chip and keep the code size small, only use the definitions for the first chip with the certain layout. Signed-off-by: Jonas Gorski <jogo@openwrt.org> Patchwork: http://patchwork.linux-mips.org/patch/5006/ Acked-by: John Crispin <blogic@openwrt.org>
1 parent 41ef2d5 commit 8a398d7

3 files changed

Lines changed: 10 additions & 64 deletions

File tree

‎arch/mips/bcm63xx/dev-spi.c‎

Lines changed: 6 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,6 @@
2222
/*
2323
* register offsets
2424
*/
25-
static const unsigned long bcm6338_regs_spi[] = {
26-
__GEN_SPI_REGS_TABLE(6338)
27-
};
28-
2925
static const unsigned long bcm6348_regs_spi[] = {
3026
__GEN_SPI_REGS_TABLE(6348)
3127
};
@@ -34,23 +30,15 @@ static const unsigned long bcm6358_regs_spi[] = {
3430
__GEN_SPI_REGS_TABLE(6358)
3531
};
3632

37-
static const unsigned long bcm6368_regs_spi[] = {
38-
__GEN_SPI_REGS_TABLE(6368)
39-
};
40-
4133
const unsigned long *bcm63xx_regs_spi;
4234
EXPORT_SYMBOL(bcm63xx_regs_spi);
4335

4436
static __init void bcm63xx_spi_regs_init(void)
4537
{
46-
if (BCMCPU_IS_6338())
47-
bcm63xx_regs_spi = bcm6338_regs_spi;
48-
if (BCMCPU_IS_6348())
38+
if (BCMCPU_IS_6338() || BCMCPU_IS_6348())
4939
bcm63xx_regs_spi = bcm6348_regs_spi;
50-
if (BCMCPU_IS_6358())
40+
if (BCMCPU_IS_6358() || BCMCPU_IS_6368())
5141
bcm63xx_regs_spi = bcm6358_regs_spi;
52-
if (BCMCPU_IS_6368())
53-
bcm63xx_regs_spi = bcm6368_regs_spi;
5442
}
5543
#else
5644
static __init void bcm63xx_spi_regs_init(void) { }
@@ -104,10 +92,10 @@ int __init bcm63xx_spi_register(void)
10492
spi_resources[1].start = bcm63xx_get_irq_number(IRQ_SPI);
10593

10694
if (BCMCPU_IS_6338() || BCMCPU_IS_6348()) {
107-
spi_resources[0].end += BCM_6338_RSET_SPI_SIZE - 1;
108-
spi_pdata.fifo_size = SPI_6338_MSG_DATA_SIZE;
109-
spi_pdata.msg_type_shift = SPI_6338_MSG_TYPE_SHIFT;
110-
spi_pdata.msg_ctl_width = SPI_6338_MSG_CTL_WIDTH;
95+
spi_resources[0].end += BCM_6348_RSET_SPI_SIZE - 1;
96+
spi_pdata.fifo_size = SPI_6348_MSG_DATA_SIZE;
97+
spi_pdata.msg_type_shift = SPI_6348_MSG_TYPE_SHIFT;
98+
spi_pdata.msg_ctl_width = SPI_6348_MSG_CTL_WIDTH;
11199
}
112100

113101
if (BCMCPU_IS_6358() || BCMCPU_IS_6368()) {

‎arch/mips/include/asm/mach-bcm63xx/bcm63xx_dev_spi.h‎

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -72,18 +72,12 @@ static inline unsigned long bcm63xx_spireg(enum bcm63xx_regs_spi reg)
7272

7373
return bcm63xx_regs_spi[reg];
7474
#else
75-
#ifdef CONFIG_BCM63XX_CPU_6338
76-
__GEN_SPI_RSET(6338)
77-
#endif
78-
#ifdef CONFIG_BCM63XX_CPU_6348
75+
#if defined(CONFIG_BCM63XX_CPU_6338) || defined(CONFIG_BCM63XX_CPU_6348)
7976
__GEN_SPI_RSET(6348)
8077
#endif
81-
#ifdef CONFIG_BCM63XX_CPU_6358
78+
#if defined(CONFIG_BCM63XX_CPU_6358) || defined(CONFIG_BCM63XX_CPU_6368)
8279
__GEN_SPI_RSET(6358)
8380
#endif
84-
#ifdef CONFIG_BCM63XX_CPU_6368
85-
__GEN_SPI_RSET(6368)
86-
#endif
8781
#endif
8882
return 0;
8983
}

‎arch/mips/include/asm/mach-bcm63xx/bcm63xx_regs.h‎

Lines changed: 2 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -1223,24 +1223,7 @@
12231223
* _REG relative to RSET_SPI
12241224
*************************************************************************/
12251225

1226-
/* BCM 6338 SPI core */
1227-
#define SPI_6338_CMD 0x00 /* 16-bits register */
1228-
#define SPI_6338_INT_STATUS 0x02
1229-
#define SPI_6338_INT_MASK_ST 0x03
1230-
#define SPI_6338_INT_MASK 0x04
1231-
#define SPI_6338_ST 0x05
1232-
#define SPI_6338_CLK_CFG 0x06
1233-
#define SPI_6338_FILL_BYTE 0x07
1234-
#define SPI_6338_MSG_TAIL 0x09
1235-
#define SPI_6338_RX_TAIL 0x0b
1236-
#define SPI_6338_MSG_CTL 0x40 /* 8-bits register */
1237-
#define SPI_6338_MSG_CTL_WIDTH 8
1238-
#define SPI_6338_MSG_DATA 0x41
1239-
#define SPI_6338_MSG_DATA_SIZE 0x3f
1240-
#define SPI_6338_RX_DATA 0x80
1241-
#define SPI_6338_RX_DATA_SIZE 0x3f
1242-
1243-
/* BCM 6348 SPI core */
1226+
/* BCM 6338/6348 SPI core */
12441227
#define SPI_6348_CMD 0x00 /* 16-bits register */
12451228
#define SPI_6348_INT_STATUS 0x02
12461229
#define SPI_6348_INT_MASK_ST 0x03
@@ -1257,7 +1240,7 @@
12571240
#define SPI_6348_RX_DATA 0x80
12581241
#define SPI_6348_RX_DATA_SIZE 0x3f
12591242

1260-
/* BCM 6358 SPI core */
1243+
/* BCM 6358/6368 SPI core */
12611244
#define SPI_6358_MSG_CTL 0x00 /* 16-bits register */
12621245
#define SPI_6358_MSG_CTL_WIDTH 16
12631246
#define SPI_6358_MSG_DATA 0x02
@@ -1274,34 +1257,15 @@
12741257
#define SPI_6358_MSG_TAIL 0x709
12751258
#define SPI_6358_RX_TAIL 0x70B
12761259

1277-
/* BCM 6358 SPI core */
1278-
#define SPI_6368_MSG_CTL 0x00 /* 16-bits register */
1279-
#define SPI_6368_MSG_CTL_WIDTH 16
1280-
#define SPI_6368_MSG_DATA 0x02
1281-
#define SPI_6368_MSG_DATA_SIZE 0x21e
1282-
#define SPI_6368_RX_DATA 0x400
1283-
#define SPI_6368_RX_DATA_SIZE 0x220
1284-
#define SPI_6368_CMD 0x700 /* 16-bits register */
1285-
#define SPI_6368_INT_STATUS 0x702
1286-
#define SPI_6368_INT_MASK_ST 0x703
1287-
#define SPI_6368_INT_MASK 0x704
1288-
#define SPI_6368_ST 0x705
1289-
#define SPI_6368_CLK_CFG 0x706
1290-
#define SPI_6368_FILL_BYTE 0x707
1291-
#define SPI_6368_MSG_TAIL 0x709
1292-
#define SPI_6368_RX_TAIL 0x70B
1293-
12941260
/* Shared SPI definitions */
12951261

12961262
/* Message configuration */
12971263
#define SPI_FD_RW 0x00
12981264
#define SPI_HD_W 0x01
12991265
#define SPI_HD_R 0x02
13001266
#define SPI_BYTE_CNT_SHIFT 0
1301-
#define SPI_6338_MSG_TYPE_SHIFT 6
13021267
#define SPI_6348_MSG_TYPE_SHIFT 6
13031268
#define SPI_6358_MSG_TYPE_SHIFT 14
1304-
#define SPI_6368_MSG_TYPE_SHIFT 14
13051269

13061270
/* Command */
13071271
#define SPI_CMD_NOOP 0x00

0 commit comments

Comments
 (0)