// SPDX-License-Identifier: GPL-2.0-only /* * SPI controller driver for the Mikrotik RB4xx boards * * Copyright (C) 2010 Gabor Juhos <juhosg@openwrt.org> * Copyright (C) 2015 Bert Vermeulen <bert@biot.com> * * This file was based on the patches for Linux 2.6.27.39 published by * MikroTik for their RouterBoard 4xx series devices.
*/
for (i = 7; i >= 0; i--)
do_spi_clk(rbspi, spi_ioc, byte >> i);
}
/* The CS2 pin is used to clock in a second bit per clock cycle. */ staticinlinevoid do_spi_clk_two(struct rb4xx_spi *rbspi, u32 spi_ioc,
u8 value)
{
u32 regval;
regval = spi_ioc; if (value & BIT(1))
regval |= AR71XX_SPI_IOC_DO; if (value & BIT(0))
regval |= AR71XX_SPI_IOC_CS2;
/* * Setting CS is done along with bitbanging the actual values, * since it's all on the same hardware register. However the * CPLD needs CS deselected after every command.
*/ if (enable)
rb4xx_write(rbspi, AR71XX_SPI_REG_IOC,
AR71XX_SPI_IOC_CS0 | AR71XX_SPI_IOC_CS1);
}
/* * Prime the SPI register with the SPI device selected. The m25p80 boot * flash and CPLD share the CS0 pin. This works because the CPLD's * command set was designed to almost not clash with that of the * boot flash.
*/ if (spi_get_chipselect(spi, 0) == 2) /* MMC */
spi_ioc = AR71XX_SPI_IOC_CS0; else /* Boot flash and CPLD */
spi_ioc = AR71XX_SPI_IOC_CS1;
tx_buf = t->tx_buf;
rx_buf = t->rx_buf; for (i = 0; i < t->len; ++i) { if (t->tx_nbits == SPI_NBITS_DUAL) /* CPLD can use two-wire transfers */
do_spi_byte_two(rbspi, spi_ioc, tx_buf[i]); else
do_spi_byte(rbspi, spi_ioc, tx_buf[i]); if (!rx_buf) continue;
rx_buf[i] = rb4xx_read(rbspi, AR71XX_SPI_REG_RDS);
}
spi_finalize_current_transfer(host);
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.