Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

[PATCH] SharpSL: Abstract c7x0 specifics from Corgi Touchscreen driver

Separate out the Sharp Zaurus c7x0 series specific code from the Corgi
Touchscreen driver. Use the new functions in corgi_lcd.c via sharpsl.h for
hsync handling and pass the IRQ as a platform device resource. Move a
function prototype into the w100fb header file where it belongs.

This enables the driver to be used by the Zaurus cxx00 series.

Signed-Off-by: Richard Purdie <rpurdie@rpsys.net>
Cc: Vojtech Pavlik <vojtech@suse.cz>
Cc: Russell King <rmk@arm.linux.org.uk>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>

authored by

Richard Purdie and committed by
Linus Torvalds
513b6e1a 9fc7896b

+64 -31
+18
arch/arm/mach-pxa/corgi.c
··· 130 130 /* 131 131 * Corgi Touch Screen Device 132 132 */ 133 + static struct resource corgits_resources[] = { 134 + [0] = { 135 + .start = CORGI_IRQ_GPIO_TP_INT, 136 + .end = CORGI_IRQ_GPIO_TP_INT, 137 + .flags = IORESOURCE_IRQ, 138 + }, 139 + }; 140 + 141 + static struct corgits_machinfo corgi_ts_machinfo = { 142 + .get_hsync_len = corgi_get_hsync_len, 143 + .put_hsync = corgi_put_hsync, 144 + .wait_hsync = corgi_wait_hsync, 145 + }; 146 + 133 147 static struct platform_device corgits_device = { 134 148 .name = "corgi-ts", 135 149 .dev = { 136 150 .parent = &corgissp_device.dev, 151 + .platform_data = &corgi_ts_machinfo, 137 152 }, 138 153 .id = -1, 154 + .num_resources = ARRAY_SIZE(corgits_resources), 155 + .resource = corgits_resources, 139 156 }; 140 157 141 158 ··· 256 239 corgi_ssp_set_machinfo(&corgi_ssp_machinfo); 257 240 258 241 pxa_gpio_mode(CORGI_GPIO_USB_PULLUP | GPIO_OUT); 242 + pxa_gpio_mode(CORGI_GPIO_HSYNC | GPIO_IN); 259 243 pxa_set_udc_info(&udc_info); 260 244 pxa_set_mci_info(&corgi_mci_platform_data); 261 245
+3 -3
drivers/input/touchscreen/Kconfig
··· 24 24 module will be called h3600_ts_input. 25 25 26 26 config TOUCHSCREEN_CORGI 27 - tristate "Corgi touchscreen (for Sharp SL-C7xx)" 27 + tristate "SharpSL (Corgi and Spitz series) touchscreen driver" 28 28 depends on PXA_SHARPSL 29 29 default y 30 30 help 31 31 Say Y here to enable the driver for the touchscreen on the 32 - Sharp SL-C7xx series of PDAs. 32 + Sharp SL-C7xx and SL-Cxx00 series of PDAs. 33 33 34 34 If unsure, say N. 35 35 36 36 To compile this driver as a module, choose M here: the 37 - module will be called ads7846_ts. 37 + module will be called corgi_ts. 38 38 39 39 config TOUCHSCREEN_GUNZE 40 40 tristate "Gunze AHL-51S touchscreen"
+42 -28
drivers/input/touchscreen/corgi_ts.c
··· 1 1 /* 2 - * Touchscreen driver for Sharp Corgi models (SL-C7xx) 2 + * Touchscreen driver for Sharp SL-C7xx and SL-Cxx00 models 3 3 * 4 4 * Copyright (c) 2004-2005 Richard Purdie 5 5 * ··· 19 19 #include <linux/slab.h> 20 20 #include <asm/irq.h> 21 21 22 - #include <asm/arch/corgi.h> 22 + #include <asm/arch/sharpsl.h> 23 23 #include <asm/arch/hardware.h> 24 24 #include <asm/arch/pxa-regs.h> 25 25 ··· 47 47 struct ts_event tc; 48 48 int pendown; 49 49 int power_mode; 50 + int irq_gpio; 51 + struct corgits_machinfo *machinfo; 50 52 }; 51 53 52 - #define STATUS_HSYNC (GPLR(CORGI_GPIO_HSYNC) & GPIO_bit(CORGI_GPIO_HSYNC)) 53 - 54 - #define SyncHS() while((STATUS_HSYNC) == 0); while((STATUS_HSYNC) != 0); 54 + #ifdef CONFIG_PXA25x 55 55 #define CCNT(a) asm volatile ("mrc p14, 0, %0, C1, C0, 0" : "=r"(a)) 56 56 #define PMNC_GET(x) asm volatile ("mrc p14, 0, %0, C0, C0, 0" : "=r"(x)) 57 57 #define PMNC_SET(x) asm volatile ("mcr p14, 0, %0, C0, C0, 0" : : "r"(x)) 58 - 58 + #endif 59 + #ifdef CONFIG_PXA27x 60 + #define CCNT(a) asm volatile ("mrc p14, 0, %0, C1, C1, 0" : "=r"(a)) 61 + #define PMNC_GET(x) asm volatile ("mrc p14, 0, %0, C0, C1, 0" : "=r"(x)) 62 + #define PMNC_SET(x) asm volatile ("mcr p14, 0, %0, C0, C1, 0" : : "r"(x)) 63 + #endif 59 64 60 65 /* ADS7846 Touch Screen Controller bit definitions */ 61 66 #define ADSCTRL_PD0 (1u << 0) /* PD0 */ ··· 71 66 #define ADSCTRL_STS (1u << 7) /* Start Bit */ 72 67 73 68 /* External Functions */ 74 - extern unsigned long w100fb_get_hsynclen(struct device *dev); 75 69 extern unsigned int get_clk_frequency_khz(int info); 76 70 77 - static unsigned long calc_waittime(void) 71 + static unsigned long calc_waittime(struct corgi_ts *corgi_ts) 78 72 { 79 - unsigned long hsync_len = w100fb_get_hsynclen(&corgifb_device.dev); 73 + unsigned long hsync_len = corgi_ts->machinfo->get_hsync_len(); 80 74 81 75 if (hsync_len) 82 76 return get_clk_frequency_khz(0)*1000/hsync_len; ··· 83 79 return 0; 84 80 } 85 81 86 - static int sync_receive_data_send_cmd(int doRecive, int doSend, unsigned int address, unsigned long wait_time) 82 + static int sync_receive_data_send_cmd(struct corgi_ts *corgi_ts, int doRecive, int doSend, 83 + unsigned int address, unsigned long wait_time) 87 84 { 88 85 unsigned long timer1 = 0, timer2, pmnc = 0; 89 86 int pos = 0; ··· 95 90 PMNC_SET(0x01); 96 91 97 92 /* polling HSync */ 98 - SyncHS(); 93 + corgi_ts->machinfo->wait_hsync(); 99 94 /* get CCNT */ 100 95 CCNT(timer1); 101 96 } ··· 114 109 CCNT(timer2); 115 110 if (timer2-timer1 > wait_time) { 116 111 /* too slow - timeout, try again */ 117 - SyncHS(); 112 + corgi_ts->machinfo->wait_hsync(); 118 113 /* get OSCR */ 119 114 CCNT(timer1); 120 115 /* Wait after HSync */ ··· 138 133 /* critical section */ 139 134 local_irq_save(flags); 140 135 corgi_ssp_ads7846_lock(); 141 - wait_time=calc_waittime(); 136 + wait_time = calc_waittime(corgi_ts); 142 137 143 138 /* Y-axis */ 144 - sync_receive_data_send_cmd(0, 1, 1u, wait_time); 139 + sync_receive_data_send_cmd(corgi_ts, 0, 1, 1u, wait_time); 145 140 146 141 /* Y-axis */ 147 - sync_receive_data_send_cmd(1, 1, 1u, wait_time); 142 + sync_receive_data_send_cmd(corgi_ts, 1, 1, 1u, wait_time); 148 143 149 144 /* X-axis */ 150 - y = sync_receive_data_send_cmd(1, 1, 5u, wait_time); 145 + y = sync_receive_data_send_cmd(corgi_ts, 1, 1, 5u, wait_time); 151 146 152 147 /* Z1 */ 153 - x = sync_receive_data_send_cmd(1, 1, 3u, wait_time); 148 + x = sync_receive_data_send_cmd(corgi_ts, 1, 1, 3u, wait_time); 154 149 155 150 /* Z2 */ 156 - z1 = sync_receive_data_send_cmd(1, 1, 4u, wait_time); 157 - z2 = sync_receive_data_send_cmd(1, 0, 4u, wait_time); 151 + z1 = sync_receive_data_send_cmd(corgi_ts, 1, 1, 4u, wait_time); 152 + z2 = sync_receive_data_send_cmd(corgi_ts, 1, 0, 4u, wait_time); 158 153 159 154 /* Power-Down Enable */ 160 155 corgi_ssp_ads7846_put((1u << ADSCTRL_ADR_SH) | ADSCTRL_STS); ··· 194 189 195 190 static void ts_interrupt_main(struct corgi_ts *corgi_ts, int isTimer, struct pt_regs *regs) 196 191 { 197 - if ((GPLR(CORGI_GPIO_TP_INT) & GPIO_bit(CORGI_GPIO_TP_INT)) == 0) { 192 + if ((GPLR(IRQ_TO_GPIO(corgi_ts->irq_gpio)) & GPIO_bit(IRQ_TO_GPIO(corgi_ts->irq_gpio))) == 0) { 198 193 /* Disable Interrupt */ 199 - set_irq_type(CORGI_IRQ_GPIO_TP_INT, IRQT_NOEDGE); 194 + set_irq_type(corgi_ts->irq_gpio, IRQT_NOEDGE); 200 195 if (read_xydata(corgi_ts)) { 201 196 corgi_ts->pendown = 1; 202 197 new_data(corgi_ts, regs); ··· 215 210 } 216 211 217 212 /* Enable Falling Edge */ 218 - set_irq_type(CORGI_IRQ_GPIO_TP_INT, IRQT_FALLING); 213 + set_irq_type(corgi_ts->irq_gpio, IRQT_FALLING); 219 214 corgi_ts->pendown = 0; 220 215 } 221 216 } ··· 259 254 260 255 corgi_ssp_ads7846_putget((4u << ADSCTRL_ADR_SH) | ADSCTRL_STS); 261 256 /* Enable Falling Edge */ 262 - set_irq_type(CORGI_IRQ_GPIO_TP_INT, IRQT_FALLING); 257 + set_irq_type(corgi_ts->irq_gpio, IRQT_FALLING); 263 258 corgi_ts->power_mode = PWR_MODE_ACTIVE; 264 259 } 265 260 return 0; ··· 272 267 static int __init corgits_probe(struct device *dev) 273 268 { 274 269 struct corgi_ts *corgi_ts; 270 + struct platform_device *pdev = to_platform_device(dev); 275 271 276 272 if (!(corgi_ts = kmalloc(sizeof(struct corgi_ts), GFP_KERNEL))) 277 273 return -ENOMEM; ··· 280 274 dev_set_drvdata(dev, corgi_ts); 281 275 282 276 memset(corgi_ts, 0, sizeof(struct corgi_ts)); 277 + 278 + corgi_ts->machinfo = dev->platform_data; 279 + corgi_ts->irq_gpio = platform_get_irq(pdev, 0); 280 + 281 + if (corgi_ts->irq_gpio < 0) { 282 + kfree(corgi_ts); 283 + return -ENODEV; 284 + } 283 285 284 286 init_input_dev(&corgi_ts->input); 285 287 corgi_ts->input.evbit[0] = BIT(EV_KEY) | BIT(EV_ABS); ··· 307 293 corgi_ts->input.id.product = 0x0002; 308 294 corgi_ts->input.id.version = 0x0100; 309 295 310 - pxa_gpio_mode(CORGI_GPIO_TP_INT | GPIO_IN); 311 - pxa_gpio_mode(CORGI_GPIO_HSYNC | GPIO_IN); 296 + pxa_gpio_mode(IRQ_TO_GPIO(corgi_ts->irq_gpio) | GPIO_IN); 312 297 313 298 /* Initiaize ADS7846 Difference Reference mode */ 314 299 corgi_ssp_ads7846_putget((1u << ADSCTRL_ADR_SH) | ADSCTRL_STS); ··· 326 313 input_register_device(&corgi_ts->input); 327 314 corgi_ts->power_mode = PWR_MODE_ACTIVE; 328 315 329 - if (request_irq(CORGI_IRQ_GPIO_TP_INT, ts_interrupt, SA_INTERRUPT, "ts", corgi_ts)) { 316 + if (request_irq(corgi_ts->irq_gpio, ts_interrupt, SA_INTERRUPT, "ts", corgi_ts)) { 330 317 input_unregister_device(&corgi_ts->input); 331 318 kfree(corgi_ts); 332 319 return -EBUSY; 333 320 } 334 321 335 322 /* Enable Falling Edge */ 336 - set_irq_type(CORGI_IRQ_GPIO_TP_INT, IRQT_FALLING); 323 + set_irq_type(corgi_ts->irq_gpio, IRQT_FALLING); 337 324 338 325 printk(KERN_INFO "input: Corgi Touchscreen Registered\n"); 339 326 ··· 344 331 { 345 332 struct corgi_ts *corgi_ts = dev_get_drvdata(dev); 346 333 347 - free_irq(CORGI_IRQ_GPIO_TP_INT, NULL); 334 + free_irq(corgi_ts->irq_gpio, NULL); 348 335 del_timer_sync(&corgi_ts->timer); 336 + corgi_ts->machinfo->put_hsync(); 349 337 input_unregister_device(&corgi_ts->input); 350 338 kfree(corgi_ts); 351 339 return 0;
+1
include/video/w100fb.h
··· 19 19 20 20 unsigned long w100fb_gpio_read(int port); 21 21 void w100fb_gpio_write(int port, unsigned long value); 22 + unsigned long w100fb_get_hsynclen(struct device *dev); 22 23 23 24 /* LCD Specific Routines and Config */ 24 25 struct w100_tg_info {