pxa/hx4700: Add Synaptics NavPoint (PXA27x SSP/SPI) driver
Subsystems (5)
PATCH v3 1/2 pxa/hx4700: Add Synaptics NavPoint (PXA27x SSP/SPI) driver
Add support for the Synaptics NavPoint touchpad connected to a PXA27x SSP port in SPI slave mode. The driver implements a simple navigation pad. The four raised dots are mapped to UP/DOWN/LEFT/RIGHT buttons and the centre of the touchpad is mapped to the ENTER button.
---
V3:
Patch numbered 1/n because hx4700 platform glue depends on driver. Removed reference to hx4700 in Kconfig description.
Keep the list sorted in Makefile.
Use tabs for alignment in struct driver_data declaration.
Removed ternary operator.
Added module header byte definition to document magic numbers. drv_data, ssp, input assignments moved to declaration lines. navpoint_suspend() and navpoint_resume() now compiled unconditionally. X/Y coordinate limits now provided by module parameters.
GPIO102 configuration moved from mfp-pxa27x.h to hx4700.c. navpoint_suspend() and navpoint_resume() now clear/set GPIO102 unconditionally. Driver can now be built as a module.
arch/arm/mach-pxa/include/mach/mfp-pxa27x.h +1 -0
@@ -206,6 +206,7 @@#define GPIO113_I2S_SYSCLK MFP_CFG_OUT(GPIO113, AF1, DRIVE_LOW)/* SSP 1 */ +#define GPIO23_SSP1_SCLK_IN MFP_CFG_IN(GPIO23, AF2)#define GPIO23_SSP1_SCLK MFP_CFG_OUT(GPIO23, AF2, DRIVE_LOW)#define GPIO29_SSP1_SCLK MFP_CFG_IN(GPIO29, AF3)#define GPIO27_SSP1_SYSCLK MFP_CFG_OUT(GPIO27, AF1, DRIVE_LOW)
drivers/input/mouse/Kconfig +9 -0
@@ -322,4 +322,13 @@ config MOUSE_SYNAPTICS_I2C To compile this driver as a module, choose M here: the module will be called synaptics_i2c. +config MOUSE_NAVPOINT_PXA27x + tristate "Synaptics NavPoint (PXA27x SSP/SPI)" + depends on PXA27x && PXA_SSP + help + This option enables support for the Synaptics NavPoint connected to + a PXA27x SSP port in SPI slave mode. The driver implements a simple + navigation pad. The four raised dots are mapped to UP/DOWN/LEFT/RIGHT + buttons and the centre of the touchpad is mapped to the ENTER button. + endif
drivers/input/mouse/Makefile +1 -0
@@ -12,6 +12,7 @@ obj-$(CONFIG_MOUSE_GPIO) += gpio_mouse. obj-$(CONFIG_MOUSE_INPORT) += inport.o obj-$(CONFIG_MOUSE_LOGIBM) += logibm.o obj-$(CONFIG_MOUSE_MAPLE) += maplemouse.o +obj-$(CONFIG_MOUSE_NAVPOINT_PXA27x) += navpoint.o obj-$(CONFIG_MOUSE_PC110PAD) += pc110pad.o obj-$(CONFIG_MOUSE_PS2) += psmouse.o obj-$(CONFIG_MOUSE_PXA930_TRKBALL) += pxa930_trkball.o
drivers/input/mouse/navpoint.c +323 -0
323 lines not on this page · raw message
include/linux/input/navpoint.h +12 -0
@@ -0,0 +1,12 @@ +/* +* Copyright (C) 2011 Paul Parsons <[email protected]> +* +* This program is free software; you can redistribute it and/or modify +* it under the terms of the GNU General Public License version 2 as +* published by the Free Software Foundation. +*/ + +struct navpoint_platform_data { +int port;/* PXA SSP port for pxa_ssp_request() */ +int gpio;/* GPIO for power on/off */ +};
PATCH v3 1/2 pxa/hx4700: Add Synaptics NavPoint (PXA27x SSP/SPI) driver
Quoted 7 lines · Paul Parsons
Add support for the Synaptics NavPoint touchpad connected to a PXA27x SSP port in SPI slave mode. The driver implements a simple navigation pad. The four raised dots are mapped to UP/DOWN/LEFT/RIGHT buttons and the centre of the touchpad is mapped to the ENTER button.
Signed-off-by Paul Parsons <[email protected]>---
Both patches look good to me. Sadly, I can't test them as Navpoint on my hx4700 is broken for a long time :(
BTW, it's funny that driver is placed in input/mouse, but actually reports only keyboard events :)
Anyway, reporting coordinates can be added at some later point.
Signature · 2 lines
Best regards, Dmitry "MAD" Artamonow
PATCH v3 1/2 pxa/hx4700: Add Synaptics NavPoint (PXA27x SSP/SPI) driver
Quoted 5 lines · Dmitry Artamonow
BTW, it's funny that driver is placed in input/mouse, but actually
reports only keyboard events :)
Anyway, reporting coordinates can be added at some later point.
That's right, the underlying hardware is a touchpad so the driver could report mouse events if required. Obviously the hx4700 already has a working touchscreen so it's not obvious what benefit a second mouse device would add. And I'm not aware of any other platforms which use the NavPoint.
PATCH v3 1/2 pxa/hx4700: Add Synaptics NavPoint (PXA27x SSP/SPI) driver
Am Mittwoch, den 23.11.2011, 20:45 +0000 schrieb Paul Parsons:
Quoted 8 lines
Quoted 5 lines · Dmitry Artamonow
BTW, it's funny that driver is placed in input/mouse, but actually
reports only keyboard events :)
Anyway, reporting coordinates can be added at some later point.That's right, the underlying hardware is a touchpad so the driver could report mouse events if required. Obviously the hx4700 already has a working touchscreen so it's not obvious what benefit a second mouse device would add. And I'm not aware of any other platforms which use the NavPoint.
I agree, the NavPoint is pretty useless as a touchpad.
I think there's some kind of Logitech Wireless Keyboard / Remote that has a NavPoint, but I'm not aware of anything with them that would run linux either.
regards
Philipp
PATCH v3 1/2 pxa/hx4700: Add Synaptics NavPoint (PXA27x SSP/SPI) driver
In reply to Paul ParsonsAm Mittwoch, den 23.11.2011, 16:45 +0000 schrieb Paul Parsons:
Quoted 4 lines
Add support for the Synaptics NavPoint touchpad connected to a PXA27x SSP port in SPI slave mode. The driver implements a simple navigation pad. The four raised dots are mapped to UP/DOWN/LEFT/RIGHT buttons and the centre of the touchpad is mapped to the ENTER button.
Looked good on first glance, but a quick test run of those two patches against v3.2-rc2 resulted in an Oops in navpoint_int as soon as I touched the navpoint:
Unable to handle kernel paging request at virtual address 746e696f
...
[<c0184f74>] (__dev_printk+0x24/0x88) from [<c018509c>] (dev_warn +0x34/0x48)
[<c018509c>] (dev_warn+0x34/0x48) from [<c01c8c8c>] (navpoint_int +0xb0/0x1e0)
...
(approximately, using CONFIG_FONT_MINI_4x6 from the magician_defconfig...)
[...]
drivers/input/mouse/navpoint.c line 147
Quoted 12 lines
drivers/input/mouse/navpoint.c +12
-0+static irqreturn_t navpoint_int (int irq,void *dev) +{ +struct driver_data *drv_data = dev; +struct ssp_device *ssp = drv_data->ssp; +u32 status; +irqreturn_t ret; + + status =pxa_ssp_read_reg (ssp,SSSR ); + ret =IRQ_NONE ; + +if (status & sssr) { +dev_warn (dev,"spurious interrupt: 0x%02x\n" , status);
I guess that's because you effectively pass drv_data into dev_warn as first argument here. Fix that and maybe rename the second parameter of navpoint_int to void *dev_id to avoid confusion.
I assume I hit this spurious interrupt because I was booting with haret and you use the SDG bootloader?
best regards
Philipp
PATCH v3 1/2 pxa/hx4700: Add Synaptics NavPoint (PXA27x SSP/SPI) driver
Quoted 21 lines · Philipp Zabel
Am Mittwoch, den 23.11.2011, 16:45 +0000 schrieb Paul Parsons:
Quoted 4 lines
Add support for the Synaptics NavPoint touchpad connected to a PXA27x SSP port in SPI slave mode. The driver implements a simple navigation pad. The four raised dots are mapped to UP/DOWN/LEFT/RIGHT buttons and the centre of the touchpad is mapped to the ENTER button.
Looked good on first glance, but a quick test run of those two patches against v3.2-rc2 resulted in an Oops in
navpoint_intas soon as I touched the navpoint:Unable to handle kernel paging request at virtual address 746e696f...
[<c0184f74>] (__dev_printk+0x24/0x88) from [<c018509c>] (dev_warn+0x34/0x48)
[<c018509c>] (dev_warn+0x34/0x48) from [<c01c8c8c>] (navpoint_int+0xb0/0x1e0)
...
(approximately, usingCONFIG_FONT_MINI_4x6from themagician_defconfig...)[...]
Quoted 16 lines
Review
Quoted 12 lines
(quoted diff) +12
-0+static irqreturn_t navpoint_int(int irq, void *dev) +{ + ? ? struct driver_data *drv_data = dev; + ? ? struct ssp_device *ssp = drv_data->ssp; + ? ? u32 status; + ? ? irqreturn_t ret; + + ? ? status = pxa_ssp_read_reg(ssp, SSSR); + ? ? ret = IRQ_NONE; + + ? ? if (status & sssr) { + ? ? ? ? ? ? dev_warn(dev, "spurious interrupt: 0x%02x\n", status);I guess that's because you effectively pass
drv_dataintodev_warnas first argument here. Fix that and maybe rename the second parameter ofnavpoint_intto void*dev_idto avoid confusion.
Or maybe a better way would be to really pass the device into irq_request and use dev_get_drvdata like in the suspend/resume functions.
And to call platform_set_drvdata before irq_request in case it fires immediately.
regards
Philipp
PATCH v3 1/2 pxa/hx4700: Add Synaptics NavPoint (PXA27x SSP/SPI) driver
In reply to Philipp ZabelQuoted 5 lines · Philipp Zabel
Looked good on first glance, but a quick test run of those two patches
against v3.2-rc2 resulted in an Oops innavpoint_intas soon as I
touched the navpoint:
oops, sorry about that.
Quoted 5 lines
I guess that's because you effectively pass
drv_dataintodev_warnas
first argument here. Fix that and maybe rename the second parameter ofnavpoint_intto void*dev_idto avoid confusion.
Yes, void* and naming confusion conspired to pass unnoticed.
Quoted 3 lines
I assume I hit this spurious interrupt because I was booting with haret
and you use the SDG bootloader?
Yes I do use the SDG bootloader, but I don't know whether that accounts for my absence of spuriousness. If it does then perhaps there is a problem with haret intialization?
PATCH v3 1/2 pxa/hx4700: Add Synaptics NavPoint (PXA27x SSP/SPI) driver
In reply to Paul Parsonsdrivers/input/mouse/navpoint.c line 138
Quoted 3 lines · Paul Parsons
drivers/input/mouse/navpoint.c +3
-0+static irqreturn_t navpoint_int (int irq,void *dev) +{ +struct driver_data *drv_data = dev;
So 'dev' is a driver_data structure.
drivers/input/mouse/navpoint.c line 147
Quoted 9 lines
drivers/input/mouse/navpoint.c +9
-0+struct ssp_device *ssp = drv_data->ssp; +u32 status; +irqreturn_t ret; + + status =pxa_ssp_read_reg (ssp,SSSR ); + ret =IRQ_NONE ; + +if (status & sssr) { +dev_warn (dev,"spurious interrupt: 0x%02x\n" , status);
but you pass it to dev_warn(). This is not what dev_warn() is expecting.
Quoted 13 lines
drivers/input/mouse/navpoint.c +13
-0+pxa_ssp_write_reg (ssp,SSSR , (status & sssr)); + ret =IRQ_HANDLED ; + } + +if (status &SSSR_RFS ) { +while (status &SSSR_RNE ) { +u32 data; + + data =pxa_ssp_read_reg (ssp,SSDR ); + drv_data->data[drv_data->index +0 ] = (data >>8 ); + drv_data->data[drv_data->index +1 ] = data; + drv_data->index +=2 ; +if (HEADER_LENGTH (drv_data->data[0 ]) < drv_data->index)
drivers/input/mouse/navpoint.c line 170
Quoted 10 lines
drivers/input/mouse/navpoint.c +10
-0+navpoint_packet (dev); + status =pxa_ssp_read_reg (ssp,SSSR ); + } + ret =IRQ_HANDLED ; + } + +return ret; +} + +int navpoint_suspend (struct device *dev)
static?
Quoted 4 lines
drivers/input/mouse/navpoint.c +4
-0+{ +struct driver_data *drv_data =dev_get_drvdata (dev); +struct ssp_device *ssp = drv_data->ssp; +
drivers/input/mouse/navpoint.c line 184
Quoted 10 lines
drivers/input/mouse/navpoint.c +10
-0+gpio_set_value (drv_data->gpio,0 ); + +pxa_ssp_write_reg (ssp,SSCR0 ,0 ); + +clk_disable (ssp->clk); + +return 0 ; +} + +int navpoint_resume (struct device *dev)
static?
Quoted 6 lines
drivers/input/mouse/navpoint.c +6
-0+{ +struct driver_data *drv_data =dev_get_drvdata (dev); +struct ssp_device *ssp = drv_data->ssp; + +clk_enable (ssp->clk); +
drivers/input/mouse/navpoint.c line 200
Quoted 10 lines
drivers/input/mouse/navpoint.c +10
-0+pxa_ssp_write_reg (ssp,SSCR1 , sscr1); +pxa_ssp_write_reg (ssp,SSSR , sssr); +pxa_ssp_write_reg (ssp,SSTO ,0 ); +pxa_ssp_write_reg (ssp,SSCR0 , sscr0);/* SSCR0_SSE written last */ + +gpio_set_value (drv_data->gpio,1 ); + +/* Wait until SSP port is ready for slave clock operations */ +while (pxa_ssp_read_reg (ssp,SSSR ) &SSSR_CSS ) +msleep (1 );
What if it never becomes ready? Should this time out?
Quoted 10 lines
drivers/input/mouse/navpoint.c +10
-0+ +return 0 ; +} + +#ifdef CONFIG_SUSPEND +static const struct dev_pm_ops navpoint_pm_ops = { + .suspend = navpoint_suspend, + .resume = navpoint_resume, +}; +#endif
drivers/input/mouse/navpoint.c line 220
Quoted 10 lines
drivers/input/mouse/navpoint.c +10
-0+ +static int __devinit navpoint_probe (struct platform_device *pdev) +{ +struct navpoint_platform_data *pdata = pdev->dev.platform_data; +int ret; +struct driver_data *drv_data; +struct ssp_device *ssp; +struct input_dev *input; + + drv_data =kzalloc (sizeof (struct driver_data ),GFP_KERNEL );
We normally like to see sizeof(*drv_data) now.
Quoted 4 lines
drivers/input/mouse/navpoint.c +4
-0+if (!drv_data) { + ret = -ENOMEM ; + goto ret0; + }
drivers/input/mouse/navpoint.c line 234
Quoted 10 lines
drivers/input/mouse/navpoint.c +10
-0+ + ssp =pxa_ssp_request (pdata->port, pdev->name); +if (!ssp) { + ret = -ENODEV ; + goto ret1; + } + + ret =request_irq (ssp->irq, navpoint_int,0 , pdev->name, drv_data); +if (ret) + goto ret2;
What if you immediately receive an interrupt right now, after requesting this interrupt? Will your handler try to dereference anything in drv_data which is -currently- NULL ? (I think you'll oops when dereferencing drv_data->ssp->something.)
Quoted 15 lines
drivers/input/mouse/navpoint.c +15
-0+ + input =input_allocate_device (); +if (!input) { + ret = -ENOMEM ; + goto ret3; + } + input->name = pdev->name; +__set_bit (EV_KEY , input->evbit); +__set_bit (KEY_ENTER , input->keybit); +__set_bit (KEY_UP , input->keybit); +__set_bit (KEY_LEFT , input->keybit); +__set_bit (KEY_RIGHT , input->keybit); +__set_bit (KEY_DOWN , input->keybit); + input->dev.parent = &pdev->dev; + ret =input_register_device (input);
drivers/input/mouse/navpoint.c line 259
Quoted 10 lines
drivers/input/mouse/navpoint.c +10
-0+if (ret) + goto ret4; + + drv_data->ssp = ssp; + drv_data->gpio = pdata->gpio; + drv_data->input = input; + +platform_set_drvdata (pdev, drv_data); + + (void )navpoint_resume (&pdev->dev);
That cast to 'void' is not required.
Quoted 14 lines
drivers/input/mouse/navpoint.c +14
-0+ +dev_info (&pdev->dev,"ssp%d, irq %d\n" , pdata->port, ssp->irq); + +return 0 ; + +ret4: +input_free_device (input); +ret3: +free_irq (ssp->irq, drv_data); +ret2: +pxa_ssp_free (ssp); +ret1: +kfree (drv_data); +ret0:
drivers/input/mouse/navpoint.c line 283
Quoted 10 lines
drivers/input/mouse/navpoint.c +10
-0+return ret; +} + +static int __devexit navpoint_remove(struct platform_device *pdev) +{ +struct driver_data *drv_data =platform_get_drvdata (pdev); +struct ssp_device *ssp = drv_data->ssp; +struct input_dev *input = drv_data->input; + + (void )navpoint_suspend (&pdev->dev);
Cast to void is not required.
Quoted 62 lines
drivers/input/mouse/navpoint.c +40
-0+ +input_unregister_device (input); + +free_irq (ssp->irq, drv_data); + +pxa_ssp_free (ssp); + +kfree (drv_data); + +return 0 ; +} + +static struct platform_driver navpoint_driver = { + .probe = navpoint_probe, + .remove =__devexit_p (navpoint_remove), + .driver = { + .name ="navpoint" , + .owner =THIS_MODULE , +#ifdef CONFIG_SUSPEND + .pm = &navpoint_pm_ops, +#endif + }, +}; + +static int __init navpoint_init (void ) +{ +return platform_driver_register (&navpoint_driver); +} + +static void __exit navpoint_exit(void) +{ +platform_driver_unregister (&navpoint_driver); +} + +module_init (navpoint_init); +module_exit (navpoint_exit); + +MODULE_AUTHOR ("Paul Parsons <[email protected]>" ); +MODULE_DESCRIPTION ("Synaptics NavPoint (PXA27x SSP/SPI) driver" ); +MODULE_LICENSE ("GPL" );diff -uprN
clean-3.2-rc2/include/linux/input/navpoint.hlinux-3.2-rc2/include/linux/input/navpoint.hinclude/linux/input/navpoint.h +12
-0@@ -0,0 +1,12 @@ +/* +* Copyright (C) 2011 Paul Parsons <[email protected]> +* +* This program is free software; you can redistribute it and/or modify +* it under the terms of the GNU General Public License version 2 as +* published by the Free Software Foundation. +*/ + +struct navpoint_platform_data { +int port;/* PXA SSP port for pxa_ssp_request() */ +int gpio;/* GPIO for power on/off */ +};_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel at lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
PATCH v3 1/2 pxa/hx4700: Add Synaptics NavPoint (PXA27x SSP/SPI) driver
Quoted 3 lines · Russell King - ARM Linux
So 'dev' is a
driver_datastructure.
but you pass it todev_warn(). This is not whatdev_warn()is expecting.
Correct; alas Philipp discovered this the hard way. I'm on it.
Quoted 3 lines
Quoted 1 line
+int
navpoint_suspend(struct device *dev)static?
Yes, will do.
Quoted 3 lines
Quoted 1 line
+int
navpoint_resume(struct device *dev)static?
Ditto.
Quoted 8 lines
Quoted 1 line
+ /* Wait until SSP port is ready
for slave clock operations */
Quoted 1 line
+ while (
pxa_ssp_read_reg(ssp, SSSR)&
SSSR_CSS)Quoted 1 line
+ msleep(1);
What if it never becomes ready? Should this time
out?
This loop was an early sanity check which I never removed. But I agree that broken hardware might cause it to hang. So I'll either remove it or, more usefully, add a timeout with error message.
Quoted 4 lines
Quoted 1 line
+
drv_data= kzalloc(sizeof(struct
driver_data),GFP_KERNEL);We normally like to see
sizeof(*drv_data)now.
OK.
Quoted 5 lines
Quoted 1 line
+ ret = request_irq(ssp->irq,
navpoint_int, 0,pdev->name,drv_data);drivers/input/mouse/navpoint.c line 234
Quoted 2 lines
drivers/input/mouse/navpoint.c +2
-0+if (ret) + goto ret2;
Quoted 7 lines
What if you immediately receive an interrupt right now, after requesting
this interrupt? Will your handler try to dereference anything indrv_datawhich is -currently- NULL ? (I think you'll oops when
dereferencingdrv_data->ssp->something.)
Shouldn't happen because the SSP port is not enabled until the later call to navpoint_resume(). However, Philipp has discovered spurious interrupts with the haret bootloader; perhaps it already enabled the SSP port. I'm on it.
Quoted 4 lines
Quoted 1 line
+ (void)
navpoint_resume(&pdev->dev);That cast to 'void' is not required.
True, but that function must return a value and I was just documenting the fact that it's being intentionally ignored here. I'm happy to remove it.
Quoted 4 lines
Quoted 1 line
+ (void)
navpoint_suspend(&pdev->dev);Cast to void is not required.
Ditto.