Lines Matching +full:rx +full:- +full:inactive

1 // SPDX-License-Identifier: GPL-2.0-or-later
3 * SPI host driver for ICP DAS LP-8841 RTC
11 * Copyright (C) 2003 - 2007 Paul Mundt
43 data->state |= SPI_LP8841_RTC_CLK; in setsck()
45 data->state &= ~SPI_LP8841_RTC_CLK; in setsck()
46 writeb(data->state, data->iomem); in setsck()
53 data->state |= SPI_LP8841_RTC_MOSI; in setmosi()
55 data->state &= ~SPI_LP8841_RTC_MOSI; in setmosi()
56 writeb(data->state, data->iomem); in setmosi()
62 return ioread8(data->iomem) & SPI_LP8841_RTC_MISO; in getmiso()
72 u32 shift = 32 - bits; in bitbang_txrx_be_cpha0_lsb()
73 /* clock starts at inactive polarity */ in bitbang_txrx_be_cpha0_lsb()
74 for (; likely(bits); bits--) { in bitbang_txrx_be_cpha0_lsb()
103 unsigned count = t->len; in spi_lp8841_rtc_transfer_one()
104 const u8 *tx = t->tx_buf; in spi_lp8841_rtc_transfer_one()
105 u8 *rx = t->rx_buf; in spi_lp8841_rtc_transfer_one() local
110 data->state &= ~SPI_LP8841_RTC_nWE; in spi_lp8841_rtc_transfer_one()
111 writeb(data->state, data->iomem); in spi_lp8841_rtc_transfer_one()
116 count--; in spi_lp8841_rtc_transfer_one()
118 } else if (rx) { in spi_lp8841_rtc_transfer_one()
119 data->state |= SPI_LP8841_RTC_nWE; in spi_lp8841_rtc_transfer_one()
120 writeb(data->state, data->iomem); in spi_lp8841_rtc_transfer_one()
124 *rx++ = word; in spi_lp8841_rtc_transfer_one()
125 count--; in spi_lp8841_rtc_transfer_one()
128 ret = -EINVAL; in spi_lp8841_rtc_transfer_one()
139 struct spi_lp8841_rtc *data = spi_controller_get_devdata(spi->controller); in spi_lp8841_rtc_set_cs()
141 data->state = 0; in spi_lp8841_rtc_set_cs()
142 writeb(data->state, data->iomem); in spi_lp8841_rtc_set_cs()
145 data->state |= SPI_LP8841_RTC_CE; in spi_lp8841_rtc_set_cs()
146 writeb(data->state, data->iomem); in spi_lp8841_rtc_set_cs()
154 if ((spi->mode & SPI_CS_HIGH) == 0) { in spi_lp8841_rtc_setup()
155 dev_err(&spi->dev, "unsupported active low chip select\n"); in spi_lp8841_rtc_setup()
156 return -EINVAL; in spi_lp8841_rtc_setup()
159 if ((spi->mode & SPI_LSB_FIRST) == 0) { in spi_lp8841_rtc_setup()
160 dev_err(&spi->dev, "unsupported MSB first mode\n"); in spi_lp8841_rtc_setup()
161 return -EINVAL; in spi_lp8841_rtc_setup()
164 if ((spi->mode & SPI_3WIRE) == 0) { in spi_lp8841_rtc_setup()
165 dev_err(&spi->dev, "unsupported wiring. 3 wires required\n"); in spi_lp8841_rtc_setup()
166 return -EINVAL; in spi_lp8841_rtc_setup()
174 { .compatible = "icpdas,lp8841-spi-rtc" },
188 host = spi_alloc_host(&pdev->dev, sizeof(*data)); in spi_lp8841_rtc_probe()
190 return -ENOMEM; in spi_lp8841_rtc_probe()
193 host->flags = SPI_CONTROLLER_HALF_DUPLEX; in spi_lp8841_rtc_probe()
194 host->mode_bits = SPI_CS_HIGH | SPI_3WIRE | SPI_LSB_FIRST; in spi_lp8841_rtc_probe()
196 host->bus_num = pdev->id; in spi_lp8841_rtc_probe()
197 host->num_chipselect = 1; in spi_lp8841_rtc_probe()
198 host->setup = spi_lp8841_rtc_setup; in spi_lp8841_rtc_probe()
199 host->set_cs = spi_lp8841_rtc_set_cs; in spi_lp8841_rtc_probe()
200 host->transfer_one = spi_lp8841_rtc_transfer_one; in spi_lp8841_rtc_probe()
201 host->bits_per_word_mask = SPI_BPW_MASK(8); in spi_lp8841_rtc_probe()
203 host->dev.of_node = pdev->dev.of_node; in spi_lp8841_rtc_probe()
208 data->iomem = devm_platform_ioremap_resource(pdev, 0); in spi_lp8841_rtc_probe()
209 ret = PTR_ERR_OR_ZERO(data->iomem); in spi_lp8841_rtc_probe()
211 dev_err(&pdev->dev, "failed to get IO address\n"); in spi_lp8841_rtc_probe()
216 ret = devm_spi_register_controller(&pdev->dev, host); in spi_lp8841_rtc_probe()
218 dev_err(&pdev->dev, "cannot register spi host\n"); in spi_lp8841_rtc_probe()
242 MODULE_DESCRIPTION("SPI host driver for ICP DAS LP-8841 RTC");