kernel-ark/drivers/char
Jim Cromie 62c83cde92 [PATCH] chardev: GPIO for SCx200 & PC-8736x: whitespace pre-clean
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.

These patches have been seen recently on Kernel-Mentors, and then
Kernel-Newbies ML, where Jesper Juhl kindly reviewed it.  His feedback has
been incorporated.  Thanks Jesper !

Its also gone to soekris-tech@soekris.com for possible testing by linux folks,
I've gotten 1 promise so far.  Theyre mostly BSD folk over there, but we'll
see..

Device-file & Sysfs

The driver preserves the existing device-file interface, including the
write/cmd set, but adds v 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 I've thus
reduced the pin-mode-updates from dev_info to dev_dbg.

I've recently bolted on a proto sysfs interface for both new drivers.  Im not
including those patches here; they (the patch + doc-pre-patch) are still quite
raw (and unreviewed on KNML), and since they 'invent' a convention for GPIO, a
proper vetting is needed.  Since this patchset is much bigger than my previous
ones, Id like to keep things simpler, and address it 1st, before bolting on
more stuff.

The driver-split

The Geode CPU and the PC-87366 Super-IO chip have GPIO units which share a
common pin-architecture (same pin features, with same bits controlling), but
with different addressing mechanics and port organizations.

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.

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.

heres how the pins are presented in syslog:

[ 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

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 some of 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).  A driver-spcific open() 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.preclean        # scripts/Lindent fixes, editor-ctrl comments

# API Modernization

gpio-scx/patch.api26        # what I learned from LDD3
gpio-scx/patch.platform-dev-2    # 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
# gpio-scx/patch.add-DEBUG    # enable all dev_dbg()s

# 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    # another 'c' 'command'
# 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*

# post KMentors-post patches ..

gpio-scx/patch.mutexes        # use mutexes for config-locks
gpio-scx/patch.viewpins-values    # extend dump to obsolete separate 'c' cmd

gpio-scx/patch.kconfig        # add stuff for kbuild

# TBC
# combine api26 with pdev, which is just one step.
# merge c&v commands to single do-all-fn
# delay viewpins, dump-diet should also un-ifdef it too.

diff.sys-gpio-rollup-1

This patch:

Removed editor format-control comments, and used scripts/Lindent to clean up
whitespace, then deleted the bogus chunks :-(

Signed-off-by: Jim Cromie <jim.cromie@gmail.com>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
2006-06-27 17:32:42 -07:00
..
agp Merge git://git.kernel.org/pub/scm/linux/kernel/git/bunk/trivial 2006-06-26 13:33:14 -07:00
drm [PATCH] spin/rwlock init cleanups 2006-06-27 17:32:39 -07:00
ftape drivers/char/ftape/lowlevel/fdc-io.c: Correct a comment 2006-03-26 19:18:07 +02:00
hw_random [PATCH] Add TI OMAP CPU family HW RNG driver 2006-06-26 09:58:19 -07:00
ip2 [PATCH] char/ip2: more section fixes (replacement) 2006-06-25 10:01:16 -07:00
ipmi [PATCH] IPMI: use schedule in kthread 2006-06-27 17:32:40 -07:00
mwave [PATCH] fix array overrun in drivers/char/mwave/mwavedd.c 2006-04-28 08:33:46 -07:00
pcmcia [PATCH] More !tty cleanups in drivers/char 2006-06-25 10:01:19 -07:00
rio spelling fixes 2006-06-26 18:35:02 +02:00
tpm [PATCH] tpm: more bios log parsing fixes 2006-05-31 16:27:10 -07:00
watchdog [WATCHDOG] s3c2410_wdt.c stop watchdog after boot 2006-05-15 21:38:14 +02:00
.gitignore
amiserial.c [PATCH] kill _INLINE_ 2006-03-23 07:38:16 -08:00
applicom.c [PATCH] drivers/char/applicom.c: proper module_{init,exit} 2006-06-25 10:01:05 -07:00
applicom.h
cd1865.h
ChangeLog
consolemap.c
cp437.uni
cs5535_gpio.c [PATCH] cs5535_gpio.c: call cdev_del() during module_exit to unmap kobject references and other cleanups 2006-04-20 07:54:03 -07:00
cyclades.c [PATCH] Cyclades Cleanup 2006-06-25 10:01:17 -07:00
decserial.c
defkeymap.c_shipped
defkeymap.map
digi1.h
digi.h
digiFep1.h
digiPCI.h
ds1286.c
ds1302.c
ds1620.c
dsp56k.c
dtlk.c [PATCH] Remove extraneous \n in doubletalk init printk. 2006-04-11 06:18:41 -07:00
ec3104_keyb.c
efirtc.c
epca.c [PATCH] spin/rwlock init cleanups 2006-06-27 17:32:39 -07:00
epca.h
epcaconfig.h
esp.c [PATCH] Clean up char/esp.c 2006-06-25 10:01:17 -07:00
generic_nvram.c [PATCH] powerpc: Kill _machine and hard-coded platform numbers 2006-03-28 23:15:54 +11:00
generic_serial.c [PATCH] sem2mutex: serial ->port_write_mutex 2006-03-23 07:38:14 -08:00
genrtc.c [PATCH] genrtc: fix read on 64-bit platforms 2006-05-01 18:17:47 -07:00
hangcheck-timer.c [PATCH] hangcheck: remove monotomic_clock on x86 2006-06-26 09:58:20 -07:00
hpet.c HPET: fix ACPI memory range length handling 2006-04-01 22:07:51 -05:00
hvc_console.c [PATCH] powerpc: Make rtas console _much_ faster 2006-06-09 21:24:18 +10:00
hvc_console.h [PATCH] powerpc: hvc_console updates 2006-03-28 16:45:26 +11:00
hvc_rtas.c [PATCH] powerpc: Cleanup hvc_rtas.c a little 2006-06-09 21:24:20 +10:00
hvc_vio.c [PATCH] powerpc: hvc_console updates 2006-03-28 16:45:26 +11:00
hvcs.c [PATCH] powerpc/pseries: Change H_StudlyCaps to H_SHOUTING_CAPS 2006-04-01 22:36:57 +11:00
hvsi.c [PATCH] powerpc: Quiet HVSI boot output 2006-04-22 18:45:07 +10:00
i8k.c
ip27-rtc.c
isicom.c [PATCH] More !tty cleanups in drivers/char 2006-06-25 10:01:19 -07:00
istallion.c [PATCH] drivers/char/[i]stallion: Clean up kmalloc usage 2006-03-31 12:18:56 -08:00
ite_gpio.c
Kconfig [PATCH] VT binding: Make VT binding a Kconfig option 2006-06-26 09:58:33 -07:00
keyboard.c Merge master.kernel.org:/pub/scm/linux/kernel/git/dtor/input 2006-06-26 11:01:58 -07:00
lcd.c
lcd.h
lp.c
Makefile [PATCH] Add new generic HW RNG core 2006-06-26 09:58:19 -07:00
mbcs.c
mbcs.h
mem.c [PATCH] splice: add ->splice_write support for /dev/null 2006-04-26 14:40:08 +02:00
misc.c [PATCH] mark f_ops const in the inode 2006-03-28 09:16:05 -08:00
mmtimer.c [PATCH] mm: remove VM_LOCKED before remap_pfn_range and drop VM_SHM 2006-06-25 10:00:55 -07:00
moxa.c [PATCH] spin/rwlock init cleanups 2006-06-27 17:32:39 -07:00
mxser.c [PATCH] moxa: partial CodingStyle cleanup & spelling fixes 2006-06-25 10:01:08 -07:00
mxser.h [PATCH] Typo fixes 2006-03-28 09:16:08 -08:00
n_hdlc.c
n_r3964.c [PATCH] R3964: fix GFP_KERNEL allocations in timer function 2006-06-25 10:01:17 -07:00
n_tty.c [PATCH] Fix for the PPTP hangs that have been reported 2006-06-11 20:40:39 -07:00
nvram.c
nwbutton.c
nwbutton.h
nwflash.c [PATCH] sem2mutex: drivers/char/ 2006-03-23 07:38:11 -08:00
ppdev.c [PATCH] parport: move PP_MAJOR from ppdev.h to major.h 2006-03-25 08:22:53 -08:00
pty.c
qtronix.c
qtronixmap.c_shipped
qtronixmap.map
random.c [IPV6]: Unexport secure_ipv6_port_ephemeral 2006-04-09 22:29:17 -07:00
raw.c [PATCH] sem2mutex: drivers: raw, connector, dcdbas, ppp_generic 2006-03-23 07:38:10 -08:00
riscom8_reg.h
riscom8.c [PATCH] Remove MODULE_PARM 2006-03-25 08:22:52 -08:00
riscom8.h
rocket_int.h
rocket.c [PATCH] fix memory leak in rocketport rp_do_receive 2006-06-25 10:01:22 -07:00
rocket.h
rtc.c [SPARC64]: Use in-kernel PROM tree for EBUS and ISA. 2006-06-23 23:15:28 -07:00
s3c2410-rtc.c [PATCH] handle errors returned by platform_get_irq*() 2006-03-20 13:42:57 -08:00
scan_keyb.c
scan_keyb.h
scc.h
scx200_gpio.c [PATCH] chardev: GPIO for SCx200 & PC-8736x: whitespace pre-clean 2006-06-27 17:32:42 -07:00
selection.c
ser_a2232.c [PATCH] sem2mutex: serial ->port_write_mutex 2006-03-23 07:38:14 -08:00
ser_a2232.h
ser_a2232fw.ax
ser_a2232fw.h
serial167.c
snsc_event.c [PATCH] snsc kmalloc2kzalloc 2006-03-23 07:38:15 -08:00
snsc.c [PATCH] Altix snsc: duplicate kobject fix 2006-04-22 09:19:53 -07:00
snsc.h
sonypi.c Pull acpi_bus_register_driver into release branch 2006-06-15 21:28:57 -04:00
specialix_io8.h
specialix.c [PATCH] spin/rwlock init cleanups 2006-06-27 17:32:39 -07:00
stallion.c [PATCH] stallion clean up 2006-06-27 17:32:40 -07:00
sx.c [PATCH] spin/rwlock init cleanups 2006-06-27 17:32:39 -07:00
sx.h
sxboards.h
sxwindow.h
synclink_gt.c [PATCH] synclink_gt: add GT2 adapter support 2006-06-25 10:01:24 -07:00
synclink.c [PATCH] Typo fixes 2006-03-28 09:16:08 -08:00
synclinkmp.c [PATCH] More !tty cleanups in drivers/char 2006-06-25 10:01:19 -07:00
sysrq.c [PATCH] sysrq cleanup 2006-03-25 08:22:52 -08:00
tb0219.c [PATCH] tb0219: convert to the new platform device interface 2006-03-22 07:53:56 -08:00
tipar.c [PATCH] tipar oops fix 2006-04-28 08:33:46 -07:00
tlclk.c [PATCH] type-oh bug in tlclk.c 2006-06-26 14:12:02 -07:00
toshiba.c [PATCH] remove ISA legacy functions: drivers/char/toshiba.c 2006-03-24 07:33:19 -08:00
tty_io.c [PATCH] tty: fix TCSBRK comment 2006-06-27 17:32:39 -07:00
tty_ioctl.c
vc_screen.c
viocons.c
viotape.c [PATCH] powerpc: update iSeries viocd and viotape device-tree 2006-05-19 14:35:31 +10:00
vme_scc.c [PATCH] sem2mutex: serial ->port_write_mutex 2006-03-23 07:38:14 -08:00
vr41xx_giu.c [PATCH] vr41xx: convert to the new platform device interface 2006-03-22 07:53:56 -08:00
vt_ioctl.c
vt.c [PATCH] VT binding: Make VT binding a Kconfig option 2006-06-26 09:58:33 -07:00