spi-lm70llp 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. spi_lm70llp : LM70-LLP parport-to-SPI adapter
  2. ==============================================
  3. Supported board/chip:
  4. * National Semiconductor LM70 LLP evaluation board
  5. Datasheet: http://www.national.com/pf/LM/LM70.html
  6. Author:
  7. Kaiwan N Billimoria <kaiwan@designergraphix.com>
  8. Description
  9. -----------
  10. This driver provides glue code connecting a National Semiconductor LM70 LLP
  11. temperature sensor evaluation board to the kernel's SPI core subsystem.
  12. In effect, this driver turns the parallel port interface on the eval board
  13. into a SPI bus with a single device, which will be driven by the generic
  14. LM70 driver (drivers/hwmon/lm70.c).
  15. The hardware interfacing on the LM70 LLP eval board is as follows:
  16. Parallel LM70 LLP
  17. Port Direction JP2 Header
  18. ----------- --------- ----------------
  19. D0 2 - -
  20. D1 3 --> V+ 5
  21. D2 4 --> V+ 5
  22. D3 5 --> V+ 5
  23. D4 6 --> V+ 5
  24. D5 7 --> nCS 8
  25. D6 8 --> SCLK 3
  26. D7 9 --> SI/O 5
  27. GND 25 - GND 7
  28. Select 13 <-- SI/O 1
  29. ----------- --------- ----------------
  30. Note that since the LM70 uses a "3-wire" variant of SPI, the SI/SO pin
  31. is connected to both pin D7 (as Master Out) and Select (as Master In)
  32. using an arrangment that lets either the parport or the LM70 pull the
  33. pin low. This can't be shared with true SPI devices, but other 3-wire
  34. devices might share the same SI/SO pin.
  35. The bitbanger routine in this driver (lm70_txrx) is called back from
  36. the bound "hwmon/lm70" protocol driver through its sysfs hook, using a
  37. spi_write_then_read() call. It performs Mode 0 (SPI/Microwire) bitbanging.
  38. The lm70 driver then inteprets the resulting digital temperature value
  39. and exports it through sysfs.
  40. A "gotcha": National Semiconductor's LM70 LLP eval board circuit schematic
  41. shows that the SI/O line from the LM70 chip is connected to the base of a
  42. transistor Q1 (and also a pullup, and a zener diode to D7); while the
  43. collector is tied to VCC.
  44. Interpreting this circuit, when the LM70 SI/O line is High (or tristate
  45. and not grounded by the host via D7), the transistor conducts and switches
  46. the collector to zero, which is reflected on pin 13 of the DB25 parport
  47. connector. When SI/O is Low (driven by the LM70 or the host) on the other
  48. hand, the transistor is cut off and the voltage tied to it's collector is
  49. reflected on pin 13 as a High level.
  50. So: the getmiso inline routine in this driver takes this fact into account,
  51. inverting the value read at pin 13.
  52. Thanks to
  53. ---------
  54. o David Brownell for mentoring the SPI-side driver development.
  55. o Dr.Craig Hollabaugh for the (early) "manual" bitbanging driver version.
  56. o Nadir Billimoria for help interpreting the circuit schematic.