9 #include <linux/module.h>
10 #include <linux/device.h>
18 #include <lantiq_soc.h>
20 #define DRV_NAME "sflash-falcon"
22 #define FALCON_SPI_XFER_BEGIN (1 << 0)
23 #define FALCON_SPI_XFER_END (1 << 1)
26 #define BUSRCON0 0x00000010
28 #define BUSWCON0 0x00000018
30 #define SFCON 0x00000080
32 #define SFTIME 0x00000084
34 #define SFSTAT 0x00000088
36 #define SFCMD 0x0000008C
38 #define SFADDR 0x00000090
40 #define SFDATA 0x00000094
42 #define SFIO 0x00000098
44 #define EBUCC 0x000000C4
47 #define SFCMD_DUMLEN_OFFSET 16
48 #define SFCMD_DUMLEN_MASK 0x000F0000
50 #define SFCMD_CS_OFFSET 24
51 #define SFCMD_CS_MASK 0x07000000
53 #define SFCMD_ALEN_OFFSET 20
54 #define SFCMD_ALEN_MASK 0x00700000
56 #define SFTIME_SCKR_POS_OFFSET 8
57 #define SFTIME_SCKR_POS_MASK 0x00000F00
59 #define SFTIME_SCK_PER_OFFSET 0
60 #define SFTIME_SCK_PER_MASK 0x0000000F
62 #define SFTIME_SCKF_POS_OFFSET 12
63 #define SFTIME_SCKF_POS_MASK 0x0000F000
65 #define SFCON_DEV_SIZE_A23_0 0x03000000
66 #define SFCON_DEV_SIZE_MASK 0x0F000000
68 #define SFTIME_RD_POS_MASK 0x000F0000
70 #define SFIO_UNUSED_WD_MASK 0x0000000F
72 #define SFCMD_OPC_MASK 0x000000FF
74 #define SFCMD_DIR_WRITE 0x00000100
76 #define SFCMD_DLEN_OFFSET 9
78 #define SFSTAT_CMD_ERR 0x20000000
80 #define SFSTAT_CMD_PEND 0x00400000
82 #define EBUCC_EBUDIV_SELF100 0x00000001
84 #define BUSRCON0_AGEN_SERIAL_FLASH 0xF0000000
86 #define BUSRCON0_PORTW_8_BIT_MUX 0x00000000
88 #define BUSWCON0_AGEN_SERIAL_FLASH 0xF0000000
90 #define SFCMD_KEEP_CS_KEEP_SELECTED 0x00008000
92 #define CLOCK_100M 100000000
93 #define CLOCK_50M 50000000
107 unsigned int bytelen = ((8 * t->
len + 7) / 8);
108 unsigned int len, alen, dumlen;
112 state_command_prepare,
117 }
state = state_init;
127 "BEGIN without tx data!\n");
149 state = state_command_prepare;
152 dev_dbg(dev,
"write cmd %02X\n",
157 if (txp && bytelen) {
162 if (rxp && bytelen) {
168 state = state_disable_cs;
174 case state_command_prepare:
180 while (bytelen > 0) {
182 val = (val << 8) | (*txp++);
184 }
else if ((dumlen < 15) && (*txp == 0)) {
202 dev_dbg(dev,
"wr %02X, alen=%d (addr=%06X) dlen=%d\n",
211 state = state_disable_cs;
229 val |= (*txp++) << (8 * len++);
235 if ((len == 4) || (bytelen == 0)) {
259 len = (bytelen > 4) ? 4 : bytelen;
269 dev_err(dev,
"SFSTAT: CMD_ERR");
287 case state_disable_cs:
295 dev_err(dev,
"SFSTAT: CMD_ERR (%x)\n", val);
305 }
while (
state != state_end);
329 for (i = 1; i < 7; i++) {
355 spin_unlock_irqrestore(&ebu_lock, flags);
389 spin_unlock_irqrestore(&ebu_lock, flags);
413 dev_err(&pdev->
dev,
"invalid bootstrap options\n");
421 priv = spi_master_get_devdata(master);
427 master->
setup = falcon_sflash_setup;
431 master->
dev.of_node = pdev->
dev.of_node;
433 platform_set_drvdata(pdev, priv);
437 spi_master_put(master);
450 static const struct of_device_id falcon_sflash_match[] = {
451 { .compatible =
"lantiq,sflash-falcon" },
457 .probe = falcon_sflash_probe,
462 .of_match_table = falcon_sflash_match,