Lines Matching +full:spi +full:- +full:clk

1 // SPDX-License-Identifier: GPL-2.0-only
3 * SPI controller driver for the Mikrotik RB4xx boards
15 #include <linux/clk.h>
16 #include <linux/spi/spi.h>
19 #include <asm/mach-ath79/ar71xx_regs.h>
23 struct clk *clk; member
28 return __raw_readl(rbspi->base + reg); in rb4xx_read()
33 __raw_writel(value, rbspi->base + reg); in rb4xx_write()
52 for (i = 7; i >= 0; i--) in do_spi_byte()
81 static void rb4xx_set_cs(struct spi_device *spi, bool enable) in rb4xx_set_cs() argument
83 struct rb4xx_spi *rbspi = spi_master_get_devdata(spi->master); in rb4xx_set_cs()
96 struct spi_device *spi, struct spi_transfer *t) in rb4xx_transfer_one() argument
105 * Prime the SPI register with the SPI device selected. The m25p80 boot in rb4xx_transfer_one()
110 if (spi->chip_select == 2) in rb4xx_transfer_one()
117 tx_buf = t->tx_buf; in rb4xx_transfer_one()
118 rx_buf = t->rx_buf; in rb4xx_transfer_one()
119 for (i = 0; i < t->len; ++i) { in rb4xx_transfer_one()
120 if (t->tx_nbits == SPI_NBITS_DUAL) in rb4xx_transfer_one()
121 /* CPLD can use two-wire transfers */ in rb4xx_transfer_one()
137 struct clk *ahb_clk; in rb4xx_spi_probe()
146 master = devm_spi_alloc_master(&pdev->dev, sizeof(*rbspi)); in rb4xx_spi_probe()
148 return -ENOMEM; in rb4xx_spi_probe()
150 ahb_clk = devm_clk_get(&pdev->dev, "ahb"); in rb4xx_spi_probe()
154 master->dev.of_node = pdev->dev.of_node; in rb4xx_spi_probe()
155 master->bus_num = 0; in rb4xx_spi_probe()
156 master->num_chipselect = 3; in rb4xx_spi_probe()
157 master->mode_bits = SPI_TX_DUAL; in rb4xx_spi_probe()
158 master->bits_per_word_mask = SPI_BPW_MASK(8); in rb4xx_spi_probe()
159 master->flags = SPI_MASTER_MUST_TX; in rb4xx_spi_probe()
160 master->transfer_one = rb4xx_transfer_one; in rb4xx_spi_probe()
161 master->set_cs = rb4xx_set_cs; in rb4xx_spi_probe()
164 rbspi->base = spi_base; in rb4xx_spi_probe()
165 rbspi->clk = ahb_clk; in rb4xx_spi_probe()
168 err = devm_spi_register_master(&pdev->dev, master); in rb4xx_spi_probe()
170 dev_err(&pdev->dev, "failed to register SPI master\n"); in rb4xx_spi_probe()
178 /* Enable SPI */ in rb4xx_spi_probe()
188 clk_disable_unprepare(rbspi->clk); in rb4xx_spi_remove()
194 { .compatible = "mikrotik,rb4xx-spi" },
203 .name = "rb4xx-spi",
210 MODULE_DESCRIPTION("Mikrotik RB4xx SPI controller driver");