Lines Matching +full:2 +full:- +full:layered

1 // SPDX-License-Identifier: GPL-2.0-or-later
3 * Driver for LM70EVAL-LLP board for the LM70 sensor
23 * The LM70 communicates with a host processor using a 3-wire variant of
26 * port to bitbang an SPI-parport bridge. Accordingly, this is an SPI
28 * driver", layered on top of this one and usable without the lm70llp.
33 * The schematic for this particular board (the LM70EVAL-LLP) is
37 * Also see Documentation/spi/spi-lm70llp.rst. The SPI<->parport code here is
38 * (heavily) based on spi-butterfly by David Brownell.
44 * ----------- --------- ------------
45 * D0 2 - -
46 * D1 3 --> V+ 5
47 * D2 4 --> V+ 5
48 * D3 5 --> V+ 5
49 * D4 6 --> V+ 5
50 * D5 7 --> nCS 8
51 * D6 8 --> SCLK 3
52 * D7 9 --> SI/O 5
53 * GND 25 - GND 7
54 * Select 13 <-- SI/O 1
61 #define DRVNAME "spi-lm70llp"
68 /*-------------------------------------------------------------------------*/
82 /*-------------------------------------------------------------------*/
86 return spi->controller_data; in spidev_to_pp()
89 /*---------------------- LM70 LLP eval board-specific inlines follow */
98 u8 data = parport_read_data(pp->port); in deassertCS()
100 data &= ~0x80; /* pull D7/SI-out low while de-asserted */ in deassertCS()
101 parport_write_data(pp->port, data | nCS); in deassertCS()
106 u8 data = parport_read_data(pp->port); in assertCS()
108 data |= 0x80; /* pull D7/SI-out high so lm70 drives SO-in */ in assertCS()
109 parport_write_data(pp->port, data & ~nCS); in assertCS()
114 u8 data = parport_read_data(pp->port); in clkHigh()
116 parport_write_data(pp->port, data | SCLK); in clkHigh()
121 u8 data = parport_read_data(pp->port); in clkLow()
123 parport_write_data(pp->port, data & ~SCLK); in clkLow()
126 /*------------------------- SPI-LM70-specific inlines ----------------------*/
153 * Why do we return 0 when the SIO line is high and vice-versa?
156 * switches it to low reflecting this on the parport (pin 13), and vice-versa.
162 return ((SIO == (parport_read_status(pp->port) & SIO)) ? 0 : 1); in getmiso()
165 /*--------------------------------------------------------------------*/
167 #include "spi-bitbang-txrx.h"
205 host = spi_alloc_host(p->physport->dev, sizeof(*pp)); in spi_lm70llp_attach()
207 status = -ENOMEM; in spi_lm70llp_attach()
215 pp->bitbang.ctlr = host; in spi_lm70llp_attach()
216 pp->bitbang.chipselect = lm70_chipselect; in spi_lm70llp_attach()
217 pp->bitbang.txrx_word[SPI_MODE_0] = lm70_txrx; in spi_lm70llp_attach()
218 pp->bitbang.flags = SPI_3WIRE; in spi_lm70llp_attach()
223 pp->port = p; in spi_lm70llp_attach()
230 status = -ENOMEM; in spi_lm70llp_attach()
233 pp->pd = pd; in spi_lm70llp_attach()
242 status = spi_bitbang_start(&pp->bitbang); in spi_lm70llp_attach()
244 dev_warn(&pd->dev, "spi_bitbang_start failed with status %d\n", in spi_lm70llp_attach()
255 strcpy(pp->info.modalias, "lm70"); in spi_lm70llp_attach()
256 pp->info.max_speed_hz = 6 * 1000 * 1000; in spi_lm70llp_attach()
257 pp->info.chip_select = 0; in spi_lm70llp_attach()
258 pp->info.mode = SPI_3WIRE | SPI_MODE_0; in spi_lm70llp_attach()
261 parport_write_data(pp->port, lm70_INIT); in spi_lm70llp_attach()
266 pp->info.controller_data = pp; in spi_lm70llp_attach()
267 pp->spidev_lm70 = spi_new_device(pp->bitbang.ctlr, &pp->info); in spi_lm70llp_attach()
268 if (pp->spidev_lm70) in spi_lm70llp_attach()
269 dev_dbg(&pp->spidev_lm70->dev, "spidev_lm70 at %s\n", in spi_lm70llp_attach()
270 dev_name(&pp->spidev_lm70->dev)); in spi_lm70llp_attach()
272 dev_warn(&pd->dev, "spi_new_device failed\n"); in spi_lm70llp_attach()
273 status = -ENODEV; in spi_lm70llp_attach()
276 pp->spidev_lm70->bits_per_word = 8; in spi_lm70llp_attach()
282 spi_bitbang_stop(&pp->bitbang); in spi_lm70llp_attach()
285 parport_write_data(pp->port, 0); in spi_lm70llp_attach()
287 parport_release(pp->pd); in spi_lm70llp_attach()
300 if (!lm70llp || lm70llp->port != p) in spi_lm70llp_detach()
304 spi_bitbang_stop(&pp->bitbang); in spi_lm70llp_detach()
307 parport_write_data(pp->port, 0); in spi_lm70llp_detach()
309 parport_release(pp->pd); in spi_lm70llp_detach()
310 parport_unregister_device(pp->pd); in spi_lm70llp_detach()
312 spi_controller_put(pp->bitbang.ctlr); in spi_lm70llp_detach()