1 // SPDX-License-Identifier: GPL-2.0+
3 * ASPEED FMC/SPI Controller driver
5 * Copyright (c) 2022 ASPEED Corporation.
6 * Copyright (c) 2022 IBM Corporation.
9 * Chin-Ting Kuo <chin-ting_kuo@aspeedtech.com>
10 * Cedric Le Goater <clg@kaod.org>
17 #include <dm/device_compat.h>
18 #include <linux/bitops.h>
19 #include <linux/bug.h>
20 #include <linux/err.h>
21 #include <linux/iopoll.h>
22 #include <linux/kernel.h>
23 #include <linux/mtd/spi-nor.h>
24 #include <linux/sizes.h>
29 #define ASPEED_SPI_MAX_CS 5
31 #define CTRL_IO_SINGLE_DATA 0
32 #define CTRL_IO_QUAD_DATA BIT(30)
33 #define CTRL_IO_DUAL_DATA BIT(29)
35 #define CTRL_IO_MODE_USER GENMASK(1, 0)
36 #define CTRL_IO_MODE_CMD_READ BIT(0)
37 #define CTRL_IO_MODE_CMD_WRITE BIT(1)
38 #define CTRL_STOP_ACTIVE BIT(2)
40 struct aspeed_spi_regs {
41 u32 conf; /* 0x00 CE Type Setting */
42 u32 ctrl; /* 0x04 CE Control */
43 u32 intr_ctrl; /* 0x08 Interrupt Control and Status */
44 u32 cmd_ctrl; /* 0x0c Command Control */
45 u32 ce_ctrl[ASPEED_SPI_MAX_CS]; /* 0x10 .. 0x20 CEx Control */
46 u32 _reserved0[3]; /* .. */
47 u32 segment_addr[ASPEED_SPI_MAX_CS]; /* 0x30 .. 0x40 Segment Address */
48 u32 _reserved1[3]; /* .. */
49 u32 soft_rst_cmd_ctrl; /* 0x50 Auto Soft-Reset Command Control */
50 u32 _reserved2[11]; /* .. */
51 u32 dma_ctrl; /* 0x80 DMA Control/Status */
52 u32 dma_flash_addr; /* 0x84 DMA Flash Side Address */
53 u32 dma_dram_addr; /* 0x88 DMA DRAM Side Address */
54 u32 dma_len; /* 0x8c DMA Length Register */
55 u32 dma_checksum; /* 0x90 Checksum Calculation Result */
56 u32 timings[ASPEED_SPI_MAX_CS]; /* 0x94 Read Timing Compensation */
59 struct aspeed_spi_plat {
61 void __iomem *ahb_base; /* AHB address base for all flash devices. */
62 fdt_size_t ahb_sz; /* Overall AHB window size for all flash device. */
65 struct aspeed_spi_flash {
66 void __iomem *ahb_base;
72 struct aspeed_spi_priv {
74 struct aspeed_spi_regs *regs;
75 struct aspeed_spi_info *info;
76 struct aspeed_spi_flash flashes[ASPEED_SPI_MAX_CS];
79 struct aspeed_spi_info {
83 void (*set_4byte)(struct udevice *bus, u32 cs);
84 u32 (*segment_start)(struct udevice *bus, u32 reg);
85 u32 (*segment_end)(struct udevice *bus, u32 reg);
86 u32 (*segment_reg)(u32 start, u32 end);
89 static const struct aspeed_spi_info ast2400_spi_info;
90 static int aspeed_spi_decoded_range_config(struct udevice *bus);
92 static u32 aspeed_spi_get_io_mode(u32 bus_width)
96 return CTRL_IO_SINGLE_DATA;
98 return CTRL_IO_DUAL_DATA;
100 return CTRL_IO_QUAD_DATA;
102 /* keep in default value */
103 return CTRL_IO_SINGLE_DATA;
107 static u32 ast2400_spi_segment_start(struct udevice *bus, u32 reg)
109 struct aspeed_spi_plat *plat = dev_get_plat(bus);
110 u32 start_offset = ((reg >> 16) & 0xff) << 23;
112 if (start_offset == 0)
113 return (u32)plat->ahb_base;
115 return (u32)plat->ahb_base + start_offset;
118 static u32 ast2400_spi_segment_end(struct udevice *bus, u32 reg)
120 struct aspeed_spi_plat *plat = dev_get_plat(bus);
121 u32 end_offset = ((reg >> 24) & 0xff) << 23;
123 /* Meaningless end_offset, set to physical ahb base. */
125 return (u32)plat->ahb_base;
127 return (u32)plat->ahb_base + end_offset;
130 static u32 ast2400_spi_segment_reg(u32 start, u32 end)
135 return ((((start) >> 23) & 0xff) << 16) | ((((end) >> 23) & 0xff) << 24);
138 static void ast2400_fmc_chip_set_4byte(struct udevice *bus, u32 cs)
140 struct aspeed_spi_priv *priv = dev_get_priv(bus);
143 reg_val = readl(&priv->regs->ctrl);
144 reg_val |= 0x1 << cs;
145 writel(reg_val, &priv->regs->ctrl);
148 static void ast2400_spi_chip_set_4byte(struct udevice *bus, u32 cs)
150 struct aspeed_spi_priv *priv = dev_get_priv(bus);
151 struct aspeed_spi_flash *flash = &priv->flashes[cs];
153 flash->ce_ctrl_read |= BIT(13);
154 writel(flash->ce_ctrl_read, &priv->regs->ctrl);
157 static u32 ast2500_spi_segment_start(struct udevice *bus, u32 reg)
159 struct aspeed_spi_plat *plat = dev_get_plat(bus);
160 u32 start_offset = ((reg >> 16) & 0xff) << 23;
162 if (start_offset == 0)
163 return (u32)plat->ahb_base;
165 return (u32)plat->ahb_base + start_offset;
168 static u32 ast2500_spi_segment_end(struct udevice *bus, u32 reg)
170 struct aspeed_spi_plat *plat = dev_get_plat(bus);
171 u32 end_offset = ((reg >> 24) & 0xff) << 23;
173 /* Meaningless end_offset, set to physical ahb base. */
175 return (u32)plat->ahb_base;
177 return (u32)plat->ahb_base + end_offset;
180 static u32 ast2500_spi_segment_reg(u32 start, u32 end)
185 return ((((start) >> 23) & 0xff) << 16) | ((((end) >> 23) & 0xff) << 24);
188 static void ast2500_spi_chip_set_4byte(struct udevice *bus, u32 cs)
190 struct aspeed_spi_priv *priv = dev_get_priv(bus);
193 reg_val = readl(&priv->regs->ctrl);
194 reg_val |= 0x1 << cs;
195 writel(reg_val, &priv->regs->ctrl);
198 static u32 ast2600_spi_segment_start(struct udevice *bus, u32 reg)
200 struct aspeed_spi_plat *plat = dev_get_plat(bus);
201 u32 start_offset = (reg << 16) & 0x0ff00000;
203 if (start_offset == 0)
204 return (u32)plat->ahb_base;
206 return (u32)plat->ahb_base + start_offset;
209 static u32 ast2600_spi_segment_end(struct udevice *bus, u32 reg)
211 struct aspeed_spi_plat *plat = dev_get_plat(bus);
212 u32 end_offset = reg & 0x0ff00000;
214 /* Meaningless end_offset, set to physical ahb base. */
216 return (u32)plat->ahb_base;
218 return (u32)plat->ahb_base + end_offset + 0x100000;
221 static u32 ast2600_spi_segment_reg(u32 start, u32 end)
226 return ((start & 0x0ff00000) >> 16) | ((end - 0x100000) & 0x0ff00000);
229 static void ast2600_spi_chip_set_4byte(struct udevice *bus, u32 cs)
231 struct aspeed_spi_priv *priv = dev_get_priv(bus);
234 reg_val = readl(&priv->regs->ctrl);
235 reg_val |= 0x11 << cs;
236 writel(reg_val, &priv->regs->ctrl);
239 static int aspeed_spi_read_from_ahb(void __iomem *ahb_base, void *buf,
244 if (IS_ALIGNED((uintptr_t)ahb_base, sizeof(uintptr_t)) &&
245 IS_ALIGNED((uintptr_t)buf, sizeof(uintptr_t))) {
246 readsl(ahb_base, buf, len >> 2);
251 readsb(ahb_base, (u8 *)buf + offset, len);
256 static int aspeed_spi_write_to_ahb(void __iomem *ahb_base, const void *buf,
261 if (IS_ALIGNED((uintptr_t)ahb_base, sizeof(uintptr_t)) &&
262 IS_ALIGNED((uintptr_t)buf, sizeof(uintptr_t))) {
263 writesl(ahb_base, buf, len >> 2);
268 writesb(ahb_base, (u8 *)buf + offset, len);
274 * Currently, only support 1-1-1, 1-1-2 or 1-1-4
275 * SPI NOR flash operation format.
277 static bool aspeed_spi_supports_op(struct spi_slave *slave,
278 const struct spi_mem_op *op)
280 struct udevice *bus = slave->dev->parent;
281 struct aspeed_spi_priv *priv = dev_get_priv(bus);
283 if (op->cmd.buswidth > 1)
286 if (op->addr.nbytes != 0) {
287 if (op->addr.buswidth > 1)
289 if (op->addr.nbytes < 3 || op->addr.nbytes > 4)
293 if (op->dummy.nbytes != 0) {
294 if (op->dummy.buswidth > 1 || op->dummy.nbytes > 7)
298 if (op->data.nbytes != 0 &&
299 op->data.buswidth > priv->info->max_bus_width)
302 if (!spi_mem_default_supports_op(slave, op))
308 static int aspeed_spi_exec_op_user_mode(struct spi_slave *slave,
309 const struct spi_mem_op *op)
311 struct udevice *dev = slave->dev;
312 struct udevice *bus = dev->parent;
313 struct aspeed_spi_priv *priv = dev_get_priv(bus);
314 struct dm_spi_slave_plat *slave_plat = dev_get_parent_plat(slave->dev);
315 u32 cs = slave_plat->cs;
316 u32 ce_ctrl_reg = (u32)&priv->regs->ce_ctrl[cs];
318 struct aspeed_spi_flash *flash = &priv->flashes[cs];
319 u8 dummy_data[16] = {0};
323 dev_dbg(dev, "cmd:%x(%d),addr:%llx(%d),dummy:%d(%d),data_len:0x%x(%d)\n",
324 op->cmd.opcode, op->cmd.buswidth, op->addr.val,
325 op->addr.buswidth, op->dummy.nbytes, op->dummy.buswidth,
326 op->data.nbytes, op->data.buswidth);
328 if (priv->info == &ast2400_spi_info)
329 ce_ctrl_reg = (u32)&priv->regs->ctrl;
332 * Set controller to 4-byte address mode
333 * if flash is in 4-byte address mode.
335 if (op->cmd.opcode == SPINOR_OP_EN4B)
336 priv->info->set_4byte(bus, cs);
338 /* Start user mode */
339 ce_ctrl_val = flash->ce_ctrl_user;
340 writel(ce_ctrl_val, ce_ctrl_reg);
341 ce_ctrl_val &= (~CTRL_STOP_ACTIVE);
342 writel(ce_ctrl_val, ce_ctrl_reg);
345 aspeed_spi_write_to_ahb(flash->ahb_base, &op->cmd.opcode, 1);
348 for (i = op->addr.nbytes; i > 0; i--) {
349 addr[op->addr.nbytes - i] =
350 ((u32)op->addr.val >> ((i - 1) * 8)) & 0xff;
354 ce_ctrl_val &= ~priv->info->io_mode_mask;
355 ce_ctrl_val |= aspeed_spi_get_io_mode(op->addr.buswidth);
356 writel(ce_ctrl_val, ce_ctrl_reg);
357 aspeed_spi_write_to_ahb(flash->ahb_base, addr, op->addr.nbytes);
359 /* Send dummy cycles */
360 aspeed_spi_write_to_ahb(flash->ahb_base, dummy_data, op->dummy.nbytes);
363 ce_ctrl_val &= ~priv->info->io_mode_mask;
364 ce_ctrl_val |= aspeed_spi_get_io_mode(op->data.buswidth);
365 writel(ce_ctrl_val, ce_ctrl_reg);
368 if (op->data.dir == SPI_MEM_DATA_OUT) {
369 aspeed_spi_write_to_ahb(flash->ahb_base, op->data.buf.out,
372 aspeed_spi_read_from_ahb(flash->ahb_base, op->data.buf.in,
376 ce_ctrl_val |= CTRL_STOP_ACTIVE;
377 writel(ce_ctrl_val, ce_ctrl_reg);
379 /* Restore controller setting. */
380 writel(flash->ce_ctrl_read, ce_ctrl_reg);
385 static int aspeed_spi_dirmap_create(struct spi_mem_dirmap_desc *desc)
388 struct udevice *dev = desc->slave->dev;
389 struct udevice *bus = dev->parent;
390 struct aspeed_spi_priv *priv = dev_get_priv(bus);
391 struct dm_spi_slave_plat *slave_plat = dev_get_parent_plat(dev);
392 const struct aspeed_spi_info *info = priv->info;
393 struct spi_mem_op op_tmpl = desc->info.op_tmpl;
395 u32 cs = slave_plat->cs;
399 if (desc->info.op_tmpl.data.dir == SPI_MEM_DATA_OUT) {
401 * dirmap_write is not supported currently due to a HW
402 * limitation for command write mode: The written data
403 * length should be multiple of 4-byte.
408 ce_ctrl_reg = (u32)&priv->regs->ce_ctrl[cs];
409 if (info == &ast2400_spi_info)
410 ce_ctrl_reg = (u32)&priv->regs->ctrl;
412 if (desc->info.length > 0x1000000)
413 priv->info->set_4byte(bus, cs);
415 /* AST2400 SPI1 doesn't have decoded address segment register. */
416 if (info != &ast2400_spi_info) {
417 priv->flashes[cs].ahb_decoded_sz = desc->info.length;
419 for (i = 0; i < priv->num_cs; i++) {
420 dev_dbg(dev, "cs: %d, sz: 0x%x\n", i,
421 priv->flashes[cs].ahb_decoded_sz);
424 ret = aspeed_spi_decoded_range_config(bus);
429 reg_val = aspeed_spi_get_io_mode(op_tmpl.data.buswidth) |
430 op_tmpl.cmd.opcode << 16 |
431 ((op_tmpl.dummy.nbytes) & 0x3) << 6 |
432 ((op_tmpl.dummy.nbytes) & 0x4) << 14 |
433 CTRL_IO_MODE_CMD_READ;
435 writel(reg_val, ce_ctrl_reg);
437 priv->flashes[cs].ce_ctrl_read = reg_val;
439 dev_dbg(dev, "read bus width: %d ce_ctrl_val: 0x%08x\n",
440 op_tmpl.data.buswidth, priv->flashes[cs].ce_ctrl_read);
445 static ssize_t aspeed_spi_dirmap_read(struct spi_mem_dirmap_desc *desc,
446 u64 offs, size_t len, void *buf)
448 struct udevice *dev = desc->slave->dev;
449 struct aspeed_spi_priv *priv = dev_get_priv(dev->parent);
450 struct dm_spi_slave_plat *slave_plat = dev_get_parent_plat(dev);
451 u32 cs = slave_plat->cs;
454 dev_dbg(dev, "read op:0x%x, addr:0x%llx, len:0x%x\n",
455 desc->info.op_tmpl.cmd.opcode, offs, len);
457 if (priv->flashes[cs].ahb_decoded_sz < offs + len ||
459 ret = aspeed_spi_exec_op_user_mode(desc->slave,
460 &desc->info.op_tmpl);
464 memcpy_fromio(buf, priv->flashes[cs].ahb_base + offs, len);
470 static struct aspeed_spi_flash *aspeed_spi_get_flash(struct udevice *dev)
472 struct udevice *bus = dev->parent;
473 struct dm_spi_slave_plat *slave_plat = dev_get_parent_plat(dev);
474 struct aspeed_spi_plat *plat = dev_get_plat(bus);
475 struct aspeed_spi_priv *priv = dev_get_priv(bus);
476 u32 cs = slave_plat->cs;
478 if (cs >= plat->max_cs) {
479 dev_err(dev, "invalid CS %u\n", cs);
483 return &priv->flashes[cs];
486 static void aspeed_spi_decoded_base_calculate(struct udevice *bus)
488 struct aspeed_spi_plat *plat = dev_get_plat(bus);
489 struct aspeed_spi_priv *priv = dev_get_priv(bus);
492 priv->flashes[0].ahb_base = plat->ahb_base;
494 for (cs = 1; cs < plat->max_cs; cs++) {
495 priv->flashes[cs].ahb_base =
496 priv->flashes[cs - 1].ahb_base +
497 priv->flashes[cs - 1].ahb_decoded_sz;
501 static void aspeed_spi_decoded_range_set(struct udevice *bus)
503 struct aspeed_spi_plat *plat = dev_get_plat(bus);
504 struct aspeed_spi_priv *priv = dev_get_priv(bus);
506 u32 start_addr, end_addr;
509 for (cs = 0; cs < plat->max_cs; cs++) {
510 start_addr = (u32)priv->flashes[cs].ahb_base;
511 end_addr = (u32)priv->flashes[cs].ahb_base +
512 priv->flashes[cs].ahb_decoded_sz;
514 decoded_reg_val = priv->info->segment_reg(start_addr, end_addr);
516 writel(decoded_reg_val, &priv->regs->segment_addr[cs]);
518 dev_dbg(bus, "cs: %d, decoded_reg: 0x%x, start: 0x%x, end: 0x%x\n",
519 cs, decoded_reg_val, start_addr, end_addr);
523 static int aspeed_spi_decoded_range_config(struct udevice *bus)
525 aspeed_spi_decoded_base_calculate(bus);
526 aspeed_spi_decoded_range_set(bus);
532 * Initialize SPI controller for each chip select.
533 * Here, only the minimum decode range is configured
534 * in order to get device (SPI NOR flash) information
535 * at the early stage.
537 static int aspeed_spi_ctrl_init(struct udevice *bus)
540 struct aspeed_spi_plat *plat = dev_get_plat(bus);
541 struct aspeed_spi_priv *priv = dev_get_priv(bus);
546 /* Enable write capability for all CS. */
547 reg_val = readl(&priv->regs->conf);
548 if (priv->info == &ast2400_spi_info) {
549 writel(reg_val | BIT(0), &priv->regs->conf);
551 writel(reg_val | (GENMASK(plat->max_cs - 1, 0) << 16),
555 memset(priv->flashes, 0x0,
556 sizeof(struct aspeed_spi_flash) * ASPEED_SPI_MAX_CS);
558 /* Initial user mode. */
559 for (cs = 0; cs < priv->num_cs; cs++) {
560 priv->flashes[cs].ce_ctrl_user =
561 (CTRL_STOP_ACTIVE | CTRL_IO_MODE_USER);
565 * SPI1 on AST2400 only supports CS0.
566 * It is unnecessary to configure segment address register.
568 if (priv->info == &ast2400_spi_info) {
569 priv->flashes[cs].ahb_base = plat->ahb_base;
570 priv->flashes[cs].ahb_decoded_sz = 0x10000000;
574 /* Assign basic AHB decoded size for each CS. */
575 for (cs = 0; cs < plat->max_cs; cs++) {
576 reg_val = readl(&priv->regs->segment_addr[cs]);
577 decoded_sz = priv->info->segment_end(bus, reg_val) -
578 priv->info->segment_start(bus, reg_val);
580 if (decoded_sz < priv->info->min_decoded_sz)
581 decoded_sz = priv->info->min_decoded_sz;
583 priv->flashes[cs].ahb_decoded_sz = decoded_sz;
586 ret = aspeed_spi_decoded_range_config(bus);
591 static const struct aspeed_spi_info ast2400_fmc_info = {
592 .io_mode_mask = 0x70000000,
594 .min_decoded_sz = 0x800000,
595 .set_4byte = ast2400_fmc_chip_set_4byte,
596 .segment_start = ast2400_spi_segment_start,
597 .segment_end = ast2400_spi_segment_end,
598 .segment_reg = ast2400_spi_segment_reg,
601 static const struct aspeed_spi_info ast2400_spi_info = {
602 .io_mode_mask = 0x70000000,
604 .min_decoded_sz = 0x800000,
605 .set_4byte = ast2400_spi_chip_set_4byte,
606 .segment_start = ast2400_spi_segment_start,
607 .segment_end = ast2400_spi_segment_end,
608 .segment_reg = ast2400_spi_segment_reg,
611 static const struct aspeed_spi_info ast2500_fmc_info = {
612 .io_mode_mask = 0x70000000,
614 .min_decoded_sz = 0x800000,
615 .set_4byte = ast2500_spi_chip_set_4byte,
616 .segment_start = ast2500_spi_segment_start,
617 .segment_end = ast2500_spi_segment_end,
618 .segment_reg = ast2500_spi_segment_reg,
622 * There are some different between FMC and SPI controllers.
623 * For example, DMA operation, but this isn't implemented currently.
625 static const struct aspeed_spi_info ast2500_spi_info = {
626 .io_mode_mask = 0x70000000,
628 .min_decoded_sz = 0x800000,
629 .set_4byte = ast2500_spi_chip_set_4byte,
630 .segment_start = ast2500_spi_segment_start,
631 .segment_end = ast2500_spi_segment_end,
632 .segment_reg = ast2500_spi_segment_reg,
635 static const struct aspeed_spi_info ast2600_fmc_info = {
636 .io_mode_mask = 0xf0000000,
638 .min_decoded_sz = 0x200000,
639 .set_4byte = ast2600_spi_chip_set_4byte,
640 .segment_start = ast2600_spi_segment_start,
641 .segment_end = ast2600_spi_segment_end,
642 .segment_reg = ast2600_spi_segment_reg,
645 static const struct aspeed_spi_info ast2600_spi_info = {
646 .io_mode_mask = 0xf0000000,
648 .min_decoded_sz = 0x200000,
649 .set_4byte = ast2600_spi_chip_set_4byte,
650 .segment_start = ast2600_spi_segment_start,
651 .segment_end = ast2600_spi_segment_end,
652 .segment_reg = ast2600_spi_segment_reg,
655 static int aspeed_spi_claim_bus(struct udevice *dev)
657 struct udevice *bus = dev->parent;
658 struct dm_spi_slave_plat *slave_plat = dev_get_parent_plat(dev);
660 dev_dbg(bus, "%s: claim bus CS%u\n", bus->name, slave_plat->cs);
665 static int aspeed_spi_release_bus(struct udevice *dev)
667 struct udevice *bus = dev->parent;
668 struct dm_spi_slave_plat *slave_plat = dev_get_parent_plat(dev);
670 dev_dbg(bus, "%s: release bus CS%u\n", bus->name, slave_plat->cs);
672 if (!aspeed_spi_get_flash(dev))
678 static int aspeed_spi_set_mode(struct udevice *bus, uint mode)
680 dev_dbg(bus, "%s: setting mode to %x\n", bus->name, mode);
685 static int aspeed_spi_set_speed(struct udevice *bus, uint hz)
687 dev_dbg(bus, "%s: setting speed to %u\n", bus->name, hz);
689 * ASPEED SPI controller supports multiple CS with different
690 * clock frequency. We cannot distinguish which CS here.
691 * Thus, the related implementation is postponed to claim_bus.
697 static int apseed_spi_of_to_plat(struct udevice *bus)
699 struct aspeed_spi_plat *plat = dev_get_plat(bus);
700 struct aspeed_spi_priv *priv = dev_get_priv(bus);
702 priv->regs = (void __iomem *)devfdt_get_addr_index(bus, 0);
703 if ((u32)priv->regs == FDT_ADDR_T_NONE) {
704 dev_err(bus, "wrong ctrl base\n");
709 (void __iomem *)devfdt_get_addr_size_index(bus, 1, &plat->ahb_sz);
710 if ((u32)plat->ahb_base == FDT_ADDR_T_NONE) {
711 dev_err(bus, "wrong AHB base\n");
715 plat->max_cs = dev_read_u32_default(bus, "num-cs", ASPEED_SPI_MAX_CS);
716 if (plat->max_cs > ASPEED_SPI_MAX_CS)
719 dev_dbg(bus, "ctrl_base = 0x%x, ahb_base = 0x%p, size = 0x%lx\n",
720 (u32)priv->regs, plat->ahb_base, plat->ahb_sz);
721 dev_dbg(bus, "max_cs = %d\n", plat->max_cs);
726 static int aspeed_spi_probe(struct udevice *bus)
729 struct aspeed_spi_priv *priv = dev_get_priv(bus);
732 priv->info = (struct aspeed_spi_info *)dev_get_driver_data(bus);
735 for (device_find_first_child(bus, &dev); dev;
736 device_find_next_child(&dev)) {
740 if (priv->num_cs > ASPEED_SPI_MAX_CS)
743 ret = aspeed_spi_ctrl_init(bus);
748 static const struct spi_controller_mem_ops aspeed_spi_mem_ops = {
749 .supports_op = aspeed_spi_supports_op,
750 .exec_op = aspeed_spi_exec_op_user_mode,
751 .dirmap_create = aspeed_spi_dirmap_create,
752 .dirmap_read = aspeed_spi_dirmap_read,
755 static const struct dm_spi_ops aspeed_spi_ops = {
756 .claim_bus = aspeed_spi_claim_bus,
757 .release_bus = aspeed_spi_release_bus,
758 .set_speed = aspeed_spi_set_speed,
759 .set_mode = aspeed_spi_set_mode,
760 .mem_ops = &aspeed_spi_mem_ops,
763 static const struct udevice_id aspeed_spi_ids[] = {
764 { .compatible = "aspeed,ast2400-fmc", .data = (ulong)&ast2400_fmc_info, },
765 { .compatible = "aspeed,ast2400-spi", .data = (ulong)&ast2400_spi_info, },
766 { .compatible = "aspeed,ast2500-fmc", .data = (ulong)&ast2500_fmc_info, },
767 { .compatible = "aspeed,ast2500-spi", .data = (ulong)&ast2500_spi_info, },
768 { .compatible = "aspeed,ast2600-fmc", .data = (ulong)&ast2600_fmc_info, },
769 { .compatible = "aspeed,ast2600-spi", .data = (ulong)&ast2600_spi_info, },
773 U_BOOT_DRIVER(aspeed_spi) = {
774 .name = "aspeed_spi_smc",
776 .of_match = aspeed_spi_ids,
777 .ops = &aspeed_spi_ops,
778 .of_to_plat = apseed_spi_of_to_plat,
779 .plat_auto = sizeof(struct aspeed_spi_plat),
780 .priv_auto = sizeof(struct aspeed_spi_priv),
781 .probe = aspeed_spi_probe,