Skip to content

Commit ef7839a

Browse files
committed
spi: move SPI0 base address into soc_info
Use the main soc table to also store the first SPI controller's MMIO base address, so that we don't need to decide this in the SPI flash code. Only SoCs that are covered by fel-spiflash.c get a base address assigned, so this value being not 0 is used as an indicator that the SoC is supported. This will simplify supporting future generations of SoCs. Signed-off-by: Andre Przywara <osp@andrep.de>
1 parent fa9fe76 commit ef7839a

3 files changed

Lines changed: 18 additions & 16 deletions

File tree

fel-spiflash.c

Lines changed: 1 addition & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -124,22 +124,7 @@ void fel_writel(feldev_handle *dev, uint32_t addr, uint32_t val);
124124

125125
static uint32_t spi_base(feldev_handle *dev)
126126
{
127-
soc_info_t *soc_info = dev->soc_info;
128-
switch (soc_info->soc_id) {
129-
case 0x1623: /* A10 */
130-
case 0x1625: /* A13 */
131-
case 0x1651: /* A20 */
132-
case 0x1663: /* F1C100s */
133-
case 0x1701: /* R40 */
134-
return 0x01C05000;
135-
case 0x1816: /* V536 */
136-
case 0x1817: /* V831 */
137-
case 0x1728: /* H6 */
138-
case 0x1823: /* H616 */
139-
return 0x05010000;
140-
default:
141-
return 0x01C68000;
142-
}
127+
return dev->soc_info->spi_base;
143128
}
144129

145130
/*

soc_info.c

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -336,6 +336,7 @@ soc_info_t soc_info_table[] = {
336336
.watchdog = &wd_a10_compat,
337337
.gpio_base = SUNXI_PIO_BASE,
338338
.ccu_base = AW_CCM_BASE,
339+
.spi_base = SUN4I_SPI_BASE,
339340
.flags = NEEDS_L2EN,
340341
},{
341342
.soc_id = 0x1625, /* Allwinner A10s, A13, R8 */
@@ -348,6 +349,7 @@ soc_info_t soc_info_table[] = {
348349
.watchdog = &wd_a10_compat,
349350
.gpio_base = SUNXI_PIO_BASE,
350351
.ccu_base = AW_CCM_BASE,
352+
.spi_base = SUN4I_SPI_BASE,
351353
.flags = NEEDS_L2EN,
352354
},{
353355
.soc_id = 0x1651, /* Allwinner A20 */
@@ -361,6 +363,7 @@ soc_info_t soc_info_table[] = {
361363
.watchdog = &wd_a10_compat,
362364
.gpio_base = SUNXI_PIO_BASE,
363365
.ccu_base = AW_CCM_BASE,
366+
.spi_base = SUN4I_SPI_BASE,
364367
},{
365368
.soc_id = 0x1650, /* Allwinner A23 */
366369
.name = "A23",
@@ -412,6 +415,7 @@ soc_info_t soc_info_table[] = {
412415
.watchdog = &wd_h3_compat,
413416
.gpio_base = SUNXI_PIO_BASE,
414417
.ccu_base = AW_CCM_BASE,
418+
.spi_base = SUN6I_SPI_BASE,
415419
},{
416420
.soc_id = 0x1639, /* Allwinner A80 */
417421
.name = "A80",
@@ -437,6 +441,7 @@ soc_info_t soc_info_table[] = {
437441
.watchdog = &wd_h3_compat,
438442
.gpio_base = SUNXI_PIO_BASE,
439443
.ccu_base = AW_CCM_BASE,
444+
.spi_base = SUN4I_SPI_BASE,
440445
},{
441446
.soc_id = 0x1673, /* Allwinner A83T */
442447
.name = "A83T",
@@ -467,6 +472,7 @@ soc_info_t soc_info_table[] = {
467472
.watchdog = &wd_h3_compat,
468473
.gpio_base = SUNXI_PIO_BASE,
469474
.ccu_base = AW_CCM_BASE,
475+
.spi_base = SUN6I_SPI_BASE,
470476
.flags = NEEDS_SID_FIX,
471477
},{
472478
.soc_id = 0x1681, /* Allwinner V3s */
@@ -481,6 +487,7 @@ soc_info_t soc_info_table[] = {
481487
.watchdog = &wd_h3_compat,
482488
.gpio_base = SUNXI_PIO_BASE,
483489
.ccu_base = AW_CCM_BASE,
490+
.spi_base = SUN6I_SPI_BASE,
484491
},{
485492
.soc_id = 0x1708, /* Allwinner T7 */
486493
.name = "T7",
@@ -513,6 +520,7 @@ soc_info_t soc_info_table[] = {
513520
.watchdog = &wd_h3_compat,
514521
.gpio_base = SUNXI_PIO_BASE,
515522
.ccu_base = AW_CCM_BASE,
523+
.spi_base = SUN6I_SPI_BASE,
516524
},{
517525
.soc_id = 0x1701, /* Allwinner R40 */
518526
.name = "R40",
@@ -526,6 +534,7 @@ soc_info_t soc_info_table[] = {
526534
.watchdog = &wd_a10_compat,
527535
.gpio_base = SUNXI_PIO_BASE,
528536
.ccu_base = AW_CCM_BASE,
537+
.spi_base = SUN4I_SPI_BASE,
529538
},{
530539
.soc_id = 0x1719, /* Allwinner A63 */
531540
.name = "A63",
@@ -559,6 +568,7 @@ soc_info_t soc_info_table[] = {
559568
.watchdog = &wd_h6_compat,
560569
.gpio_base = H6_PIO_BASE,
561570
.ccu_base = H6_CCM_BASE,
571+
.spi_base = H6_SPI_BASE,
562572
.flags = H6_STYLE_CLOCKS,
563573
},{
564574
.soc_id = 0x1816, /* Allwinner V536 */
@@ -574,6 +584,7 @@ soc_info_t soc_info_table[] = {
574584
.watchdog = &wd_h6_compat,
575585
.gpio_base = H6_PIO_BASE,
576586
.ccu_base = H6_CCM_BASE,
587+
.spi_base = H6_SPI_BASE,
577588
.flags = H6_STYLE_CLOCKS,
578589
},{
579590
.soc_id = 0x1817, /* Allwinner V831 */
@@ -589,6 +600,7 @@ soc_info_t soc_info_table[] = {
589600
.watchdog = &wd_h6_compat,
590601
.gpio_base = H6_PIO_BASE,
591602
.ccu_base = H6_CCM_BASE,
603+
.spi_base = H6_SPI_BASE,
592604
.flags = H6_STYLE_CLOCKS,
593605
},{
594606
.soc_id = 0x1823, /* Allwinner H616 */
@@ -607,6 +619,7 @@ soc_info_t soc_info_table[] = {
607619
.watchdog = &wd_h6_compat,
608620
.gpio_base = H6_PIO_BASE,
609621
.ccu_base = H6_CCM_BASE,
622+
.spi_base = H6_SPI_BASE,
610623
.flags = H6_STYLE_CLOCKS,
611624
},{
612625
.soc_id = 0x1851, /* Allwinner R329 */

soc_info.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,9 @@ enum soc_flags {
9797
#define V853_PIO_BASE 0x02000000
9898
#define R329_PIO_BASE 0x02000400
9999
#define R329_CCM_BASE 0x02001000
100+
#define SUN4I_SPI_BASE 0x01c05000
101+
#define SUN6I_SPI_BASE 0x01c68000
102+
#define H6_SPI_BASE 0x05010000
100103

101104
/*
102105
* Each SoC variant may have its own list of memory buffers to be exchanged
@@ -158,6 +161,7 @@ typedef struct {
158161
sram_swap_buffers *swap_buffers;
159162
uint32_t gpio_base;
160163
uint32_t ccu_base;
164+
uint32_t spi_base;
161165
uint32_t flags;
162166
} soc_info_t;
163167

0 commit comments

Comments
 (0)