From: <he...@us...> - 2004-12-03 21:33:53
|
Update of /cvsroot/gc-linux/linux/drivers/input In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv2391/drivers/input Modified Files: gcn-si.c Log Message: Added HACK_FORCE_KEYBOARD_PORT hack. Enabling it allows one to specify a port that will be considered a keyboard port when something is detected on it without being correctly identified. Use the "force_keyboard_port=n" where n=1..4 as a kernel command-line parameter when the driver is compiled built-in. Use it as a module parameter when the driver is compiled as a module. Used the driver name to associate resources to. Fixed io accesses to use the __iomem anotations, like needed in 2.6.10. Fixed a misusage of the |= operator. Removed broken uncompilable debugging output. Changed output to show ports from 1 to 4 instead of 0 to 3. Index: gcn-si.c =================================================================== RCS file: /cvsroot/gc-linux/linux/drivers/input/gcn-si.c,v retrieving revision 1.6 retrieving revision 1.7 diff -u -d -r1.6 -r1.7 --- gcn-si.c 16 Nov 2004 21:37:54 -0000 1.6 +++ gcn-si.c 3 Dec 2004 21:33:45 -0000 1.7 @@ -30,6 +30,14 @@ # define DPRINTK(fmt, args...) #endif +/* + * Defining HACK_FORCE_KEYBOARD_PORT allows one to specify a port that + * will be identified as a keyboard port in case the port gets incorrectly + * identified. + */ +#define HACK_FORCE_KEYBOARD_PORT + + #define DRV_MODULE_NAME "gcn-si" #define DRV_DESCRIPTION "Nintendo GameCube Serial Interface driver" #define DRV_AUTHOR "Steven Looman <st...@kr...>" @@ -42,21 +50,23 @@ #define si_printk(level, format, arg...) \ printk(level PFX format , ## arg) + /* * This keymap is for a datel adapter + normal US keyboard. */ #include "gcn-keymap.h" + #define REFRESH_TIME HZ/100 -#define SICOUTBUF(x) (0xcc006400 + x * 12) -#define SICINBUFH(x) (0xcc006404 + x * 12) -#define SICINBUFL(x) (0xcc006408 + x * 12) +#define SICOUTBUF(x) ((void __iomem *)(0xcc006400 + (x)*12)) +#define SICINBUFH(x) ((void __iomem *)(0xcc006404 + (x)*12)) +#define SICINBUFL(x) ((void __iomem *)(0xcc006408 + (x)*12)) -#define SIPOLL 0xcc006430 -#define SICOMCSR 0xcc006434 -#define SISR 0xcc006438 -#define SIEXILK 0xcc00643c +#define SIPOLL ((void __iomem *)0xcc006430) +#define SICOMCSR ((void __iomem *)0xcc006434) +#define SISR ((void __iomem *)0xcc006438) +#define SIEXILK ((void __iomem *)0xcc00643c) #define ID_PAD 0x0900 #define ID_KEYBOARD 0x0820 @@ -76,8 +86,9 @@ #define PAD_RIGHT (1 << 17) #define PAD_LEFT (1 << 16) + static struct resource gcn_si_resources = { - "GCN SI", + DRV_MODULE_NAME, 0xcc006400, 0xcc006500, IORESOURCE_MEM | IORESOURCE_BUSY @@ -110,6 +121,28 @@ /* char phys[32]; */ } port[4]; + +#ifdef HACK_FORCE_KEYBOARD_PORT + +static int gcn_si_force_keyboard_port = -1; + +#ifdef MODULE +module_param_named(force_keyboard_port, gcn_si_force_keyboard_port, int, 0644); +MODULE_PARM_DESC(force_keyboard_port, "port n becomes a keyboard port if" + " automatic identification fails"); +#else +static int __init gcn_si_force_keyboard_port_setup(char *line) +{ + if (sscanf(line, "%d", &gcn_si_force_keyboard_port) != 1) { + gcn_si_force_keyboard_port = -1; + } + return 1; +} +__setup("force_keyboard_port=", gcn_si_force_keyboard_port_setup); +#endif /* MODULE */ + +#endif /* HACK_FORCE_KEYBOARD_PORT */ + /** * */ @@ -135,20 +168,20 @@ writel(0, SICOMCSR); writel(0, SISR); - writel(0, 0xcc006480); - writel(0, 0xcc006484); - writel(0, 0xcc006488); - writel(0, 0xcc00648c); + writel(0, (void __iomem *)0xcc006480); + writel(0, (void __iomem *)0xcc006484); + writel(0, (void __iomem *)0xcc006488); + writel(0, (void __iomem *)0xcc00648c); - writel(0, 0xcc006490); - writel(0, 0xcc006494); - writel(0, 0xcc006498); - writel(0, 0xcc00649c); + writel(0, (void __iomem *)0xcc006490); + writel(0, (void __iomem *)0xcc006494); + writel(0, (void __iomem *)0xcc006498); + writel(0, (void __iomem *)0xcc00649c); - writel(0, 0xcc0064a0); - writel(0, 0xcc0064a4); - writel(0, 0xcc0064a8); - writel(0, 0xcc0064ac); + writel(0, (void __iomem *)0xcc0064a0); + writel(0, (void __iomem *)0xcc0064a4); + writel(0, (void __iomem *)0xcc0064a8); + writel(0, (void __iomem *)0xcc0064ac); } /** @@ -162,7 +195,7 @@ transfer_done = readl(SICOMCSR) & (1 << 31); } while (!transfer_done); - writel(readl(SICOMCSR) |= (1 << 31), SICOMCSR); /* ack IRQ */ + writel(readl(SICOMCSR) | (1 << 31), SICOMCSR); /* ack IRQ */ } /** @@ -179,7 +212,7 @@ gcn_si_wait_transfer_done(); - return readl(0xcc006480); + return readl((void __iomem *)0xcc006480); } /** @@ -398,15 +431,25 @@ strcpy(port[i].name, "Keyboard"); } else { port[i].id = CTL_UNKNOWN; - if (port[i].si_id) + if (port[i].si_id) { sprintf(port[i].name, "Unknown (%x)", port[i].si_id); - else +#ifdef HACK_FORCE_KEYBOARD_PORT + if (i+1 == gcn_si_force_keyboard_port) { + si_printk(KERN_WARNING, + "port %d forced to" + " keyboard mode\n", i+1); + port[i].si_id = ID_KEYBOARD; + port[i].id = CTL_KEYBOARD; + strcpy(port[i].name, "Keyboard" + " (forced)"); + } +#endif /* HACK_FORCE_KEYBOARD_PORT */ + } else { strcpy(port[i].name, "Not Present"); + } } - DPRINTK("port[%d] = 0x%x\n", i, id); - init_input_dev(&port[i].idev); port[i].idev.open = gcn_si_open; @@ -502,7 +545,7 @@ /* this is here to avoid compiler warnings */ break; } - si_printk(KERN_INFO, "Port %d: %s\n", i, port[i].name); + si_printk(KERN_INFO, "Port %d: %s\n", i+1, port[i].name); } gcn_si_set_polling(); |