GPIO SUPPORT FOR SCx200 & PC8736x
The patch-set reworks the 2.4 vintage scx200_gpio driver for modern
2.6, and refactors GPIO support to reuse it in a new driver for the
GPIO on PC-8736x chips.
Its handy for the Soekris.com net-4801, which has both chips.
The driver preserves the existing device-file interface, including the
write/cmd set, but adds v,c to 'view' the pin-settings & configs by
inducing, via gpio_dump(), a dev_info() call. Its a fairly crappy way
to get status, but it sticks to the syslog approach, conservatively.
Allowing users to voluntarily trigger logging is good, it gives them a
familiar way to confirm their app's control & use of the pins, and Ive
thus reduced the pin-mode-updates from dev_info to dev_dbg.
The Split
The Geode CPU and the PC-87366 Super-IO chip have GPIO units which
share a common pin-architecture, with different addressing mechanics.
The vintage driver expresses the pin capabilities with pin-mode
commands [OoPpTt],etc that change the pin configurations, and since
the 2 chips share pin-arch, we can reuse the read(), write() commands,
once the implementation is suitably adjusted.
[ 1890.176223] scx200_gpio.0: io00: 0x0044 TS OD PUE EDGE LO DEBOUNCE
[ 1890.287223] scx200_gpio.0: io01: 0x0003 OE PP PUD EDGE LO
The patchset adds a vtable: struct nsc_gpio_ops, to abstract the
existing gpio operations, then adjusts fileops.write() code to invoke
operations via that vtable. Driver specific open()s set private_data
to the vtable so its available for use by write().
The vtable gets the gpio_dump() too, since its user-friendly, and
(could be construed as) part of the current device-file interface. To
support use of dev_dbg() in write() & _dump(), the vtable gets a dev
ptr too, set by both scx200 & pc8736x _gpio drivers.
nsc_gpio.c: new file is new home of several file-ops methods, which
are modified to get their vtable from filp->private_data, and use it
where needed.
scx200_gpio.c: keeps its existing gpio routines, but now wires them up
via the vtable (they're invoked by nsc_gpio.c:nsc_gpio_write() thru
this vtable). open() now initializes filp->private_data with the
vtable.
Once the split is clean, and the scx200_gpio driver is working, we
copy and modify the function and variable names, and rework the
access-method bodies for the different addressing scheme.
Heres a working overview of the patchset:
# series file for GPIO
# Spring Cleaning
gpio-scx/patch.white-preclean # trim whitespace, run indent script
gpio-scx/patch.no-editor-cmts # remove editor control comments
# API Modernization
gpio-scx/patch.api26 # what I learned from LDD3
gpio-scx/patch.platform-dev # get pdev, support for dev_dbg()
gpio-scx/patch.unsigned-minor # fix to match std practice
# Debuggability
gpio-scx/patch.dump-diet # shrink gpio_dump()
gpio-scx/patch.viewpins # add new 'command' to call dump()
gpio-scx/patch.init-refactor # pull shadow-register init to sub
# Access-Abstraction (add vtable)
gpio-scx/patch.access-vtable # introduce nsg_gpio_ops vtable, w dump
gpio-scx/patch.vtable-calls # add & use the vtable in scx200_gpio
gpio-scx/patch.nscgpio-shell # add empty driver for common-fops
# move code under abstraction
gpio-scx/patch.migrate-fops # move file-ops methods from scx200_gpio
gpio-scx/patch.common-dump # mv scx200.c:scx200_gpio_dump() to nsc_gpio.c
gpio-scx/patch.add-pc8736x-gpio # add new driver, like old, w chip adapt
# Cleanups
# finish printk -> dev_dbg() etc
gpio-scx/patch.pdev-pc8736x # new drvr needs pdev too,
gpio-scx/patch.devdbg-nscgpio # add device to 'vtable', use in dev_dbg()
gpio-scx/patch.pin-config-view # add another 'command' to 'c' the pin-config
# gpio-scx/quiet-getset # take out excess dbg stuff (pretty quiet now)
gpio-scx/patch.shadow-current # imitate scx200_gpio's shadow regs in pc87*
gpio-scx/patch.kconfig # add stuff for kbuild
I think Ive got my thunderbird-gmail-shuffle down now, (starting with web-mail)
Im sure it will become obvious soon if otherwise.
thanks in advance
Jim Cromie
|