Skip to content

Commit 7656bba

Browse files
committed
fel-spiflash: Add support for V853 family
Tested with V851S :)
1 parent df60a46 commit 7656bba

1 file changed

Lines changed: 23 additions & 2 deletions

File tree

fel-spiflash.c

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,10 @@ void fel_writel(feldev_handle *dev, uint32_t addr, uint32_t val);
8787
#define H6_CCM_SPI_BGR (0x03001000 + 0x96C)
8888
#define H6_CCM_SPI0_GATE_RESET (1 << 0 | 1 << 16)
8989

90+
#define V853_CCM_SPI0_CLK (0x02001000 + 0x940)
91+
#define V853_CCM_SPI_BGR (0x02001000 + 0x96C)
92+
#define V853_CCM_SPI0_GATE_RESET (1 << 0 | 1 << 16)
93+
9094
#define SUNIV_GPC_SPI0 (2)
9195
#define SUNXI_GPC_SPI0 (3)
9296
#define SUN50I_GPC_SPI0 (4)
@@ -117,6 +121,8 @@ void fel_writel(feldev_handle *dev, uint32_t addr, uint32_t val);
117121
#define SUN6I_SPI0_TXD (spi_base(dev) + 0x200)
118122
#define SUN6I_SPI0_RXD (spi_base(dev) + 0x300)
119123

124+
#define V853_SPI_BA_CCR (spi_base(dev) + 0x44)
125+
120126
#define CCM_SPI0_CLK_DIV_BY_2 (0x1000)
121127
#define CCM_SPI0_CLK_DIV_BY_4 (0x1001)
122128
#define CCM_SPI0_CLK_DIV_BY_6 (0x1002)
@@ -126,6 +132,8 @@ static uint32_t gpio_base(feldev_handle *dev)
126132
{
127133
soc_info_t *soc_info = dev->soc_info;
128134
switch (soc_info->soc_id) {
135+
case 0x1886: /* V853 */
136+
return 0x02000018;
129137
case 0x1816: /* V536 */
130138
case 0x1817: /* V831 */
131139
case 0x1728: /* H6 */
@@ -146,6 +154,8 @@ static uint32_t spi_base(feldev_handle *dev)
146154
case 0x1663: /* F1C100s */
147155
case 0x1701: /* R40 */
148156
return 0x01C05000;
157+
case 0x1886: /* V853 */
158+
return 0x04025000;
149159
case 0x1816: /* V536 */
150160
case 0x1817: /* V831 */
151161
case 0x1728: /* H6 */
@@ -166,7 +176,7 @@ static void gpio_set_cfgpin(feldev_handle *dev, int port_num, int pin_num,
166176
uint32_t cfg_reg = port_base + 4 * (pin_num / 8);
167177
uint32_t pin_idx = pin_num % 8;
168178
uint32_t x = readl(cfg_reg);
169-
x &= ~(0x7 << (pin_idx * 4));
179+
x &= ~(0xF << (pin_idx * 4));
170180
x |= val << (pin_idx * 4);
171181
writel(x, cfg_reg);
172182
}
@@ -192,6 +202,7 @@ static bool soc_is_h6_style(feldev_handle *dev)
192202
case 0x1817: /* V831 */
193203
case 0x1728: /* H6 */
194204
case 0x1823: /* H616 */
205+
case 0x1886: /* V853 */
195206
return true;
196207
default:
197208
return false;
@@ -244,6 +255,7 @@ static bool spi0_init(feldev_handle *dev)
244255
break;
245256
case 0x1816: /* Allwinner V536 */
246257
case 0x1817: /* Allwinner V831 */
258+
case 0x1886: /* Allwinner V853 */
247259
gpio_set_cfgpin(dev, PC, 1, SUN50I_GPC_SPI0); /* SPI0-CS */
248260
/* fall-through */
249261
case 0x1728: /* Allwinner H6 */
@@ -265,7 +277,11 @@ static bool spi0_init(feldev_handle *dev)
265277
return false;
266278
}
267279

268-
if (soc_is_h6_style(dev)) {
280+
if (soc_info->soc_id == 0x1886) { /* V853 */
281+
reg_val = readl(V853_CCM_SPI_BGR);
282+
reg_val |= V853_CCM_SPI0_GATE_RESET;
283+
writel(reg_val, V853_CCM_SPI_BGR);
284+
} else if (soc_is_h6_style(dev)) {
269285
reg_val = readl(H6_CCM_SPI_BGR);
270286
reg_val |= H6_CCM_SPI0_GATE_RESET;
271287
writel(reg_val, H6_CCM_SPI_BGR);
@@ -296,6 +312,11 @@ static bool spi0_init(feldev_handle *dev)
296312
writel(0x00003180, SUNIV_AHB_APB_CFG);
297313
/* divide by 32 */
298314
writel(CCM_SPI0_CLK_DIV_BY_32, SUN6I_SPI0_CCTL);
315+
} else if (soc_info->soc_id == 0x1886) { /* V853 */
316+
/* Divide 24MHz OSC by 4 */
317+
writel(CCM_SPI0_CLK_DIV_BY_4, V853_SPI_BA_CCR);
318+
/* Choose 24MHz from OSC24M and enable clock */
319+
writel((1U << 31), V853_CCM_SPI0_CLK);
299320
} else {
300321
/* divide 24MHz OSC by 4 */
301322
writel(CCM_SPI0_CLK_DIV_BY_4,

0 commit comments

Comments
 (0)