xref: /linux/Documentation/spi/spi-lm70llp.rst (revision 7397175cb7b48f7a3fc699083aa46f1234904c7e)
19cdd273eSMauro Carvalho Chehab==============================================
29cdd273eSMauro Carvalho Chehabspi_lm70llp :  LM70-LLP parport-to-SPI adapter
39cdd273eSMauro Carvalho Chehab==============================================
49cdd273eSMauro Carvalho Chehab
59cdd273eSMauro Carvalho ChehabSupported board/chip:
69cdd273eSMauro Carvalho Chehab
79cdd273eSMauro Carvalho Chehab  * National Semiconductor LM70 LLP evaluation board
89cdd273eSMauro Carvalho Chehab
9*7397175cSKousik Sanagavarapu    Datasheet: https://www.ti.com/lit/gpn/lm70
109cdd273eSMauro Carvalho Chehab
119cdd273eSMauro Carvalho ChehabAuthor:
129cdd273eSMauro Carvalho Chehab        Kaiwan N Billimoria <kaiwan@designergraphix.com>
139cdd273eSMauro Carvalho Chehab
149cdd273eSMauro Carvalho ChehabDescription
159cdd273eSMauro Carvalho Chehab-----------
169cdd273eSMauro Carvalho ChehabThis driver provides glue code connecting a National Semiconductor LM70 LLP
179cdd273eSMauro Carvalho Chehabtemperature sensor evaluation board to the kernel's SPI core subsystem.
189cdd273eSMauro Carvalho Chehab
199cdd273eSMauro Carvalho ChehabThis is a SPI master controller driver. It can be used in conjunction with
209cdd273eSMauro Carvalho Chehab(layered under) the LM70 logical driver (a "SPI protocol driver").
219cdd273eSMauro Carvalho ChehabIn effect, this driver turns the parallel port interface on the eval board
229cdd273eSMauro Carvalho Chehabinto a SPI bus with a single device, which will be driven by the generic
239cdd273eSMauro Carvalho ChehabLM70 driver (drivers/hwmon/lm70.c).
249cdd273eSMauro Carvalho Chehab
259cdd273eSMauro Carvalho Chehab
269cdd273eSMauro Carvalho ChehabHardware Interfacing
279cdd273eSMauro Carvalho Chehab--------------------
289cdd273eSMauro Carvalho ChehabThe schematic for this particular board (the LM70EVAL-LLP) is
299cdd273eSMauro Carvalho Chehabavailable (on page 4) here:
309cdd273eSMauro Carvalho Chehab
31*7397175cSKousik Sanagavarapu  https://download.datasheets.com/pdfs/documentation/nat/kit&board/lm70llpevalmanual.pdf
329cdd273eSMauro Carvalho Chehab
339cdd273eSMauro Carvalho ChehabThe hardware interfacing on the LM70 LLP eval board is as follows:
349cdd273eSMauro Carvalho Chehab
359cdd273eSMauro Carvalho Chehab   ======== == =========   ==========
369cdd273eSMauro Carvalho Chehab   Parallel                 LM70 LLP
379cdd273eSMauro Carvalho Chehab     Port   .  Direction   JP2 Header
389cdd273eSMauro Carvalho Chehab   ======== == =========   ==========
399cdd273eSMauro Carvalho Chehab      D0     2      -         -
409cdd273eSMauro Carvalho Chehab      D1     3     -->      V+   5
419cdd273eSMauro Carvalho Chehab      D2     4     -->      V+   5
429cdd273eSMauro Carvalho Chehab      D3     5     -->      V+   5
439cdd273eSMauro Carvalho Chehab      D4     6     -->      V+   5
449cdd273eSMauro Carvalho Chehab      D5     7     -->      nCS  8
459cdd273eSMauro Carvalho Chehab      D6     8     -->      SCLK 3
469cdd273eSMauro Carvalho Chehab      D7     9     -->      SI/O 5
479cdd273eSMauro Carvalho Chehab     GND    25      -       GND  7
489cdd273eSMauro Carvalho Chehab    Select  13     <--      SI/O 1
499cdd273eSMauro Carvalho Chehab   ======== == =========   ==========
509cdd273eSMauro Carvalho Chehab
519cdd273eSMauro Carvalho ChehabNote that since the LM70 uses a "3-wire" variant of SPI, the SI/SO pin
529cdd273eSMauro Carvalho Chehabis connected to both pin D7 (as Master Out) and Select (as Master In)
539cdd273eSMauro Carvalho Chehabusing an arrangement that lets either the parport or the LM70 pull the
549cdd273eSMauro Carvalho Chehabpin low.  This can't be shared with true SPI devices, but other 3-wire
559cdd273eSMauro Carvalho Chehabdevices might share the same SI/SO pin.
569cdd273eSMauro Carvalho Chehab
579cdd273eSMauro Carvalho ChehabThe bitbanger routine in this driver (lm70_txrx) is called back from
589cdd273eSMauro Carvalho Chehabthe bound "hwmon/lm70" protocol driver through its sysfs hook, using a
599cdd273eSMauro Carvalho Chehabspi_write_then_read() call.  It performs Mode 0 (SPI/Microwire) bitbanging.
600f6d2ceeSRandy DunlapThe lm70 driver then interprets the resulting digital temperature value
619cdd273eSMauro Carvalho Chehaband exports it through sysfs.
629cdd273eSMauro Carvalho Chehab
639cdd273eSMauro Carvalho ChehabA "gotcha": National Semiconductor's LM70 LLP eval board circuit schematic
649cdd273eSMauro Carvalho Chehabshows that the SI/O line from the LM70 chip is connected to the base of a
659cdd273eSMauro Carvalho Chehabtransistor Q1 (and also a pullup, and a zener diode to D7); while the
669cdd273eSMauro Carvalho Chehabcollector is tied to VCC.
679cdd273eSMauro Carvalho Chehab
689cdd273eSMauro Carvalho ChehabInterpreting this circuit, when the LM70 SI/O line is High (or tristate
699cdd273eSMauro Carvalho Chehaband not grounded by the host via D7), the transistor conducts and switches
709cdd273eSMauro Carvalho Chehabthe collector to zero, which is reflected on pin 13 of the DB25 parport
719cdd273eSMauro Carvalho Chehabconnector.  When SI/O is Low (driven by the LM70 or the host) on the other
72d56b699dSBjorn Helgaashand, the transistor is cut off and the voltage tied to its collector is
739cdd273eSMauro Carvalho Chehabreflected on pin 13 as a High level.
749cdd273eSMauro Carvalho Chehab
759cdd273eSMauro Carvalho ChehabSo: the getmiso inline routine in this driver takes this fact into account,
769cdd273eSMauro Carvalho Chehabinverting the value read at pin 13.
779cdd273eSMauro Carvalho Chehab
789cdd273eSMauro Carvalho Chehab
799cdd273eSMauro Carvalho ChehabThanks to
809cdd273eSMauro Carvalho Chehab---------
819cdd273eSMauro Carvalho Chehab
829cdd273eSMauro Carvalho Chehab- David Brownell for mentoring the SPI-side driver development.
839cdd273eSMauro Carvalho Chehab- Dr.Craig Hollabaugh for the (early) "manual" bitbanging driver version.
849cdd273eSMauro Carvalho Chehab- Nadir Billimoria for help interpreting the circuit schematic.
85