From: <hap...@us...> - 2007-09-14 13:08:28
|
Revision: 1316 http://hackndev.svn.sourceforge.net/hackndev/?rev=1316&view=rev Author: happy-slapin Date: 2007-09-14 06:08:25 -0700 (Fri, 14 Sep 2007) Log Message: ----------- cleanup: Device cleanup Modified Paths: -------------- linux4palm/linux/branches/cleanup-branch-never-commit/arch/arm/mach-pxa/asus730/a730_flash.c linux4palm/linux/branches/cleanup-branch-never-commit/arch/arm/mach-pxa/generic.c linux4palm/linux/branches/cleanup-branch-never-commit/arch/arm/mach-pxa/h5400/h5400.c Modified: linux4palm/linux/branches/cleanup-branch-never-commit/arch/arm/mach-pxa/asus730/a730_flash.c =================================================================== --- linux4palm/linux/branches/cleanup-branch-never-commit/arch/arm/mach-pxa/asus730/a730_flash.c 2007-09-14 12:44:17 UTC (rev 1315) +++ linux4palm/linux/branches/cleanup-branch-never-commit/arch/arm/mach-pxa/asus730/a730_flash.c 2007-09-14 13:08:25 UTC (rev 1316) @@ -117,9 +117,8 @@ static struct mtd_info *mtds_concat = NULL; static int mtds_found = 0; -#ifdef CONFIG_MTD_PARTITIONS static const char *part_probes[] = {"cmdlinepart", "RedBoot", NULL}; -#endif + static int mphysmap_map_device(struct map_info *map) { static const char *rom_probe_types[] = {"cfi_probe", "jedec_probe", "map_rom", NULL}; @@ -184,10 +183,9 @@ static int a730_physmap_flash_probe(struct device *dev) { int i; -#ifdef CONFIG_MTD_PARTITIONS struct mtd_partition* mtd_parts; int mtd_parts_nb; -#endif + for (i = 0; i < ARRAY_SIZE(mphysmap_static_maps); i++) { if (strcmp(mphysmap_static_maps[i].name, "") != 0 && mphysmap_static_maps[i].size != 0 && mphysmap_static_maps[i].bankwidth != 0) Modified: linux4palm/linux/branches/cleanup-branch-never-commit/arch/arm/mach-pxa/generic.c =================================================================== --- linux4palm/linux/branches/cleanup-branch-never-commit/arch/arm/mach-pxa/generic.c 2007-09-14 12:44:17 UTC (rev 1315) +++ linux4palm/linux/branches/cleanup-branch-never-commit/arch/arm/mach-pxa/generic.c 2007-09-14 13:08:25 UTC (rev 1316) @@ -233,6 +233,21 @@ #include <linux/gpiodev2.h> struct gpio_ops gpio_desc[16]; + +int gpio_direction_input(unsigned gpio) +{ + if (gpio < GPIO_BASE_INCREMENT) + return pxa_gpio_mode(gpio | GPIO_IN); + return -EINVAL; +} + +int gpio_direction_output(unsigned gpio) +{ + if (gpio < GPIO_BASE_INCREMENT) + return pxa_gpio_mode(gpio | GPIO_OUT); + return -EINVAL; +} + /* * Return GPIO level */ @@ -252,7 +267,8 @@ { if (gpio < GPIO_BASE_INCREMENT) __gpio_set_value(gpio, value); - gpiodev2_set_value(gpio, value); + else + gpiodev2_set_value(gpio, value); } EXPORT_SYMBOL(pxa_gpio_set_value); Modified: linux4palm/linux/branches/cleanup-branch-never-commit/arch/arm/mach-pxa/h5400/h5400.c =================================================================== --- linux4palm/linux/branches/cleanup-branch-never-commit/arch/arm/mach-pxa/h5400/h5400.c 2007-09-14 12:44:17 UTC (rev 1315) +++ linux4palm/linux/branches/cleanup-branch-never-commit/arch/arm/mach-pxa/h5400/h5400.c 2007-09-14 13:08:25 UTC (rev 1316) @@ -38,8 +38,7 @@ #include <linux/input_pda.h> #include <linux/adc.h> #include <linux/mfd/samcop_adc.h> -#include <linux/gpiodev_keys.h> -#include <linux/gpiodev_diagonal.h> +#include <linux/gpiodev_keys2.h> #include <linux/mtd/mtd.h> #include <linux/mtd/partitions.h> #include <linux/mtd/physmap.h> @@ -508,7 +507,7 @@ GPIO_NR_H5400_IRDA_SD | GPIO_OUT, /* GPIO58 */ 59 | GPIO_OUT, /* GPIO59 XXX docs say "usb charge on" input */ GPIO_NR_H5400_POWER_SD_N | GPIO_OUT, /* GPIO60 XXX not really active low? */ - GPIO_NR_H5400_POWER_RS232_N | GPIO_OUT | GPIO_DFLT_HIGH, + GPIO_NR_H5400_POWER_RS232_N_OR_FS | GPIO_OUT | GPIO_DFLT_HIGH, GPIO_NR_H5400_POWER_ACCEL_N | GPIO_OUT | GPIO_DFLT_HIGH, 63 | GPIO_OUT, /* GPIO63 NC */ GPIO_NR_H5400_OPT_NVRAM | GPIO_OUT , @@ -649,8 +648,8 @@ .gpacon2 = 0x5a, .gpadat = 0x0, .gpaup = 0x0, - .gpioint = { 0x66666666, 0x60006, 0x0, }, - .gpioflt = { 0x3fff0000, 0x3fff3fff, 0x3fff, 0, 0, 0x3fff3fff, 0, }, + .gpioint = { 0xeeeeeeee, 0x6766eeee, 0x0444444f, }, + .gpioflt = { 0x3fff0001, 0x3fff3fff, 0x3fff3fff, 0x3fff3fff, 0x3fff3fff, 0x3fff3fff, 0x000f3fff, }, .gpioenint = { 0x3f, 0x7f, }, }, .child_devs = samcop_child_devs, @@ -669,52 +668,68 @@ }; EXPORT_SYMBOL(h5400_samcop); -static struct gpiodev_keys_button h5400_button_table[] = { - { KEY_POWER, { &pxagpio_device.dev, GPIO_NR_H5400_POWER_BUTTON }, 1, "Power button" }, - { _KEY_RECORD, { &h5400_samcop.dev, SAMCOP_GPA_RECORD }, 1, "Record button" }, - { _KEY_CALENDAR, { &h5400_samcop.dev, SAMCOP_GPA_APPBTN1 }, 1, "Calendar button" }, - { _KEY_CONTACTS, { &h5400_samcop.dev, SAMCOP_GPA_APPBTN2 }, 1, "Contacts button" }, - { _KEY_MAIL, { &h5400_samcop.dev, SAMCOP_GPA_APPBTN3 }, 1, "Mail button" }, - { _KEY_HOMEPAGE, { &h5400_samcop.dev, SAMCOP_GPA_APPBTN4 }, 1, "Homepage button" }, - { KEY_VOLUMEUP, { &h5400_samcop.dev, SAMCOP_GPA_TOGGLEUP }, 1, "Volume up" }, - { KEY_VOLUMEDOWN, { &h5400_samcop.dev, SAMCOP_GPA_TOGGLEDOWN }, 1, "Volume down" }, +static struct gpiodev_keys2_gpio h5000_gpiodev_keys2_gpios[] = { + { "Power button", { &pxagpio_device.dev, GPIO_NR_H5400_POWER_BUTTON }, 0, }, + { "Record button", { &h5400_samcop.dev, SAMCOP_GPA_RECORD }, 1, }, + { "Calendar button", { &h5400_samcop.dev, SAMCOP_GPA_APPBTN1 }, 1, }, + { "Contacts button", { &h5400_samcop.dev, SAMCOP_GPA_APPBTN2 }, 1, }, + { "Mail button", { &h5400_samcop.dev, SAMCOP_GPA_APPBTN3 }, 1, }, + { "Homepage button", { &h5400_samcop.dev, SAMCOP_GPA_APPBTN4 }, 1, }, + { "Volume up", { &h5400_samcop.dev, SAMCOP_GPA_TOGGLEUP }, 1, }, + { "Volume down", { &h5400_samcop.dev, SAMCOP_GPA_TOGGLEDOWN }, 1, }, + { "Joypad NW", { &h5400_samcop.dev, SAMCOP_GPA_JOYSTICK1 }, 1, }, + { "Joypad NE", { &h5400_samcop.dev, SAMCOP_GPA_JOYSTICK2 }, 1, }, + { "Joypad SE", { &h5400_samcop.dev, SAMCOP_GPA_JOYSTICK3 }, 1, }, + { "Joypad SW", { &h5400_samcop.dev, SAMCOP_GPA_JOYSTICK4 }, 1, }, + { "Joypad action", { &h5400_samcop.dev, SAMCOP_GPA_JOYSTICK5 }, 1, }, }; - -static struct gpiodev_keys_platform_data h5400_pxa_keys_data = { - .buttons = h5400_button_table, - .nbuttons = ARRAY_SIZE(h5400_button_table), +static struct gpiodev_keys2_button h5000_gpiodev_keys2_buttons[] = { + { KEY_POWER, { "Power button", NULL }, 0, 0, }, + { _KEY_CALENDAR, { "Calendar button", NULL }, 0, 0, }, + { _KEY_CONTACTS, { "Contacts button", NULL }, 0, 0, }, + { _KEY_MAIL, { "Mail button", NULL }, 0, 0, }, + { _KEY_HOMEPAGE, { "Homepage button", NULL }, 0, 0, }, + /* Side buttons */ + { _KEY_RECORD, { "Record button", "Volume up", "Volume down", NULL }, 75, 1, }, + { KEY_VOLUMEUP, { "Volume up", NULL }, 75, 0, }, + { KEY_VOLUMEDOWN, { "Volume down", "Record button", NULL }, 75, 0, }, + /* Diagonal joypad */ + { KEY_ENTER, { "Joypad action", NULL }, 0, 0}, + /* One diagonal pressed */ + /* NE */ + { KEY_UP, { "Joypad NE", "Joypad action", NULL}, 0, 1}, + { KEY_RIGHT, { "Joypad NE", "Joypad action", NULL}, 0, 1}, + /* NW */ + { KEY_UP, { "Joypad NW", "Joypad action", NULL}, 0, 1}, + { KEY_LEFT, { "Joypad NW", "Joypad action", NULL}, 0, 1}, + /* SE */ + { KEY_DOWN, { "Joypad SE", "Joypad action", NULL}, 0, 1}, + { KEY_RIGHT, { "Joypad SE", "Joypad action", NULL}, 0, 1}, + /* SW */ + { KEY_DOWN, { "Joypad SW", "Joypad action", NULL}, 0, 1}, + { KEY_LEFT, { "Joypad SW", "Joypad action", NULL}, 0, 1}, + /* Two diagonals pressed */ + { KEY_UP, { "Joypad NE", "Joypad NW", "Joypad action", NULL }, 0, 2}, + { KEY_LEFT, { "Joypad NW", "Joypad SW", "Joypad action", NULL }, 0, 2}, + { KEY_DOWN, { "Joypad SW", "Joypad SE", "Joypad action", NULL }, 0, 2}, + { KEY_RIGHT, { "Joypad SE", "Joypad NE", "Joypad action", NULL }, 0, 2}, }; -static struct platform_device h5400_pxa_keys = { - .name = "gpiodev-keys", - .dev = { - .platform_data = &h5400_pxa_keys_data, - }, +static struct gpiodev_keys2_platform_data h5000_gpiodev_keys2_platform_data = { + .gpios = h5000_gpiodev_keys2_gpios, + .ngpios = ARRAY_SIZE(h5000_gpiodev_keys2_gpios), + .buttons = h5000_gpiodev_keys2_buttons, + .nbuttons = ARRAY_SIZE(h5000_gpiodev_keys2_buttons), }; -static struct gpiodev_diagonal_button h5400_joypad_table[] = { - { { &h5400_samcop.dev, SAMCOP_GPA_JOYSTICK1 }, 1, GPIODEV_DIAG_LEFT | GPIODEV_DIAG_UP, "Joypad left-up" }, - { { &h5400_samcop.dev, SAMCOP_GPA_JOYSTICK2 }, 1, GPIODEV_DIAG_RIGHT | GPIODEV_DIAG_UP, "Joypad right-up" }, - { { &h5400_samcop.dev, SAMCOP_GPA_JOYSTICK3 }, 1, GPIODEV_DIAG_RIGHT | GPIODEV_DIAG_DOWN, "Joypad right-down" }, - { { &h5400_samcop.dev, SAMCOP_GPA_JOYSTICK4 }, 1, GPIODEV_DIAG_LEFT | GPIODEV_DIAG_DOWN, "Joypad left-down" }, - { { &h5400_samcop.dev, SAMCOP_GPA_JOYSTICK5 }, 1, GPIODEV_DIAG_ACTION, "Joypad action" }, -}; - -static struct gpiodev_diagonal_platform_data h5400_pxa_joypad_data = { - .buttons = h5400_joypad_table, - .nbuttons = ARRAY_SIZE(h5400_joypad_table), - .dir_disables_enter = 1, -}; - -static struct platform_device h5400_pxa_joypad = { - .name = "gpiodev-diagonal", +static struct platform_device h5000_gpiodev_keys2 = { + .name = "gpiodev-keys2", .dev = { - .platform_data = &h5400_pxa_joypad_data, + .platform_data = &h5000_gpiodev_keys2_platform_data, }, }; - static void __init h5400_init (void) { @@ -723,8 +738,7 @@ platform_device_register (&h5000_flash[0]); platform_device_register (&h5000_flash[1]); platform_device_register (&h5400_samcop); - platform_device_register (&h5400_pxa_keys); - platform_device_register (&h5400_pxa_joypad); + platform_device_register (&h5000_gpiodev_keys2); pxa_set_udc_info (&h5400_udc_mach_info); pxa_set_dma_needs_bounce (h5400_dma_needs_bounce); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <hap...@us...> - 2007-09-17 13:32:10
|
Revision: 1324 http://hackndev.svn.sourceforge.net/hackndev/?rev=1324&view=rev Author: happy-slapin Date: 2007-09-17 06:32:07 -0700 (Mon, 17 Sep 2007) Log Message: ----------- cleanup: z31: remove debug data, magican: update from hh.org Modified Paths: -------------- linux4palm/linux/branches/cleanup-branch-never-commit/arch/arm/mach-pxa/Makefile linux4palm/linux/branches/cleanup-branch-never-commit/arch/arm/mach-pxa/magician/magician.c linux4palm/linux/branches/cleanup-branch-never-commit/arch/arm/mach-pxa/palmz31/Kconfig linux4palm/linux/branches/cleanup-branch-never-commit/arch/arm/mach-pxa/palmz31/Makefile Removed Paths: ------------- linux4palm/linux/branches/cleanup-branch-never-commit/arch/arm/mach-pxa/palmz31/gpioed-ng.c linux4palm/linux/branches/cleanup-branch-never-commit/arch/arm/mach-pxa/palmz31/gpioed.c Modified: linux4palm/linux/branches/cleanup-branch-never-commit/arch/arm/mach-pxa/Makefile =================================================================== --- linux4palm/linux/branches/cleanup-branch-never-commit/arch/arm/mach-pxa/Makefile 2007-09-17 13:00:29 UTC (rev 1323) +++ linux4palm/linux/branches/cleanup-branch-never-commit/arch/arm/mach-pxa/Makefile 2007-09-17 13:32:07 UTC (rev 1324) @@ -44,8 +44,6 @@ obj-y += aximx5/ obj-y += aximx30/ obj-y += rover/ -obj-$(CONFIG_MACH_RECON) += plat-recon/ -obj-$(CONFIG_MACH_LOOXC550) += looxc550/ obj-$(CONFIG_MACH_X50) += aximx50/ obj-$(CONFIG_MACH_TUNGE2) += palmte2/ obj-$(CONFIG_MACH_OMAP_PALMTC) += ssp.o palmtc/ Modified: linux4palm/linux/branches/cleanup-branch-never-commit/arch/arm/mach-pxa/magician/magician.c =================================================================== --- linux4palm/linux/branches/cleanup-branch-never-commit/arch/arm/mach-pxa/magician/magician.c 2007-09-17 13:00:29 UTC (rev 1323) +++ linux4palm/linux/branches/cleanup-branch-never-commit/arch/arm/mach-pxa/magician/magician.c 2007-09-17 13:32:07 UTC (rev 1324) @@ -574,9 +574,30 @@ }, }; -static struct platform_device magician_led = { - .name = "magician-led", +struct gpio_led gpio_leds[] = { + { + .name = "magician:vibra", + .default_trigger = "none", + .gpio = GPIO22_MAGICIAN_VIBRA_EN, + }, + { + .name = "magician:phone_bl", + .default_trigger = "backlight", + .gpio = GPIO103_MAGICIAN_LED_KP, + }, +}; + +static struct gpio_led_platform_data gpio_led_info = { + .leds = gpio_leds, + .num_leds = ARRAY_SIZE(gpio_leds), +}; + +static struct platform_device leds_gpio = { + .name = "leds-gpio", .id = -1, + .dev = { + .platform_data = &gpio_led_info, + }, }; /* @@ -789,7 +810,7 @@ &magician_phone, &magician_flash, &pasic3, - &magician_led, + &leds_gpio, #if 0 &pxa_spi_ssp2, #endif Modified: linux4palm/linux/branches/cleanup-branch-never-commit/arch/arm/mach-pxa/palmz31/Kconfig =================================================================== --- linux4palm/linux/branches/cleanup-branch-never-commit/arch/arm/mach-pxa/palmz31/Kconfig 2007-09-17 13:00:29 UTC (rev 1323) +++ linux4palm/linux/branches/cleanup-branch-never-commit/arch/arm/mach-pxa/palmz31/Kconfig 2007-09-17 13:32:07 UTC (rev 1324) @@ -11,20 +11,3 @@ help This driver translates button presses on a Palm Tungsten E2 to Linux input subsystem events. - - -config GPIOED - tristate "GPIOED" - depends on MACH_ZIRE31 - default n - help - Gpioed: only for debuging and testing! - - -config GPIOEDNG - tristate "GPIOEDNG" - depends on MACH_ZIRE31 - default n - help - Gpioed-ng: only for debuging and testing! - Modified: linux4palm/linux/branches/cleanup-branch-never-commit/arch/arm/mach-pxa/palmz31/Makefile =================================================================== --- linux4palm/linux/branches/cleanup-branch-never-commit/arch/arm/mach-pxa/palmz31/Makefile 2007-09-17 13:00:29 UTC (rev 1323) +++ linux4palm/linux/branches/cleanup-branch-never-commit/arch/arm/mach-pxa/palmz31/Makefile 2007-09-17 13:32:07 UTC (rev 1324) @@ -4,5 +4,3 @@ obj-$(CONFIG_MACH_ZIRE31) += palmz31.o obj-$(CONFIG_PALMZ31_BUTTONS) += palmz31_buttons.o -obj-$(CONFIG_GPIOED) += gpioed.o -obj-$(CONFIG_GPIOEDNG) += gpioed-ng.o Deleted: linux4palm/linux/branches/cleanup-branch-never-commit/arch/arm/mach-pxa/palmz31/gpioed-ng.c =================================================================== --- linux4palm/linux/branches/cleanup-branch-never-commit/arch/arm/mach-pxa/palmz31/gpioed-ng.c 2007-09-17 13:00:29 UTC (rev 1323) +++ linux4palm/linux/branches/cleanup-branch-never-commit/arch/arm/mach-pxa/palmz31/gpioed-ng.c 2007-09-17 13:32:07 UTC (rev 1324) @@ -1,175 +0,0 @@ -#include <linux/module.h> -#include <linux/kernel.h> -#include <linux/init.h> -#include <linux/proc_fs.h> - -#include <linux/interrupt.h> -#include <asm/irq.h> -#include <asm/mach/arch.h> -#include <asm/mach/map.h> -#include <asm/mach-types.h> -#include <asm/hardware.h> -#include <linux/sched.h> -#include <linux/workqueue.h> -#include <asm/arch/pxa-regs.h> -#include <asm/arch/irqs.h> -#include <asm/uaccess.h> - -#include <linux/debugfs.h> -#include <linux/seq_file.h> - -#define PROCFS_NAME "gpio" -#define DEBUGFS_NAME "gpio" - -static struct proc_dir_entry *proc_intf; -static struct dentry *debugfs_intf; - -#define PROCFS_MAX_SIZE 20 - -static char procfs_buffer[PROCFS_MAX_SIZE]; -static unsigned long procfs_buffer_size = 0; - -#define GPIO_TEST(reg, gp) (reg(gp) & GPIO_bit(gp)) -static int dfs_show(struct seq_file *s, void *_) -{ - int i,afn; - seq_printf(s, "GPIO lines status:\n"); - - for(i=0;i<121;i++) { - afn = (GAFR(i) & (0x3 << (((i) & 0xf)*2))) >> (((i) & 0xf)*2); - seq_printf(s, "%s%d: %s %s %s %s %lx\n", - i<10?"0":"", - i, - GPIO_TEST(GPLR, i)?"*":" ", - GPIO_TEST(GPDR, i)?"->":"<-", - GPIO_TEST(GRER, i)?"_/":" ", - GPIO_TEST(GFER, i)?"\\_":" ", - afn); - - } - - return 0; -} - -static int dfs_open(struct inode *inode, struct file *file) -{ - return single_open(file, dfs_show, inode->u.generic_ip); -} - -static struct file_operations debug_fops = { - .open = dfs_open, - .read = seq_read, - .llseek = seq_lseek, - .release = single_release, -}; - -static void gpio_set(int id, int on) -{ - do { - if (on) - GPSR(id) = GPIO_bit(id); - else - GPCR(id) = GPIO_bit(id); - } while (0); -} - -void set_afn(int gpio, int fn) -{ - int gafr; - gafr = GAFR(gpio) & ~(0x3 << (((gpio) & 0xf)*2)); - GAFR(gpio) = gafr | (fn << (((gpio) & 0xf)*2)); -} - -void handle_request() -{ - char *p = NULL; - unsigned long id = simple_strtoul(procfs_buffer+2, &p, 10); - switch(procfs_buffer[0]) { - case 'L': - gpio_set(id, 1); - printk(KERN_ERR "GPIOed: GPIO %lu set high\n", id); - break; - case 'l': - gpio_set(id, 0); - printk(KERN_ERR "GPIOed: GPIO %lu set low\n", id); - break; - case 'd': - GPDR(id) &= ~(GPIO_bit(id)); - break; - case 'D': - GPDR(id) |= GPIO_bit(id); - break; - case '0': - set_afn(id, 0); - break; - case '1': - set_afn(id, 1); - break; - case '2': - set_afn(id, 2); - break; - default: - printk(KERN_ERR "GPIOed: Unknown request\n"); - break; - } -} - - -int procfile_write(struct file *file, const char *buffer, unsigned long count, void *data) -{ - procfs_buffer_size = count; - if (procfs_buffer_size > PROCFS_MAX_SIZE ) { - procfs_buffer_size = PROCFS_MAX_SIZE; - } - - /* write data to the buffer */ - if ( copy_from_user(procfs_buffer, buffer, procfs_buffer_size) ) { - return -EFAULT; - } - - handle_request(); - - return procfs_buffer_size; -} - - -static int __init gpioed_init(void) -{ - proc_intf = create_proc_entry(PROCFS_NAME, 0644, NULL); - if (proc_intf == NULL) { - remove_proc_entry(PROCFS_NAME, &proc_root); - printk(KERN_ALERT "Error: Could not initialize /proc/%s\n", PROCFS_NAME); - return -ENOMEM; - } - - /*proc_intf->read_proc = procfile_read;*/ - proc_intf->write_proc = procfile_write; - proc_intf->owner = THIS_MODULE; - proc_intf->mode = S_IFREG | S_IRUGO; - proc_intf->uid = 0; - proc_intf->gid = 0; - proc_intf->size = 37; - - debugfs_intf = debugfs_create_file(DEBUGFS_NAME, S_IRUGO, NULL, NULL, &debug_fops); - - printk(KERN_INFO "/proc/%s created\n", PROCFS_NAME); - - return 0; -} - -static void __exit gpioed_exit(void) -{ - debugfs_remove(debugfs_intf); - remove_proc_entry(PROCFS_NAME, &proc_root); - printk(KERN_INFO "/proc/%s removed\n", PROCFS_NAME); -} - - -/*** Some more stuff ***/ -module_init(gpioed_init); -module_exit(gpioed_exit); - -MODULE_LICENSE("GPL"); -MODULE_AUTHOR("Vladimir \"Farcaller\" Pouzanov <far...@gm...>"); -MODULE_DESCRIPTION("GPIO editor for PXA26x, second edition"); - Deleted: linux4palm/linux/branches/cleanup-branch-never-commit/arch/arm/mach-pxa/palmz31/gpioed.c =================================================================== --- linux4palm/linux/branches/cleanup-branch-never-commit/arch/arm/mach-pxa/palmz31/gpioed.c 2007-09-17 13:00:29 UTC (rev 1323) +++ linux4palm/linux/branches/cleanup-branch-never-commit/arch/arm/mach-pxa/palmz31/gpioed.c 2007-09-17 13:32:07 UTC (rev 1324) @@ -1,279 +0,0 @@ -/*** Basic includes ***/ -#include <linux/module.h> -#include <linux/kernel.h> -#include <linux/init.h> -#include <linux/proc_fs.h> - -#include <linux/irq.h> -#include <linux/interrupt.h> -#include <asm/irq.h> -#include <asm/mach/arch.h> -#include <asm/mach/map.h> -#include <asm/mach-types.h> -#include <asm/hardware.h> -#include <linux/sched.h> -#include <linux/workqueue.h> -#include <asm/arch/pxa-regs.h> -#include <asm/arch/irqs.h> -#include <asm/uaccess.h> - -/*** GPIO macros ***/ -#define GET_PALMT3_GPIO(gpio) \ - (GPLR(GPIO_NR_PALMT3_ ## gpio) & GPIO_bit(GPIO_NR_PALMT3_ ## gpio)) - -#define SET_PALMT3_GPIO(gpio, setp) \ - do { \ - if (setp) \ - GPSR(GPIO_NR_PALMT3_ ## gpio) = GPIO_bit(GPIO_NR_PALMT3_ ## gpio); \ - else \ - GPCR(GPIO_NR_PALMT3_ ## gpio) = GPIO_bit(GPIO_NR_PALMT3_ ## gpio); \ - } while (0) - -#define SET_PALMT3_GPIO_N(gpio, setp) \ - do { \ - if (setp) \ - GPCR(GPIO_NR_PALMT3_ ## gpio) = GPIO_bit(GPIO_NR_PALMT3_ ## gpio); \ - else \ - GPSR(GPIO_NR_PALMT3_ ## gpio) = GPIO_bit(GPIO_NR_PALMT3_ ## gpio); \ - } while (0) - -#define GET_GPIO_REG(reg,gpio) (GP##reg(gpio) & GPIO_bit(gpio)) -#define GET_GPIO(gpio) (GPLR(gpio) & GPIO_bit(gpio)) -#define GET_GPIOD(gpio) (GPDR(gpio) & GPIO_bit(gpio)) - -/*** /proc interface ***/ -static struct proc_dir_entry *proc_intf; -#define procfs_name "gpioed" -#define PROCFS_MAX_SIZE 20 - -static char procfs_buffer[PROCFS_MAX_SIZE]; -static unsigned long procfs_buffer_size = 0; - -int gpio_info(char *buffer); - -int procfile_read(char *buffer, char **buffer_location, off_t offset, int buffer_length, int *eof, void *data) -{ - int ret; - - if (offset > 0) { - /* we have finished to read, return 0 */ - ret = 0; - } else { - /* fill the buffer, return the buffer size */ - ret = gpio_info(buffer); - //ret = sprintf(buffer, "HelloWorld!\n"); - } - return ret; -} - -int gpio_info(char *buffer) -// output all knowen infomation about the gpios to /proc/gpioed -{ - int i; - int ret; - sprintf(buffer, "Infomation about gpios:\n| Gpio | Direction | State |\n"); - for(i=0; i<85; i++) - { - sprintf(buffer, "%s| %2i ", buffer, i); - if(GET_GPIOD(i) == 0) //In - sprintf(buffer, "%s| In ",buffer); - else //Out - sprintf(buffer, "%s| Out ",buffer); - if(GET_GPIO(i) == 0) //Low - sprintf(buffer, "%s| Low |\n", buffer); - else //high - sprintf(buffer, "%s| High |\n", buffer); - } - ret = sprintf(buffer, "%s---------------------------\n Alternate Functions:\n 0L: %X 0U: %X 1L: %X 1U: %X 2L: %X 2U: %X\n", buffer, GAFR0_L, GAFR0_U, GAFR1_L, GAFR1_U, GAFR2_L, GAFR2_U); - - return ret; -} - -void handle_request(void); - -int procfile_write(struct file *file, const char *buffer, unsigned long count, void *data) -{ - procfs_buffer_size = count; - if (procfs_buffer_size > PROCFS_MAX_SIZE ) { - procfs_buffer_size = PROCFS_MAX_SIZE; - } - - /* write data to the buffer */ - if ( copy_from_user(procfs_buffer, buffer, procfs_buffer_size) ) { - return -EFAULT; - } - - handle_request(); - - return procfs_buffer_size; -} - -/*** IRQ (GPIO) handling ***/ -static struct workqueue_struct *my_workqueue; -#define MY_WORK_QUEUE_NAME "GPIOed" - -static void handle_gpio(void* irq) -{ - int gpn = (int)irq; - printk(KERN_ERR "*** GPIO *** %d *** is *** %s ***\n", gpn, GET_GPIO(gpn) ? "high" : "low "); -} - -irqreturn_t gpio_irq(int irq, void *dev_id, struct pt_regs *regs) -{ - static int initialised = 0; - static struct work_struct task; - - if (initialised == 0) { - INIT_WORK(&task, handle_gpio, dev_id); - initialised = 1; - } else { - PREPARE_WORK(&task, handle_gpio, dev_id); - } - - queue_work(my_workqueue, &task); - - return IRQ_HANDLED; -} - -/*** GPIO R/W ***/ -static int gpio_get(int id) -{ - return GET_GPIO(id); -} - -static void gpio_set(int id, int on) -{ - do { - if (on) - GPSR(id) = GPIO_bit(id); - else - GPCR(id) = GPIO_bit(id); - } while (0); -} - -static int gpio_watch(int x) -{ - int ret; - ret = request_irq (IRQ_GPIO(x), gpio_irq, SA_SAMPLE_RANDOM, "test_handler", (void*)x); - set_irq_type (IRQ_GPIO(x), IRQT_BOTHEDGE); - if(ret!=0) { - printk(KERN_ERR "GPIOed: failed to register for GPIO %d\n", x); - return 1; - } else { - printk(KERN_ERR "GPIOed: Registered GPIO %d\n", x); - return 0; - } -} - -void set_afn(int gpio, int fn) -{ - int gafr; - gafr = GAFR(gpio) & ~(0x3 << (((gpio) & 0xf)*2)); - GAFR(gpio) = gafr | (fn << (((gpio) & 0xf)*2)); -} - - -/*** Request handler ***/ -void handle_request() -{ - char *p = NULL; - unsigned long base = 10; - unsigned long id; - - if((procfs_buffer[0] == 'P') || (procfs_buffer[0] == 'V')) - base = 16; - id = simple_strtoul(procfs_buffer+2, &p, base); - switch(procfs_buffer[0]) { - case 'r': - printk(KERN_ERR "GPIOed: GPIO %lu is %s\n", id, gpio_get(id)?"high":"low "); - break; - case 's': - gpio_watch(id); - break; - case 'h': - gpio_set(id, 1); - printk(KERN_ERR "GPIOed: GPIO %lu set high\n", id); - break; - case 'l': - gpio_set(id, 0); - printk(KERN_ERR "GPIOed: GPIO %lu set low\n", id); - break; - case 'd': - printk(KERN_ERR "GPIOed: GPIO %lu is %s\n", id, GET_GPIO_REG(DR,id)?"output":"input"); - break; - - case 'P': - printk(KERN_ERR "GPIOed: P-V for 0x%x is 0x%x\n", id, (unsigned int)phys_to_virt(id)); - break; - case 'V': - printk(KERN_ERR "GPIOed: V-P for 0x%x is 0x%x\n", id, (unsigned int)virt_to_phys(id)); - break; - case 'D': - base = *((unsigned int*)id); - printk(KERN_ERR "GPIOed: 0x%x = 0x%x\n", id, base); - break; - case 'o': - GPDR(id) &= ~(GPIO_bit(id)); - break; - case 'i': - GPDR(id) |= GPIO_bit(id); - break; - - case '0': - set_afn(id, 0); - break; - case '1': - set_afn(id, 1); - break; - case '2': - set_afn(id, 2); - break; - - default: - printk(KERN_ERR "GPIOed: Unknown request\n"); - break; - } -} - -/*** init&exit ***/ -static int __init gpioed_init(void) -{ - my_workqueue = create_workqueue(MY_WORK_QUEUE_NAME); - - proc_intf = create_proc_entry(procfs_name, 0644, NULL); - if (proc_intf == NULL) { - remove_proc_entry(procfs_name, &proc_root); - printk(KERN_ALERT "Error: Could not initialize /proc/%s\n", - procfs_name); - return -ENOMEM; - } - - proc_intf->read_proc = procfile_read; - proc_intf->write_proc = procfile_write; - proc_intf->owner = THIS_MODULE; - proc_intf->mode = S_IFREG | S_IRUGO; - proc_intf->uid = 0; - proc_intf->gid = 0; - proc_intf->size = 37; - - printk(KERN_INFO "/proc/%s created\n", procfs_name); - - return 0; -} - -static void __exit gpioed_exit(void) -{ - destroy_workqueue(my_workqueue); - remove_proc_entry(procfs_name, &proc_root); - printk(KERN_INFO "/proc/%s removed\n", procfs_name); -} - - -/*** Some more stuff ***/ -module_init(gpioed_init); -module_exit(gpioed_exit); - -MODULE_LICENSE("GPL"); -MODULE_AUTHOR("Vladimir \"Farcaller\" Pouzanov <far...@gm...>"); -MODULE_DESCRIPTION("GPIO editor for PXA26x"); - This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |