From: John Crispin Date: Sat, 26 Jan 2008 03:16:11 +0000 (+0000) Subject: add generic gpio char dev for CONFIG_GENERIC_GPIO archs X-Git-Url: http://git.lede-project.org./?a=commitdiff_plain;h=0844d5fe4950f671712ca16bfecd9baf4ffdf8a6;p=openwrt%2Fstaging%2Flynxis%2Fomap.git add generic gpio char dev for CONFIG_GENERIC_GPIO archs SVN-Revision: 10261 --- diff --git a/package/base-files/files/etc/hotplug2-common.rules b/package/base-files/files/etc/hotplug2-common.rules index ed785e3b1c..875fa12eea 100644 --- a/package/base-files/files/etc/hotplug2-common.rules +++ b/package/base-files/files/etc/hotplug2-common.rules @@ -1,5 +1,5 @@ -DEVICENAME ~~ (null|full|ptmx|tty|zero) { +DEVICENAME ~~ (null|full|ptmx|tty|zero|gpio) { nothrottle makedev /dev/%DEVICENAME% 0666 next diff --git a/target/linux/generic-2.6/config-2.6.23 b/target/linux/generic-2.6/config-2.6.23 index b6a2361c8f..62d5ec0918 100644 --- a/target/linux/generic-2.6/config-2.6.23 +++ b/target/linux/generic-2.6/config-2.6.23 @@ -1730,3 +1730,4 @@ CONFIG_ZLIB_DEFLATE=y CONFIG_ZLIB_INFLATE=y CONFIG_ZONE_DMA=y CONFIG_ZONE_DMA_FLAG=1 +# CONFIG_GPIO_DEVICE is not set diff --git a/target/linux/generic-2.6/files/drivers/gpio/.built-in.o.cmd b/target/linux/generic-2.6/files/drivers/gpio/.built-in.o.cmd new file mode 100644 index 0000000000..5022c4d07c --- /dev/null +++ b/target/linux/generic-2.6/files/drivers/gpio/.built-in.o.cmd @@ -0,0 +1 @@ +cmd_drivers/gpio/built-in.o := armeb-linux-uclibc-ld -EB -r -o drivers/gpio/built-in.o drivers/gpio/gpio_dev.o diff --git a/target/linux/generic-2.6/files/drivers/gpio/.gpio_dev.o.cmd b/target/linux/generic-2.6/files/drivers/gpio/.gpio_dev.o.cmd new file mode 100644 index 0000000000..7e4e1ab5e0 --- /dev/null +++ b/target/linux/generic-2.6/files/drivers/gpio/.gpio_dev.o.cmd @@ -0,0 +1,371 @@ +cmd_drivers/gpio/gpio_dev.o := armeb-linux-uclibc-gcc -Wp,-MD,drivers/gpio/.gpio_dev.o.d -nostdinc -isystem /mnt/ixp/staging_dir/toolchain-armeb_gcc4.1.2/lib/gcc/armeb-linux-uclibc/4.1.2/include -D__KERNEL__ -Iinclude -include include/linux/autoconf.h -mbig-endian -Wall -Wundef -Wstrict-prototypes -Wno-trigraphs -fno-strict-aliasing -fno-common -Werror-implicit-function-declaration -Os -marm -fno-omit-frame-pointer -mapcs -mno-sched-prolog -mabi=aapcs-linux -mno-thumb-interwork -D__LINUX_ARM_ARCH__=5 -march=armv5te -mtune=xscale -Wa,-mcpu=xscale -msoft-float -Uarm -fno-omit-frame-pointer -fno-optimize-sibling-calls -fno-stack-protector -funit-at-a-time -Wdeclaration-after-statement -Wno-pointer-sign -D"KBUILD_STR(s)=\#s" -D"KBUILD_BASENAME=KBUILD_STR(gpio_dev)" -D"KBUILD_MODNAME=KBUILD_STR(gpio_dev)" -c -o drivers/gpio/gpio_dev.o drivers/gpio/gpio_dev.c + +deps_drivers/gpio/gpio_dev.o := \ + drivers/gpio/gpio_dev.c \ + include/linux/module.h \ + $(wildcard include/config/modules.h) \ + $(wildcard include/config/modversions.h) \ + $(wildcard include/config/unused/symbols.h) \ + $(wildcard include/config/generic/bug.h) \ + $(wildcard include/config/module/unload.h) \ + $(wildcard include/config/kallsyms.h) \ + $(wildcard include/config/sysfs.h) \ + include/linux/list.h \ + $(wildcard include/config/debug/list.h) \ + include/linux/stddef.h \ + include/linux/compiler.h \ + $(wildcard include/config/enable/must/check.h) \ + include/linux/compiler-gcc4.h \ + $(wildcard include/config/forced/inlining.h) \ + include/linux/compiler-gcc.h \ + include/linux/poison.h \ + include/linux/prefetch.h \ + include/linux/types.h \ + $(wildcard include/config/uid16.h) \ + $(wildcard include/config/lbd.h) \ + $(wildcard include/config/lsf.h) \ + $(wildcard include/config/resources/64bit.h) \ + include/linux/posix_types.h \ + include/asm/posix_types.h \ + include/asm/types.h \ + include/asm/processor.h \ + $(wildcard include/config/mmu.h) \ + include/asm/ptrace.h \ + $(wildcard include/config/arm/thumb.h) \ + $(wildcard include/config/smp.h) \ + include/asm/hwcap.h \ + include/asm/cache.h \ + include/asm/system.h \ + $(wildcard include/config/cpu/cp15.h) \ + $(wildcard include/config/cpu/xsc3.h) \ + $(wildcard include/config/cpu/xscale.h) \ + $(wildcard include/config/cpu/sa1100.h) \ + $(wildcard include/config/cpu/sa110.h) \ + include/asm/memory.h \ + $(wildcard include/config/dram/size.h) \ + $(wildcard include/config/dram/base.h) \ + $(wildcard include/config/discontigmem.h) \ + include/asm/arch/memory.h \ + $(wildcard include/config/pci.h) \ + include/asm/sizes.h \ + include/asm-generic/memory_model.h \ + $(wildcard include/config/flatmem.h) \ + $(wildcard include/config/sparsemem.h) \ + $(wildcard include/config/out/of/line/pfn/to/page.h) \ + include/linux/linkage.h \ + include/asm/linkage.h \ + include/linux/irqflags.h \ + $(wildcard include/config/trace/irqflags.h) \ + $(wildcard include/config/trace/irqflags/support.h) \ + $(wildcard include/config/x86.h) \ + include/asm/irqflags.h \ + include/linux/stat.h \ + include/asm/stat.h \ + include/linux/time.h \ + include/linux/cache.h \ + include/linux/kernel.h \ + $(wildcard include/config/preempt/voluntary.h) \ + $(wildcard include/config/debug/spinlock/sleep.h) \ + $(wildcard include/config/printk.h) \ + $(wildcard include/config/numa.h) \ + /mnt/ixp/staging_dir/toolchain-armeb_gcc4.1.2/lib/gcc/armeb-linux-uclibc/4.1.2/include/stdarg.h \ + include/linux/bitops.h \ + include/asm/bitops.h \ + include/asm-generic/bitops/non-atomic.h \ + include/asm-generic/bitops/fls64.h \ + include/asm-generic/bitops/sched.h \ + include/asm-generic/bitops/hweight.h \ + include/linux/log2.h \ + $(wildcard include/config/arch/has/ilog2/u32.h) \ + $(wildcard include/config/arch/has/ilog2/u64.h) \ + include/asm/byteorder.h \ + include/linux/byteorder/big_endian.h \ + include/linux/byteorder/swab.h \ + include/linux/byteorder/generic.h \ + include/asm/bug.h \ + $(wildcard include/config/bug.h) \ + $(wildcard include/config/debug/bugverbose.h) \ + include/asm-generic/bug.h \ + include/linux/seqlock.h \ + include/linux/spinlock.h \ + $(wildcard include/config/debug/spinlock.h) \ + $(wildcard include/config/preempt.h) \ + $(wildcard include/config/debug/lock/alloc.h) \ + include/linux/preempt.h \ + $(wildcard include/config/debug/preempt.h) \ + $(wildcard include/config/preempt/notifiers.h) \ + include/linux/thread_info.h \ + include/asm/thread_info.h \ + $(wildcard include/config/debug/stack/usage.h) \ + include/asm/fpstate.h \ + $(wildcard include/config/iwmmxt.h) \ + include/asm/domain.h \ + $(wildcard include/config/io/36.h) \ + include/linux/stringify.h \ + include/linux/bottom_half.h \ + include/linux/spinlock_types.h \ + include/linux/spinlock_types_up.h \ + include/linux/lockdep.h \ + $(wildcard include/config/lockdep.h) \ + $(wildcard include/config/lock/stat.h) \ + $(wildcard include/config/generic/hardirqs.h) \ + $(wildcard include/config/prove/locking.h) \ + include/linux/spinlock_up.h \ + include/linux/spinlock_api_up.h \ + include/asm/atomic.h \ + include/asm-generic/atomic.h \ + include/linux/kmod.h \ + $(wildcard include/config/kmod.h) \ + include/linux/errno.h \ + include/asm/errno.h \ + include/asm-generic/errno.h \ + include/asm-generic/errno-base.h \ + include/linux/elf.h \ + include/linux/auxvec.h \ + include/asm/auxvec.h \ + include/linux/elf-em.h \ + include/asm/elf.h \ + include/asm/user.h \ + include/asm/page.h \ + $(wildcard include/config/cpu/copy/v3.h) \ + $(wildcard include/config/cpu/copy/v4wt.h) \ + $(wildcard include/config/cpu/copy/v4wb.h) \ + $(wildcard include/config/cpu/copy/v6.h) \ + $(wildcard include/config/aeabi.h) \ + include/asm/glue.h \ + $(wildcard include/config/cpu/arm610.h) \ + $(wildcard include/config/cpu/arm710.h) \ + $(wildcard include/config/cpu/abrt/lv4t.h) \ + $(wildcard include/config/cpu/abrt/ev4.h) \ + $(wildcard include/config/cpu/abrt/ev4t.h) \ + $(wildcard include/config/cpu/abrt/ev5tj.h) \ + $(wildcard include/config/cpu/abrt/ev5t.h) \ + $(wildcard include/config/cpu/abrt/ev6.h) \ + $(wildcard include/config/cpu/abrt/ev7.h) \ + include/asm-generic/page.h \ + include/linux/kobject.h \ + $(wildcard include/config/hotplug.h) \ + include/linux/sysfs.h \ + include/linux/kref.h \ + include/linux/wait.h \ + include/asm/current.h \ + include/linux/moduleparam.h \ + include/linux/init.h \ + $(wildcard include/config/hotplug/cpu.h) \ + $(wildcard include/config/memory/hotplug.h) \ + $(wildcard include/config/acpi/hotplug/memory.h) \ + include/asm/local.h \ + include/asm-generic/local.h \ + include/linux/percpu.h \ + include/linux/slab.h \ + $(wildcard include/config/slab/debug.h) \ + $(wildcard include/config/slub.h) \ + $(wildcard include/config/slob.h) \ + $(wildcard include/config/debug/slab.h) \ + include/linux/gfp.h \ + $(wildcard include/config/zone/dma.h) \ + $(wildcard include/config/zone/dma32.h) \ + $(wildcard include/config/highmem.h) \ + include/linux/mmzone.h \ + $(wildcard include/config/force/max/zoneorder.h) \ + $(wildcard include/config/arch/populates/node/map.h) \ + $(wildcard include/config/flat/node/mem/map.h) \ + $(wildcard include/config/have/memory/present.h) \ + $(wildcard include/config/need/node/memmap/size.h) \ + $(wildcard include/config/need/multiple/nodes.h) \ + $(wildcard include/config/have/arch/early/pfn/to/nid.h) \ + $(wildcard include/config/sparsemem/extreme.h) \ + $(wildcard include/config/nodes/span/other/nodes.h) \ + $(wildcard include/config/holes/in/zone.h) \ + include/linux/threads.h \ + $(wildcard include/config/nr/cpus.h) \ + $(wildcard include/config/base/small.h) \ + include/linux/numa.h \ + $(wildcard include/config/nodes/shift.h) \ + include/linux/nodemask.h \ + include/linux/bitmap.h \ + include/linux/string.h \ + include/asm/string.h \ + include/linux/memory_hotplug.h \ + $(wildcard include/config/have/arch/nodedata/extension.h) \ + include/linux/notifier.h \ + include/linux/mutex.h \ + $(wildcard include/config/debug/mutexes.h) \ + include/linux/rwsem.h \ + $(wildcard include/config/rwsem/generic/spinlock.h) \ + include/linux/rwsem-spinlock.h \ + include/linux/srcu.h \ + include/linux/topology.h \ + $(wildcard include/config/sched/smt.h) \ + $(wildcard include/config/sched/mc.h) \ + include/linux/cpumask.h \ + include/linux/smp.h \ + include/asm/topology.h \ + include/asm-generic/topology.h \ + include/linux/slab_def.h \ + include/linux/kmalloc_sizes.h \ + include/asm/percpu.h \ + include/asm-generic/percpu.h \ + include/linux/hardirq.h \ + $(wildcard include/config/preempt/bkl.h) \ + $(wildcard include/config/virt/cpu/accounting.h) \ + include/linux/smp_lock.h \ + $(wildcard include/config/lock/kernel.h) \ + include/asm/hardirq.h \ + include/asm/irq.h \ + include/asm/arch/irqs.h \ + $(wildcard include/config/cpu/ixp46x.h) \ + $(wildcard include/config/cpu/ixp43x.h) \ + include/linux/irq_cpustat.h \ + include/asm/module.h \ + include/asm/uaccess.h \ + include/linux/sched.h \ + $(wildcard include/config/sched/debug.h) \ + $(wildcard include/config/no/hz.h) \ + $(wildcard include/config/detect/softlockup.h) \ + $(wildcard include/config/split/ptlock/cpus.h) \ + $(wildcard include/config/keys.h) \ + $(wildcard include/config/bsd/process/acct.h) \ + $(wildcard include/config/taskstats.h) \ + $(wildcard include/config/audit.h) \ + $(wildcard include/config/inotify/user.h) \ + $(wildcard include/config/schedstats.h) \ + $(wildcard include/config/task/delay/acct.h) \ + $(wildcard include/config/fair/group/sched.h) \ + $(wildcard include/config/blk/dev/io/trace.h) \ + $(wildcard include/config/cc/stackprotector.h) \ + $(wildcard include/config/sysvipc.h) \ + $(wildcard include/config/rt/mutexes.h) \ + $(wildcard include/config/task/xacct.h) \ + $(wildcard include/config/cpusets.h) \ + $(wildcard include/config/compat.h) \ + $(wildcard include/config/fault/injection.h) \ + include/asm/param.h \ + $(wildcard include/config/hz.h) \ + include/linux/capability.h \ + include/linux/timex.h \ + include/asm/timex.h \ + include/asm/arch/timex.h \ + include/asm/hardware.h \ + include/asm/arch/hardware.h \ + include/asm/arch/ixp4xx-regs.h \ + include/asm/arch/cpu.h \ + include/asm/arch/platform.h \ + include/asm/arch/ixdp425.h \ + include/asm/arch/avila.h \ + include/asm/arch/coyote.h \ + include/asm/arch/prpmc1100.h \ + include/asm/arch/nslu2.h \ + include/asm/arch/nas100d.h \ + include/asm/arch/dsmg600.h \ + include/asm/arch/fsg.h \ + include/linux/jiffies.h \ + include/linux/calc64.h \ + include/asm/div64.h \ + include/linux/rbtree.h \ + include/asm/semaphore.h \ + include/asm/locks.h \ + include/asm/mmu.h \ + $(wildcard include/config/cpu/has/asid.h) \ + include/asm/cputime.h \ + include/asm-generic/cputime.h \ + include/linux/sem.h \ + include/linux/ipc.h \ + include/asm/ipcbuf.h \ + include/asm/sembuf.h \ + include/linux/signal.h \ + include/asm/signal.h \ + include/asm-generic/signal.h \ + include/asm/sigcontext.h \ + include/asm/siginfo.h \ + include/asm-generic/siginfo.h \ + include/linux/securebits.h \ + include/linux/fs_struct.h \ + include/linux/completion.h \ + include/linux/pid.h \ + include/linux/rcupdate.h \ + include/linux/seccomp.h \ + $(wildcard include/config/seccomp.h) \ + include/linux/futex.h \ + $(wildcard include/config/futex.h) \ + include/linux/rtmutex.h \ + $(wildcard include/config/debug/rt/mutexes.h) \ + include/linux/plist.h \ + $(wildcard include/config/debug/pi/list.h) \ + include/linux/param.h \ + include/linux/resource.h \ + include/asm/resource.h \ + include/asm-generic/resource.h \ + include/linux/timer.h \ + $(wildcard include/config/timer/stats.h) \ + include/linux/ktime.h \ + $(wildcard include/config/ktime/scalar.h) \ + include/linux/hrtimer.h \ + $(wildcard include/config/high/res/timers.h) \ + include/linux/task_io_accounting.h \ + $(wildcard include/config/task/io/accounting.h) \ + include/linux/aio.h \ + include/linux/workqueue.h \ + include/linux/aio_abi.h \ + include/linux/uio.h \ + include/asm/io.h \ + include/asm/arch/io.h \ + $(wildcard include/config/ixp4xx/indirect/pci.h) \ + include/asm/gpio.h \ + include/asm/arch/gpio.h \ + include/asm-generic/gpio.h \ + include/linux/genhd.h \ + $(wildcard include/config/block.h) \ + $(wildcard include/config/fail/make/request.h) \ + $(wildcard include/config/solaris/x86/partition.h) \ + $(wildcard include/config/bsd/disklabel.h) \ + $(wildcard include/config/unixware/disklabel.h) \ + $(wildcard include/config/minix/subpartition.h) \ + include/linux/major.h \ + include/linux/device.h \ + $(wildcard include/config/debug/devres.h) \ + include/linux/ioport.h \ + include/linux/klist.h \ + include/linux/pm.h \ + $(wildcard include/config/suspend.h) \ + $(wildcard include/config/pm/sleep.h) \ + include/asm/device.h \ + $(wildcard include/config/dmabounce.h) \ + include/linux/fs.h \ + $(wildcard include/config/dnotify.h) \ + $(wildcard include/config/quota.h) \ + $(wildcard include/config/inotify.h) \ + $(wildcard include/config/security.h) \ + $(wildcard include/config/epoll.h) \ + $(wildcard include/config/auditsyscall.h) \ + $(wildcard include/config/fs/xip.h) \ + $(wildcard include/config/migration.h) \ + include/linux/limits.h \ + include/linux/ioctl.h \ + include/asm/ioctl.h \ + include/asm-generic/ioctl.h \ + include/linux/kdev_t.h \ + include/linux/dcache.h \ + $(wildcard include/config/profiling.h) \ + include/linux/namei.h \ + include/linux/radix-tree.h \ + include/linux/prio_tree.h \ + include/linux/sysctl.h \ + include/linux/quota.h \ + include/linux/dqblk_xfs.h \ + include/linux/dqblk_v1.h \ + include/linux/dqblk_v2.h \ + include/linux/nfs_fs_i.h \ + include/linux/nfs.h \ + include/linux/sunrpc/msg_prot.h \ + include/linux/fcntl.h \ + include/asm/fcntl.h \ + include/asm-generic/fcntl.h \ + $(wildcard include/config/64bit.h) \ + include/linux/err.h \ + include/linux/platform_device.h \ + include/linux/gpio_dev.h \ + +drivers/gpio/gpio_dev.o: $(deps_drivers/gpio/gpio_dev.o) + +$(deps_drivers/gpio/gpio_dev.o): diff --git a/target/linux/generic-2.6/files/drivers/gpio/Kconfig b/target/linux/generic-2.6/files/drivers/gpio/Kconfig new file mode 100644 index 0000000000..d97fc1b4f1 --- /dev/null +++ b/target/linux/generic-2.6/files/drivers/gpio/Kconfig @@ -0,0 +1,15 @@ +menuconfig NEW_GPIO + bool "GPIO Support" + depends on GENERIC_GPIO + help + Say Y to enable Linux GPIO device support. This allows control of + GPIO pins using a character device + +if NEW_GPIO + +config GPIO_DEVICE + tristate "GPIO device support" + help + This option enables the gpio character device + +endif # NEW_GPIO diff --git a/target/linux/generic-2.6/files/drivers/gpio/Makefile b/target/linux/generic-2.6/files/drivers/gpio/Makefile new file mode 100644 index 0000000000..166c5c7434 --- /dev/null +++ b/target/linux/generic-2.6/files/drivers/gpio/Makefile @@ -0,0 +1 @@ +obj-$(CONFIG_GPIO_DEVICE) += gpio_dev.o diff --git a/target/linux/generic-2.6/files/drivers/gpio/gpio_dev.c b/target/linux/generic-2.6/files/drivers/gpio/gpio_dev.c new file mode 100644 index 0000000000..2adbb96d40 --- /dev/null +++ b/target/linux/generic-2.6/files/drivers/gpio/gpio_dev.c @@ -0,0 +1,194 @@ +/* + * character device wrapper for generic gpio layer + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA02111-1307USA + * + * Feedback, Bugs... blogic@openwrt.org + * + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#define DRVNAME "gpiodev" +#define DEVNAME "gpio" + +static int dev_major; +static int gpio_is_open = 0; +unsigned int gpio_access_mask = 0; +static struct class *gpio_class; + +static int +gpio_ioctl(struct inode * inode, struct file * file, unsigned int cmd, unsigned long arg) +{ + int retval = 0; + + if ((arg & gpio_access_mask) != arg) + { + retval = -EINVAL; + goto out; + } + + switch (cmd) + { + case GPIO_GET: + retval = gpio_get_value(arg); + break; + + case GPIO_SET: + gpio_set_value(arg, 0); + break; + + case GPIO_CLEAR: + gpio_set_value(arg, 0); + break; + + case GPIO_DIR_IN: + gpio_direction_input(arg); + break; + + case GPIO_DIR_OUT: + gpio_direction_output(arg, 0); + break; + + default: + retval = -EINVAL; + break; + } + +out: + return retval; +} + +static int +gpio_open(struct inode *inode, struct file *file) +{ + int result = 0; + unsigned int dev_minor = MINOR(inode->i_rdev); + + if (dev_minor != 0) + { + printk(KERN_ERR DRVNAME ": trying to access unknown minor device -> %d\n", dev_minor); + result = -ENODEV; + goto out; + } + + if (gpio_is_open) + { + printk(KERN_ERR DRVNAME ": Device with minor ID %d already in use\n", dev_minor); + result = -EBUSY; + goto out; + } + + gpio_is_open = 1; + +out: + return result; +} + +static int +gpio_close(struct inode * inode, struct file * file) +{ + gpio_is_open = 0; + + return 0; +} + +struct file_operations gpio_fops = { + ioctl: gpio_ioctl, + open: gpio_open, + release: gpio_close +}; + +static int +gpio_probe(struct platform_device *dev) +{ + int result = 0; + + dev_major = register_chrdev(0, DEVNAME, &gpio_fops); + if (!dev_major) + { + printk(KERN_ERR DRVNAME ": Error whilst opening %s \n", DEVNAME); + result = -ENODEV; + goto out; + } + + gpio_class = class_create(THIS_MODULE, DEVNAME); + class_device_create(gpio_class, NULL, MKDEV(dev_major, 0), NULL, DEVNAME); + + printk(KERN_INFO DRVNAME ": gpio device registered with major %d\n", dev_major); + + if (dev->num_resources != 1) + { + printk(KERN_ERR DRVNAME ": device may only have 1 resource\n"); + result = -ENODEV; + goto out; + } + + gpio_access_mask = dev->resource[0].start; + + printk(KERN_INFO DRVNAME ": gpio platform device registered with access mask %08X\n", gpio_access_mask); +out: + return result; +} + +static int +gpio_remove(struct platform_device *dev) +{ + unregister_chrdev(dev_major, DEVNAME); + return 0; +} + +static struct +platform_driver gpio_driver = { + .probe = gpio_probe, + .remove = gpio_remove, + .driver = { + .name = "GPIODEV", + .owner = THIS_MODULE, + }, +}; + +static int __init +gpio_mod_init(void) +{ + int ret = platform_driver_register(&gpio_driver); + if (ret) + printk(KERN_INFO DRVNAME ": Error registering platfom driver!"); + + return ret; +} + +static void __exit +gpio_mod_exit(void) +{ + platform_driver_unregister(&gpio_driver); +} + +module_init (gpio_mod_init); +module_exit (gpio_mod_exit); + +MODULE_LICENSE("GPL"); +MODULE_AUTHOR("John Crispin / OpenWrt"); +MODULE_DESCRIPTION("Character device for for generic gpio api"); diff --git a/target/linux/generic-2.6/patches-2.6.23/920-gpio_dev.patch b/target/linux/generic-2.6/patches-2.6.23/920-gpio_dev.patch new file mode 100644 index 0000000000..81c206b657 --- /dev/null +++ b/target/linux/generic-2.6/patches-2.6.23/920-gpio_dev.patch @@ -0,0 +1,35 @@ +Index: linux-2.6.23.14/arch/arm/Kconfig +=================================================================== +--- linux-2.6.23.14.orig/arch/arm/Kconfig 2008-01-26 02:46:18.000000000 +0100 ++++ linux-2.6.23.14/arch/arm/Kconfig 2008-01-26 02:46:33.000000000 +0100 +@@ -1039,6 +1039,8 @@ + + source "drivers/leds/Kconfig" + ++source "drivers/gpio/Kconfig" ++ + source "drivers/media/Kconfig" + + source "drivers/video/Kconfig" +Index: linux-2.6.23.14/drivers/Kconfig +=================================================================== +--- linux-2.6.23.14.orig/drivers/Kconfig 2008-01-26 02:45:44.000000000 +0100 ++++ linux-2.6.23.14/drivers/Kconfig 2008-01-26 02:46:05.000000000 +0100 +@@ -74,6 +74,8 @@ + + source "drivers/leds/Kconfig" + ++source "drivers/gpio/Kconfig" ++ + source "drivers/infiniband/Kconfig" + + source "drivers/edac/Kconfig" +Index: linux-2.6.23.14/drivers/Makefile +=================================================================== +--- linux-2.6.23.14.orig/drivers/Makefile 2008-01-26 02:44:13.000000000 +0100 ++++ linux-2.6.23.14/drivers/Makefile 2008-01-26 02:44:42.000000000 +0100 +@@ -88,3 +88,4 @@ + obj-$(CONFIG_HID) += hid/ + obj-$(CONFIG_PPC_PS3) += ps3/ + obj-$(CONFIG_OF) += of/ ++obj-$(CONFIG_GPIO_DEVICE) += gpio/ diff --git a/target/linux/ixp4xx/patches-2.6.23/302-gpio_device.patch b/target/linux/ixp4xx/patches-2.6.23/302-gpio_device.patch new file mode 100644 index 0000000000..0a1831b4fc --- /dev/null +++ b/target/linux/ixp4xx/patches-2.6.23/302-gpio_device.patch @@ -0,0 +1,49 @@ +Index: linux-2.6.23.14/arch/arm/mach-ixp4xx/avila-setup.c +=================================================================== +--- linux-2.6.23.14.orig/arch/arm/mach-ixp4xx/avila-setup.c 2008-01-26 02:59:30.000000000 +0100 ++++ linux-2.6.23.14/arch/arm/mach-ixp4xx/avila-setup.c 2008-01-26 03:03:07.000000000 +0100 +@@ -183,6 +183,23 @@ + }; + #endif + ++#ifdef CONFIG_GPIO_DEVICE ++static struct resource avila_gpio_resources[] = { ++ { ++ .name = "gpio", ++ .start = AVILA_GPIO_MASK, ++ .end = AVILA_GPIO_MASK, ++ .flags = 0, ++ }, ++}; ++ ++static struct platform_device avila_gpio = { ++ .name = "GPIODEV", ++ .id = -1, ++ .num_resources = ARRAY_SIZE(avila_gpio_resources), ++ .resource = avila_gpio_resources, ++}; ++#endif + + static struct platform_device *avila_devices[] __initdata = { + &avila_i2c_gpio, +@@ -193,6 +210,9 @@ + #ifdef CONFIG_LEDS_IXP4XX + &avila_leds, + #endif ++#ifdef CONFIG_GPIO_DEVICE ++ &avila_gpio, ++#endif + }; + + static char avila_rtc_probe[] __initdata = "rtc-ds1672.probe=0,0x68 "; +Index: linux-2.6.23.14/include/asm-arm/arch-ixp4xx/avila.h +=================================================================== +--- linux-2.6.23.14.orig/include/asm-arm/arch-ixp4xx/avila.h 2008-01-26 03:03:27.000000000 +0100 ++++ linux-2.6.23.14/include/asm-arm/arch-ixp4xx/avila.h 2008-01-26 03:07:02.000000000 +0100 +@@ -38,3 +38,6 @@ + + /* User LED */ + #define AVILA_LED_USER_GPIO 3 ++ ++/* gpio mask used by platform device */ ++#define AVILA_GPIO_MASK (1 << 1) | (1 << 3) | (1 << 5) | (1 << 7) | (1 << 9)