diff options
| author | Linus Torvalds <torvalds@linux-foundation.org> | 2013-05-01 16:20:04 -0400 |
|---|---|---|
| committer | Linus Torvalds <torvalds@linux-foundation.org> | 2013-05-01 16:20:04 -0400 |
| commit | 251df49db3327c64bf917bfdba94491fde2b4ee0 (patch) | |
| tree | 71eef72e1c393057f7b14cc4d8da5e48c7728336 | |
| parent | 8a72f3820c4d14b27ad5336aed00063a7a7f1bef (diff) | |
| parent | bf61c8840efe60fd8f91446860b63338fb424158 (diff) | |
Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/dtor/input
Pull input updates from Dmitry Torokhov:
"Assorted fixes and cleanups to the existing drivers plus a new driver
for IMS Passenger Control Unit device they use for ther in-flight
entertainment system."
* 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/dtor/input: (44 commits)
Input: trackpoint - Optimize trackpoint init to use power-on reset
Input: apbps2 - convert to devm_ioremap_resource()
Input: ALPS - use %ph to print buffers
ARM - shmobile: Armadillo800EVA: Move st1232 reset pin handling
Input: st1232 - add reset pin handling
Input: st1232 - convert to devm_* infrastructure
Input: MT - handle semi-mt devices in core
Input: adxl34x - use spi_get_drvdata()
Input: ad7877 - use spi_get_drvdata() and spi_set_drvdata()
Input: ads7846 - use spi_get_drvdata() and spi_set_drvdata()
Input: ims-pcu - fix a memory leak on error
Input: sysrq - supplement reset sequence with timeout functionality
Input: tegra-kbc - support for defining row/columns based on SoC
Input: imx_keypad - switch to using managed resources
Input: arc_ps2 - add support for device tree
Input: mma8450 - fix signed 12bits to 32bits conversion
Input: eeti_ts - remove redundant null check
Input: edt-ft5x06 - remove redundant null check before kfree
Input: ad714x - add CONFIG_PM_SLEEP to suspend/resume functions
Input: adxl34x - add CONFIG_PM_SLEEP to suspend/resume functions
...
49 files changed, 2917 insertions, 444 deletions
diff --git a/Documentation/devicetree/bindings/input/ps2keyb-mouse-apbps2.txt b/Documentation/devicetree/bindings/input/ps2keyb-mouse-apbps2.txt new file mode 100644 index 000000000000..3029c5694cf6 --- /dev/null +++ b/Documentation/devicetree/bindings/input/ps2keyb-mouse-apbps2.txt | |||
| @@ -0,0 +1,16 @@ | |||
| 1 | Aeroflex Gaisler APBPS2 PS/2 Core, supporting Keyboard or Mouse. | ||
| 2 | |||
| 3 | The APBPS2 PS/2 core is available in the GRLIB VHDL IP core library. | ||
| 4 | |||
| 5 | Note: In the ordinary environment for the APBPS2 core, a LEON SPARC system, | ||
| 6 | these properties are built from information in the AMBA plug&play and from | ||
| 7 | bootloader settings. | ||
| 8 | |||
| 9 | Required properties: | ||
| 10 | |||
| 11 | - name : Should be "GAISLER_APBPS2" or "01_060" | ||
| 12 | - reg : Address and length of the register set for the device | ||
| 13 | - interrupts : Interrupt numbers for this device | ||
| 14 | |||
| 15 | For further information look in the documentation for the GLIB IP core library: | ||
| 16 | http://www.gaisler.com/products/grlib/grip.pdf | ||
diff --git a/Documentation/devicetree/bindings/input/touchscreen/auo_pixcir_ts.txt b/Documentation/devicetree/bindings/input/touchscreen/auo_pixcir_ts.txt new file mode 100644 index 000000000000..f40f21c642b9 --- /dev/null +++ b/Documentation/devicetree/bindings/input/touchscreen/auo_pixcir_ts.txt | |||
| @@ -0,0 +1,30 @@ | |||
| 1 | * AUO in-cell touchscreen controller using Pixcir sensors | ||
| 2 | |||
| 3 | Required properties: | ||
| 4 | - compatible: must be "auo,auo_pixcir_ts" | ||
| 5 | - reg: I2C address of the chip | ||
| 6 | - interrupts: interrupt to which the chip is connected | ||
| 7 | - gpios: gpios the chip is connected to | ||
| 8 | first one is the interrupt gpio and second one the reset gpio | ||
| 9 | - x-size: horizontal resolution of touchscreen | ||
| 10 | - y-size: vertical resolution of touchscreen | ||
| 11 | |||
| 12 | Example: | ||
| 13 | |||
| 14 | i2c@00000000 { | ||
| 15 | /* ... */ | ||
| 16 | |||
| 17 | auo_pixcir_ts@5c { | ||
| 18 | compatible = "auo,auo_pixcir_ts"; | ||
| 19 | reg = <0x5c>; | ||
| 20 | interrupts = <2 0>; | ||
| 21 | |||
| 22 | gpios = <&gpf 2 0 2>, /* INT */ | ||
| 23 | <&gpf 5 1 0>; /* RST */ | ||
| 24 | |||
| 25 | x-size = <800>; | ||
| 26 | y-size = <600>; | ||
| 27 | }; | ||
| 28 | |||
| 29 | /* ... */ | ||
| 30 | }; | ||
diff --git a/Documentation/devicetree/bindings/input/touchscreen/sitronix-st1232.txt b/Documentation/devicetree/bindings/input/touchscreen/sitronix-st1232.txt new file mode 100644 index 000000000000..64ad48b824a2 --- /dev/null +++ b/Documentation/devicetree/bindings/input/touchscreen/sitronix-st1232.txt | |||
| @@ -0,0 +1,24 @@ | |||
| 1 | * Sitronix st1232 touchscreen controller | ||
| 2 | |||
| 3 | Required properties: | ||
| 4 | - compatible: must be "sitronix,st1232" | ||
| 5 | - reg: I2C address of the chip | ||
| 6 | - interrupts: interrupt to which the chip is connected | ||
| 7 | |||
| 8 | Optional properties: | ||
| 9 | - gpios: a phandle to the reset GPIO | ||
| 10 | |||
| 11 | Example: | ||
| 12 | |||
| 13 | i2c@00000000 { | ||
| 14 | /* ... */ | ||
| 15 | |||
| 16 | touchscreen@55 { | ||
| 17 | compatible = "sitronix,st1232"; | ||
| 18 | reg = <0x55>; | ||
| 19 | interrupts = <2 0>; | ||
| 20 | gpios = <&gpio1 166 0>; | ||
| 21 | }; | ||
| 22 | |||
| 23 | /* ... */ | ||
| 24 | }; | ||
diff --git a/Documentation/devicetree/bindings/serio/snps-arc_ps2.txt b/Documentation/devicetree/bindings/serio/snps-arc_ps2.txt new file mode 100644 index 000000000000..38c2f21e8044 --- /dev/null +++ b/Documentation/devicetree/bindings/serio/snps-arc_ps2.txt | |||
| @@ -0,0 +1,16 @@ | |||
| 1 | * ARC PS/2 driver: PS/2 block used in some ARC FPGA's & nSIM OSCI model | ||
| 2 | |||
| 3 | Required properties: | ||
| 4 | - compatible : "snps,arc_ps2" | ||
| 5 | - reg : offset and length (always 0x14) of registers | ||
| 6 | - interrupts : interrupt | ||
| 7 | - interrupt-names : name of interrupt, must be "arc_ps2_irq" | ||
| 8 | |||
| 9 | Example: | ||
| 10 | |||
| 11 | serio@c9000400 { | ||
| 12 | compatible = "snps,arc_ps2"; | ||
| 13 | reg = <0xc9000400 0x14>; | ||
| 14 | interrupts = <13>; | ||
| 15 | interrupt-names = "arc_ps2_irq"; | ||
| 16 | } | ||
diff --git a/arch/arm/mach-shmobile/board-armadillo800eva.c b/arch/arm/mach-shmobile/board-armadillo800eva.c index ff8b7ba9b93c..881e5c0e41dd 100644 --- a/arch/arm/mach-shmobile/board-armadillo800eva.c +++ b/arch/arm/mach-shmobile/board-armadillo800eva.c | |||
| @@ -24,6 +24,7 @@ | |||
| 24 | #include <linux/err.h> | 24 | #include <linux/err.h> |
| 25 | #include <linux/kernel.h> | 25 | #include <linux/kernel.h> |
| 26 | #include <linux/input.h> | 26 | #include <linux/input.h> |
| 27 | #include <linux/platform_data/st1232_pdata.h> | ||
| 27 | #include <linux/irq.h> | 28 | #include <linux/irq.h> |
| 28 | #include <linux/platform_device.h> | 29 | #include <linux/platform_device.h> |
| 29 | #include <linux/gpio.h> | 30 | #include <linux/gpio.h> |
| @@ -882,10 +883,15 @@ static struct platform_device i2c_gpio_device = { | |||
| 882 | }; | 883 | }; |
| 883 | 884 | ||
| 884 | /* I2C */ | 885 | /* I2C */ |
| 886 | static struct st1232_pdata st1232_i2c0_pdata = { | ||
| 887 | .reset_gpio = 166, | ||
| 888 | }; | ||
| 889 | |||
| 885 | static struct i2c_board_info i2c0_devices[] = { | 890 | static struct i2c_board_info i2c0_devices[] = { |
| 886 | { | 891 | { |
| 887 | I2C_BOARD_INFO("st1232-ts", 0x55), | 892 | I2C_BOARD_INFO("st1232-ts", 0x55), |
| 888 | .irq = evt2irq(0x0340), | 893 | .irq = evt2irq(0x0340), |
| 894 | .platform_data = &st1232_i2c0_pdata, | ||
| 889 | }, | 895 | }, |
| 890 | { | 896 | { |
| 891 | I2C_BOARD_INFO("wm8978", 0x1a), | 897 | I2C_BOARD_INFO("wm8978", 0x1a), |
| @@ -1009,7 +1015,6 @@ static void __init eva_init(void) | |||
| 1009 | 1015 | ||
| 1010 | /* Touchscreen */ | 1016 | /* Touchscreen */ |
| 1011 | gpio_request(GPIO_FN_IRQ10, NULL); /* TP_INT */ | 1017 | gpio_request(GPIO_FN_IRQ10, NULL); /* TP_INT */ |
| 1012 | gpio_request_one(GPIO_PORT166, GPIOF_OUT_INIT_HIGH, NULL); /* TP_RST_B */ | ||
| 1013 | 1018 | ||
| 1014 | /* GETHER */ | 1019 | /* GETHER */ |
| 1015 | gpio_request(GPIO_FN_ET_CRS, NULL); | 1020 | gpio_request(GPIO_FN_ET_CRS, NULL); |
diff --git a/drivers/base/devres.c b/drivers/base/devres.c index 668390664764..507379e7b763 100644 --- a/drivers/base/devres.c +++ b/drivers/base/devres.c | |||
| @@ -671,6 +671,80 @@ int devres_release_group(struct device *dev, void *id) | |||
| 671 | EXPORT_SYMBOL_GPL(devres_release_group); | 671 | EXPORT_SYMBOL_GPL(devres_release_group); |
| 672 | 672 | ||
| 673 | /* | 673 | /* |
| 674 | * Custom devres actions allow inserting a simple function call | ||
| 675 | * into the teadown sequence. | ||
| 676 | */ | ||
| 677 | |||
| 678 | struct action_devres { | ||
| 679 | void *data; | ||
| 680 | void (*action)(void *); | ||
| 681 | }; | ||
| 682 | |||
| 683 | static int devm_action_match(struct device *dev, void *res, void *p) | ||
| 684 | { | ||
| 685 | struct action_devres *devres = res; | ||
| 686 | struct action_devres *target = p; | ||
| 687 | |||
| 688 | return devres->action == target->action && | ||
| 689 | devres->data == target->data; | ||
| 690 | } | ||
| 691 | |||
| 692 | static void devm_action_release(struct device *dev, void *res) | ||
| 693 | { | ||
| 694 | struct action_devres *devres = res; | ||
| 695 | |||
| 696 | devres->action(devres->data); | ||
| 697 | } | ||
| 698 | |||
| 699 | /** | ||
| 700 | * devm_add_action() - add a custom action to list of managed resources | ||
| 701 | * @dev: Device that owns the action | ||
| 702 | * @action: Function that should be called | ||
| 703 | * @data: Pointer to data passed to @action implementation | ||
| 704 | * | ||
| 705 | * This adds a custom action to the list of managed resources so that | ||
| 706 | * it gets executed as part of standard resource unwinding. | ||
| 707 | */ | ||
| 708 | int devm_add_action(struct device *dev, void (*action)(void *), void *data) | ||
| 709 | { | ||
| 710 | struct action_devres *devres; | ||
| 711 | |||
| 712 | devres = devres_alloc(devm_action_release, | ||
| 713 | sizeof(struct action_devres), GFP_KERNEL); | ||
| 714 | if (!devres) | ||
| 715 | return -ENOMEM; | ||
| 716 | |||
| 717 | devres->data = data; | ||
| 718 | devres->action = action; | ||
| 719 | |||
| 720 | devres_add(dev, devres); | ||
| 721 | return 0; | ||
| 722 | } | ||
| 723 | EXPORT_SYMBOL_GPL(devm_add_action); | ||
| 724 | |||
| 725 | /** | ||
| 726 | * devm_remove_action() - removes previously added custom action | ||
| 727 | * @dev: Device that owns the action | ||
| 728 | * @action: Function implementing the action | ||
| 729 | * @data: Pointer to data passed to @action implementation | ||
| 730 | * | ||
| 731 | * Removes instance of @action previously added by devm_add_action(). | ||
| 732 | * Both action and data should match one of the existing entries. | ||
| 733 | */ | ||
| 734 | void devm_remove_action(struct device *dev, void (*action)(void *), void *data) | ||
| 735 | { | ||
| 736 | struct action_devres devres = { | ||
| 737 | .data = data, | ||
| 738 | .action = action, | ||
| 739 | }; | ||
| 740 | |||
| 741 | WARN_ON(devres_destroy(dev, devm_action_release, devm_action_match, | ||
| 742 | &devres)); | ||
| 743 | |||
| 744 | } | ||
| 745 | EXPORT_SYMBOL_GPL(devm_remove_action); | ||
| 746 | |||
| 747 | /* | ||
| 674 | * Managed kzalloc/kfree | 748 | * Managed kzalloc/kfree |
| 675 | */ | 749 | */ |
| 676 | static void devm_kzalloc_release(struct device *dev, void *res) | 750 | static void devm_kzalloc_release(struct device *dev, void *res) |
diff --git a/drivers/input/input-mt.c b/drivers/input/input-mt.c index 71db1930573f..d398f1321f14 100644 --- a/drivers/input/input-mt.c +++ b/drivers/input/input-mt.c | |||
| @@ -79,6 +79,8 @@ int input_mt_init_slots(struct input_dev *dev, unsigned int num_slots, | |||
| 79 | } | 79 | } |
| 80 | if (flags & INPUT_MT_DIRECT) | 80 | if (flags & INPUT_MT_DIRECT) |
| 81 | __set_bit(INPUT_PROP_DIRECT, dev->propbit); | 81 | __set_bit(INPUT_PROP_DIRECT, dev->propbit); |
| 82 | if (flags & INPUT_MT_SEMI_MT) | ||
| 83 | __set_bit(INPUT_PROP_SEMI_MT, dev->propbit); | ||
| 82 | if (flags & INPUT_MT_TRACK) { | 84 | if (flags & INPUT_MT_TRACK) { |
| 83 | unsigned int n2 = num_slots * num_slots; | 85 | unsigned int n2 = num_slots * num_slots; |
| 84 | mt->red = kcalloc(n2, sizeof(*mt->red), GFP_KERNEL); | 86 | mt->red = kcalloc(n2, sizeof(*mt->red), GFP_KERNEL); |
| @@ -246,6 +248,7 @@ void input_mt_sync_frame(struct input_dev *dev) | |||
| 246 | { | 248 | { |
| 247 | struct input_mt *mt = dev->mt; | 249 | struct input_mt *mt = dev->mt; |
| 248 | struct input_mt_slot *s; | 250 | struct input_mt_slot *s; |
| 251 | bool use_count = false; | ||
| 249 | 252 | ||
| 250 | if (!mt) | 253 | if (!mt) |
| 251 | return; | 254 | return; |
| @@ -259,7 +262,10 @@ void input_mt_sync_frame(struct input_dev *dev) | |||
| 259 | } | 262 | } |
| 260 | } | 263 | } |
| 261 | 264 | ||
| 262 | input_mt_report_pointer_emulation(dev, (mt->flags & INPUT_MT_POINTER)); | 265 | if ((mt->flags & INPUT_MT_POINTER) && !(mt->flags & INPUT_MT_SEMI_MT)) |
| 266 | use_count = true; | ||
| 267 | |||
| 268 | input_mt_report_pointer_emulation(dev, use_count); | ||
| 263 | 269 | ||
| 264 | mt->frame++; | 270 | mt->frame++; |
| 265 | } | 271 | } |
diff --git a/drivers/input/keyboard/amikbd.c b/drivers/input/keyboard/amikbd.c index 79172af164f2..ba0b36f7daea 100644 --- a/drivers/input/keyboard/amikbd.c +++ b/drivers/input/keyboard/amikbd.c | |||
| @@ -260,18 +260,6 @@ static struct platform_driver amikbd_driver = { | |||
| 260 | }, | 260 | }, |
| 261 | }; | 261 | }; |
| 262 | 262 | ||
| 263 | static int __init amikbd_init(void) | 263 | module_platform_driver_probe(amikbd_driver, amikbd_probe); |
| 264 | { | ||
| 265 | return platform_driver_probe(&amikbd_driver, amikbd_probe); | ||
| 266 | } | ||
| 267 | |||
| 268 | module_init(amikbd_init); | ||
| 269 | |||
| 270 | static void __exit amikbd_exit(void) | ||
| 271 | { | ||
| 272 | platform_driver_unregister(&amikbd_driver); | ||
| 273 | } | ||
| 274 | |||
| 275 | module_exit(amikbd_exit); | ||
| 276 | 264 | ||
| 277 | MODULE_ALIAS("platform:amiga-keyboard"); | 265 | MODULE_ALIAS("platform:amiga-keyboard"); |
diff --git a/drivers/input/keyboard/davinci_keyscan.c b/drivers/input/keyboard/davinci_keyscan.c index 4e4e453ea15e..829753702b62 100644 --- a/drivers/input/keyboard/davinci_keyscan.c +++ b/drivers/input/keyboard/davinci_keyscan.c | |||
| @@ -329,17 +329,7 @@ static struct platform_driver davinci_ks_driver = { | |||
| 329 | .remove = davinci_ks_remove, | 329 | .remove = davinci_ks_remove, |
| 330 | }; | 330 | }; |
| 331 | 331 | ||
| 332 | static int __init davinci_ks_init(void) | 332 | module_platform_driver_probe(davinci_ks_driver, davinci_ks_probe); |
| 333 | { | ||
| 334 | return platform_driver_probe(&davinci_ks_driver, davinci_ks_probe); | ||
| 335 | } | ||
| 336 | module_init(davinci_ks_init); | ||
| 337 | |||
| 338 | static void __exit davinci_ks_exit(void) | ||
| 339 | { | ||
| 340 | platform_driver_unregister(&davinci_ks_driver); | ||
| 341 | } | ||
| 342 | module_exit(davinci_ks_exit); | ||
| 343 | 333 | ||
| 344 | MODULE_AUTHOR("Miguel Aguilar"); | 334 | MODULE_AUTHOR("Miguel Aguilar"); |
| 345 | MODULE_DESCRIPTION("Texas Instruments DaVinci Key Scan Driver"); | 335 | MODULE_DESCRIPTION("Texas Instruments DaVinci Key Scan Driver"); |
diff --git a/drivers/input/keyboard/imx_keypad.c b/drivers/input/keyboard/imx_keypad.c index 98f9113251d2..03c8cc5cb6c1 100644 --- a/drivers/input/keyboard/imx_keypad.c +++ b/drivers/input/keyboard/imx_keypad.c | |||
| @@ -448,24 +448,17 @@ static int imx_keypad_probe(struct platform_device *pdev) | |||
| 448 | return -EINVAL; | 448 | return -EINVAL; |
| 449 | } | 449 | } |
| 450 | 450 | ||
| 451 | res = request_mem_region(res->start, resource_size(res), pdev->name); | 451 | input_dev = devm_input_allocate_device(&pdev->dev); |
| 452 | if (res == NULL) { | ||
| 453 | dev_err(&pdev->dev, "failed to request I/O memory\n"); | ||
| 454 | return -EBUSY; | ||
| 455 | } | ||
| 456 | |||
| 457 | input_dev = input_allocate_device(); | ||
| 458 | if (!input_dev) { | 452 | if (!input_dev) { |
| 459 | dev_err(&pdev->dev, "failed to allocate the input device\n"); | 453 | dev_err(&pdev->dev, "failed to allocate the input device\n"); |
| 460 | error = -ENOMEM; | 454 | return -ENOMEM; |
| 461 | goto failed_rel_mem; | ||
| 462 | } | 455 | } |
| 463 | 456 | ||
| 464 | keypad = kzalloc(sizeof(struct imx_keypad), GFP_KERNEL); | 457 | keypad = devm_kzalloc(&pdev->dev, sizeof(struct imx_keypad), |
| 458 | GFP_KERNEL); | ||
| 465 | if (!keypad) { | 459 | if (!keypad) { |
| 466 | dev_err(&pdev->dev, "not enough memory for driver data\n"); | 460 | dev_err(&pdev->dev, "not enough memory for driver data\n"); |
| 467 | error = -ENOMEM; | 461 | return -ENOMEM; |
| 468 | goto failed_free_input; | ||
| 469 | } | 462 | } |
| 470 | 463 | ||
| 471 | keypad->input_dev = input_dev; | 464 | keypad->input_dev = input_dev; |
| @@ -475,18 +468,14 @@ static int imx_keypad_probe(struct platform_device *pdev) | |||
| 475 | setup_timer(&keypad->check_matrix_timer, | 468 | setup_timer(&keypad->check_matrix_timer, |
| 476 | imx_keypad_check_for_events, (unsigned long) keypad); | 469 | imx_keypad_check_for_events, (unsigned long) keypad); |
| 477 | 470 | ||
| 478 | keypad->mmio_base = ioremap(res->start, resource_size(res)); | 471 | keypad->mmio_base = devm_ioremap_resource(&pdev->dev, res); |
| 479 | if (keypad->mmio_base == NULL) { | 472 | if (IS_ERR(keypad->mmio_base)) |
| 480 | dev_err(&pdev->dev, "failed to remap I/O memory\n"); | 473 | return PTR_ERR(keypad->mmio_base); |
| 481 | error = -ENOMEM; | ||
| 482 | goto failed_free_priv; | ||
| 483 | } | ||
| 484 | 474 | ||
| 485 | keypad->clk = clk_get(&pdev->dev, NULL); | 475 | keypad->clk = devm_clk_get(&pdev->dev, NULL); |
| 486 | if (IS_ERR(keypad->clk)) { | 476 | if (IS_ERR(keypad->clk)) { |
| 487 | dev_err(&pdev->dev, "failed to get keypad clock\n"); | 477 | dev_err(&pdev->dev, "failed to get keypad clock\n"); |
| 488 | error = PTR_ERR(keypad->clk); | 478 | return PTR_ERR(keypad->clk); |
| 489 | goto failed_unmap; | ||
| 490 | } | 479 | } |
| 491 | 480 | ||
| 492 | /* Init the Input device */ | 481 | /* Init the Input device */ |
| @@ -502,7 +491,7 @@ static int imx_keypad_probe(struct platform_device *pdev) | |||
| 502 | keypad->keycodes, input_dev); | 491 | keypad->keycodes, input_dev); |
| 503 | if (error) { | 492 | if (error) { |
| 504 | dev_err(&pdev->dev, "failed to build keymap\n"); | 493 | dev_err(&pdev->dev, "failed to build keymap\n"); |
| 505 | goto failed_clock_put; | 494 | return error; |
| 506 | } | 495 | } |
| 507 | 496 | ||
| 508 | /* Search for rows and cols enabled */ | 497 | /* Search for rows and cols enabled */ |
| @@ -527,61 +516,24 @@ static int imx_keypad_probe(struct platform_device *pdev) | |||
| 527 | imx_keypad_inhibit(keypad); | 516 | imx_keypad_inhibit(keypad); |
| 528 | clk_disable_unprepare(keypad->clk); | 517 | clk_disable_unprepare(keypad->clk); |
| 529 | 518 | ||
| 530 | error = request_irq(irq, imx_keypad_irq_handler, 0, | 519 | error = devm_request_irq(&pdev->dev, irq, imx_keypad_irq_handler, 0, |
| 531 | pdev->name, keypad); | 520 | pdev->name, keypad); |
| 532 | if (error) { | 521 | if (error) { |
| 533 | dev_err(&pdev->dev, "failed to request IRQ\n"); | 522 | dev_err(&pdev->dev, "failed to request IRQ\n"); |
| 534 | goto failed_clock_put; | 523 | return error; |
| 535 | } | 524 | } |
| 536 | 525 | ||
| 537 | /* Register the input device */ | 526 | /* Register the input device */ |
| 538 | error = input_register_device(input_dev); | 527 | error = input_register_device(input_dev); |
| 539 | if (error) { | 528 | if (error) { |
| 540 | dev_err(&pdev->dev, "failed to register input device\n"); | 529 | dev_err(&pdev->dev, "failed to register input device\n"); |
| 541 | goto failed_free_irq; | 530 | return error; |
| 542 | } | 531 | } |
| 543 | 532 | ||
| 544 | platform_set_drvdata(pdev, keypad); | 533 | platform_set_drvdata(pdev, keypad); |
| 545 | device_init_wakeup(&pdev->dev, 1); | 534 | device_init_wakeup(&pdev->dev, 1); |
| 546 | 535 | ||
| 547 | return 0; | 536 | return 0; |
| 548 | |||
| 549 | failed_free_irq: | ||
| 550 | free_irq(irq, pdev); | ||
| 551 | failed_clock_put: | ||
| 552 | clk_put(keypad->clk); | ||
| 553 | failed_unmap: | ||
| 554 | iounmap(keypad->mmio_base); | ||
| 555 | failed_free_priv: | ||
| 556 | kfree(keypad); | ||
| 557 | failed_free_input: | ||
| 558 | input_free_device(input_dev); | ||
| 559 | failed_rel_mem: | ||
| 560 | release_mem_region(res->start, resource_size(res)); | ||
| 561 | return error; | ||
| 562 | } | ||
| 563 | |||
| 564 | static int imx_keypad_remove(struct platform_device *pdev) | ||
| 565 | { | ||
| 566 | struct imx_keypad *keypad = platform_get_drvdata(pdev); | ||
| 567 | struct resource *res; | ||
| 568 | |||
| 569 | dev_dbg(&pdev->dev, ">%s\n", __func__); | ||
| 570 | |||
| 571 | platform_set_drvdata(pdev, NULL); | ||
| 572 | |||
| 573 | input_unregister_device(keypad->input_dev); | ||
| 574 | |||
| 575 | free_irq(keypad->irq, keypad); | ||
| 576 | clk_put(keypad->clk); | ||
| 577 | |||
| 578 | iounmap(keypad->mmio_base); | ||
| 579 | res = platform_get_resource(pdev, IORESOURCE_MEM, 0); | ||
| 580 | release_mem_region(res->start, resource_size(res)); | ||
| 581 | |||
| 582 | kfree(keypad); | ||
| 583 | |||
| 584 | return 0; | ||
| 585 | } | 537 | } |
| 586 | 538 | ||
| 587 | #ifdef CONFIG_PM_SLEEP | 539 | #ifdef CONFIG_PM_SLEEP |
| @@ -640,7 +592,6 @@ static struct platform_driver imx_keypad_driver = { | |||
| 640 | .of_match_table = of_match_ptr(imx_keypad_of_match), | 592 | .of_match_table = of_match_ptr(imx_keypad_of_match), |
| 641 | }, | 593 | }, |
| 642 | .probe = imx_keypad_probe, | 594 | .probe = imx_keypad_probe, |
| 643 | .remove = imx_keypad_remove, | ||
| 644 | }; | 595 | }; |
| 645 | module_platform_driver(imx_keypad_driver); | 596 | module_platform_driver(imx_keypad_driver); |
| 646 | 597 | ||
diff --git a/drivers/input/keyboard/nomadik-ske-keypad.c b/drivers/input/keyboard/nomadik-ske-keypad.c index 0e6a8151fee3..c7d505cce72f 100644 --- a/drivers/input/keyboard/nomadik-ske-keypad.c +++ b/drivers/input/keyboard/nomadik-ske-keypad.c | |||
| @@ -430,17 +430,7 @@ static struct platform_driver ske_keypad_driver = { | |||
| 430 | .remove = ske_keypad_remove, | 430 | .remove = ske_keypad_remove, |
| 431 | }; | 431 | }; |
| 432 | 432 | ||
| 433 | static int __init ske_keypad_init(void) | 433 | module_platform_driver_probe(ske_keypad_driver, ske_keypad_probe); |
| 434 | { | ||
| 435 | return platform_driver_probe(&ske_keypad_driver, ske_keypad_probe); | ||
| 436 | } | ||
| 437 | module_init(ske_keypad_init); | ||
| 438 | |||
| 439 | static void __exit ske_keypad_exit(void) | ||
| 440 | { | ||
| 441 | platform_driver_unregister(&ske_keypad_driver); | ||
| 442 | } | ||
| 443 | module_exit(ske_keypad_exit); | ||
| 444 | 434 | ||
| 445 | MODULE_LICENSE("GPL v2"); | 435 | MODULE_LICENSE("GPL v2"); |
| 446 | MODULE_AUTHOR("Naveen Kumar <naveen.gaddipati@stericsson.com> / Sundar Iyer <sundar.iyer@stericsson.com>"); | 436 | MODULE_AUTHOR("Naveen Kumar <naveen.gaddipati@stericsson.com> / Sundar Iyer <sundar.iyer@stericsson.com>"); |
diff --git a/drivers/input/keyboard/tegra-kbc.c b/drivers/input/keyboard/tegra-kbc.c index 0e138ebcc768..b46142f78ef2 100644 --- a/drivers/input/keyboard/tegra-kbc.c +++ b/drivers/input/keyboard/tegra-kbc.c | |||
| @@ -27,17 +27,19 @@ | |||
| 27 | #include <linux/io.h> | 27 | #include <linux/io.h> |
| 28 | #include <linux/interrupt.h> | 28 | #include <linux/interrupt.h> |
| 29 | #include <linux/of.h> | 29 | #include <linux/of.h> |
| 30 | #include <linux/of_device.h> | ||
| 30 | #include <linux/clk.h> | 31 | #include <linux/clk.h> |
| 31 | #include <linux/slab.h> | 32 | #include <linux/slab.h> |
| 32 | #include <linux/input/matrix_keypad.h> | 33 | #include <linux/input/matrix_keypad.h> |
| 33 | #include <linux/clk/tegra.h> | 34 | #include <linux/clk/tegra.h> |
| 35 | #include <linux/err.h> | ||
| 34 | 36 | ||
| 35 | #define KBC_MAX_GPIO 24 | ||
| 36 | #define KBC_MAX_KPENT 8 | 37 | #define KBC_MAX_KPENT 8 |
| 37 | 38 | ||
| 38 | #define KBC_MAX_ROW 16 | 39 | /* Maximum row/column supported by Tegra KBC yet is 16x8 */ |
| 39 | #define KBC_MAX_COL 8 | 40 | #define KBC_MAX_GPIO 24 |
| 40 | #define KBC_MAX_KEY (KBC_MAX_ROW * KBC_MAX_COL) | 41 | /* Maximum keys supported by Tegra KBC yet is 16 x 8*/ |
| 42 | #define KBC_MAX_KEY (16 * 8) | ||
| 41 | 43 | ||
| 42 | #define KBC_MAX_DEBOUNCE_CNT 0x3ffu | 44 | #define KBC_MAX_DEBOUNCE_CNT 0x3ffu |
| 43 | 45 | ||
| @@ -80,6 +82,12 @@ enum tegra_pin_type { | |||
| 80 | PIN_CFG_ROW, | 82 | PIN_CFG_ROW, |
| 81 | }; | 83 | }; |
| 82 | 84 | ||
| 85 | /* Tegra KBC hw support */ | ||
| 86 | struct tegra_kbc_hw_support { | ||
| 87 | int max_rows; | ||
| 88 | int max_columns; | ||
| 89 | }; | ||
| 90 | |||
| 83 | struct tegra_kbc_pin_cfg { | 91 | struct tegra_kbc_pin_cfg { |
| 84 | enum tegra_pin_type type; | 92 | enum tegra_pin_type type; |
| 85 | unsigned char num; | 93 | unsigned char num; |
| @@ -108,6 +116,9 @@ struct tegra_kbc { | |||
| 108 | u32 wakeup_key; | 116 | u32 wakeup_key; |
| 109 | struct timer_list timer; | 117 | struct timer_list timer; |
| 110 | struct clk *clk; | 118 | struct clk *clk; |
| 119 | const struct tegra_kbc_hw_support *hw_support; | ||
| 120 | int max_keys; | ||
| 121 | int num_rows_and_columns; | ||
| 111 | }; | 122 | }; |
| 112 | 123 | ||
| 113 | static void tegra_kbc_report_released_keys(struct input_dev *input, | 124 | static void tegra_kbc_report_released_keys(struct input_dev *input, |
| @@ -204,11 +215,11 @@ static void tegra_kbc_report_keys(struct tegra_kbc *kbc) | |||
| 204 | 215 | ||
| 205 | /* | 216 | /* |
| 206 | * If the platform uses Fn keymaps, translate keys on a Fn keypress. | 217 | * If the platform uses Fn keymaps, translate keys on a Fn keypress. |
| 207 | * Function keycodes are KBC_MAX_KEY apart from the plain keycodes. | 218 | * Function keycodes are max_keys apart from the plain keycodes. |
| 208 | */ | 219 | */ |
| 209 | if (fn_keypress) { | 220 | if (fn_keypress) { |
| 210 | for (i = 0; i < num_down; i++) { | 221 | for (i = 0; i < num_down; i++) { |
| 211 | scancodes[i] += KBC_MAX_KEY; | 222 | scancodes[i] += kbc->max_keys; |
| 212 | keycodes[i] = kbc->keycode[scancodes[i]]; | 223 | keycodes[i] = kbc->keycode[scancodes[i]]; |
| 213 | } | 224 | } |
| 214 | } | 225 | } |
| @@ -315,7 +326,7 @@ static void tegra_kbc_setup_wakekeys(struct tegra_kbc *kbc, bool filter) | |||
| 315 | /* Either mask all keys or none. */ | 326 | /* Either mask all keys or none. */ |
| 316 | rst_val = (filter && !kbc->wakeup) ? ~0 : 0; | 327 | rst_val = (filter && !kbc->wakeup) ? ~0 : 0; |
| 317 | 328 | ||
| 318 | for (i = 0; i < KBC_MAX_ROW; i++) | 329 | for (i = 0; i < kbc->hw_support->max_rows; i++) |
| 319 | writel(rst_val, kbc->mmio + KBC_ROW0_MASK_0 + i * 4); | 330 | writel(rst_val, kbc->mmio + KBC_ROW0_MASK_0 + i * 4); |
| 320 | } | 331 | } |
| 321 | 332 | ||
| @@ -452,7 +463,7 @@ static bool tegra_kbc_check_pin_cfg(const struct tegra_kbc *kbc, | |||
| 452 | 463 | ||
| 453 | switch (pin_cfg->type) { | 464 | switch (pin_cfg->type) { |
| 454 | case PIN_CFG_ROW: | 465 | case PIN_CFG_ROW: |
| 455 | if (pin_cfg->num >= KBC_MAX_ROW) { | 466 | if (pin_cfg->num >= kbc->hw_support->max_rows) { |
| 456 | dev_err(kbc->dev, | 467 | dev_err(kbc->dev, |
| 457 | "pin_cfg[%d]: invalid row number %d\n", | 468 | "pin_cfg[%d]: invalid row number %d\n", |
| 458 | i, pin_cfg->num); | 469 | i, pin_cfg->num); |
| @@ -462,7 +473,7 @@ static bool tegra_kbc_check_pin_cfg(const struct tegra_kbc *kbc, | |||
| 462 | break; | 473 | break; |
| 463 | 474 | ||
| 464 | case PIN_CFG_COL: | 475 | case PIN_CFG_COL: |
| 465 | if (pin_cfg->num >= KBC_MAX_COL) { | 476 | if (pin_cfg->num >= kbc->hw_support->max_columns) { |
| 466 | dev_err(kbc->dev, | 477 | dev_err(kbc->dev, |
| 467 | "pin_cfg[%d]: invalid column number %d\n", | 478 | "pin_cfg[%d]: invalid column number %d\n", |
| 468 | i, pin_cfg->num); | 479 | i, pin_cfg->num); |
| @@ -520,6 +531,18 @@ static int tegra_kbc_parse_dt(struct tegra_kbc *kbc) | |||
| 520 | } | 531 | } |
| 521 | num_cols = proplen / sizeof(u32); | 532 | num_cols = proplen / sizeof(u32); |
| 522 | 533 | ||
| 534 | if (num_rows > kbc->hw_support->max_rows) { | ||
| 535 | dev_err(kbc->dev, | ||
| 536 | "Number of rows is more than supported by hardware\n"); | ||
| 537 | return -EINVAL; | ||
| 538 | } | ||
| 539 | |||
| 540 | if (num_cols > kbc->hw_support->max_columns) { | ||
| 541 | dev_err(kbc->dev, | ||
| 542 | "Number of cols is more than supported by hardware\n"); | ||
| 543 | return -EINVAL; | ||
| 544 | } | ||
| 545 | |||
| 523 | if (!of_get_property(np, "linux,keymap", &proplen)) { | 546 | if (!of_get_property(np, "linux,keymap", &proplen)) { |
| 524 | dev_err(kbc->dev, "property linux,keymap not found\n"); | 547 | dev_err(kbc->dev, "property linux,keymap not found\n"); |
| 525 | return -ENOENT; | 548 | return -ENOENT; |
| @@ -532,7 +555,7 @@ static int tegra_kbc_parse_dt(struct tegra_kbc *kbc) | |||
| 532 | } | 555 | } |
| 533 | 556 | ||
| 534 | /* Set all pins as non-configured */ | 557 | /* Set all pins as non-configured */ |
| 535 | for (i = 0; i < KBC_MAX_GPIO; i++) | 558 | for (i = 0; i < kbc->num_rows_and_columns; i++) |
| 536 | kbc->pin_cfg[i].type = PIN_CFG_IGNORE; | 559 | kbc->pin_cfg[i].type = PIN_CFG_IGNORE; |
| 537 | 560 | ||
| 538 | ret = of_property_read_u32_array(np, "nvidia,kbc-row-pins", | 561 | ret = of_property_read_u32_array(np, "nvidia,kbc-row-pins", |
| @@ -562,6 +585,24 @@ static int tegra_kbc_parse_dt(struct tegra_kbc *kbc) | |||
| 562 | return 0; | 585 | return 0; |
| 563 | } | 586 | } |
| 564 | 587 | ||
| 588 | static const struct tegra_kbc_hw_support tegra20_kbc_hw_support = { | ||
| 589 | .max_rows = 16, | ||
| 590 | .max_columns = 8, | ||
| 591 | }; | ||
| 592 | |||
| 593 | static const struct tegra_kbc_hw_support tegra11_kbc_hw_support = { | ||
| 594 | .max_rows = 11, | ||
| 595 | .max_columns = 8, | ||
| 596 | }; | ||
| 597 | |||
| 598 | static const struct of_device_id tegra_kbc_of_match[] = { | ||
| 599 | { .compatible = "nvidia,tegra114-kbc", .data = &tegra11_kbc_hw_support}, | ||
| 600 | { .compatible = "nvidia,tegra30-kbc", .data = &tegra20_kbc_hw_support}, | ||
| 601 | { .compatible = "nvidia,tegra20-kbc", .data = &tegra20_kbc_hw_support}, | ||
| 602 | { }, | ||
| 603 | }; | ||
| 604 | MODULE_DEVICE_TABLE(of, tegra_kbc_of_match); | ||
| 605 | |||
| 565 | static int tegra_kbc_probe(struct platform_device *pdev) | 606 | static int tegra_kbc_probe(struct platform_device *pdev) |
| 566 | { | 607 | { |
| 567 | struct tegra_kbc *kbc; | 608 | struct tegra_kbc *kbc; |
| @@ -570,7 +611,10 @@ static int tegra_kbc_probe(struct platform_device *pdev) | |||
| 570 | int num_rows = 0; | 611 | int num_rows = 0; |
| 571 | unsigned int debounce_cnt; | 612 | unsigned int debounce_cnt; |
| 572 | unsigned int scan_time_rows; | 613 | unsigned int scan_time_rows; |
| 573 | unsigned int keymap_rows = KBC_MAX_KEY; | 614 | unsigned int keymap_rows; |
| 615 | const struct of_device_id *match; | ||
| 616 | |||
| 617 | match = of_match_device(of_match_ptr(tegra_kbc_of_match), &pdev->dev); | ||
| 574 | 618 | ||
| 575 | kbc = devm_kzalloc(&pdev->dev, sizeof(*kbc), GFP_KERNEL); | 619 | kbc = devm_kzalloc(&pdev->dev, sizeof(*kbc), GFP_KERNEL); |
| 576 | if (!kbc) { | 620 | if (!kbc) { |
| @@ -579,6 +623,12 @@ static int tegra_kbc_probe(struct platform_device *pdev) | |||
| 579 | } | 623 | } |
| 580 | 624 | ||
| 581 | kbc->dev = &pdev->dev; | 625 | kbc->dev = &pdev->dev; |
| 626 | kbc->hw_support = match->data; | ||
| 627 | kbc->max_keys = kbc->hw_support->max_rows * | ||
| 628 | kbc->hw_support->max_columns; | ||
| 629 | kbc->num_rows_and_columns = kbc->hw_support->max_rows + | ||
| 630 | kbc->hw_support->max_columns; | ||
| 631 | keymap_rows = kbc->max_keys; | ||
| 582 | spin_lock_init(&kbc->lock); | 632 | spin_lock_init(&kbc->lock); |
| 583 | 633 | ||
| 584 | err = tegra_kbc_parse_dt(kbc); | 634 | err = tegra_kbc_parse_dt(kbc); |
| @@ -608,11 +658,9 @@ static int tegra_kbc_probe(struct platform_device *pdev) | |||
| 608 | 658 | ||
| 609 | setup_timer(&kbc->timer, tegra_kbc_keypress_timer, (unsigned long)kbc); | 659 | setup_timer(&kbc->timer, tegra_kbc_keypress_timer, (unsigned long)kbc); |
| 610 | 660 | ||
| 611 | kbc->mmio = devm_request_and_ioremap(&pdev->dev, res); | 661 | kbc->mmio = devm_ioremap_resource(&pdev->dev, res); |
| 612 | if (!kbc->mmio) { | 662 | if (IS_ERR(kbc->mmio)) |
| 613 | dev_err(&pdev->dev, "Cannot request memregion/iomap address\n"); | 663 | return PTR_ERR(kbc->mmio); |
| 614 | return -EBUSY; | ||
| 615 | } | ||
| 616 | 664 | ||
| 617 | kbc->clk = devm_clk_get(&pdev->dev, NULL); | 665 | kbc->clk = devm_clk_get(&pdev->dev, NULL); |
| 618 | if (IS_ERR(kbc->clk)) { | 666 | if (IS_ERR(kbc->clk)) { |
| @@ -641,7 +689,8 @@ static int tegra_kbc_probe(struct platform_device *pdev) | |||
| 641 | keymap_rows *= 2; | 689 | keymap_rows *= 2; |
| 642 | 690 | ||
| 643 | err = matrix_keypad_build_keymap(kbc->keymap_data, NULL, | 691 | err = matrix_keypad_build_keymap(kbc->keymap_data, NULL, |
| 644 | keymap_rows, KBC_MAX_COL, | 692 | keymap_rows, |
| 693 | kbc->hw_support->max_columns, | ||
| 645 | kbc->keycode, kbc->idev); | 694 | kbc->keycode, kbc->idev); |
| 646 | if (err) { | 695 | if (err) { |
| 647 | dev_err(&pdev->dev, "failed to setup keymap\n"); | 696 | dev_err(&pdev->dev, "failed to setup keymap\n"); |
| @@ -767,12 +816,6 @@ static int tegra_kbc_resume(struct device *dev) | |||
| 767 | 816 | ||
| 768 | static SIMPLE_DEV_PM_OPS(tegra_kbc_pm_ops, tegra_kbc_suspend, tegra_kbc_resume); | 817 | static SIMPLE_DEV_PM_OPS(tegra_kbc_pm_ops, tegra_kbc_suspend, tegra_kbc_resume); |
| 769 | 818 | ||
| 770 | static const struct of_device_id tegra_kbc_of_match[] = { | ||
| 771 | { .compatible = "nvidia,tegra20-kbc", }, | ||
| 772 | { }, | ||
| 773 | }; | ||
| 774 | MODULE_DEVICE_TABLE(of, tegra_kbc_of_match); | ||
| 775 | |||
| 776 | static struct platform_driver tegra_kbc_driver = { | 819 | static struct platform_driver tegra_kbc_driver = { |
| 777 | .probe = tegra_kbc_probe, | 820 | .probe = tegra_kbc_probe, |
| 778 | .driver = { | 821 | .driver = { |
diff --git a/drivers/input/misc/Kconfig b/drivers/input/misc/Kconfig index 259ef31abb18..af80928a46b4 100644 --- a/drivers/input/misc/Kconfig +++ b/drivers/input/misc/Kconfig | |||
| @@ -590,6 +590,16 @@ config INPUT_ADXL34X_SPI | |||
| 590 | To compile this driver as a module, choose M here: the | 590 | To compile this driver as a module, choose M here: the |
| 591 | module will be called adxl34x-spi. | 591 | module will be called adxl34x-spi. |
| 592 | 592 | ||
| 593 | config INPUT_IMS_PCU | ||
| 594 | tristate "IMS Passenger Control Unit driver" | ||
| 595 | depends on USB | ||
| 596 | depends on LEDS_CLASS | ||
| 597 | help | ||
| 598 | Say Y here if you have system with IMS Rave Passenger Control Unit. | ||
| 599 | |||
| 600 | To compile this driver as a module, choose M here: the module will be | ||
| 601 | called ims_pcu. | ||
| 602 | |||
| 593 | config INPUT_CMA3000 | 603 | config INPUT_CMA3000 |
| 594 | tristate "VTI CMA3000 Tri-axis accelerometer" | 604 | tristate "VTI CMA3000 Tri-axis accelerometer" |
| 595 | help | 605 | help |
diff --git a/drivers/input/misc/Makefile b/drivers/input/misc/Makefile index 1f1e1b109d9d..d7fc17f11d77 100644 --- a/drivers/input/misc/Makefile +++ b/drivers/input/misc/Makefile | |||
| @@ -29,6 +29,7 @@ obj-$(CONFIG_INPUT_DM355EVM) += dm355evm_keys.o | |||
| 29 | obj-$(CONFIG_INPUT_GP2A) += gp2ap002a00f.o | 29 | obj-$(CONFIG_INPUT_GP2A) += gp2ap002a00f.o |
| 30 | obj-$(CONFIG_INPUT_GPIO_TILT_POLLED) += gpio_tilt_polled.o | 30 | obj-$(CONFIG_INPUT_GPIO_TILT_POLLED) += gpio_tilt_polled.o |
| 31 | obj-$(CONFIG_HP_SDC_RTC) += hp_sdc_rtc.o | 31 | obj-$(CONFIG_HP_SDC_RTC) += hp_sdc_rtc.o |
| 32 | obj-$(CONFIG_INPUT_IMS_PCU) += ims-pcu.o | ||
| 32 | obj-$(CONFIG_INPUT_IXP4XX_BEEPER) += ixp4xx-beeper.o | 33 | obj-$(CONFIG_INPUT_IXP4XX_BEEPER) += ixp4xx-beeper.o |
| 33 | obj-$(CONFIG_INPUT_KEYSPAN_REMOTE) += keyspan_remote.o | 34 | obj-$(CONFIG_INPUT_KEYSPAN_REMOTE) += keyspan_remote.o |
| 34 | obj-$(CONFIG_INPUT_KXTJ9) += kxtj9.o | 35 | obj-$(CONFIG_INPUT_KXTJ9) += kxtj9.o |
diff --git a/drivers/input/misc/ad714x-i2c.c b/drivers/input/misc/ad714x-i2c.c index 29d2064c26f2..e0f522516ef5 100644 --- a/drivers/input/misc/ad714x-i2c.c +++ b/drivers/input/misc/ad714x-i2c.c | |||
| @@ -13,7 +13,7 @@ | |||
| 13 | #include <linux/pm.h> | 13 | #include <linux/pm.h> |
| 14 | #include "ad714x.h" | 14 | #include "ad714x.h" |
| 15 | 15 | ||
| 16 | #ifdef CONFIG_PM | 16 | #ifdef CONFIG_PM_SLEEP |
| 17 | static int ad714x_i2c_suspend(struct device *dev) | 17 | static int ad714x_i2c_suspend(struct device *dev) |
| 18 | { | 18 | { |
| 19 | return ad714x_disable(i2c_get_clientdata(to_i2c_client(dev))); | 19 | return ad714x_disable(i2c_get_clientdata(to_i2c_client(dev))); |
diff --git a/drivers/input/misc/ad714x-spi.c b/drivers/input/misc/ad714x-spi.c index bdccca42d138..61891486067c 100644 --- a/drivers/input/misc/ad714x-spi.c +++ b/drivers/input/misc/ad714x-spi.c | |||
| @@ -16,7 +16,7 @@ | |||
| 16 | #define AD714x_SPI_CMD_PREFIX 0xE000 /* bits 15:11 */ | 16 | #define AD714x_SPI_CMD_PREFIX 0xE000 /* bits 15:11 */ |
| 17 | #define AD714x_SPI_READ BIT(10) | 17 | #define AD714x_SPI_READ BIT(10) |
| 18 | 18 | ||
| 19 | #ifdef CONFIG_PM | 19 | #ifdef CONFIG_PM_SLEEP |
| 20 | static int ad714x_spi_suspend(struct device *dev) | 20 | static int ad714x_spi_suspend(struct device *dev) |
| 21 | { | 21 | { |
| 22 | return ad714x_disable(spi_get_drvdata(to_spi_device(dev))); | 22 | return ad714x_disable(spi_get_drvdata(to_spi_device(dev))); |
diff --git a/drivers/input/misc/adxl34x-i2c.c b/drivers/input/misc/adxl34x-i2c.c index 535dda48cace..416f47ddcc90 100644 --- a/drivers/input/misc/adxl34x-i2c.c +++ b/drivers/input/misc/adxl34x-i2c.c | |||
| @@ -105,7 +105,7 @@ static int adxl34x_i2c_remove(struct i2c_client *client) | |||
| 105 | return adxl34x_remove(ac); | 105 | return adxl34x_remove(ac); |
| 106 | } | 106 | } |
| 107 | 107 | ||
| 108 | #ifdef CONFIG_PM | 108 | #ifdef CONFIG_PM_SLEEP |
| 109 | static int adxl34x_i2c_suspend(struct device *dev) | 109 | static int adxl34x_i2c_suspend(struct device *dev) |
| 110 | { | 110 | { |
| 111 | struct i2c_client *client = to_i2c_client(dev); | 111 | struct i2c_client *client = to_i2c_client(dev); |
diff --git a/drivers/input/misc/adxl34x-spi.c b/drivers/input/misc/adxl34x-spi.c index ad5f40d37e48..76dc0679d3b1 100644 --- a/drivers/input/misc/adxl34x-spi.c +++ b/drivers/input/misc/adxl34x-spi.c | |||
| @@ -89,16 +89,16 @@ static int adxl34x_spi_probe(struct spi_device *spi) | |||
| 89 | 89 | ||
| 90 | static int adxl34x_spi_remove(struct spi_device *spi) | 90 | static int adxl34x_spi_remove(struct spi_device *spi) |
| 91 | { | 91 | { |
| 92 | struct adxl34x *ac = dev_get_drvdata(&spi->dev); | 92 | struct adxl34x *ac = spi_get_drvdata(spi); |
| 93 | 93 | ||
| 94 | return adxl34x_remove(ac); | 94 | return adxl34x_remove(ac); |
| 95 | } | 95 | } |
| 96 | 96 | ||
| 97 | #ifdef CONFIG_PM | 97 | #ifdef CONFIG_PM_SLEEP |
| 98 | static int adxl34x_spi_suspend(struct device *dev) | 98 | static int adxl34x_spi_suspend(struct device *dev) |
| 99 | { | 99 | { |
| 100 | struct spi_device *spi = to_spi_device(dev); | 100 | struct spi_device *spi = to_spi_device(dev); |
| 101 | struct adxl34x *ac = dev_get_drvdata(&spi->dev); | 101 | struct adxl34x *ac = spi_get_drvdata(spi); |
| 102 | 102 | ||
| 103 | adxl34x_suspend(ac); | 103 | adxl34x_suspend(ac); |
| 104 | 104 | ||
| @@ -108,7 +108,7 @@ static int adxl34x_spi_suspend(struct device *dev) | |||
| 108 | static int adxl34x_spi_resume(struct device *dev) | 108 | static int adxl34x_spi_resume(struct device *dev) |
| 109 | { | 109 | { |
| 110 | struct spi_device *spi = to_spi_device(dev); | 110 | struct spi_device *spi = to_spi_device(dev); |
| 111 | struct adxl34x *ac = dev_get_drvdata(&spi->dev); | 111 | struct adxl34x *ac = spi_get_drvdata(spi); |
| 112 | 112 | ||
| 113 | adxl34x_resume(ac); | 113 | adxl34x_resume(ac); |
| 114 | 114 | ||
diff --git a/drivers/input/misc/ims-pcu.c b/drivers/input/misc/ims-pcu.c new file mode 100644 index 000000000000..e204f26b0011 --- /dev/null +++ b/drivers/input/misc/ims-pcu.c | |||
| @@ -0,0 +1,1901 @@ | |||
| 1 | /* | ||
| 2 | * Driver for IMS Passenger Control Unit Devices | ||
| 3 | * | ||
| 4 | * Copyright (C) 2013 The IMS Company | ||
| 5 | * | ||
| 6 | * This program is free software; you can redistribute it and/or modify | ||
| 7 | * it under the terms of the GNU General Public License version 2 | ||
| 8 | * as published by the Free Software Foundation. | ||
| 9 | */ | ||
| 10 | |||
| 11 | #include <linux/completion.h> | ||
| 12 | #include <linux/device.h> | ||
| 13 | #include <linux/firmware.h> | ||
| 14 | #include <linux/ihex.h> | ||
| 15 | #include <linux/input.h> | ||
| 16 | #include <linux/kernel.h> | ||
| 17 | #include <linux/leds.h> | ||
| 18 | #include <linux/module.h> | ||
| 19 | #include <linux/slab.h> | ||
| 20 | #include <linux/types.h> | ||
| 21 | #include <linux/usb/input.h> | ||
| 22 | #include <linux/usb/cdc.h> | ||
| 23 | #include <asm/unaligned.h> | ||
| 24 | |||
| 25 | #define IMS_PCU_KEYMAP_LEN 32 | ||
| 26 | |||
| 27 | struct ims_pcu_buttons { | ||
| 28 | struct input_dev *input; | ||
| 29 | char name[32]; | ||
| 30 | char phys[32]; | ||
| 31 | unsigned short keymap[IMS_PCU_KEYMAP_LEN]; | ||
| 32 | }; | ||
| 33 | |||
| 34 | struct ims_pcu_gamepad { | ||
| 35 | struct input_dev *input; | ||
| 36 | char name[32]; | ||
| 37 | char phys[32]; | ||
| 38 | }; | ||
| 39 | |||
| 40 | struct ims_pcu_backlight { | ||
| 41 | struct led_classdev cdev; | ||
| 42 | struct work_struct work; | ||
| 43 | enum led_brightness desired_brightness; | ||
| 44 | char name[32]; | ||
| 45 | }; | ||
| 46 | |||
| 47 | #define IMS_PCU_PART_NUMBER_LEN 15 | ||
| 48 | #define IMS_PCU_SERIAL_NUMBER_LEN 8 | ||
| 49 | #define IMS_PCU_DOM_LEN 8 | ||
| 50 | #define IMS_PCU_FW_VERSION_LEN (9 + 1) | ||
| 51 | #define IMS_PCU_BL_VERSION_LEN (9 + 1) | ||
| 52 | #define IMS_PCU_BL_RESET_REASON_LEN (2 + 1) | ||
| 53 | |||
| 54 | #define IMS_PCU_BUF_SIZE 128 | ||
| 55 | |||
| 56 | struct ims_pcu { | ||
| 57 | struct usb_device *udev; | ||
| 58 | struct device *dev; /* control interface's device, used for logging */ | ||
| 59 | |||
| 60 | unsigned int device_no; | ||
| 61 | |||
| 62 | bool bootloader_mode; | ||
| 63 | |||
| 64 | char part_number[IMS_PCU_PART_NUMBER_LEN]; | ||
| 65 | char serial_number[IMS_PCU_SERIAL_NUMBER_LEN]; | ||
| 66 | char date_of_manufacturing[IMS_PCU_DOM_LEN]; | ||
| 67 | char fw_version[IMS_PCU_FW_VERSION_LEN]; | ||
| 68 | char bl_version[IMS_PCU_BL_VERSION_LEN]; | ||
| 69 | char reset_reason[IMS_PCU_BL_RESET_REASON_LEN]; | ||
| 70 | int update_firmware_status; | ||
| 71 | |||
| 72 | struct usb_interface *ctrl_intf; | ||
| 73 | |||
| 74 | struct usb_endpoint_descriptor *ep_ctrl; | ||
| 75 | struct urb *urb_ctrl; | ||
| 76 | u8 *urb_ctrl_buf; | ||
| 77 | dma_addr_t ctrl_dma; | ||
| 78 | size_t max_ctrl_size; | ||
| 79 | |||
| 80 | struct usb_interface *data_intf; | ||
| 81 | |||
| 82 | struct usb_endpoint_descriptor *ep_in; | ||
| 83 | struct urb *urb_in; | ||
| 84 | u8 *urb_in_buf; | ||
| 85 | dma_addr_t read_dma; | ||
| 86 | size_t max_in_size; | ||
| 87 | |||
| 88 | struct usb_endpoint_descriptor *ep_out; | ||
| 89 | u8 *urb_out_buf; | ||
| 90 | size_t max_out_size; | ||
| 91 | |||
| 92 | u8 read_buf[IMS_PCU_BUF_SIZE]; | ||
| 93 | u8 read_pos; | ||
| 94 | u8 check_sum; | ||
| 95 | bool have_stx; | ||
| 96 | bool have_dle; | ||
| 97 | |||
| 98 | u8 cmd_buf[IMS_PCU_BUF_SIZE]; | ||
| 99 | u8 ack_id; | ||
| 100 | u8 expected_response; | ||
| 101 | u8 cmd_buf_len; | ||
| 102 | struct completion cmd_done; | ||
| 103 | struct mutex cmd_mutex; | ||
| 104 | |||
| 105 | u32 fw_start_addr; | ||
| 106 | u32 fw_end_addr; | ||
| 107 | struct completion async_firmware_done; | ||
| 108 | |||
| 109 | struct ims_pcu_buttons buttons; | ||
| 110 | struct ims_pcu_gamepad *gamepad; | ||
| 111 | struct ims_pcu_backlight backlight; | ||
| 112 | |||
| 113 | bool setup_complete; /* Input and LED devices have been created */ | ||
| 114 | }; | ||
| 115 | |||
| 116 | |||
| 117 | /********************************************************************* | ||
| 118 | * Buttons Input device support * | ||
| 119 | *********************************************************************/ | ||
| 120 | |||
| 121 | static const unsigned short ims_pcu_keymap_1[] = { | ||
| 122 | [1] = KEY_ATTENDANT_OFF, | ||
| 123 | [2] = KEY_ATTENDANT_ON, | ||
| 124 | [3] = KEY_LIGHTS_TOGGLE, | ||
| 125 | [4] = KEY_VOLUMEUP, | ||
| 126 | [5] = KEY_VOLUMEDOWN, | ||
| 127 | [6] = KEY_INFO, | ||
| 128 | }; | ||
| 129 | |||
| 130 | static const unsigned short ims_pcu_keymap_2[] = { | ||
| 131 | [4] = KEY_VOLUMEUP, | ||
| 132 | [5] = KEY_VOLUMEDOWN, | ||
| 133 | [6] = KEY_INFO, | ||
| 134 | }; | ||
| 135 | |||
| 136 | static const unsigned short ims_pcu_keymap_3[] = { | ||
| 137 | [1] = KEY_HOMEPAGE, | ||
| 138 | [2] = KEY_ATTENDANT_TOGGLE, | ||
| 139 | [3] = KEY_LIGHTS_TOGGLE, | ||
| 140 | [4] = KEY_VOLUMEUP, | ||
| 141 | [5] = KEY_VOLUMEDOWN, | ||
| 142 | [6] = KEY_DISPLAYTOGGLE, | ||
| 143 | [18] = KEY_PLAYPAUSE, | ||
| 144 | }; | ||
| 145 | |||
| 146 | static const unsigned short ims_pcu_keymap_4[] = { | ||
| 147 | [1] = KEY_ATTENDANT_OFF, | ||
| 148 | [2] = KEY_ATTENDANT_ON, | ||
| 149 | [3] = KEY_LIGHTS_TOGGLE, | ||
| 150 | [4] = KEY_VOLUMEUP, | ||
| 151 | [5] = KEY_VOLUMEDOWN, | ||
| 152 | [6] = KEY_INFO, | ||
| 153 | [18] = KEY_PLAYPAUSE, | ||
| 154 | }; | ||
| 155 | |||
| 156 | static const unsigned short ims_pcu_keymap_5[] = { | ||
| 157 | [1] = KEY_ATTENDANT_OFF, | ||
| 158 | [2] = KEY_ATTENDANT_ON, | ||
| 159 | [3] = KEY_LIGHTS_TOGGLE, | ||
| 160 | }; | ||
| 161 | |||
| 162 | struct ims_pcu_device_info { | ||
| 163 | const unsigned short *keymap; | ||
| 164 | size_t keymap_len; | ||
| 165 | bool has_gamepad; | ||
| 166 | }; | ||
| 167 | |||
| 168 | #define IMS_PCU_DEVINFO(_n, _gamepad) \ | ||
| 169 | [_n] = { \ | ||
| 170 | .keymap = ims_pcu_keymap_##_n, \ | ||
| 171 | .keymap_len = ARRAY_SIZE(ims_pcu_keymap_##_n), \ | ||
| 172 | .has_gamepad = _gamepad, \ | ||
| 173 | } | ||
| 174 | |||
| 175 | static const struct ims_pcu_device_info ims_pcu_device_info[] = { | ||
| 176 | IMS_PCU_DEVINFO(1, true), | ||
| 177 | IMS_PCU_DEVINFO(2, true), | ||
| 178 | IMS_PCU_DEVINFO(3, true), | ||
| 179 | IMS_PCU_DEVINFO(4, true), | ||
| 180 | IMS_PCU_DEVINFO(5, false), | ||
| 181 | }; | ||
| 182 | |||
| 183 | static void ims_pcu_buttons_report(struct ims_pcu *pcu, u32 data) | ||
| 184 | { | ||
| 185 | struct ims_pcu_buttons *buttons = &pcu->buttons; | ||
| 186 | struct input_dev *input = buttons->input; | ||
| 187 | int i; | ||
| 188 | |||
| 189 | for (i = 0; i < 32; i++) { | ||
| 190 | unsigned short keycode = buttons->keymap[i]; | ||
| 191 | |||
| 192 | if (keycode != KEY_RESERVED) | ||
| 193 | input_report_key(input, keycode, data & (1UL << i)); | ||
| 194 | } | ||
| 195 | |||
| 196 | input_sync(input); | ||
| 197 | } | ||
| 198 | |||
| 199 | static int ims_pcu_setup_buttons(struct ims_pcu *pcu, | ||
| 200 | const unsigned short *keymap, | ||
| 201 | size_t keymap_len) | ||
| 202 | { | ||
| 203 | struct ims_pcu_buttons *buttons = &pcu->buttons; | ||
| 204 | struct input_dev *input; | ||
| 205 | int i; | ||
| 206 | int error; | ||
| 207 | |||
| 208 | input = input_allocate_device(); | ||
| 209 | if (!input) { | ||
| 210 | dev_err(pcu->dev, | ||
| 211 | "Not enough memory for input input device\n"); | ||
| 212 | return -ENOMEM; | ||
| 213 | } | ||
| 214 | |||
| 215 | snprintf(buttons->name, sizeof(buttons->name), | ||
| 216 | "IMS PCU#%d Button Interface", pcu->device_no); | ||
| 217 | |||
| 218 | usb_make_path(pcu->udev, buttons->phys, sizeof(buttons->phys)); | ||
| 219 | strlcat(buttons->phys, "/input0", sizeof(buttons->phys)); | ||
| 220 | |||
| 221 | memcpy(buttons->keymap, keymap, sizeof(*keymap) * keymap_len); | ||
| 222 | |||
| 223 | input->name = buttons->name; | ||
| 224 | input->phys = buttons->phys; | ||
| 225 | usb_to_input_id(pcu->udev, &input->id); | ||
| 226 | input->dev.parent = &pcu->ctrl_intf->dev; | ||
| 227 | |||
| 228 | input->keycode = buttons->keymap; | ||
| 229 | input->keycodemax = ARRAY_SIZE(buttons->keymap); | ||
| 230 | input->keycodesize = sizeof(buttons->keymap[0]); | ||
| 231 | |||
| 232 | __set_bit(EV_KEY, input->evbit); | ||
| 233 | for (i = 0; i < IMS_PCU_KEYMAP_LEN; i++) | ||
| 234 | __set_bit(buttons->keymap[i], input->keybit); | ||
| 235 | __clear_bit(KEY_RESERVED, input->keybit); | ||
| 236 | |||
| 237 | error = input_register_device(input); | ||
| 238 | if (error) { | ||
| 239 | dev_err(pcu->dev, | ||
| 240 | "Failed to register buttons input device: %d\n", | ||
| 241 | error); | ||
| 242 | input_free_device(input); | ||
| 243 | return error; | ||
| 244 | } | ||
| 245 | |||
| 246 | buttons->input = input; | ||
| 247 | return 0; | ||
| 248 | } | ||
| 249 | |||
| 250 | static void ims_pcu_destroy_buttons(struct ims_pcu *pcu) | ||
| 251 | { | ||
| 252 | struct ims_pcu_buttons *buttons = &pcu->buttons; | ||
| 253 | |||
| 254 | input_unregister_device(buttons->input); | ||
| 255 | } | ||
| 256 | |||
| 257 | |||
| 258 | /********************************************************************* | ||
| 259 | * Gamepad Input device support * | ||
| 260 | *********************************************************************/ | ||
| 261 | |||
| 262 | static void ims_pcu_gamepad_report(struct ims_pcu *pcu, u32 data) | ||
| 263 | { | ||
| 264 | struct ims_pcu_gamepad *gamepad = pcu->gamepad; | ||
| 265 | struct input_dev *input = gamepad->input; | ||
| 266 | int x, y; | ||
| 267 | |||
| 268 | x = !!(data & (1 << 14)) - !!(data & (1 << 13)); | ||
| 269 | y = !!(data & (1 << 12)) - !!(data & (1 << 11)); | ||
| 270 | |||
| 271 | input_report_abs(input, ABS_X, x); | ||
| 272 | input_report_abs(input, ABS_Y, y); | ||
| 273 | |||
| 274 | input_report_key(input, BTN_A, data & (1 << 7)); | ||
| 275 | input_report_key(input, BTN_B, data & (1 << 8)); | ||
| 276 | input_report_key(input, BTN_X, data & (1 << 9)); | ||
| 277 | input_report_key(input, BTN_Y, data & (1 << 10)); | ||
| 278 | input_report_key(input, BTN_START, data & (1 << 15)); | ||
| 279 | input_report_key(input, BTN_SELECT, data & (1 << 16)); | ||
| 280 | |||
| 281 | input_sync(input); | ||
| 282 | } | ||
| 283 | |||
| 284 | static int ims_pcu_setup_gamepad(struct ims_pcu *pcu) | ||
| 285 | { | ||
| 286 | struct ims_pcu_gamepad *gamepad; | ||
| 287 | struct input_dev *input; | ||
| 288 | int error; | ||
| 289 | |||
| 290 | gamepad = kzalloc(sizeof(struct ims_pcu_gamepad), GFP_KERNEL); | ||
| 291 | input = input_allocate_device(); | ||
| 292 | if (!gamepad || !input) { | ||
| 293 | dev_err(pcu->dev, | ||
| 294 | "Not enough memory for gamepad device\n"); | ||
| 295 | error = -ENOMEM; | ||
| 296 | goto err_free_mem; | ||
| 297 | } | ||
| 298 | |||
| 299 | gamepad->input = input; | ||
| 300 | |||
| 301 | snprintf(gamepad->name, sizeof(gamepad->name), | ||
| 302 | "IMS PCU#%d Gamepad Interface", pcu->device_no); | ||
| 303 | |||
| 304 | usb_make_path(pcu->udev, gamepad->phys, sizeof(gamepad->phys)); | ||
| 305 | strlcat(gamepad->phys, "/input1", sizeof(gamepad->phys)); | ||
| 306 | |||
| 307 | input->name = gamepad->name; | ||
| 308 | input->phys = gamepad->phys; | ||
| 309 | usb_to_input_id(pcu->udev, &input->id); | ||
| 310 | input->dev.parent = &pcu->ctrl_intf->dev; | ||
| 311 | |||
| 312 | __set_bit(EV_KEY, input->evbit); | ||
| 313 | __set_bit(BTN_A, input->keybit); | ||
| 314 | __set_bit(BTN_B, input->keybit); | ||
| 315 | __set_bit(BTN_X, input->keybit); | ||
| 316 | __set_bit(BTN_Y, input->keybit); | ||
| 317 | __set_bit(BTN_START, input->keybit); | ||
| 318 | __set_bit(BTN_SELECT, input->keybit); | ||
| 319 | |||
| 320 | __set_bit(EV_ABS, input->evbit); | ||
| 321 | input_set_abs_params(input, ABS_X, -1, 1, 0, 0); | ||
| 322 | input_set_abs_params(input, ABS_Y, -1, 1, 0, 0); | ||
| 323 | |||
| 324 | error = input_register_device(input); | ||
| 325 | if (error) { | ||
| 326 | dev_err(pcu->dev, | ||
| 327 | "Failed to register gamepad input device: %d\n", | ||
| 328 | error); | ||
| 329 | goto err_free_mem; | ||
| 330 | } | ||
| 331 | |||
| 332 | pcu->gamepad = gamepad; | ||
| 333 | return 0; | ||
| 334 | |||
| 335 | err_free_mem: | ||
| 336 | input_free_device(input); | ||
| 337 | kfree(gamepad); | ||
| 338 | return -ENOMEM; | ||
| 339 | } | ||
| 340 | |||
| 341 | static void ims_pcu_destroy_gamepad(struct ims_pcu *pcu) | ||
| 342 | { | ||
| 343 | struct ims_pcu_gamepad *gamepad = pcu->gamepad; | ||
| 344 | |||
| 345 | input_unregister_device(gamepad->input); | ||
| 346 | kfree(gamepad); | ||
| 347 | } | ||
| 348 | |||
| 349 | |||
| 350 | /********************************************************************* | ||
| 351 | * PCU Communication protocol handling * | ||
| 352 | *********************************************************************/ | ||
| 353 | |||
| 354 | #define IMS_PCU_PROTOCOL_STX 0x02 | ||
| 355 | #define IMS_PCU_PROTOCOL_ETX 0x03 | ||
| 356 | #define IMS_PCU_PROTOCOL_DLE 0x10 | ||
| 357 | |||
| 358 | /* PCU commands */ | ||
| 359 | #define IMS_PCU_CMD_STATUS 0xa0 | ||
| 360 | #define IMS_PCU_CMD_PCU_RESET 0xa1 | ||
| 361 | #define IMS_PCU_CMD_RESET_REASON 0xa2 | ||
| 362 | #define IMS_PCU_CMD_SEND_BUTTONS 0xa3 | ||
| 363 | #define IMS_PCU_CMD_JUMP_TO_BTLDR 0xa4 | ||
| 364 | #define IMS_PCU_CMD_GET_INFO 0xa5 | ||
| 365 | #define IMS_PCU_CMD_SET_BRIGHTNESS 0xa6 | ||
| 366 | #define IMS_PCU_CMD_EEPROM 0xa7 | ||
| 367 | #define IMS_PCU_CMD_GET_FW_VERSION 0xa8 | ||
| 368 | #define IMS_PCU_CMD_GET_BL_VERSION 0xa9 | ||
| 369 | #define IMS_PCU_CMD_SET_INFO 0xab | ||
| 370 | #define IMS_PCU_CMD_GET_BRIGHTNESS 0xac | ||
| 371 | #define IMS_PCU_CMD_GET_DEVICE_ID 0xae | ||
| 372 | #define IMS_PCU_CMD_SPECIAL_INFO 0xb0 | ||
| 373 | #define IMS_PCU_CMD_BOOTLOADER 0xb1 /* Pass data to bootloader */ | ||
| 374 | |||
| 375 | /* PCU responses */ | ||
| 376 | #define IMS_PCU_RSP_STATUS 0xc0 | ||
| 377 | #define IMS_PCU_RSP_PCU_RESET 0 /* Originally 0xc1 */ | ||
| 378 | #define IMS_PCU_RSP_RESET_REASON 0xc2 | ||
| 379 | #define IMS_PCU_RSP_SEND_BUTTONS 0xc3 | ||
| 380 | #define IMS_PCU_RSP_JUMP_TO_BTLDR 0 /* Originally 0xc4 */ | ||
| 381 | #define IMS_PCU_RSP_GET_INFO 0xc5 | ||
| 382 | #define IMS_PCU_RSP_SET_BRIGHTNESS 0xc6 | ||
| 383 | #define IMS_PCU_RSP_EEPROM 0xc7 | ||
| 384 | #define IMS_PCU_RSP_GET_FW_VERSION 0xc8 | ||
| 385 | #define IMS_PCU_RSP_GET_BL_VERSION 0xc9 | ||
| 386 | #define IMS_PCU_RSP_SET_INFO 0xcb | ||
| 387 | #define IMS_PCU_RSP_GET_BRIGHTNESS 0xcc | ||
| 388 | #define IMS_PCU_RSP_CMD_INVALID 0xcd | ||
| 389 | #define IMS_PCU_RSP_GET_DEVICE_ID 0xce | ||
| 390 | #define IMS_PCU_RSP_SPECIAL_INFO 0xd0 | ||
| 391 | #define IMS_PCU_RSP_BOOTLOADER 0xd1 /* Bootloader response */ | ||
| 392 | |||
| 393 | #define IMS_PCU_RSP_EVNT_BUTTONS 0xe0 /* Unsolicited, button state */ | ||
| 394 | #define IMS_PCU_GAMEPAD_MASK 0x0001ff80UL /* Bits 7 through 16 */ | ||
| 395 | |||
| 396 | |||
| 397 | #define IMS_PCU_MIN_PACKET_LEN 3 | ||
| 398 | #define IMS_PCU_DATA_OFFSET 2 | ||
| 399 | |||
| 400 | #define IMS_PCU_CMD_WRITE_TIMEOUT 100 /* msec */ | ||
| 401 | #define IMS_PCU_CMD_RESPONSE_TIMEOUT 500 /* msec */ | ||
| 402 | |||
| 403 | static void ims_pcu_report_events(struct ims_pcu *pcu) | ||
| 404 | { | ||
| 405 | u32 data = get_unaligned_be32(&pcu->read_buf[3]); | ||
| 406 | |||
| 407 | ims_pcu_buttons_report(pcu, data & ~IMS_PCU_GAMEPAD_MASK); | ||
| 408 | if (pcu->gamepad) | ||
| 409 | ims_pcu_gamepad_report(pcu, data); | ||
| 410 | } | ||
| 411 | |||
| 412 | static void ims_pcu_handle_response(struct ims_pcu *pcu) | ||
| 413 | { | ||
| 414 | switch (pcu->read_buf[0]) { | ||
| 415 | case IMS_PCU_RSP_EVNT_BUTTONS: | ||
| 416 | if (likely(pcu->setup_complete)) | ||
| 417 | ims_pcu_report_events(pcu); | ||
| 418 | break; | ||
| 419 | |||
| 420 | default: | ||
| 421 | /* | ||
| 422 | * See if we got command completion. | ||
| 423 | * If both the sequence and response code match save | ||
| 424 | * the data and signal completion. | ||
| 425 | */ | ||
| 426 | if (pcu->read_buf[0] == pcu->expected_response && | ||
| 427 | pcu->read_buf[1] == pcu->ack_id - 1) { | ||
| 428 | |||
| 429 | memcpy(pcu->cmd_buf, pcu->read_buf, pcu->read_pos); | ||
| 430 | pcu->cmd_buf_len = pcu->read_pos; | ||
| 431 | complete(&pcu->cmd_done); | ||
| 432 | } | ||
| 433 | break; | ||
| 434 | } | ||
| 435 | } | ||
| 436 | |||
| 437 | static void ims_pcu_process_data(struct ims_pcu *pcu, struct urb *urb) | ||
| 438 | { | ||
| 439 | int i; | ||
| 440 | |||
| 441 | for (i = 0; i < urb->actual_length; i++) { | ||
| 442 | u8 data = pcu->urb_in_buf[i]; | ||
| 443 | |||
| 444 | /* Skip everything until we get Start Xmit */ | ||
| 445 | if (!pcu->have_stx && data != IMS_PCU_PROTOCOL_STX) | ||
| 446 | continue; | ||
| 447 | |||
| 448 | if (pcu->have_dle) { | ||
| 449 | pcu->have_dle = false; | ||
| 450 | pcu->read_buf[pcu->read_pos++] = data; | ||
| 451 | pcu->check_sum += data; | ||
| 452 | continue; | ||
| 453 | } | ||
| 454 | |||
| 455 | switch (data) { | ||
| 456 | case IMS_PCU_PROTOCOL_STX: | ||
| 457 | if (pcu->have_stx) | ||
| 458 | dev_warn(pcu->dev, | ||
| 459 | "Unexpected STX at byte %d, discarding old data\n", | ||
| 460 | pcu->read_pos); | ||
| 461 | pcu->have_stx = true; | ||
| 462 | pcu->have_dle = false; | ||
| 463 | pcu->read_pos = 0; | ||
| 464 | pcu->check_sum = 0; | ||
| 465 | break; | ||
| 466 | |||
| 467 | case IMS_PCU_PROTOCOL_DLE: | ||
| 468 | pcu->have_dle = true; | ||
| 469 | break; | ||
| 470 | |||
| 471 | case IMS_PCU_PROTOCOL_ETX: | ||
| 472 | if (pcu->read_pos < IMS_PCU_MIN_PACKET_LEN) { | ||
| 473 | dev_warn(pcu->dev, | ||
| 474 | "Short packet received (%d bytes), ignoring\n", | ||
| 475 | pcu->read_pos); | ||
| 476 | } else if (pcu->check_sum != 0) { | ||
| 477 | dev_warn(pcu->dev, | ||
| 478 | "Invalid checksum in packet (%d bytes), ignoring\n", | ||
| 479 | pcu->read_pos); | ||
| 480 | } else { | ||
| 481 | ims_pcu_handle_response(pcu); | ||
| 482 | } | ||
| 483 | |||
| 484 | pcu->have_stx = false; | ||
| 485 | pcu->have_dle = false; | ||
| 486 | pcu->read_pos = 0; | ||
| 487 | break; | ||
| 488 | |||
| 489 | default: | ||
| 490 | pcu->read_buf[pcu->read_pos++] = data; | ||
| 491 | pcu->check_sum += data; | ||
| 492 | break; | ||
| 493 | } | ||
| 494 | } | ||
| 495 | } | ||
| 496 | |||
| 497 | static bool ims_pcu_byte_needs_escape(u8 byte) | ||
| 498 | { | ||
| 499 | return byte == IMS_PCU_PROTOCOL_STX || | ||
| 500 | byte == IMS_PCU_PROTOCOL_ETX || | ||
| 501 | byte == IMS_PCU_PROTOCOL_DLE; | ||
| 502 | } | ||
| 503 | |||
| 504 | static int ims_pcu_send_cmd_chunk(struct ims_pcu *pcu, | ||
| 505 | u8 command, int chunk, int len) | ||
| 506 | { | ||
| 507 | int error; | ||
| 508 | |||
| 509 | error = usb_bulk_msg(pcu->udev, | ||
| 510 | usb_sndbulkpipe(pcu->udev, | ||
| 511 | pcu->ep_out->bEndpointAddress), | ||
| 512 | pcu->urb_out_buf, len, | ||
| 513 | NULL, IMS_PCU_CMD_WRITE_TIMEOUT); | ||
| 514 | if (error < 0) { | ||
| 515 | dev_dbg(pcu->dev, | ||
| 516 | "Sending 0x%02x command failed at chunk %d: %d\n", | ||
| 517 | command, chunk, error); | ||
| 518 | return error; | ||
| 519 | } | ||
| 520 | |||
| 521 | return 0; | ||
| 522 | } | ||
| 523 | |||
| 524 | static int ims_pcu_send_command(struct ims_pcu *pcu, | ||
| 525 | u8 command, const u8 *data, int len) | ||
| 526 | { | ||
| 527 | int count = 0; | ||
| 528 | int chunk = 0; | ||
| 529 | int delta; | ||
| 530 | int i; | ||
| 531 | int error; | ||
| 532 | u8 csum = 0; | ||
| 533 | u8 ack_id; | ||
| 534 | |||
| 535 | pcu->urb_out_buf[count++] = IMS_PCU_PROTOCOL_STX; | ||
| 536 | |||
| 537 | /* We know the command need not be escaped */ | ||
| 538 | pcu->urb_out_buf[count++] = command; | ||
| 539 | csum += command; | ||
| 540 | |||
| 541 | ack_id = pcu->ack_id++; | ||
| 542 | if (ack_id == 0xff) | ||
| 543 | ack_id = pcu->ack_id++; | ||
| 544 | |||
| 545 | if (ims_pcu_byte_needs_escape(ack_id)) | ||
| 546 | pcu->urb_out_buf[count++] = IMS_PCU_PROTOCOL_DLE; | ||
| 547 | |||
| 548 | pcu->urb_out_buf[count++] = ack_id; | ||
| 549 | csum += ack_id; | ||
| 550 | |||
| 551 | for (i = 0; i < len; i++) { | ||
| 552 | |||
| 553 | delta = ims_pcu_byte_needs_escape(data[i]) ? 2 : 1; | ||
| 554 | if (count + delta >= pcu->max_out_size) { | ||
| 555 | error = ims_pcu_send_cmd_chunk(pcu, command, | ||
| 556 | ++chunk, count); | ||
| 557 | if (error) | ||
| 558 | return error; | ||
| 559 | |||
| 560 | count = 0; | ||
| 561 | } | ||
| 562 | |||
| 563 | if (delta == 2) | ||
| 564 | pcu->urb_out_buf[count++] = IMS_PCU_PROTOCOL_DLE; | ||
| 565 | |||
| 566 | pcu->urb_out_buf[count++] = data[i]; | ||
| 567 | csum += data[i]; | ||
| 568 | } | ||
| 569 | |||
| 570 | csum = 1 + ~csum; | ||
| 571 | |||
| 572 | delta = ims_pcu_byte_needs_escape(csum) ? 3 : 2; | ||
| 573 | if (count + delta >= pcu->max_out_size) { | ||
| 574 | error = ims_pcu_send_cmd_chunk(pcu, command, ++chunk, count); | ||
| 575 | if (error) | ||
| 576 | return error; | ||
| 577 | |||
| 578 | count = 0; | ||
| 579 | } | ||
| 580 | |||
| 581 | if (delta == 3) | ||
| 582 | pcu->urb_out_buf[count++] = IMS_PCU_PROTOCOL_DLE; | ||
| 583 | |||
| 584 | pcu->urb_out_buf[count++] = csum; | ||
| 585 | pcu->urb_out_buf[count++] = IMS_PCU_PROTOCOL_ETX; | ||
| 586 | |||
| 587 | return ims_pcu_send_cmd_chunk(pcu, command, ++chunk, count); | ||
| 588 | } | ||
| 589 | |||
| 590 | static int __ims_pcu_execute_command(struct ims_pcu *pcu, | ||
| 591 | u8 command, const void *data, size_t len, | ||
| 592 | u8 expected_response, int response_time) | ||
| 593 | { | ||
| 594 | int error; | ||
| 595 | |||
| 596 | pcu->expected_response = expected_response; | ||
| 597 | init_completion(&pcu->cmd_done); | ||
| 598 | |||
| 599 | error = ims_pcu_send_command(pcu, command, data, len); | ||
| 600 | if (error) | ||
| 601 | return error; | ||
| 602 | |||
| 603 | if (expected_response && | ||
| 604 | !wait_for_completion_timeout(&pcu->cmd_done, | ||
| 605 | msecs_to_jiffies(response_time))) { | ||
| 606 | dev_dbg(pcu->dev, "Command 0x%02x timed out\n", command); | ||
| 607 | return -ETIMEDOUT; | ||
| 608 | } | ||
| 609 | |||
| 610 | return 0; | ||
| 611 | } | ||
| 612 | |||
| 613 | #define ims_pcu_execute_command(pcu, code, data, len) \ | ||
| 614 | __ims_pcu_execute_command(pcu, \ | ||
| 615 | IMS_PCU_CMD_##code, data, len, \ | ||
| 616 | IMS_PCU_RSP_##code, \ | ||
| 617 | IMS_PCU_CMD_RESPONSE_TIMEOUT) | ||
| 618 | |||
| 619 | #define ims_pcu_execute_query(pcu, code) \ | ||
| 620 | ims_pcu_execute_command(pcu, code, NULL, 0) | ||
| 621 | |||
| 622 | /* Bootloader commands */ | ||
| 623 | #define IMS_PCU_BL_CMD_QUERY_DEVICE 0xa1 | ||
| 624 | #define IMS_PCU_BL_CMD_UNLOCK_CONFIG 0xa2 | ||
| 625 | #define IMS_PCU_BL_CMD_ERASE_APP 0xa3 | ||
| 626 | #define IMS_PCU_BL_CMD_PROGRAM_DEVICE 0xa4 | ||
| 627 | #define IMS_PCU_BL_CMD_PROGRAM_COMPLETE 0xa5 | ||
| 628 | #define IMS_PCU_BL_CMD_READ_APP 0xa6 | ||
| 629 | #define IMS_PCU_BL_CMD_RESET_DEVICE 0xa7 | ||
| 630 | #define IMS_PCU_BL_CMD_LAUNCH_APP 0xa8 | ||
| 631 | |||
| 632 | /* Bootloader commands */ | ||
| 633 | #define IMS_PCU_BL_RSP_QUERY_DEVICE 0xc1 | ||
| 634 | #define IMS_PCU_BL_RSP_UNLOCK_CONFIG 0xc2 | ||
| 635 | #define IMS_PCU_BL_RSP_ERASE_APP 0xc3 | ||
| 636 | #define IMS_PCU_BL_RSP_PROGRAM_DEVICE 0xc4 | ||
| 637 | #define IMS_PCU_BL_RSP_PROGRAM_COMPLETE 0xc5 | ||
| 638 | #define IMS_PCU_BL_RSP_READ_APP 0xc6 | ||
| 639 | #define IMS_PCU_BL_RSP_RESET_DEVICE 0 /* originally 0xa7 */ | ||
| 640 | #define IMS_PCU_BL_RSP_LAUNCH_APP 0 /* originally 0xa8 */ | ||
| 641 | |||
| 642 | #define IMS_PCU_BL_DATA_OFFSET 3 | ||
| 643 | |||
| 644 | static int __ims_pcu_execute_bl_command(struct ims_pcu *pcu, | ||
| 645 | u8 command, const void *data, size_t len, | ||
| 646 | u8 expected_response, int response_time) | ||
| 647 | { | ||
| 648 | int error; | ||
| 649 | |||
| 650 | pcu->cmd_buf[0] = command; | ||
| 651 | if (data) | ||
| 652 | memcpy(&pcu->cmd_buf[1], data, len); | ||
| 653 | |||
| 654 | error = __ims_pcu_execute_command(pcu, | ||
| 655 | IMS_PCU_CMD_BOOTLOADER, pcu->cmd_buf, len + 1, | ||
| 656 | expected_response ? IMS_PCU_RSP_BOOTLOADER : 0, | ||
| 657 | response_time); | ||
| 658 | if (error) { | ||
| 659 | dev_err(pcu->dev, | ||
| 660 | "Failure when sending 0x%02x command to bootloader, error: %d\n", | ||
| 661 | pcu->cmd_buf[0], error); | ||
| 662 | return error; | ||
| 663 | } | ||
| 664 | |||
| 665 | if (expected_response && pcu->cmd_buf[2] != expected_response) { | ||
| 666 | dev_err(pcu->dev, | ||
| 667 | "Unexpected response from bootloader: 0x%02x, wanted 0x%02x\n", | ||
| 668 | pcu->cmd_buf[2], expected_response); | ||
| 669 | return -EINVAL; | ||
| 670 | } | ||
| 671 | |||
| 672 | return 0; | ||
| 673 | } | ||
| 674 | |||
| 675 | #define ims_pcu_execute_bl_command(pcu, code, data, len, timeout) \ | ||
| 676 | __ims_pcu_execute_bl_command(pcu, \ | ||
| 677 | IMS_PCU_BL_CMD_##code, data, len, \ | ||
| 678 | IMS_PCU_BL_RSP_##code, timeout) \ | ||
| 679 | |||
| 680 | #define IMS_PCU_INFO_PART_OFFSET 2 | ||
| 681 | #define IMS_PCU_INFO_DOM_OFFSET 17 | ||
| 682 | #define IMS_PCU_INFO_SERIAL_OFFSET 25 | ||
| 683 | |||
| 684 | #define IMS_PCU_SET_INFO_SIZE 31 | ||
| 685 | |||
| 686 | static int ims_pcu_get_info(struct ims_pcu *pcu) | ||
| 687 | { | ||
| 688 | int error; | ||
| 689 | |||
| 690 | error = ims_pcu_execute_query(pcu, GET_INFO); | ||
| 691 | if (error) { | ||
| 692 | dev_err(pcu->dev, | ||
| 693 | "GET_INFO command failed, error: %d\n", error); | ||
| 694 | return error; | ||
| 695 | } | ||
| 696 | |||
| 697 | memcpy(pcu->part_number, | ||
| 698 | &pcu->cmd_buf[IMS_PCU_INFO_PART_OFFSET], | ||
| 699 | sizeof(pcu->part_number)); | ||
| 700 | memcpy(pcu->date_of_manufacturing, | ||
| 701 | &pcu->cmd_buf[IMS_PCU_INFO_DOM_OFFSET], | ||
| 702 | sizeof(pcu->date_of_manufacturing)); | ||
| 703 | memcpy(pcu->serial_number, | ||
| 704 | &pcu->cmd_buf[IMS_PCU_INFO_SERIAL_OFFSET], | ||
| 705 | sizeof(pcu->serial_number)); | ||
| 706 | |||
| 707 | return 0; | ||
| 708 | } | ||
| 709 | |||
| 710 | static int ims_pcu_set_info(struct ims_pcu *pcu) | ||
| 711 | { | ||
| 712 | int error; | ||
| 713 | |||
| 714 | memcpy(&pcu->cmd_buf[IMS_PCU_INFO_PART_OFFSET], | ||
| 715 | pcu->part_number, sizeof(pcu->part_number)); | ||
| 716 | memcpy(&pcu->cmd_buf[IMS_PCU_INFO_DOM_OFFSET], | ||
| 717 | pcu->date_of_manufacturing, sizeof(pcu->date_of_manufacturing)); | ||
| 718 | memcpy(&pcu->cmd_buf[IMS_PCU_INFO_SERIAL_OFFSET], | ||
| 719 | pcu->serial_number, sizeof(pcu->serial_number)); | ||
| 720 | |||
| 721 | error = ims_pcu_execute_command(pcu, SET_INFO, | ||
| 722 | &pcu->cmd_buf[IMS_PCU_DATA_OFFSET], | ||
| 723 | IMS_PCU_SET_INFO_SIZE); | ||
| 724 | if (error) { | ||
| 725 | dev_err(pcu->dev, | ||
| 726 | "Failed to update device information, error: %d\n", | ||
| 727 | error); | ||
| 728 | return error; | ||
| 729 | } | ||
| 730 | |||
| 731 | return 0; | ||
| 732 | } | ||
| 733 | |||
| 734 | static int ims_pcu_switch_to_bootloader(struct ims_pcu *pcu) | ||
| 735 | { | ||
| 736 | int error; | ||
| 737 | |||
| 738 | /* Execute jump to the bootoloader */ | ||
| 739 | error = ims_pcu_execute_command(pcu, JUMP_TO_BTLDR, NULL, 0); | ||
| 740 | if (error) { | ||
| 741 | dev_err(pcu->dev, | ||
| 742 | "Failure when sending JUMP TO BOOLTLOADER command, error: %d\n", | ||
| 743 | error); | ||
| 744 | return error; | ||
| 745 | } | ||
| 746 | |||
| 747 | return 0; | ||
| 748 | } | ||
| 749 | |||
| 750 | /********************************************************************* | ||
| 751 | * Firmware Update handling * | ||
| 752 | *********************************************************************/ | ||
| 753 | |||
| 754 | #define IMS_PCU_FIRMWARE_NAME "imspcu.fw" | ||
| 755 | |||
| 756 | struct ims_pcu_flash_fmt { | ||
| 757 | __le32 addr; | ||
| 758 | u8 len; | ||
| 759 | u8 data[]; | ||
| 760 | }; | ||
| 761 | |||
| 762 | static unsigned int ims_pcu_count_fw_records(const struct firmware *fw) | ||
| 763 | { | ||
| 764 | const struct ihex_binrec *rec = (const struct ihex_binrec *)fw->data; | ||
| 765 | unsigned int count = 0; | ||
| 766 | |||
| 767 | while (rec) { | ||
| 768 | count++; | ||
| 769 | rec = ihex_next_binrec(rec); | ||
| 770 | } | ||
| 771 | |||
| 772 | return count; | ||
| 773 | } | ||
| 774 | |||
| 775 | static int ims_pcu_verify_block(struct ims_pcu *pcu, | ||
| 776 | u32 addr, u8 len, const u8 *data) | ||
| 777 | { | ||
| 778 | struct ims_pcu_flash_fmt *fragment; | ||
| 779 | int error; | ||
| 780 | |||
| 781 | fragment = (void *)&pcu->cmd_buf[1]; | ||
| 782 | put_unaligned_le32(addr, &fragment->addr); | ||
| 783 | fragment->len = len; | ||
| 784 | |||
| 785 | error = ims_pcu_execute_bl_command(pcu, READ_APP, NULL, 5, | ||
| 786 | IMS_PCU_CMD_RESPONSE_TIMEOUT); | ||
| 787 | if (error) { | ||
| 788 | dev_err(pcu->dev, | ||
| 789 | "Failed to retrieve block at 0x%08x, len %d, error: %d\n", | ||
| 790 | addr, len, error); | ||
| 791 | return error; | ||
| 792 | } | ||
| 793 | |||
| 794 | fragment = (void *)&pcu->cmd_buf[IMS_PCU_BL_DATA_OFFSET]; | ||
| 795 | if (get_unaligned_le32(&fragment->addr) != addr || | ||
| 796 | fragment->len != len) { | ||
| 797 | dev_err(pcu->dev, | ||
| 798 | "Wrong block when retrieving 0x%08x (0x%08x), len %d (%d)\n", | ||
| 799 | addr, get_unaligned_le32(&fragment->addr), | ||
| 800 | len, fragment->len); | ||
| 801 | return -EINVAL; | ||
| 802 | } | ||
| 803 | |||
| 804 | if (memcmp(fragment->data, data, len)) { | ||
| 805 | dev_err(pcu->dev, | ||
| 806 | "Mismatch in block at 0x%08x, len %d\n", | ||
| 807 | addr, len); | ||
| 808 | return -EINVAL; | ||
| 809 | } | ||
| 810 | |||
| 811 | return 0; | ||
| 812 | } | ||
| 813 | |||
| 814 | static int ims_pcu_flash_firmware(struct ims_pcu *pcu, | ||
| 815 | const struct firmware *fw, | ||
| 816 | unsigned int n_fw_records) | ||
| 817 | { | ||
| 818 | const struct ihex_binrec *rec = (const struct ihex_binrec *)fw->data; | ||
| 819 | struct ims_pcu_flash_fmt *fragment; | ||
| 820 | unsigned int count = 0; | ||
| 821 | u32 addr; | ||
| 822 | u8 len; | ||
| 823 | int error; | ||
| 824 | |||
| 825 | error = ims_pcu_execute_bl_command(pcu, ERASE_APP, NULL, 0, 2000); | ||
| 826 | if (error) { | ||
| 827 | dev_err(pcu->dev, | ||
| 828 | "Failed to erase application image, error: %d\n", | ||
| 829 | error); | ||
| 830 | return error; | ||
| 831 | } | ||
| 832 | |||
| 833 | while (rec) { | ||
| 834 | /* | ||
| 835 | * The firmware format is messed up for some reason. | ||
| 836 | * The address twice that of what is needed for some | ||
| 837 | * reason and we end up overwriting half of the data | ||
| 838 | * with the next record. | ||
| 839 | */ | ||
| 840 | addr = be32_to_cpu(rec->addr) / 2; | ||
| 841 | len = be16_to_cpu(rec->len); | ||
| 842 | |||
| 843 | fragment = (void *)&pcu->cmd_buf[1]; | ||
| 844 | put_unaligned_le32(addr, &fragment->addr); | ||
| 845 | fragment->len = len; | ||
| 846 | memcpy(fragment->data, rec->data, len); | ||
| 847 | |||
| 848 | error = ims_pcu_execute_bl_command(pcu, PROGRAM_DEVICE, | ||
| 849 | NULL, len + 5, | ||
| 850 | IMS_PCU_CMD_RESPONSE_TIMEOUT); | ||
| 851 | if (error) { | ||
| 852 | dev_err(pcu->dev, | ||
| 853 | "Failed to write block at 0x%08x, len %d, error: %d\n", | ||
| 854 | addr, len, error); | ||
| 855 | return error; | ||
| 856 | } | ||
| 857 | |||
| 858 | if (addr >= pcu->fw_start_addr && addr < pcu->fw_end_addr) { | ||
| 859 | error = ims_pcu_verify_block(pcu, addr, len, rec->data); | ||
| 860 | if (error) | ||
| 861 | return error; | ||
| 862 | } | ||
| 863 | |||
| 864 | count++; | ||
| 865 | pcu->update_firmware_status = (count * 100) / n_fw_records; | ||
| 866 | |||
| 867 | rec = ihex_next_binrec(rec); | ||
| 868 | } | ||
| 869 | |||
| 870 | error = ims_pcu_execute_bl_command(pcu, PROGRAM_COMPLETE, | ||
| 871 | NULL, 0, 2000); | ||
| 872 | if (error) | ||
| 873 | dev_err(pcu->dev, | ||
| 874 | "Failed to send PROGRAM_COMPLETE, error: %d\n", | ||
| 875 | error); | ||
| 876 | |||
| 877 | return 0; | ||
| 878 | } | ||
| 879 | |||
| 880 | static int ims_pcu_handle_firmware_update(struct ims_pcu *pcu, | ||
| 881 | const struct firmware *fw) | ||
| 882 | { | ||
| 883 | unsigned int n_fw_records; | ||
| 884 | int retval; | ||
| 885 | |||
| 886 | dev_info(pcu->dev, "Updating firmware %s, size: %zu\n", | ||
| 887 | IMS_PCU_FIRMWARE_NAME, fw->size); | ||
| 888 | |||
| 889 | n_fw_records = ims_pcu_count_fw_records(fw); | ||
| 890 | |||
| 891 | retval = ims_pcu_flash_firmware(pcu, fw, n_fw_records); | ||
| 892 | if (retval) | ||
| 893 | goto out; | ||
| 894 | |||
| 895 | retval = ims_pcu_execute_bl_command(pcu, LAUNCH_APP, NULL, 0, 0); | ||
| 896 | if (retval) | ||
| 897 | dev_err(pcu->dev, | ||
| 898 | "Failed to start application image, error: %d\n", | ||
| 899 | retval); | ||
| 900 | |||
| 901 | out: | ||
| 902 | pcu->update_firmware_status = retval; | ||
| 903 | sysfs_notify(&pcu->dev->kobj, NULL, "update_firmware_status"); | ||
| 904 | return retval; | ||
| 905 | } | ||
| 906 | |||
| 907 | static void ims_pcu_process_async_firmware(const struct firmware *fw, | ||
| 908 | void *context) | ||
| 909 | { | ||
| 910 | struct ims_pcu *pcu = context; | ||
| 911 | int error; | ||
| 912 | |||
| 913 | if (!fw) { | ||
| 914 | dev_err(pcu->dev, "Failed to get firmware %s\n", | ||
| 915 | IMS_PCU_FIRMWARE_NAME); | ||
| 916 | goto out; | ||
| 917 | } | ||
| 918 | |||
| 919 | error = ihex_validate_fw(fw); | ||
| 920 | if (error) { | ||
| 921 | dev_err(pcu->dev, "Firmware %s is invalid\n", | ||
| 922 | IMS_PCU_FIRMWARE_NAME); | ||
| 923 | goto out; | ||
| 924 | } | ||
| 925 | |||
| 926 | mutex_lock(&pcu->cmd_mutex); | ||
| 927 | ims_pcu_handle_firmware_update(pcu, fw); | ||
| 928 | mutex_unlock(&pcu->cmd_mutex); | ||
| 929 | |||
| 930 | release_firmware(fw); | ||
| 931 | |||
| 932 | out: | ||
| 933 | complete(&pcu->async_firmware_done); | ||
| 934 | } | ||
| 935 | |||
| 936 | /********************************************************************* | ||
| 937 | * Backlight LED device support * | ||
| 938 | *********************************************************************/ | ||
| 939 | |||
| 940 | #define IMS_PCU_MAX_BRIGHTNESS 31998 | ||
| 941 | |||
| 942 | static void ims_pcu_backlight_work(struct work_struct *work) | ||
| 943 | { | ||
| 944 | struct ims_pcu_backlight *backlight = | ||
| 945 | container_of(work, struct ims_pcu_backlight, work); | ||
| 946 | struct ims_pcu *pcu = | ||
| 947 | container_of(backlight, struct ims_pcu, backlight); | ||
| 948 | int desired_brightness = backlight->desired_brightness; | ||
| 949 | __le16 br_val = cpu_to_le16(desired_brightness); | ||
| 950 | int error; | ||
| 951 | |||
| 952 | mutex_lock(&pcu->cmd_mutex); | ||
| 953 | |||
| 954 | error = ims_pcu_execute_command(pcu, SET_BRIGHTNESS, | ||
| 955 | &br_val, sizeof(br_val)); | ||
| 956 | if (error && error != -ENODEV) | ||
| 957 | dev_warn(pcu->dev, | ||
| 958 | "Failed to set desired brightness %u, error: %d\n", | ||
| 959 | desired_brightness, error); | ||
| 960 | |||
| 961 | mutex_unlock(&pcu->cmd_mutex); | ||
| 962 | } | ||
| 963 | |||
| 964 | static void ims_pcu_backlight_set_brightness(struct led_classdev *cdev, | ||
| 965 | enum led_brightness value) | ||
| 966 | { | ||
| 967 | struct ims_pcu_backlight *backlight = | ||
| 968 | container_of(cdev, struct ims_pcu_backlight, cdev); | ||
| 969 | |||
| 970 | backlight->desired_brightness = value; | ||
| 971 | schedule_work(&backlight->work); | ||
| 972 | } | ||
| 973 | |||
| 974 | static enum led_brightness | ||
| 975 | ims_pcu_backlight_get_brightness(struct led_classdev *cdev) | ||
| 976 | { | ||
| 977 | struct ims_pcu_backlight *backlight = | ||
| 978 | container_of(cdev, struct ims_pcu_backlight, cdev); | ||
| 979 | struct ims_pcu *pcu = | ||
| 980 | container_of(backlight, struct ims_pcu, backlight); | ||
| 981 | int brightness; | ||
| 982 | int error; | ||
| 983 | |||
| 984 | mutex_lock(&pcu->cmd_mutex); | ||
| 985 | |||
| 986 | error = ims_pcu_execute_query(pcu, GET_BRIGHTNESS); | ||
| 987 | if (error) { | ||
| 988 | dev_warn(pcu->dev, | ||
| 989 | "Failed to get current brightness, error: %d\n", | ||
| 990 | error); | ||
| 991 | /* Assume the LED is OFF */ | ||
| 992 | brightness = LED_OFF; | ||
| 993 | } else { | ||
| 994 | brightness = | ||
| 995 | get_unaligned_le16(&pcu->cmd_buf[IMS_PCU_DATA_OFFSET]); | ||
| 996 | } | ||
| 997 | |||
| 998 | mutex_unlock(&pcu->cmd_mutex); | ||
| 999 | |||
| 1000 | return brightness; | ||
| 1001 | } | ||
| 1002 | |||
| 1003 | static int ims_pcu_setup_backlight(struct ims_pcu *pcu) | ||
| 1004 | { | ||
| 1005 | struct ims_pcu_backlight *backlight = &pcu->backlight; | ||
| 1006 | int error; | ||
| 1007 | |||
| 1008 | INIT_WORK(&backlight->work, ims_pcu_backlight_work); | ||
| 1009 | snprintf(backlight->name, sizeof(backlight->name), | ||
| 1010 | "pcu%d::kbd_backlight", pcu->device_no); | ||
| 1011 | |||
| 1012 | backlight->cdev.name = backlight->name; | ||
| 1013 | backlight->cdev.max_brightness = IMS_PCU_MAX_BRIGHTNESS; | ||
| 1014 | backlight->cdev.brightness_get = ims_pcu_backlight_get_brightness; | ||
| 1015 | backlight->cdev.brightness_set = ims_pcu_backlight_set_brightness; | ||
| 1016 | |||
| 1017 | error = led_classdev_register(pcu->dev, &backlight->cdev); | ||
| 1018 | if (error) { | ||
| 1019 | dev_err(pcu->dev, | ||
| 1020 | "Failed to register backlight LED device, error: %d\n", | ||
| 1021 | error); | ||
| 1022 | return error; | ||
| 1023 | } | ||
| 1024 | |||
| 1025 | return 0; | ||
| 1026 | } | ||
| 1027 | |||
| 1028 | static void ims_pcu_destroy_backlight(struct ims_pcu *pcu) | ||
| 1029 | { | ||
| 1030 | struct ims_pcu_backlight *backlight = &pcu->backlight; | ||
| 1031 | |||
| 1032 | led_classdev_unregister(&backlight->cdev); | ||
| 1033 | cancel_work_sync(&backlight->work); | ||
| 1034 | } | ||
| 1035 | |||
| 1036 | |||
| 1037 | /********************************************************************* | ||
| 1038 | * Sysfs attributes handling * | ||
| 1039 | *********************************************************************/ | ||
| 1040 | |||
| 1041 | struct ims_pcu_attribute { | ||
| 1042 | struct device_attribute dattr; | ||
| 1043 | size_t field_offset; | ||
| 1044 | int field_length; | ||
| 1045 | }; | ||
| 1046 | |||
| 1047 | static ssize_t ims_pcu_attribute_show(struct device *dev, | ||
| 1048 | struct device_attribute *dattr, | ||
| 1049 | char *buf) | ||
| 1050 | { | ||
| 1051 | struct usb_interface *intf = to_usb_interface(dev); | ||
| 1052 | struct ims_pcu *pcu = usb_get_intfdata(intf); | ||
| 1053 | struct ims_pcu_attribute *attr = | ||
| 1054 | container_of(dattr, struct ims_pcu_attribute, dattr); | ||
| 1055 | char *field = (char *)pcu + attr->field_offset; | ||
| 1056 | |||
| 1057 | return scnprintf(buf, PAGE_SIZE, "%.*s\n", attr->field_length, field); | ||
| 1058 | } | ||
| 1059 | |||
| 1060 | static ssize_t ims_pcu_attribute_store(struct device *dev, | ||
| 1061 | struct device_attribute *dattr, | ||
| 1062 | const char *buf, size_t count) | ||
| 1063 | { | ||
| 1064 | |||
| 1065 | struct usb_interface *intf = to_usb_interface(dev); | ||
| 1066 | struct ims_pcu *pcu = usb_get_intfdata(intf); | ||
| 1067 | struct ims_pcu_attribute *attr = | ||
| 1068 | container_of(dattr, struct ims_pcu_attribute, dattr); | ||
| 1069 | char *field = (char *)pcu + attr->field_offset; | ||
| 1070 | size_t data_len; | ||
| 1071 | int error; | ||
| 1072 | |||
| 1073 | if (count > attr->field_length) | ||
| 1074 | return -EINVAL; | ||
| 1075 | |||
| 1076 | data_len = strnlen(buf, attr->field_length); | ||
| 1077 | if (data_len > attr->field_length) | ||
| 1078 | return -EINVAL; | ||
| 1079 | |||
| 1080 | error = mutex_lock_interruptible(&pcu->cmd_mutex); | ||
| 1081 | if (error) | ||
| 1082 | return error; | ||
| 1083 | |||
| 1084 | memset(field, 0, attr->field_length); | ||
| 1085 | memcpy(field, buf, data_len); | ||
| 1086 | |||
| 1087 | error = ims_pcu_set_info(pcu); | ||
| 1088 | |||
| 1089 | /* | ||
| 1090 | * Even if update failed, let's fetch the info again as we just | ||
| 1091 | * clobbered one of the fields. | ||
| 1092 | */ | ||
| 1093 | ims_pcu_get_info(pcu); | ||
| 1094 | |||
| 1095 | mutex_unlock(&pcu->cmd_mutex); | ||
| 1096 | |||
| 1097 | return error < 0 ? error : count; | ||
| 1098 | } | ||
| 1099 | |||
| 1100 | #define IMS_PCU_ATTR(_field, _mode) \ | ||
| 1101 | struct ims_pcu_attribute ims_pcu_attr_##_field = { \ | ||
| 1102 | .dattr = __ATTR(_field, _mode, \ | ||
| 1103 | ims_pcu_attribute_show, \ | ||
| 1104 | ims_pcu_attribute_store), \ | ||
| 1105 | .field_offset = offsetof(struct ims_pcu, _field), \ | ||
| 1106 | .field_length = sizeof(((struct ims_pcu *)NULL)->_field), \ | ||
| 1107 | } | ||
| 1108 | |||
| 1109 | #define IMS_PCU_RO_ATTR(_field) \ | ||
| 1110 | IMS_PCU_ATTR(_field, S_IRUGO) | ||
| 1111 | #define IMS_PCU_RW_ATTR(_field) \ | ||
| 1112 | IMS_PCU_ATTR(_field, S_IRUGO | S_IWUSR) | ||
| 1113 | |||
| 1114 | static IMS_PCU_RW_ATTR(part_number); | ||
| 1115 | static IMS_PCU_RW_ATTR(serial_number); | ||
| 1116 | static IMS_PCU_RW_ATTR(date_of_manufacturing); | ||
| 1117 | |||
| 1118 | static IMS_PCU_RO_ATTR(fw_version); | ||
| 1119 | static IMS_PCU_RO_ATTR(bl_version); | ||
| 1120 | static IMS_PCU_RO_ATTR(reset_reason); | ||
| 1121 | |||
| 1122 | static ssize_t ims_pcu_reset_device(struct device *dev, | ||
| 1123 | struct device_attribute *dattr, | ||
| 1124 | const char *buf, size_t count) | ||
| 1125 | { | ||
| 1126 | static const u8 reset_byte = 1; | ||
| 1127 | struct usb_interface *intf = to_usb_interface(dev); | ||
| 1128 | struct ims_pcu *pcu = usb_get_intfdata(intf); | ||
| 1129 | int value; | ||
| 1130 | int error; | ||
| 1131 | |||
| 1132 | error = kstrtoint(buf, 0, &value); | ||
| 1133 | if (error) | ||
| 1134 | return error; | ||
| 1135 | |||
| 1136 | if (value != 1) | ||
| 1137 | return -EINVAL; | ||
| 1138 | |||
| 1139 | dev_info(pcu->dev, "Attempting to reset device\n"); | ||
| 1140 | |||
| 1141 | error = ims_pcu_execute_command(pcu, PCU_RESET, &reset_byte, 1); | ||
| 1142 | if (error) { | ||
| 1143 | dev_info(pcu->dev, | ||
| 1144 | "Failed to reset device, error: %d\n", | ||
| 1145 | error); | ||
| 1146 | return error; | ||
| 1147 | } | ||
| 1148 | |||
| 1149 | return count; | ||
| 1150 | } | ||
| 1151 | |||
| 1152 | static DEVICE_ATTR(reset_device, S_IWUSR, NULL, ims_pcu_reset_device); | ||
| 1153 | |||
| 1154 | static ssize_t ims_pcu_update_firmware_store(struct device *dev, | ||
| 1155 | struct device_attribute *dattr, | ||
| 1156 | const char *buf, size_t count) | ||
| 1157 | { | ||
| 1158 | struct usb_interface *intf = to_usb_interface(dev); | ||
| 1159 | struct ims_pcu *pcu = usb_get_intfdata(intf); | ||
| 1160 | const struct firmware *fw = NULL; | ||
| 1161 | int value; | ||
| 1162 | int error; | ||
| 1163 | |||
| 1164 | error = kstrtoint(buf, 0, &value); | ||
| 1165 | if (error) | ||
| 1166 | return error; | ||
| 1167 | |||
| 1168 | if (value != 1) | ||
| 1169 | return -EINVAL; | ||
| 1170 | |||
| 1171 | error = mutex_lock_interruptible(&pcu->cmd_mutex); | ||
| 1172 | if (error) | ||
| 1173 | return error; | ||
| 1174 | |||
| 1175 | error = request_ihex_firmware(&fw, IMS_PCU_FIRMWARE_NAME, pcu->dev); | ||
| 1176 | if (error) { | ||
| 1177 | dev_err(pcu->dev, "Failed to request firmware %s, error: %d\n", | ||
| 1178 | IMS_PCU_FIRMWARE_NAME, error); | ||
| 1179 | goto out; | ||
| 1180 | } | ||
| 1181 | |||
| 1182 | /* | ||
| 1183 | * If we are already in bootloader mode we can proceed with | ||
| 1184 | * flashing the firmware. | ||
| 1185 | * | ||
| 1186 | * If we are in application mode, then we need to switch into | ||
| 1187 | * bootloader mode, which will cause the device to disconnect | ||
| 1188 | * and reconnect as different device. | ||
| 1189 | */ | ||
| 1190 | if (pcu->bootloader_mode) | ||
| 1191 | error = ims_pcu_handle_firmware_update(pcu, fw); | ||
| 1192 | else | ||
| 1193 | error = ims_pcu_switch_to_bootloader(pcu); | ||
| 1194 | |||
| 1195 | release_firmware(fw); | ||
| 1196 | |||
| 1197 | out: | ||
| 1198 | mutex_unlock(&pcu->cmd_mutex); | ||
| 1199 | return error ?: count; | ||
| 1200 | } | ||
| 1201 | |||
| 1202 | static DEVICE_ATTR(update_firmware, S_IWUSR, | ||
| 1203 | NULL, ims_pcu_update_firmware_store); | ||
| 1204 | |||
| 1205 | static ssize_t | ||
| 1206 | ims_pcu_update_firmware_status_show(struct device *dev, | ||
| 1207 | struct device_attribute *dattr, | ||
| 1208 | char *buf) | ||
| 1209 | { | ||
| 1210 | struct usb_interface *intf = to_usb_interface(dev); | ||
| 1211 | struct ims_pcu *pcu = usb_get_intfdata(intf); | ||
| 1212 | |||
| 1213 | return scnprintf(buf, PAGE_SIZE, "%d\n", pcu->update_firmware_status); | ||
| 1214 | } | ||
| 1215 | |||
| 1216 | static DEVICE_ATTR(update_firmware_status, S_IRUGO, | ||
| 1217 | ims_pcu_update_firmware_status_show, NULL); | ||
| 1218 | |||
| 1219 | static struct attribute *ims_pcu_attrs[] = { | ||
| 1220 | &ims_pcu_attr_part_number.dattr.attr, | ||
| 1221 | &ims_pcu_attr_serial_number.dattr.attr, | ||
| 1222 | &ims_pcu_attr_date_of_manufacturing.dattr.attr, | ||
| 1223 | &ims_pcu_attr_fw_version.dattr.attr, | ||
| 1224 | &ims_pcu_attr_bl_version.dattr.attr, | ||
| 1225 | &ims_pcu_attr_reset_reason.dattr.attr, | ||
| 1226 | &dev_attr_reset_device.attr, | ||
| 1227 | &dev_attr_update_firmware.attr, | ||
| 1228 | &dev_attr_update_firmware_status.attr, | ||
| 1229 | NULL | ||
| 1230 | }; | ||
| 1231 | |||
| 1232 | static umode_t ims_pcu_is_attr_visible(struct kobject *kobj, | ||
| 1233 | struct attribute *attr, int n) | ||
| 1234 | { | ||
| 1235 | struct device *dev = container_of(kobj, struct device, kobj); | ||
| 1236 | struct usb_interface *intf = to_usb_interface(dev); | ||
| 1237 | struct ims_pcu *pcu = usb_get_intfdata(intf); | ||
| 1238 | umode_t mode = attr->mode; | ||
| 1239 | |||
| 1240 | if (pcu->bootloader_mode) { | ||
| 1241 | if (attr != &dev_attr_update_firmware_status.attr && | ||
| 1242 | attr != &dev_attr_update_firmware.attr && | ||
| 1243 | attr != &dev_attr_reset_device.attr) { | ||
| 1244 | mode = 0; | ||
| 1245 | } | ||
| 1246 | } else { | ||
| 1247 | if (attr == &dev_attr_update_firmware_status.attr) | ||
| 1248 | mode = 0; | ||
| 1249 | } | ||
| 1250 | |||
| 1251 | return mode; | ||
| 1252 | } | ||
| 1253 | |||
| 1254 | static struct attribute_group ims_pcu_attr_group = { | ||
| 1255 | .is_visible = ims_pcu_is_attr_visible, | ||
| 1256 | .attrs = ims_pcu_attrs, | ||
| 1257 | }; | ||
| 1258 | |||
| 1259 | static void ims_pcu_irq(struct urb *urb) | ||
| 1260 | { | ||
| 1261 | struct ims_pcu *pcu = urb->context; | ||
| 1262 | int retval, status; | ||
| 1263 | |||
| 1264 | status = urb->status; | ||
| 1265 | |||
| 1266 | switch (status) { | ||
| 1267 | case 0: | ||
| 1268 | /* success */ | ||
| 1269 | break; | ||
| 1270 | case -ECONNRESET: | ||
| 1271 | case -ENOENT: | ||
| 1272 | case -ESHUTDOWN: | ||
| 1273 | /* this urb is terminated, clean up */ | ||
| 1274 | dev_dbg(pcu->dev, "%s - urb shutting down with status: %d\n", | ||
| 1275 | __func__, status); | ||
| 1276 | return; | ||
| 1277 | default: | ||
| 1278 | dev_dbg(pcu->dev, "%s - nonzero urb status received: %d\n", | ||
| 1279 | __func__, status); | ||
| 1280 | goto exit; | ||
| 1281 | } | ||
| 1282 | |||
| 1283 | dev_dbg(pcu->dev, "%s: received %d: %*ph\n", __func__, | ||
| 1284 | urb->actual_length, urb->actual_length, pcu->urb_in_buf); | ||
| 1285 | |||
| 1286 | if (urb == pcu->urb_in) | ||
| 1287 | ims_pcu_process_data(pcu, urb); | ||
| 1288 | |||
| 1289 | exit: | ||
| 1290 | retval = usb_submit_urb(urb, GFP_ATOMIC); | ||
| 1291 | if (retval && retval != -ENODEV) | ||
| 1292 | dev_err(pcu->dev, "%s - usb_submit_urb failed with result %d\n", | ||
| 1293 | __func__, retval); | ||
| 1294 | } | ||
| 1295 | |||
| 1296 | static int ims_pcu_buffers_alloc(struct ims_pcu *pcu) | ||
| 1297 | { | ||
| 1298 | int error; | ||
| 1299 | |||
| 1300 | pcu->urb_in_buf = usb_alloc_coherent(pcu->udev, pcu->max_in_size, | ||
| 1301 | GFP_KERNEL, &pcu->read_dma); | ||
| 1302 | if (!pcu->urb_in_buf) { | ||
| 1303 | dev_err(pcu->dev, | ||
| 1304 | "Failed to allocate memory for read buffer\n"); | ||
| 1305 | return -ENOMEM; | ||
| 1306 | } | ||
| 1307 | |||
| 1308 | pcu->urb_in = usb_alloc_urb(0, GFP_KERNEL); | ||
| 1309 | if (!pcu->urb_in) { | ||
| 1310 | dev_err(pcu->dev, "Failed to allocate input URB\n"); | ||
| 1311 | error = -ENOMEM; | ||
| 1312 | goto err_free_urb_in_buf; | ||
| 1313 | } | ||
| 1314 | |||
| 1315 | pcu->urb_in->transfer_flags |= URB_NO_TRANSFER_DMA_MAP; | ||
| 1316 | pcu->urb_in->transfer_dma = pcu->read_dma; | ||
| 1317 | |||
| 1318 | usb_fill_bulk_urb(pcu->urb_in, pcu->udev, | ||
| 1319 | usb_rcvbulkpipe(pcu->udev, | ||
| 1320 | pcu->ep_in->bEndpointAddress), | ||
| 1321 | pcu->urb_in_buf, pcu->max_in_size, | ||
| 1322 | ims_pcu_irq, pcu); | ||
| 1323 | |||
| 1324 | /* | ||
| 1325 | * We are using usb_bulk_msg() for sending so there is no point | ||
| 1326 | * in allocating memory with usb_alloc_coherent(). | ||
| 1327 | */ | ||
| 1328 | pcu->urb_out_buf = kmalloc(pcu->max_out_size, GFP_KERNEL); | ||
| 1329 | if (!pcu->urb_out_buf) { | ||
| 1330 | dev_err(pcu->dev, "Failed to allocate memory for write buffer\n"); | ||
| 1331 | error = -ENOMEM; | ||
| 1332 | goto err_free_in_urb; | ||
| 1333 | } | ||
| 1334 | |||
| 1335 | pcu->urb_ctrl_buf = usb_alloc_coherent(pcu->udev, pcu->max_ctrl_size, | ||
| 1336 | GFP_KERNEL, &pcu->ctrl_dma); | ||
| 1337 | if (!pcu->urb_ctrl_buf) { | ||
| 1338 | dev_err(pcu->dev, | ||
| 1339 | "Failed to allocate memory for read buffer\n"); | ||
| 1340 | goto err_free_urb_out_buf; | ||
| 1341 | } | ||
| 1342 | |||
| 1343 | pcu->urb_ctrl = usb_alloc_urb(0, GFP_KERNEL); | ||
| 1344 | if (!pcu->urb_ctrl) { | ||
| 1345 | dev_err(pcu->dev, "Failed to allocate input URB\n"); | ||
| 1346 | error = -ENOMEM; | ||
| 1347 | goto err_free_urb_ctrl_buf; | ||
| 1348 | } | ||
| 1349 | |||
| 1350 | pcu->urb_ctrl->transfer_flags |= URB_NO_TRANSFER_DMA_MAP; | ||
| 1351 | pcu->urb_ctrl->transfer_dma = pcu->ctrl_dma; | ||
| 1352 | |||
| 1353 | usb_fill_int_urb(pcu->urb_ctrl, pcu->udev, | ||
| 1354 | usb_rcvintpipe(pcu->udev, | ||
| 1355 | pcu->ep_ctrl->bEndpointAddress), | ||
| 1356 | pcu->urb_ctrl_buf, pcu->max_ctrl_size, | ||
| 1357 | ims_pcu_irq, pcu, pcu->ep_ctrl->bInterval); | ||
| 1358 | |||
| 1359 | return 0; | ||
| 1360 | |||
| 1361 | err_free_urb_ctrl_buf: | ||
| 1362 | usb_free_coherent(pcu->udev, pcu->max_ctrl_size, | ||
| 1363 | pcu->urb_ctrl_buf, pcu->ctrl_dma); | ||
| 1364 | err_free_urb_out_buf: | ||
| 1365 | kfree(pcu->urb_out_buf); | ||
| 1366 | err_free_in_urb: | ||
| 1367 | usb_free_urb(pcu->urb_in); | ||
| 1368 | err_free_urb_in_buf: | ||
| 1369 | usb_free_coherent(pcu->udev, pcu->max_in_size, | ||
| 1370 | pcu->urb_in_buf, pcu->read_dma); | ||
| 1371 | return error; | ||
| 1372 | } | ||
| 1373 | |||
| 1374 | static void ims_pcu_buffers_free(struct ims_pcu *pcu) | ||
| 1375 | { | ||
| 1376 | usb_kill_urb(pcu->urb_in); | ||
| 1377 | usb_free_urb(pcu->urb_in); | ||
| 1378 | |||
| 1379 | usb_free_coherent(pcu->udev, pcu->max_out_size, | ||
| 1380 | pcu->urb_in_buf, pcu->read_dma); | ||
| 1381 | |||
| 1382 | kfree(pcu->urb_out_buf); | ||
| 1383 | |||
| 1384 | usb_kill_urb(pcu->urb_ctrl); | ||
| 1385 | usb_free_urb(pcu->urb_ctrl); | ||
| 1386 | |||
| 1387 | usb_free_coherent(pcu->udev, pcu->max_ctrl_size, | ||
| 1388 | pcu->urb_ctrl_buf, pcu->ctrl_dma); | ||
| 1389 | } | ||
| 1390 | |||
| 1391 | static const struct usb_cdc_union_desc * | ||
| 1392 | ims_pcu_get_cdc_union_desc(struct usb_interface *intf) | ||
| 1393 | { | ||
| 1394 | const void *buf = intf->altsetting->extra; | ||
| 1395 | size_t buflen = intf->altsetting->extralen; | ||
| 1396 | struct usb_cdc_union_desc *union_desc; | ||
| 1397 | |||
| 1398 | if (!buf) { | ||
| 1399 | dev_err(&intf->dev, "Missing descriptor data\n"); | ||
| 1400 | return NULL; | ||
| 1401 | } | ||
| 1402 | |||
| 1403 | if (!buflen) { | ||
| 1404 | dev_err(&intf->dev, "Zero length descriptor\n"); | ||
| 1405 | return NULL; | ||
| 1406 | } | ||
| 1407 | |||
| 1408 | while (buflen > 0) { | ||
| 1409 | union_desc = (struct usb_cdc_union_desc *)buf; | ||
| 1410 | |||
| 1411 | if (union_desc->bDescriptorType == USB_DT_CS_INTERFACE && | ||
| 1412 | union_desc->bDescriptorSubType == USB_CDC_UNION_TYPE) { | ||
| 1413 | dev_dbg(&intf->dev, "Found union header\n"); | ||
| 1414 | return union_desc; | ||
| 1415 | } | ||
| 1416 | |||
| 1417 | buflen -= union_desc->bLength; | ||
| 1418 | buf += union_desc->bLength; | ||
| 1419 | } | ||
| 1420 | |||
| 1421 | dev_err(&intf->dev, "Missing CDC union descriptor\n"); | ||
| 1422 | return NULL; | ||
| 1423 | } | ||
| 1424 | |||
| 1425 | static int ims_pcu_parse_cdc_data(struct usb_interface *intf, struct ims_pcu *pcu) | ||
| 1426 | { | ||
| 1427 | const struct usb_cdc_union_desc *union_desc; | ||
| 1428 | struct usb_host_interface *alt; | ||
| 1429 | |||
| 1430 | union_desc = ims_pcu_get_cdc_union_desc(intf); | ||
| 1431 | if (!union_desc) | ||
| 1432 | return -EINVAL; | ||
| 1433 | |||
| 1434 | pcu->ctrl_intf = usb_ifnum_to_if(pcu->udev, | ||
| 1435 | union_desc->bMasterInterface0); | ||
| 1436 | |||
| 1437 | alt = pcu->ctrl_intf->cur_altsetting; | ||
| 1438 | pcu->ep_ctrl = &alt->endpoint[0].desc; | ||
| 1439 | pcu->max_ctrl_size = usb_endpoint_maxp(pcu->ep_ctrl); | ||
| 1440 | |||
| 1441 | pcu->data_intf = usb_ifnum_to_if(pcu->udev, | ||
| 1442 | union_desc->bSlaveInterface0); | ||
| 1443 | |||
| 1444 | alt = pcu->data_intf->cur_altsetting; | ||
| 1445 | if (alt->desc.bNumEndpoints != 2) { | ||
| 1446 | dev_err(pcu->dev, | ||
| 1447 | "Incorrect number of endpoints on data interface (%d)\n", | ||
| 1448 | alt->desc.bNumEndpoints); | ||
| 1449 | return -EINVAL; | ||
| 1450 | } | ||
| 1451 | |||
| 1452 | pcu->ep_out = &alt->endpoint[0].desc; | ||
| 1453 | if (!usb_endpoint_is_bulk_out(pcu->ep_out)) { | ||
| 1454 | dev_err(pcu->dev, | ||
| 1455 | "First endpoint on data interface is not BULK OUT\n"); | ||
| 1456 | return -EINVAL; | ||
| 1457 | } | ||
| 1458 | |||
| 1459 | pcu->max_out_size = usb_endpoint_maxp(pcu->ep_out); | ||
| 1460 | if (pcu->max_out_size < 8) { | ||
| 1461 | dev_err(pcu->dev, | ||
| 1462 | "Max OUT packet size is too small (%zd)\n", | ||
| 1463 | pcu->max_out_size); | ||
| 1464 | return -EINVAL; | ||
| 1465 | } | ||
| 1466 | |||
| 1467 | pcu->ep_in = &alt->endpoint[1].desc; | ||
| 1468 | if (!usb_endpoint_is_bulk_in(pcu->ep_in)) { | ||
| 1469 | dev_err(pcu->dev, | ||
| 1470 | "Second endpoint on data interface is not BULK IN\n"); | ||
| 1471 | return -EINVAL; | ||
| 1472 | } | ||
| 1473 | |||
| 1474 | pcu->max_in_size = usb_endpoint_maxp(pcu->ep_in); | ||
| 1475 | if (pcu->max_in_size < 8) { | ||
| 1476 | dev_err(pcu->dev, | ||
| 1477 | "Max IN packet size is too small (%zd)\n", | ||
| 1478 | pcu->max_in_size); | ||
| 1479 | return -EINVAL; | ||
| 1480 | } | ||
| 1481 | |||
| 1482 | return 0; | ||
| 1483 | } | ||
| 1484 | |||
| 1485 | static int ims_pcu_start_io(struct ims_pcu *pcu) | ||
| 1486 | { | ||
| 1487 | int error; | ||
| 1488 | |||
| 1489 | error = usb_submit_urb(pcu->urb_ctrl, GFP_KERNEL); | ||
| 1490 | if (error) { | ||
| 1491 | dev_err(pcu->dev, | ||
| 1492 | "Failed to start control IO - usb_submit_urb failed with result: %d\n", | ||
| 1493 | error); | ||
| 1494 | return -EIO; | ||
| 1495 | } | ||
| 1496 | |||
| 1497 | error = usb_submit_urb(pcu->urb_in, GFP_KERNEL); | ||
| 1498 | if (error) { | ||
| 1499 | dev_err(pcu->dev, | ||
| 1500 | "Failed to start IO - usb_submit_urb failed with result: %d\n", | ||
| 1501 | error); | ||
| 1502 | usb_kill_urb(pcu->urb_ctrl); | ||
| 1503 | return -EIO; | ||
| 1504 | } | ||
| 1505 | |||
| 1506 | return 0; | ||
| 1507 | } | ||
| 1508 | |||
| 1509 | static void ims_pcu_stop_io(struct ims_pcu *pcu) | ||
| 1510 | { | ||
| 1511 | usb_kill_urb(pcu->urb_in); | ||
| 1512 | usb_kill_urb(pcu->urb_ctrl); | ||
| 1513 | } | ||
| 1514 | |||
| 1515 | static int ims_pcu_line_setup(struct ims_pcu *pcu) | ||
| 1516 | { | ||
| 1517 | struct usb_host_interface *interface = pcu->ctrl_intf->cur_altsetting; | ||
| 1518 | struct usb_cdc_line_coding *line = (void *)pcu->cmd_buf; | ||
| 1519 | int error; | ||
| 1520 | |||
| 1521 | memset(line, 0, sizeof(*line)); | ||
| 1522 | line->dwDTERate = cpu_to_le32(57600); | ||
| 1523 | line->bDataBits = 8; | ||
| 1524 | |||
| 1525 | error = usb_control_msg(pcu->udev, usb_sndctrlpipe(pcu->udev, 0), | ||
| 1526 | USB_CDC_REQ_SET_LINE_CODING, | ||
| 1527 | USB_TYPE_CLASS | USB_RECIP_INTERFACE, | ||
| 1528 | 0, interface->desc.bInterfaceNumber, | ||
| 1529 | line, sizeof(struct usb_cdc_line_coding), | ||
| 1530 | 5000); | ||
| 1531 | if (error < 0) { | ||
| 1532 | dev_err(pcu->dev, "Failed to set line coding, error: %d\n", | ||
| 1533 | error); | ||
| 1534 | return error; | ||
| 1535 | } | ||
| 1536 | |||
| 1537 | error = usb_control_msg(pcu->udev, usb_sndctrlpipe(pcu->udev, 0), | ||
| 1538 | USB_CDC_REQ_SET_CONTROL_LINE_STATE, | ||
| 1539 | USB_TYPE_CLASS | USB_RECIP_INTERFACE, | ||
| 1540 | 0x03, interface->desc.bInterfaceNumber, | ||
| 1541 | NULL, 0, 5000); | ||
| 1542 | if (error < 0) { | ||
| 1543 | dev_err(pcu->dev, "Failed to set line state, error: %d\n", | ||
| 1544 | error); | ||
| 1545 | return error; | ||
| 1546 | } | ||
| 1547 | |||
| 1548 | return 0; | ||
| 1549 | } | ||
| 1550 | |||
| 1551 | static int ims_pcu_get_device_info(struct ims_pcu *pcu) | ||
| 1552 | { | ||
| 1553 | int error; | ||
| 1554 | |||
| 1555 | error = ims_pcu_get_info(pcu); | ||
| 1556 | if (error) | ||
| 1557 | return error; | ||
| 1558 | |||
| 1559 | error = ims_pcu_execute_query(pcu, GET_FW_VERSION); | ||
| 1560 | if (error) { | ||
| 1561 | dev_err(pcu->dev, | ||
| 1562 | "GET_FW_VERSION command failed, error: %d\n", error); | ||
| 1563 | return error; | ||
| 1564 | } | ||
| 1565 | |||
| 1566 | snprintf(pcu->fw_version, sizeof(pcu->fw_version), | ||
| 1567 | "%02d%02d%02d%02d.%c%c", | ||
| 1568 | pcu->cmd_buf[2], pcu->cmd_buf[3], pcu->cmd_buf[4], pcu->cmd_buf[5], | ||
| 1569 | pcu->cmd_buf[6], pcu->cmd_buf[7]); | ||
| 1570 | |||
| 1571 | error = ims_pcu_execute_query(pcu, GET_BL_VERSION); | ||
| 1572 | if (error) { | ||
| 1573 | dev_err(pcu->dev, | ||
| 1574 | "GET_BL_VERSION command failed, error: %d\n", error); | ||
| 1575 | return error; | ||
| 1576 | } | ||
| 1577 | |||
| 1578 | snprintf(pcu->bl_version, sizeof(pcu->bl_version), | ||
| 1579 | "%02d%02d%02d%02d.%c%c", | ||
| 1580 | pcu->cmd_buf[2], pcu->cmd_buf[3], pcu->cmd_buf[4], pcu->cmd_buf[5], | ||
| 1581 | pcu->cmd_buf[6], pcu->cmd_buf[7]); | ||
| 1582 | |||
| 1583 | error = ims_pcu_execute_query(pcu, RESET_REASON); | ||
| 1584 | if (error) { | ||
| 1585 | dev_err(pcu->dev, | ||
| 1586 | "RESET_REASON command failed, error: %d\n", error); | ||
| 1587 | return error; | ||
| 1588 | } | ||
| 1589 | |||
| 1590 | snprintf(pcu->reset_reason, sizeof(pcu->reset_reason), | ||
| 1591 | "%02x", pcu->cmd_buf[IMS_PCU_DATA_OFFSET]); | ||
| 1592 | |||
| 1593 | dev_dbg(pcu->dev, | ||
| 1594 | "P/N: %s, MD: %s, S/N: %s, FW: %s, BL: %s, RR: %s\n", | ||
| 1595 | pcu->part_number, | ||
| 1596 | pcu->date_of_manufacturing, | ||
| 1597 | pcu->serial_number, | ||
| 1598 | pcu->fw_version, | ||
| 1599 | pcu->bl_version, | ||
| 1600 | pcu->reset_reason); | ||
| 1601 | |||
| 1602 | return 0; | ||
| 1603 | } | ||
| 1604 | |||
| 1605 | static int ims_pcu_identify_type(struct ims_pcu *pcu, u8 *device_id) | ||
| 1606 | { | ||
| 1607 | int error; | ||
| 1608 | |||
| 1609 | error = ims_pcu_execute_query(pcu, GET_DEVICE_ID); | ||
| 1610 | if (error) { | ||
| 1611 | dev_err(pcu->dev, | ||
| 1612 | "GET_DEVICE_ID command failed, error: %d\n", error); | ||
| 1613 | return error; | ||
| 1614 | } | ||
| 1615 | |||
| 1616 | *device_id = pcu->cmd_buf[IMS_PCU_DATA_OFFSET]; | ||
| 1617 | dev_dbg(pcu->dev, "Detected device ID: %d\n", *device_id); | ||
| 1618 | |||
| 1619 | return 0; | ||
| 1620 | } | ||
| 1621 | |||
| 1622 | static int ims_pcu_init_application_mode(struct ims_pcu *pcu) | ||
| 1623 | { | ||
| 1624 | static atomic_t device_no = ATOMIC_INIT(0); | ||
| 1625 | |||
| 1626 | const struct ims_pcu_device_info *info; | ||
| 1627 | u8 device_id; | ||
| 1628 | int error; | ||
| 1629 | |||
| 1630 | error = ims_pcu_get_device_info(pcu); | ||
| 1631 | if (error) { | ||
| 1632 | /* Device does not respond to basic queries, hopeless */ | ||
| 1633 | return error; | ||
| 1634 | } | ||
| 1635 | |||
| 1636 | error = ims_pcu_identify_type(pcu, &device_id); | ||
| 1637 | if (error) { | ||
| 1638 | dev_err(pcu->dev, | ||
| 1639 | "Failed to identify device, error: %d\n", error); | ||
| 1640 | /* | ||
| 1641 | * Do not signal error, but do not create input nor | ||
| 1642 | * backlight devices either, let userspace figure this | ||
| 1643 | * out (flash a new firmware?). | ||
| 1644 | */ | ||
| 1645 | return 0; | ||
| 1646 | } | ||
| 1647 | |||
| 1648 | if (device_id >= ARRAY_SIZE(ims_pcu_device_info) || | ||
| 1649 | !ims_pcu_device_info[device_id].keymap) { | ||
| 1650 | dev_err(pcu->dev, "Device ID %d is not valid\n", device_id); | ||
| 1651 | /* Same as above, punt to userspace */ | ||
| 1652 | return 0; | ||
| 1653 | } | ||
| 1654 | |||
| 1655 | /* Device appears to be operable, complete initialization */ | ||
| 1656 | pcu->device_no = atomic_inc_return(&device_no) - 1; | ||
| 1657 | |||
| 1658 | error = ims_pcu_setup_backlight(pcu); | ||
| 1659 | if (error) | ||
| 1660 | return error; | ||
| 1661 | |||
| 1662 | info = &ims_pcu_device_info[device_id]; | ||
| 1663 | error = ims_pcu_setup_buttons(pcu, info->keymap, info->keymap_len); | ||
| 1664 | if (error) | ||
| 1665 | goto err_destroy_backlight; | ||
| 1666 | |||
| 1667 | if (info->has_gamepad) { | ||
| 1668 | error = ims_pcu_setup_gamepad(pcu); | ||
| 1669 | if (error) | ||
| 1670 | goto err_destroy_buttons; | ||
| 1671 | } | ||
| 1672 | |||
| 1673 | pcu->setup_complete = true; | ||
| 1674 | |||
| 1675 | return 0; | ||
| 1676 | |||
| 1677 | err_destroy_backlight: | ||
| 1678 | ims_pcu_destroy_backlight(pcu); | ||
| 1679 | err_destroy_buttons: | ||
| 1680 | ims_pcu_destroy_buttons(pcu); | ||
| 1681 | return error; | ||
| 1682 | } | ||
| 1683 | |||
| 1684 | static void ims_pcu_destroy_application_mode(struct ims_pcu *pcu) | ||
| 1685 | { | ||
| 1686 | if (pcu->setup_complete) { | ||
| 1687 | pcu->setup_complete = false; | ||
| 1688 | mb(); /* make sure flag setting is not reordered */ | ||
| 1689 | |||
| 1690 | if (pcu->gamepad) | ||
| 1691 | ims_pcu_destroy_gamepad(pcu); | ||
| 1692 | ims_pcu_destroy_buttons(pcu); | ||
| 1693 | ims_pcu_destroy_backlight(pcu); | ||
| 1694 | } | ||
| 1695 | } | ||
| 1696 | |||
| 1697 | static int ims_pcu_init_bootloader_mode(struct ims_pcu *pcu) | ||
| 1698 | { | ||
| 1699 | int error; | ||
| 1700 | |||
| 1701 | error = ims_pcu_execute_bl_command(pcu, QUERY_DEVICE, NULL, 0, | ||
| 1702 | IMS_PCU_CMD_RESPONSE_TIMEOUT); | ||
| 1703 | if (error) { | ||
| 1704 | dev_err(pcu->dev, "Bootloader does not respond, aborting\n"); | ||
| 1705 | return error; | ||
| 1706 | } | ||
| 1707 | |||
| 1708 | pcu->fw_start_addr = | ||
| 1709 | get_unaligned_le32(&pcu->cmd_buf[IMS_PCU_DATA_OFFSET + 11]); | ||
| 1710 | pcu->fw_end_addr = | ||
| 1711 | get_unaligned_le32(&pcu->cmd_buf[IMS_PCU_DATA_OFFSET + 15]); | ||
| 1712 | |||
| 1713 | dev_info(pcu->dev, | ||
| 1714 | "Device is in bootloader mode (addr 0x%08x-0x%08x), requesting firmware\n", | ||
| 1715 | pcu->fw_start_addr, pcu->fw_end_addr); | ||
| 1716 | |||
| 1717 | error = request_firmware_nowait(THIS_MODULE, true, | ||
| 1718 | IMS_PCU_FIRMWARE_NAME, | ||
| 1719 | pcu->dev, GFP_KERNEL, pcu, | ||
| 1720 | ims_pcu_process_async_firmware); | ||
| 1721 | if (error) { | ||
| 1722 | /* This error is not fatal, let userspace have another chance */ | ||
| 1723 | complete(&pcu->async_firmware_done); | ||
| 1724 | } | ||
| 1725 | |||
| 1726 | return 0; | ||
| 1727 | } | ||
| 1728 | |||
| 1729 | static void ims_pcu_destroy_bootloader_mode(struct ims_pcu *pcu) | ||
| 1730 | { | ||
| 1731 | /* Make sure our initial firmware request has completed */ | ||
| 1732 | wait_for_completion(&pcu->async_firmware_done); | ||
| 1733 | } | ||
| 1734 | |||
| 1735 | #define IMS_PCU_APPLICATION_MODE 0 | ||
| 1736 | #define IMS_PCU_BOOTLOADER_MODE 1 | ||
| 1737 | |||
| 1738 | static struct usb_driver ims_pcu_driver; | ||
| 1739 | |||
| 1740 | static int ims_pcu_probe(struct usb_interface *intf, | ||
| 1741 | const struct usb_device_id *id) | ||
| 1742 | { | ||
| 1743 | struct usb_device *udev = interface_to_usbdev(intf); | ||
| 1744 | struct ims_pcu *pcu; | ||
| 1745 | int error; | ||
| 1746 | |||
| 1747 | pcu = kzalloc(sizeof(struct ims_pcu), GFP_KERNEL); | ||
| 1748 | if (!pcu) | ||
| 1749 | return -ENOMEM; | ||
| 1750 | |||
| 1751 | pcu->dev = &intf->dev; | ||
| 1752 | pcu->udev = udev; | ||
| 1753 | pcu->bootloader_mode = id->driver_info == IMS_PCU_BOOTLOADER_MODE; | ||
| 1754 | mutex_init(&pcu->cmd_mutex); | ||
| 1755 | init_completion(&pcu->cmd_done); | ||
| 1756 | init_completion(&pcu->async_firmware_done); | ||
| 1757 | |||
| 1758 | error = ims_pcu_parse_cdc_data(intf, pcu); | ||
| 1759 | if (error) | ||
| 1760 | goto err_free_mem; | ||
| 1761 | |||
| 1762 | error = usb_driver_claim_interface(&ims_pcu_driver, | ||
| 1763 | pcu->data_intf, pcu); | ||
| 1764 | if (error) { | ||
| 1765 | dev_err(&intf->dev, | ||
| 1766 | "Unable to claim corresponding data interface: %d\n", | ||
| 1767 | error); | ||
| 1768 | goto err_free_mem; | ||
| 1769 | } | ||
| 1770 | |||
| 1771 | usb_set_intfdata(pcu->ctrl_intf, pcu); | ||
| 1772 | usb_set_intfdata(pcu->data_intf, pcu); | ||
| 1773 | |||
| 1774 | error = ims_pcu_buffers_alloc(pcu); | ||
| 1775 | if (error) | ||
| 1776 | goto err_unclaim_intf; | ||
| 1777 | |||
| 1778 | error = ims_pcu_start_io(pcu); | ||
| 1779 | if (error) | ||
| 1780 | goto err_free_buffers; | ||
| 1781 | |||
| 1782 | error = ims_pcu_line_setup(pcu); | ||
| 1783 | if (error) | ||
| 1784 | goto err_stop_io; | ||
| 1785 | |||
| 1786 | error = sysfs_create_group(&intf->dev.kobj, &ims_pcu_attr_group); | ||
| 1787 | if (error) | ||
| 1788 | goto err_stop_io; | ||
| 1789 | |||
| 1790 | error = pcu->bootloader_mode ? | ||
| 1791 | ims_pcu_init_bootloader_mode(pcu) : | ||
| 1792 | ims_pcu_init_application_mode(pcu); | ||
| 1793 | if (error) | ||
| 1794 | goto err_remove_sysfs; | ||
| 1795 | |||
| 1796 | return 0; | ||
| 1797 | |||
| 1798 | err_remove_sysfs: | ||
| 1799 | sysfs_remove_group(&intf->dev.kobj, &ims_pcu_attr_group); | ||
| 1800 | err_stop_io: | ||
| 1801 | ims_pcu_stop_io(pcu); | ||
| 1802 | err_free_buffers: | ||
| 1803 | ims_pcu_buffers_free(pcu); | ||
| 1804 | err_unclaim_intf: | ||
| 1805 | usb_driver_release_interface(&ims_pcu_driver, pcu->data_intf); | ||
| 1806 | err_free_mem: | ||
| 1807 | kfree(pcu); | ||
| 1808 | return error; | ||
| 1809 | } | ||
| 1810 | |||
| 1811 | static void ims_pcu_disconnect(struct usb_interface *intf) | ||
| 1812 | { | ||
| 1813 | struct ims_pcu *pcu = usb_get_intfdata(intf); | ||
| 1814 | struct usb_host_interface *alt = intf->cur_altsetting; | ||
| 1815 | |||
| 1816 | usb_set_intfdata(intf, NULL); | ||
| 1817 | |||
| 1818 | /* | ||
| 1819 | * See if we are dealing with control or data interface. The cleanup | ||
| 1820 | * happens when we unbind primary (control) interface. | ||
| 1821 | */ | ||
| 1822 | if (alt->desc.bInterfaceClass != USB_CLASS_COMM) | ||
| 1823 | return; | ||
| 1824 | |||
| 1825 | sysfs_remove_group(&intf->dev.kobj, &ims_pcu_attr_group); | ||
| 1826 | |||
| 1827 | ims_pcu_stop_io(pcu); | ||
| 1828 | |||
| 1829 | if (pcu->bootloader_mode) | ||
| 1830 | ims_pcu_destroy_bootloader_mode(pcu); | ||
| 1831 | else | ||
| 1832 | ims_pcu_destroy_application_mode(pcu); | ||
| 1833 | |||
| 1834 | ims_pcu_buffers_free(pcu); | ||
| 1835 | kfree(pcu); | ||
| 1836 | } | ||
| 1837 | |||
| 1838 | #ifdef CONFIG_PM | ||
| 1839 | static int ims_pcu_suspend(struct usb_interface *intf, | ||
| 1840 | pm_message_t message) | ||
| 1841 | { | ||
| 1842 | struct ims_pcu *pcu = usb_get_intfdata(intf); | ||
| 1843 | struct usb_host_interface *alt = intf->cur_altsetting; | ||
| 1844 | |||
| 1845 | if (alt->desc.bInterfaceClass == USB_CLASS_COMM) | ||
| 1846 | ims_pcu_stop_io(pcu); | ||
| 1847 | |||
| 1848 | return 0; | ||
| 1849 | } | ||
| 1850 | |||
| 1851 | static int ims_pcu_resume(struct usb_interface *intf) | ||
| 1852 | { | ||
| 1853 | struct ims_pcu *pcu = usb_get_intfdata(intf); | ||
| 1854 | struct usb_host_interface *alt = intf->cur_altsetting; | ||
| 1855 | int retval = 0; | ||
| 1856 | |||
| 1857 | if (alt->desc.bInterfaceClass == USB_CLASS_COMM) { | ||
| 1858 | retval = ims_pcu_start_io(pcu); | ||
| 1859 | if (retval == 0) | ||
| 1860 | retval = ims_pcu_line_setup(pcu); | ||
| 1861 | } | ||
| 1862 | |||
| 1863 | return retval; | ||
| 1864 | } | ||
| 1865 | #endif | ||
| 1866 | |||
| 1867 | static const struct usb_device_id ims_pcu_id_table[] = { | ||
| 1868 | { | ||
| 1869 | USB_DEVICE_AND_INTERFACE_INFO(0x04d8, 0x0082, | ||
| 1870 | USB_CLASS_COMM, | ||
| 1871 | USB_CDC_SUBCLASS_ACM, | ||
| 1872 | USB_CDC_ACM_PROTO_AT_V25TER), | ||
| 1873 | .driver_info = IMS_PCU_APPLICATION_MODE, | ||
| 1874 | }, | ||
| 1875 | { | ||
| 1876 | USB_DEVICE_AND_INTERFACE_INFO(0x04d8, 0x0083, | ||
| 1877 | USB_CLASS_COMM, | ||
| 1878 | USB_CDC_SUBCLASS_ACM, | ||
| 1879 | USB_CDC_ACM_PROTO_AT_V25TER), | ||
| 1880 | .driver_info = IMS_PCU_BOOTLOADER_MODE, | ||
| 1881 | }, | ||
| 1882 | { } | ||
| 1883 | }; | ||
| 1884 | |||
| 1885 | static struct usb_driver ims_pcu_driver = { | ||
| 1886 | .name = "ims_pcu", | ||
| 1887 | .id_table = ims_pcu_id_table, | ||
| 1888 | .probe = ims_pcu_probe, | ||
| 1889 | .disconnect = ims_pcu_disconnect, | ||
| 1890 | #ifdef CONFIG_PM | ||
| 1891 | .suspend = ims_pcu_suspend, | ||
| 1892 | .resume = ims_pcu_resume, | ||
| 1893 | .reset_resume = ims_pcu_resume, | ||
| 1894 | #endif | ||
| 1895 | }; | ||
| 1896 | |||
| 1897 | module_usb_driver(ims_pcu_driver); | ||
| 1898 | |||
| 1899 | MODULE_DESCRIPTION("IMS Passenger Control Unit driver"); | ||
| 1900 | MODULE_AUTHOR("Dmitry Torokhov <dmitry.torokhov@gmail.com>"); | ||
| 1901 | MODULE_LICENSE("GPL"); | ||
diff --git a/drivers/input/misc/mma8450.c b/drivers/input/misc/mma8450.c index 480557f14f23..f3309696d053 100644 --- a/drivers/input/misc/mma8450.c +++ b/drivers/input/misc/mma8450.c | |||
| @@ -123,9 +123,9 @@ static void mma8450_poll(struct input_polled_dev *dev) | |||
| 123 | if (ret < 0) | 123 | if (ret < 0) |
| 124 | return; | 124 | return; |
| 125 | 125 | ||
| 126 | x = ((buf[1] << 4) & 0xff0) | (buf[0] & 0xf); | 126 | x = ((int)(s8)buf[1] << 4) | (buf[0] & 0xf); |
| 127 | y = ((buf[3] << 4) & 0xff0) | (buf[2] & 0xf); | 127 | y = ((int)(s8)buf[3] << 4) | (buf[2] & 0xf); |
| 128 | z = ((buf[5] << 4) & 0xff0) | (buf[4] & 0xf); | 128 | z = ((int)(s8)buf[5] << 4) | (buf[4] & 0xf); |
| 129 | 129 | ||
| 130 | input_report_abs(dev->input, ABS_X, x); | 130 | input_report_abs(dev->input, ABS_X, x); |
| 131 | input_report_abs(dev->input, ABS_Y, y); | 131 | input_report_abs(dev->input, ABS_Y, y); |
diff --git a/drivers/input/misc/twl4030-pwrbutton.c b/drivers/input/misc/twl4030-pwrbutton.c index 27c2bc8aa890..b9a05fda03e4 100644 --- a/drivers/input/misc/twl4030-pwrbutton.c +++ b/drivers/input/misc/twl4030-pwrbutton.c | |||
| @@ -114,18 +114,8 @@ static struct platform_driver twl4030_pwrbutton_driver = { | |||
| 114 | }, | 114 | }, |
| 115 | }; | 115 | }; |
| 116 | 116 | ||
| 117 | static int __init twl4030_pwrbutton_init(void) | 117 | module_platform_driver_probe(twl4030_pwrbutton_driver, |
| 118 | { | ||
| 119 | return platform_driver_probe(&twl4030_pwrbutton_driver, | ||
| 120 | twl4030_pwrbutton_probe); | 118 | twl4030_pwrbutton_probe); |
| 121 | } | ||
| 122 | module_init(twl4030_pwrbutton_init); | ||
| 123 | |||
| 124 | static void __exit twl4030_pwrbutton_exit(void) | ||
| 125 | { | ||
| 126 | platform_driver_unregister(&twl4030_pwrbutton_driver); | ||
| 127 | } | ||
| 128 | module_exit(twl4030_pwrbutton_exit); | ||
| 129 | 119 | ||
| 130 | MODULE_ALIAS("platform:twl4030_pwrbutton"); | 120 | MODULE_ALIAS("platform:twl4030_pwrbutton"); |
| 131 | MODULE_DESCRIPTION("Triton2 Power Button"); | 121 | MODULE_DESCRIPTION("Triton2 Power Button"); |
diff --git a/drivers/input/mouse/alps.c b/drivers/input/mouse/alps.c index 0238e0e14335..7c5d72a6a26a 100644 --- a/drivers/input/mouse/alps.c +++ b/drivers/input/mouse/alps.c | |||
| @@ -1013,8 +1013,8 @@ static int alps_rpt_cmd(struct psmouse *psmouse, int init_command, | |||
| 1013 | if (ps2_command(ps2dev, param, PSMOUSE_CMD_GETINFO)) | 1013 | if (ps2_command(ps2dev, param, PSMOUSE_CMD_GETINFO)) |
| 1014 | return -EIO; | 1014 | return -EIO; |
| 1015 | 1015 | ||
| 1016 | psmouse_dbg(psmouse, "%2.2X report: %2.2x %2.2x %2.2x\n", | 1016 | psmouse_dbg(psmouse, "%2.2X report: %3ph\n", |
| 1017 | repeated_command, param[0], param[1], param[2]); | 1017 | repeated_command, param); |
| 1018 | return 0; | 1018 | return 0; |
| 1019 | } | 1019 | } |
| 1020 | 1020 | ||
| @@ -1274,9 +1274,7 @@ static int alps_setup_trackstick_v3(struct psmouse *psmouse, int reg_base) | |||
| 1274 | psmouse_warn(psmouse, "trackstick E7 report failed\n"); | 1274 | psmouse_warn(psmouse, "trackstick E7 report failed\n"); |
| 1275 | ret = -ENODEV; | 1275 | ret = -ENODEV; |
| 1276 | } else { | 1276 | } else { |
| 1277 | psmouse_dbg(psmouse, | 1277 | psmouse_dbg(psmouse, "trackstick E7 report: %3ph\n", param); |
| 1278 | "trackstick E7 report: %2.2x %2.2x %2.2x\n", | ||
| 1279 | param[0], param[1], param[2]); | ||
| 1280 | 1278 | ||
| 1281 | /* | 1279 | /* |
| 1282 | * Not sure what this does, but it is absolutely | 1280 | * Not sure what this does, but it is absolutely |
| @@ -1323,6 +1321,7 @@ static int alps_hw_init_v3(struct psmouse *psmouse) | |||
| 1323 | reg_val = alps_probe_trackstick_v3(psmouse, ALPS_REG_BASE_PINNACLE); | 1321 | reg_val = alps_probe_trackstick_v3(psmouse, ALPS_REG_BASE_PINNACLE); |
| 1324 | if (reg_val == -EIO) | 1322 | if (reg_val == -EIO) |
| 1325 | goto error; | 1323 | goto error; |
| 1324 | |||
| 1326 | if (reg_val == 0 && | 1325 | if (reg_val == 0 && |
| 1327 | alps_setup_trackstick_v3(psmouse, ALPS_REG_BASE_PINNACLE) == -EIO) | 1326 | alps_setup_trackstick_v3(psmouse, ALPS_REG_BASE_PINNACLE) == -EIO) |
| 1328 | goto error; | 1327 | goto error; |
| @@ -1676,8 +1675,7 @@ static int alps_identify(struct psmouse *psmouse, struct alps_data *priv) | |||
| 1676 | } | 1675 | } |
| 1677 | 1676 | ||
| 1678 | psmouse_info(psmouse, | 1677 | psmouse_info(psmouse, |
| 1679 | "Unknown ALPS touchpad: E7=%2.2x %2.2x %2.2x, EC=%2.2x %2.2x %2.2x\n", | 1678 | "Unknown ALPS touchpad: E7=%3ph, EC=%3ph\n", e7, ec); |
| 1680 | e7[0], e7[1], e7[2], ec[0], ec[1], ec[2]); | ||
| 1681 | 1679 | ||
| 1682 | return -EINVAL; | 1680 | return -EINVAL; |
| 1683 | } | 1681 | } |
diff --git a/drivers/input/mouse/amimouse.c b/drivers/input/mouse/amimouse.c index 5fa99341a39d..b55d5af217a7 100644 --- a/drivers/input/mouse/amimouse.c +++ b/drivers/input/mouse/amimouse.c | |||
| @@ -146,18 +146,6 @@ static struct platform_driver amimouse_driver = { | |||
| 146 | }, | 146 | }, |
| 147 | }; | 147 | }; |
| 148 | 148 | ||
| 149 | static int __init amimouse_init(void) | 149 | module_platform_driver_probe(amimouse_driver, amimouse_probe); |
| 150 | { | ||
| 151 | return platform_driver_probe(&amimouse_driver, amimouse_probe); | ||
| 152 | } | ||
| 153 | |||
| 154 | module_init(amimouse_init); | ||
| 155 | |||
| 156 | static void __exit amimouse_exit(void) | ||
| 157 | { | ||
| 158 | platform_driver_unregister(&amimouse_driver); | ||
| 159 | } | ||
| 160 | |||
| 161 | module_exit(amimouse_exit); | ||
| 162 | 150 | ||
| 163 | MODULE_ALIAS("platform:amiga-mouse"); | 151 | MODULE_ALIAS("platform:amiga-mouse"); |
diff --git a/drivers/input/mouse/trackpoint.c b/drivers/input/mouse/trackpoint.c index f3102494237d..ca843b6cf6bd 100644 --- a/drivers/input/mouse/trackpoint.c +++ b/drivers/input/mouse/trackpoint.c | |||
| @@ -20,9 +20,34 @@ | |||
| 20 | #include "trackpoint.h" | 20 | #include "trackpoint.h" |
| 21 | 21 | ||
| 22 | /* | 22 | /* |
| 23 | * Power-on Reset: Resets all trackpoint parameters, including RAM values, | ||
| 24 | * to defaults. | ||
| 25 | * Returns zero on success, non-zero on failure. | ||
| 26 | */ | ||
| 27 | static int trackpoint_power_on_reset(struct ps2dev *ps2dev) | ||
| 28 | { | ||
| 29 | unsigned char results[2]; | ||
| 30 | int tries = 0; | ||
| 31 | |||
| 32 | /* Issue POR command, and repeat up to once if 0xFC00 received */ | ||
| 33 | do { | ||
| 34 | if (ps2_command(ps2dev, NULL, MAKE_PS2_CMD(0, 0, TP_COMMAND)) || | ||
| 35 | ps2_command(ps2dev, results, MAKE_PS2_CMD(0, 2, TP_POR))) | ||
| 36 | return -1; | ||
| 37 | } while (results[0] == 0xFC && results[1] == 0x00 && ++tries < 2); | ||
| 38 | |||
| 39 | /* Check for success response -- 0xAA00 */ | ||
| 40 | if (results[0] != 0xAA || results[1] != 0x00) | ||
| 41 | return -1; | ||
| 42 | |||
| 43 | return 0; | ||
| 44 | } | ||
| 45 | |||
| 46 | /* | ||
| 23 | * Device IO: read, write and toggle bit | 47 | * Device IO: read, write and toggle bit |
| 24 | */ | 48 | */ |
| 25 | static int trackpoint_read(struct ps2dev *ps2dev, unsigned char loc, unsigned char *results) | 49 | static int trackpoint_read(struct ps2dev *ps2dev, |
| 50 | unsigned char loc, unsigned char *results) | ||
| 26 | { | 51 | { |
| 27 | if (ps2_command(ps2dev, NULL, MAKE_PS2_CMD(0, 0, TP_COMMAND)) || | 52 | if (ps2_command(ps2dev, NULL, MAKE_PS2_CMD(0, 0, TP_COMMAND)) || |
| 28 | ps2_command(ps2dev, results, MAKE_PS2_CMD(0, 1, loc))) { | 53 | ps2_command(ps2dev, results, MAKE_PS2_CMD(0, 1, loc))) { |
| @@ -32,7 +57,8 @@ static int trackpoint_read(struct ps2dev *ps2dev, unsigned char loc, unsigned ch | |||
| 32 | return 0; | 57 | return 0; |
| 33 | } | 58 | } |
| 34 | 59 | ||
| 35 | static int trackpoint_write(struct ps2dev *ps2dev, unsigned char loc, unsigned char val) | 60 | static int trackpoint_write(struct ps2dev *ps2dev, |
| 61 | unsigned char loc, unsigned char val) | ||
| 36 | { | 62 | { |
| 37 | if (ps2_command(ps2dev, NULL, MAKE_PS2_CMD(0, 0, TP_COMMAND)) || | 63 | if (ps2_command(ps2dev, NULL, MAKE_PS2_CMD(0, 0, TP_COMMAND)) || |
| 38 | ps2_command(ps2dev, NULL, MAKE_PS2_CMD(0, 0, TP_WRITE_MEM)) || | 64 | ps2_command(ps2dev, NULL, MAKE_PS2_CMD(0, 0, TP_WRITE_MEM)) || |
| @@ -44,7 +70,8 @@ static int trackpoint_write(struct ps2dev *ps2dev, unsigned char loc, unsigned c | |||
| 44 | return 0; | 70 | return 0; |
| 45 | } | 71 | } |
| 46 | 72 | ||
| 47 | static int trackpoint_toggle_bit(struct ps2dev *ps2dev, unsigned char loc, unsigned char mask) | 73 | static int trackpoint_toggle_bit(struct ps2dev *ps2dev, |
| 74 | unsigned char loc, unsigned char mask) | ||
| 48 | { | 75 | { |
| 49 | /* Bad things will happen if the loc param isn't in this range */ | 76 | /* Bad things will happen if the loc param isn't in this range */ |
| 50 | if (loc < 0x20 || loc >= 0x2F) | 77 | if (loc < 0x20 || loc >= 0x2F) |
| @@ -60,6 +87,18 @@ static int trackpoint_toggle_bit(struct ps2dev *ps2dev, unsigned char loc, unsig | |||
| 60 | return 0; | 87 | return 0; |
| 61 | } | 88 | } |
| 62 | 89 | ||
| 90 | static int trackpoint_update_bit(struct ps2dev *ps2dev, unsigned char loc, | ||
| 91 | unsigned char mask, unsigned char value) | ||
| 92 | { | ||
| 93 | int retval = 0; | ||
| 94 | unsigned char data; | ||
| 95 | |||
| 96 | trackpoint_read(ps2dev, loc, &data); | ||
| 97 | if (((data & mask) == mask) != !!value) | ||
| 98 | retval = trackpoint_toggle_bit(ps2dev, loc, mask); | ||
| 99 | |||
| 100 | return retval; | ||
| 101 | } | ||
| 63 | 102 | ||
| 64 | /* | 103 | /* |
| 65 | * Trackpoint-specific attributes | 104 | * Trackpoint-specific attributes |
| @@ -69,6 +108,7 @@ struct trackpoint_attr_data { | |||
| 69 | unsigned char command; | 108 | unsigned char command; |
| 70 | unsigned char mask; | 109 | unsigned char mask; |
| 71 | unsigned char inverted; | 110 | unsigned char inverted; |
| 111 | unsigned char power_on_default; | ||
| 72 | }; | 112 | }; |
| 73 | 113 | ||
| 74 | static ssize_t trackpoint_show_int_attr(struct psmouse *psmouse, void *data, char *buf) | 114 | static ssize_t trackpoint_show_int_attr(struct psmouse *psmouse, void *data, char *buf) |
| @@ -102,10 +142,11 @@ static ssize_t trackpoint_set_int_attr(struct psmouse *psmouse, void *data, | |||
| 102 | return count; | 142 | return count; |
| 103 | } | 143 | } |
| 104 | 144 | ||
| 105 | #define TRACKPOINT_INT_ATTR(_name, _command) \ | 145 | #define TRACKPOINT_INT_ATTR(_name, _command, _default) \ |
| 106 | static struct trackpoint_attr_data trackpoint_attr_##_name = { \ | 146 | static struct trackpoint_attr_data trackpoint_attr_##_name = { \ |
| 107 | .field_offset = offsetof(struct trackpoint_data, _name), \ | 147 | .field_offset = offsetof(struct trackpoint_data, _name), \ |
| 108 | .command = _command, \ | 148 | .command = _command, \ |
| 149 | .power_on_default = _default, \ | ||
| 109 | }; \ | 150 | }; \ |
| 110 | PSMOUSE_DEFINE_ATTR(_name, S_IWUSR | S_IRUGO, \ | 151 | PSMOUSE_DEFINE_ATTR(_name, S_IWUSR | S_IRUGO, \ |
| 111 | &trackpoint_attr_##_name, \ | 152 | &trackpoint_attr_##_name, \ |
| @@ -139,31 +180,60 @@ static ssize_t trackpoint_set_bit_attr(struct psmouse *psmouse, void *data, | |||
| 139 | } | 180 | } |
| 140 | 181 | ||
| 141 | 182 | ||
| 142 | #define TRACKPOINT_BIT_ATTR(_name, _command, _mask, _inv) \ | 183 | #define TRACKPOINT_BIT_ATTR(_name, _command, _mask, _inv, _default) \ |
| 143 | static struct trackpoint_attr_data trackpoint_attr_##_name = { \ | 184 | static struct trackpoint_attr_data trackpoint_attr_##_name = { \ |
| 144 | .field_offset = offsetof(struct trackpoint_data, _name), \ | 185 | .field_offset = offsetof(struct trackpoint_data, \ |
| 145 | .command = _command, \ | 186 | _name), \ |
| 146 | .mask = _mask, \ | 187 | .command = _command, \ |
| 147 | .inverted = _inv, \ | 188 | .mask = _mask, \ |
| 148 | }; \ | 189 | .inverted = _inv, \ |
| 149 | PSMOUSE_DEFINE_ATTR(_name, S_IWUSR | S_IRUGO, \ | 190 | .power_on_default = _default, \ |
| 150 | &trackpoint_attr_##_name, \ | 191 | }; \ |
| 151 | trackpoint_show_int_attr, trackpoint_set_bit_attr) | 192 | PSMOUSE_DEFINE_ATTR(_name, S_IWUSR | S_IRUGO, \ |
| 152 | 193 | &trackpoint_attr_##_name, \ | |
| 153 | TRACKPOINT_INT_ATTR(sensitivity, TP_SENS); | 194 | trackpoint_show_int_attr, trackpoint_set_bit_attr) |
| 154 | TRACKPOINT_INT_ATTR(speed, TP_SPEED); | 195 | |
| 155 | TRACKPOINT_INT_ATTR(inertia, TP_INERTIA); | 196 | #define TRACKPOINT_UPDATE_BIT(_psmouse, _tp, _name) \ |
| 156 | TRACKPOINT_INT_ATTR(reach, TP_REACH); | 197 | do { \ |
| 157 | TRACKPOINT_INT_ATTR(draghys, TP_DRAGHYS); | 198 | struct trackpoint_attr_data *_attr = &trackpoint_attr_##_name; \ |
| 158 | TRACKPOINT_INT_ATTR(mindrag, TP_MINDRAG); | 199 | \ |
| 159 | TRACKPOINT_INT_ATTR(thresh, TP_THRESH); | 200 | trackpoint_update_bit(&_psmouse->ps2dev, \ |
| 160 | TRACKPOINT_INT_ATTR(upthresh, TP_UP_THRESH); | 201 | _attr->command, _attr->mask, _tp->_name); \ |
| 161 | TRACKPOINT_INT_ATTR(ztime, TP_Z_TIME); | 202 | } while (0) |
| 162 | TRACKPOINT_INT_ATTR(jenks, TP_JENKS_CURV); | 203 | |
| 163 | 204 | #define TRACKPOINT_UPDATE(_power_on, _psmouse, _tp, _name) \ | |
| 164 | TRACKPOINT_BIT_ATTR(press_to_select, TP_TOGGLE_PTSON, TP_MASK_PTSON, 0); | 205 | do { \ |
| 165 | TRACKPOINT_BIT_ATTR(skipback, TP_TOGGLE_SKIPBACK, TP_MASK_SKIPBACK, 0); | 206 | if (!_power_on || \ |
| 166 | TRACKPOINT_BIT_ATTR(ext_dev, TP_TOGGLE_EXT_DEV, TP_MASK_EXT_DEV, 1); | 207 | _tp->_name != trackpoint_attr_##_name.power_on_default) { \ |
| 208 | if (!trackpoint_attr_##_name.mask) \ | ||
| 209 | trackpoint_write(&_psmouse->ps2dev, \ | ||
| 210 | trackpoint_attr_##_name.command, \ | ||
| 211 | _tp->_name); \ | ||
| 212 | else \ | ||
| 213 | TRACKPOINT_UPDATE_BIT(_psmouse, _tp, _name); \ | ||
| 214 | } \ | ||
| 215 | } while (0) | ||
| 216 | |||
| 217 | #define TRACKPOINT_SET_POWER_ON_DEFAULT(_tp, _name) \ | ||
| 218 | (_tp->_name = trackpoint_attr_##_name.power_on_default) | ||
| 219 | |||
| 220 | TRACKPOINT_INT_ATTR(sensitivity, TP_SENS, TP_DEF_SENS); | ||
| 221 | TRACKPOINT_INT_ATTR(speed, TP_SPEED, TP_DEF_SPEED); | ||
| 222 | TRACKPOINT_INT_ATTR(inertia, TP_INERTIA, TP_DEF_INERTIA); | ||
| 223 | TRACKPOINT_INT_ATTR(reach, TP_REACH, TP_DEF_REACH); | ||
| 224 | TRACKPOINT_INT_ATTR(draghys, TP_DRAGHYS, TP_DEF_DRAGHYS); | ||
| 225 | TRACKPOINT_INT_ATTR(mindrag, TP_MINDRAG, TP_DEF_MINDRAG); | ||
| 226 | TRACKPOINT_INT_ATTR(thresh, TP_THRESH, TP_DEF_THRESH); | ||
| 227 | TRACKPOINT_INT_ATTR(upthresh, TP_UP_THRESH, TP_DEF_UP_THRESH); | ||
| 228 | TRACKPOINT_INT_ATTR(ztime, TP_Z_TIME, TP_DEF_Z_TIME); | ||
| 229 | TRACKPOINT_INT_ATTR(jenks, TP_JENKS_CURV, TP_DEF_JENKS_CURV); | ||
| 230 | |||
| 231 | TRACKPOINT_BIT_ATTR(press_to_select, TP_TOGGLE_PTSON, TP_MASK_PTSON, 0, | ||
| 232 | TP_DEF_PTSON); | ||
| 233 | TRACKPOINT_BIT_ATTR(skipback, TP_TOGGLE_SKIPBACK, TP_MASK_SKIPBACK, 0, | ||
| 234 | TP_DEF_SKIPBACK); | ||
| 235 | TRACKPOINT_BIT_ATTR(ext_dev, TP_TOGGLE_EXT_DEV, TP_MASK_EXT_DEV, 1, | ||
| 236 | TP_DEF_EXT_DEV); | ||
| 167 | 237 | ||
| 168 | static struct attribute *trackpoint_attrs[] = { | 238 | static struct attribute *trackpoint_attrs[] = { |
| 169 | &psmouse_attr_sensitivity.dattr.attr, | 239 | &psmouse_attr_sensitivity.dattr.attr, |
| @@ -202,73 +272,72 @@ static int trackpoint_start_protocol(struct psmouse *psmouse, unsigned char *fir | |||
| 202 | return 0; | 272 | return 0; |
| 203 | } | 273 | } |
| 204 | 274 | ||
| 205 | static int trackpoint_sync(struct psmouse *psmouse) | 275 | /* |
| 276 | * Write parameters to trackpad. | ||
| 277 | * in_power_on_state: Set to true if TP is in default / power-on state (ex. if | ||
| 278 | * power-on reset was run). If so, values will only be | ||
| 279 | * written to TP if they differ from power-on default. | ||
| 280 | */ | ||
| 281 | static int trackpoint_sync(struct psmouse *psmouse, bool in_power_on_state) | ||
| 206 | { | 282 | { |
| 207 | struct trackpoint_data *tp = psmouse->private; | 283 | struct trackpoint_data *tp = psmouse->private; |
| 208 | unsigned char toggle; | ||
| 209 | |||
| 210 | /* Disable features that may make device unusable with this driver */ | ||
| 211 | trackpoint_read(&psmouse->ps2dev, TP_TOGGLE_TWOHAND, &toggle); | ||
| 212 | if (toggle & TP_MASK_TWOHAND) | ||
| 213 | trackpoint_toggle_bit(&psmouse->ps2dev, TP_TOGGLE_TWOHAND, TP_MASK_TWOHAND); | ||
| 214 | |||
| 215 | trackpoint_read(&psmouse->ps2dev, TP_TOGGLE_SOURCE_TAG, &toggle); | ||
| 216 | if (toggle & TP_MASK_SOURCE_TAG) | ||
| 217 | trackpoint_toggle_bit(&psmouse->ps2dev, TP_TOGGLE_SOURCE_TAG, TP_MASK_SOURCE_TAG); | ||
| 218 | |||
| 219 | trackpoint_read(&psmouse->ps2dev, TP_TOGGLE_MB, &toggle); | ||
| 220 | if (toggle & TP_MASK_MB) | ||
| 221 | trackpoint_toggle_bit(&psmouse->ps2dev, TP_TOGGLE_MB, TP_MASK_MB); | ||
| 222 | |||
| 223 | /* Push the config to the device */ | ||
| 224 | trackpoint_write(&psmouse->ps2dev, TP_SENS, tp->sensitivity); | ||
| 225 | trackpoint_write(&psmouse->ps2dev, TP_INERTIA, tp->inertia); | ||
| 226 | trackpoint_write(&psmouse->ps2dev, TP_SPEED, tp->speed); | ||
| 227 | |||
| 228 | trackpoint_write(&psmouse->ps2dev, TP_REACH, tp->reach); | ||
| 229 | trackpoint_write(&psmouse->ps2dev, TP_DRAGHYS, tp->draghys); | ||
| 230 | trackpoint_write(&psmouse->ps2dev, TP_MINDRAG, tp->mindrag); | ||
| 231 | |||
| 232 | trackpoint_write(&psmouse->ps2dev, TP_THRESH, tp->thresh); | ||
| 233 | trackpoint_write(&psmouse->ps2dev, TP_UP_THRESH, tp->upthresh); | ||
| 234 | 284 | ||
| 235 | trackpoint_write(&psmouse->ps2dev, TP_Z_TIME, tp->ztime); | 285 | if (!in_power_on_state) { |
| 236 | trackpoint_write(&psmouse->ps2dev, TP_JENKS_CURV, tp->jenks); | 286 | /* |
| 287 | * Disable features that may make device unusable | ||
| 288 | * with this driver. | ||
| 289 | */ | ||
| 290 | trackpoint_update_bit(&psmouse->ps2dev, TP_TOGGLE_TWOHAND, | ||
| 291 | TP_MASK_TWOHAND, TP_DEF_TWOHAND); | ||
| 237 | 292 | ||
| 238 | trackpoint_read(&psmouse->ps2dev, TP_TOGGLE_PTSON, &toggle); | 293 | trackpoint_update_bit(&psmouse->ps2dev, TP_TOGGLE_SOURCE_TAG, |
| 239 | if (((toggle & TP_MASK_PTSON) == TP_MASK_PTSON) != tp->press_to_select) | 294 | TP_MASK_SOURCE_TAG, TP_DEF_SOURCE_TAG); |
| 240 | trackpoint_toggle_bit(&psmouse->ps2dev, TP_TOGGLE_PTSON, TP_MASK_PTSON); | ||
| 241 | 295 | ||
| 242 | trackpoint_read(&psmouse->ps2dev, TP_TOGGLE_SKIPBACK, &toggle); | 296 | trackpoint_update_bit(&psmouse->ps2dev, TP_TOGGLE_MB, |
| 243 | if (((toggle & TP_MASK_SKIPBACK) == TP_MASK_SKIPBACK) != tp->skipback) | 297 | TP_MASK_MB, TP_DEF_MB); |
| 244 | trackpoint_toggle_bit(&psmouse->ps2dev, TP_TOGGLE_SKIPBACK, TP_MASK_SKIPBACK); | 298 | } |
| 245 | 299 | ||
| 246 | trackpoint_read(&psmouse->ps2dev, TP_TOGGLE_EXT_DEV, &toggle); | 300 | /* |
| 247 | if (((toggle & TP_MASK_EXT_DEV) == TP_MASK_EXT_DEV) != tp->ext_dev) | 301 | * These properties can be changed in this driver. Only |
| 248 | trackpoint_toggle_bit(&psmouse->ps2dev, TP_TOGGLE_EXT_DEV, TP_MASK_EXT_DEV); | 302 | * configure them if the values are non-default or if the TP is in |
| 303 | * an unknown state. | ||
| 304 | */ | ||
| 305 | TRACKPOINT_UPDATE(in_power_on_state, psmouse, tp, sensitivity); | ||
| 306 | TRACKPOINT_UPDATE(in_power_on_state, psmouse, tp, inertia); | ||
| 307 | TRACKPOINT_UPDATE(in_power_on_state, psmouse, tp, speed); | ||
| 308 | TRACKPOINT_UPDATE(in_power_on_state, psmouse, tp, reach); | ||
| 309 | TRACKPOINT_UPDATE(in_power_on_state, psmouse, tp, draghys); | ||
| 310 | TRACKPOINT_UPDATE(in_power_on_state, psmouse, tp, mindrag); | ||
| 311 | TRACKPOINT_UPDATE(in_power_on_state, psmouse, tp, thresh); | ||
| 312 | TRACKPOINT_UPDATE(in_power_on_state, psmouse, tp, upthresh); | ||
| 313 | TRACKPOINT_UPDATE(in_power_on_state, psmouse, tp, ztime); | ||
| 314 | TRACKPOINT_UPDATE(in_power_on_state, psmouse, tp, jenks); | ||
| 315 | |||
| 316 | /* toggles */ | ||
| 317 | TRACKPOINT_UPDATE(in_power_on_state, psmouse, tp, press_to_select); | ||
| 318 | TRACKPOINT_UPDATE(in_power_on_state, psmouse, tp, skipback); | ||
| 319 | TRACKPOINT_UPDATE(in_power_on_state, psmouse, tp, ext_dev); | ||
| 249 | 320 | ||
| 250 | return 0; | 321 | return 0; |
| 251 | } | 322 | } |
| 252 | 323 | ||
| 253 | static void trackpoint_defaults(struct trackpoint_data *tp) | 324 | static void trackpoint_defaults(struct trackpoint_data *tp) |
| 254 | { | 325 | { |
| 255 | tp->press_to_select = TP_DEF_PTSON; | 326 | TRACKPOINT_SET_POWER_ON_DEFAULT(tp, sensitivity); |
| 256 | tp->sensitivity = TP_DEF_SENS; | 327 | TRACKPOINT_SET_POWER_ON_DEFAULT(tp, speed); |
| 257 | tp->speed = TP_DEF_SPEED; | 328 | TRACKPOINT_SET_POWER_ON_DEFAULT(tp, reach); |
| 258 | tp->reach = TP_DEF_REACH; | 329 | TRACKPOINT_SET_POWER_ON_DEFAULT(tp, draghys); |
| 259 | 330 | TRACKPOINT_SET_POWER_ON_DEFAULT(tp, mindrag); | |
| 260 | tp->draghys = TP_DEF_DRAGHYS; | 331 | TRACKPOINT_SET_POWER_ON_DEFAULT(tp, thresh); |
| 261 | tp->mindrag = TP_DEF_MINDRAG; | 332 | TRACKPOINT_SET_POWER_ON_DEFAULT(tp, upthresh); |
| 262 | 333 | TRACKPOINT_SET_POWER_ON_DEFAULT(tp, ztime); | |
| 263 | tp->thresh = TP_DEF_THRESH; | 334 | TRACKPOINT_SET_POWER_ON_DEFAULT(tp, jenks); |
| 264 | tp->upthresh = TP_DEF_UP_THRESH; | 335 | TRACKPOINT_SET_POWER_ON_DEFAULT(tp, inertia); |
| 265 | 336 | ||
| 266 | tp->ztime = TP_DEF_Z_TIME; | 337 | /* toggles */ |
| 267 | tp->jenks = TP_DEF_JENKS_CURV; | 338 | TRACKPOINT_SET_POWER_ON_DEFAULT(tp, press_to_select); |
| 268 | 339 | TRACKPOINT_SET_POWER_ON_DEFAULT(tp, skipback); | |
| 269 | tp->inertia = TP_DEF_INERTIA; | 340 | TRACKPOINT_SET_POWER_ON_DEFAULT(tp, ext_dev); |
| 270 | tp->skipback = TP_DEF_SKIPBACK; | ||
| 271 | tp->ext_dev = TP_DEF_EXT_DEV; | ||
| 272 | } | 341 | } |
| 273 | 342 | ||
| 274 | static void trackpoint_disconnect(struct psmouse *psmouse) | 343 | static void trackpoint_disconnect(struct psmouse *psmouse) |
| @@ -281,10 +350,13 @@ static void trackpoint_disconnect(struct psmouse *psmouse) | |||
| 281 | 350 | ||
| 282 | static int trackpoint_reconnect(struct psmouse *psmouse) | 351 | static int trackpoint_reconnect(struct psmouse *psmouse) |
| 283 | { | 352 | { |
| 353 | int reset_fail; | ||
| 354 | |||
| 284 | if (trackpoint_start_protocol(psmouse, NULL)) | 355 | if (trackpoint_start_protocol(psmouse, NULL)) |
| 285 | return -1; | 356 | return -1; |
| 286 | 357 | ||
| 287 | if (trackpoint_sync(psmouse)) | 358 | reset_fail = trackpoint_power_on_reset(&psmouse->ps2dev); |
| 359 | if (trackpoint_sync(psmouse, !reset_fail)) | ||
| 288 | return -1; | 360 | return -1; |
| 289 | 361 | ||
| 290 | return 0; | 362 | return 0; |
| @@ -322,7 +394,12 @@ int trackpoint_detect(struct psmouse *psmouse, bool set_properties) | |||
| 322 | __set_bit(BTN_MIDDLE, psmouse->dev->keybit); | 394 | __set_bit(BTN_MIDDLE, psmouse->dev->keybit); |
| 323 | 395 | ||
| 324 | trackpoint_defaults(psmouse->private); | 396 | trackpoint_defaults(psmouse->private); |
| 325 | trackpoint_sync(psmouse); | 397 | |
| 398 | error = trackpoint_power_on_reset(&psmouse->ps2dev); | ||
| 399 | |||
| 400 | /* Write defaults to TP only if reset fails. */ | ||
| 401 | if (error) | ||
| 402 | trackpoint_sync(psmouse, false); | ||
| 326 | 403 | ||
| 327 | error = sysfs_create_group(&ps2dev->serio->dev.kobj, &trackpoint_attr_group); | 404 | error = sysfs_create_group(&ps2dev->serio->dev.kobj, &trackpoint_attr_group); |
| 328 | if (error) { | 405 | if (error) { |
diff --git a/drivers/input/mouse/trackpoint.h b/drivers/input/mouse/trackpoint.h index e558a7096618..ecd0547964a5 100644 --- a/drivers/input/mouse/trackpoint.h +++ b/drivers/input/mouse/trackpoint.h | |||
| @@ -126,6 +126,8 @@ | |||
| 126 | #define TP_DEF_PTSON 0x00 | 126 | #define TP_DEF_PTSON 0x00 |
| 127 | #define TP_DEF_SKIPBACK 0x00 | 127 | #define TP_DEF_SKIPBACK 0x00 |
| 128 | #define TP_DEF_EXT_DEV 0x00 /* 0 means enabled */ | 128 | #define TP_DEF_EXT_DEV 0x00 /* 0 means enabled */ |
| 129 | #define TP_DEF_TWOHAND 0x00 | ||
| 130 | #define TP_DEF_SOURCE_TAG 0x00 | ||
| 129 | 131 | ||
| 130 | #define MAKE_PS2_CMD(params, results, cmd) ((params<<12) | (results<<8) | (cmd)) | 132 | #define MAKE_PS2_CMD(params, results, cmd) ((params<<12) | (results<<8) | (cmd)) |
| 131 | 133 | ||
| @@ -136,9 +138,9 @@ struct trackpoint_data | |||
| 136 | unsigned char thresh, upthresh; | 138 | unsigned char thresh, upthresh; |
| 137 | unsigned char ztime, jenks; | 139 | unsigned char ztime, jenks; |
| 138 | 140 | ||
| 141 | /* toggles */ | ||
| 139 | unsigned char press_to_select; | 142 | unsigned char press_to_select; |
| 140 | unsigned char skipback; | 143 | unsigned char skipback; |
| 141 | |||
| 142 | unsigned char ext_dev; | 144 | unsigned char ext_dev; |
| 143 | }; | 145 | }; |
| 144 | 146 | ||
diff --git a/drivers/input/serio/Kconfig b/drivers/input/serio/Kconfig index 3ec5ef2dd443..aebfe3ecb945 100644 --- a/drivers/input/serio/Kconfig +++ b/drivers/input/serio/Kconfig | |||
| @@ -245,4 +245,14 @@ config SERIO_ARC_PS2 | |||
| 245 | To compile this driver as a module, choose M here; the module | 245 | To compile this driver as a module, choose M here; the module |
| 246 | will be called arc_ps2. | 246 | will be called arc_ps2. |
| 247 | 247 | ||
| 248 | config SERIO_APBPS2 | ||
| 249 | tristate "GRLIB APBPS2 PS/2 keyboard/mouse controller" | ||
| 250 | depends on OF | ||
| 251 | help | ||
| 252 | Say Y here if you want support for GRLIB APBPS2 peripherals used | ||
| 253 | to connect to PS/2 keyboard and/or mouse. | ||
| 254 | |||
| 255 | To compile this driver as a module, choose M here: the module will | ||
| 256 | be called apbps2. | ||
| 257 | |||
| 248 | endif | 258 | endif |
diff --git a/drivers/input/serio/Makefile b/drivers/input/serio/Makefile index 4b0c8f84f1c1..8edb36c2cdb4 100644 --- a/drivers/input/serio/Makefile +++ b/drivers/input/serio/Makefile | |||
| @@ -26,3 +26,4 @@ obj-$(CONFIG_SERIO_AMS_DELTA) += ams_delta_serio.o | |||
| 26 | obj-$(CONFIG_SERIO_XILINX_XPS_PS2) += xilinx_ps2.o | 26 | obj-$(CONFIG_SERIO_XILINX_XPS_PS2) += xilinx_ps2.o |
| 27 | obj-$(CONFIG_SERIO_ALTERA_PS2) += altera_ps2.o | 27 | obj-$(CONFIG_SERIO_ALTERA_PS2) += altera_ps2.o |
| 28 | obj-$(CONFIG_SERIO_ARC_PS2) += arc_ps2.o | 28 | obj-$(CONFIG_SERIO_ARC_PS2) += arc_ps2.o |
| 29 | obj-$(CONFIG_SERIO_APBPS2) += apbps2.o | ||
diff --git a/drivers/input/serio/apbps2.c b/drivers/input/serio/apbps2.c new file mode 100644 index 000000000000..17e01a807ddc --- /dev/null +++ b/drivers/input/serio/apbps2.c | |||
| @@ -0,0 +1,228 @@ | |||
| 1 | /* | ||
| 2 | * Copyright (C) 2013 Aeroflex Gaisler | ||
| 3 | * | ||
| 4 | * This driver supports the APBPS2 PS/2 core available in the GRLIB | ||
| 5 | * VHDL IP core library. | ||
| 6 | * | ||
| 7 | * Full documentation of the APBPS2 core can be found here: | ||
| 8 | * http://www.gaisler.com/products/grlib/grip.pdf | ||
| 9 | * | ||
| 10 | * See "Documentation/devicetree/bindings/input/ps2keyb-mouse-apbps2.txt" for | ||
| 11 | * information on open firmware properties. | ||
| 12 | * | ||
| 13 | * This program is free software; you can redistribute it and/or modify | ||
| 14 | * it under the terms of the GNU General Public License as published by | ||
| 15 | * the Free Software Foundation; either version 2 of the License, or | ||
| 16 | * (at your option) any later version. | ||
| 17 | * | ||
| 18 | * Contributors: Daniel Hellstrom <daniel@gaisler.com> | ||
| 19 | */ | ||
| 20 | #include <linux/platform_device.h> | ||
| 21 | #include <linux/of_device.h> | ||
| 22 | #include <linux/module.h> | ||
| 23 | #include <linux/serio.h> | ||
| 24 | #include <linux/errno.h> | ||
| 25 | #include <linux/interrupt.h> | ||
| 26 | #include <linux/of_irq.h> | ||
| 27 | #include <linux/device.h> | ||
| 28 | #include <linux/delay.h> | ||
| 29 | #include <linux/err.h> | ||
| 30 | #include <linux/slab.h> | ||
| 31 | #include <linux/string.h> | ||
| 32 | #include <linux/kernel.h> | ||
| 33 | #include <linux/io.h> | ||
| 34 | |||
| 35 | struct apbps2_regs { | ||
| 36 | u32 __iomem data; /* 0x00 */ | ||
| 37 | u32 __iomem status; /* 0x04 */ | ||
| 38 | u32 __iomem ctrl; /* 0x08 */ | ||
| 39 | u32 __iomem reload; /* 0x0c */ | ||
| 40 | }; | ||
| 41 | |||
| 42 | #define APBPS2_STATUS_DR (1<<0) | ||
| 43 | #define APBPS2_STATUS_PE (1<<1) | ||
| 44 | #define APBPS2_STATUS_FE (1<<2) | ||
| 45 | #define APBPS2_STATUS_KI (1<<3) | ||
| 46 | #define APBPS2_STATUS_RF (1<<4) | ||
| 47 | #define APBPS2_STATUS_TF (1<<5) | ||
| 48 | #define APBPS2_STATUS_TCNT (0x1f<<22) | ||
| 49 | #define APBPS2_STATUS_RCNT (0x1f<<27) | ||
| 50 | |||
| 51 | #define APBPS2_CTRL_RE (1<<0) | ||
| 52 | #define APBPS2_CTRL_TE (1<<1) | ||
| 53 | #define APBPS2_CTRL_RI (1<<2) | ||
| 54 | #define APBPS2_CTRL_TI (1<<3) | ||
| 55 | |||
| 56 | struct apbps2_priv { | ||
| 57 | struct serio *io; | ||
| 58 | struct apbps2_regs *regs; | ||
| 59 | }; | ||
| 60 | |||
| 61 | static int apbps2_idx; | ||
| 62 | |||
| 63 | static irqreturn_t apbps2_isr(int irq, void *dev_id) | ||
| 64 | { | ||
| 65 | struct apbps2_priv *priv = dev_id; | ||
| 66 | unsigned long status, data, rxflags; | ||
| 67 | irqreturn_t ret = IRQ_NONE; | ||
| 68 | |||
| 69 | while ((status = ioread32be(&priv->regs->status)) & APBPS2_STATUS_DR) { | ||
| 70 | data = ioread32be(&priv->regs->data); | ||
| 71 | rxflags = (status & APBPS2_STATUS_PE) ? SERIO_PARITY : 0; | ||
| 72 | rxflags |= (status & APBPS2_STATUS_FE) ? SERIO_FRAME : 0; | ||
| 73 | |||
| 74 | /* clear error bits? */ | ||
| 75 | if (rxflags) | ||
| 76 | iowrite32be(0, &priv->regs->status); | ||
| 77 | |||
| 78 | serio_interrupt(priv->io, data, rxflags); | ||
| 79 | |||
| 80 | ret = IRQ_HANDLED; | ||
| 81 | } | ||
| 82 | |||
| 83 | return ret; | ||
| 84 | } | ||
| 85 | |||
| 86 | static int apbps2_write(struct serio *io, unsigned char val) | ||
| 87 | { | ||
| 88 | struct apbps2_priv *priv = io->port_data; | ||
| 89 | unsigned int tleft = 10000; /* timeout in 100ms */ | ||
| 90 | |||
| 91 | /* delay until PS/2 controller has room for more chars */ | ||
| 92 | while ((ioread32be(&priv->regs->status) & APBPS2_STATUS_TF) && tleft--) | ||
| 93 | udelay(10); | ||
| 94 | |||
| 95 | if ((ioread32be(&priv->regs->status) & APBPS2_STATUS_TF) == 0) { | ||
| 96 | iowrite32be(val, &priv->regs->data); | ||
| 97 | |||
| 98 | iowrite32be(APBPS2_CTRL_RE | APBPS2_CTRL_RI | APBPS2_CTRL_TE, | ||
| 99 | &priv->regs->ctrl); | ||
| 100 | return 0; | ||
| 101 | } | ||
| 102 | |||
| 103 | return -ETIMEDOUT; | ||
| 104 | } | ||
| 105 | |||
| 106 | static int apbps2_open(struct serio *io) | ||
| 107 | { | ||
| 108 | struct apbps2_priv *priv = io->port_data; | ||
| 109 | int limit; | ||
| 110 | unsigned long tmp; | ||
| 111 | |||
| 112 | /* clear error flags */ | ||
| 113 | iowrite32be(0, &priv->regs->status); | ||
| 114 | |||
| 115 | /* Clear old data if available (unlikely) */ | ||
| 116 | limit = 1024; | ||
| 117 | while ((ioread32be(&priv->regs->status) & APBPS2_STATUS_DR) && --limit) | ||
| 118 | tmp = ioread32be(&priv->regs->data); | ||
| 119 | |||
| 120 | /* Enable reciever and it's interrupt */ | ||
| 121 | iowrite32be(APBPS2_CTRL_RE | APBPS2_CTRL_RI, &priv->regs->ctrl); | ||
| 122 | |||
| 123 | return 0; | ||
| 124 | } | ||
| 125 | |||
| 126 | static void apbps2_close(struct serio *io) | ||
| 127 | { | ||
| 128 | struct apbps2_priv *priv = io->port_data; | ||
| 129 | |||
| 130 | /* stop interrupts at PS/2 HW level */ | ||
| 131 | iowrite32be(0, &priv->regs->ctrl); | ||
| 132 | } | ||
| 133 | |||
| 134 | /* Initialize one APBPS2 PS/2 core */ | ||
| 135 | static int apbps2_of_probe(struct platform_device *ofdev) | ||
| 136 | { | ||
| 137 | struct apbps2_priv *priv; | ||
| 138 | int irq, err; | ||
| 139 | u32 freq_hz; | ||
| 140 | struct resource *res; | ||
| 141 | |||
| 142 | priv = devm_kzalloc(&ofdev->dev, sizeof(*priv), GFP_KERNEL); | ||
| 143 | if (!priv) { | ||
| 144 | dev_err(&ofdev->dev, "memory allocation failed\n"); | ||
| 145 | return -ENOMEM; | ||
| 146 | } | ||
| 147 | |||
| 148 | /* Find Device Address */ | ||
| 149 | res = platform_get_resource(ofdev, IORESOURCE_MEM, 0); | ||
| 150 | priv->regs = devm_ioremap_resource(&ofdev->dev, res); | ||
| 151 | if (IS_ERR(priv->regs)) | ||
| 152 | return PTR_ERR(priv->regs); | ||
| 153 | |||
| 154 | /* Reset hardware, disable interrupt */ | ||
| 155 | iowrite32be(0, &priv->regs->ctrl); | ||
| 156 | |||
| 157 | /* IRQ */ | ||
| 158 | irq = irq_of_parse_and_map(ofdev->dev.of_node, 0); | ||
| 159 | err = devm_request_irq(&ofdev->dev, irq, apbps2_isr, | ||
| 160 | IRQF_SHARED, "apbps2", priv); | ||
| 161 | if (err) { | ||
| 162 | dev_err(&ofdev->dev, "request IRQ%d failed\n", irq); | ||
| 163 | return err; | ||
| 164 | } | ||
| 165 | |||
| 166 | /* Get core frequency */ | ||
| 167 | if (of_property_read_u32(ofdev->dev.of_node, "freq", &freq_hz)) { | ||
| 168 | dev_err(&ofdev->dev, "unable to get core frequency\n"); | ||
| 169 | return -EINVAL; | ||
| 170 | } | ||
| 171 | |||
| 172 | /* Set reload register to core freq in kHz/10 */ | ||
| 173 | iowrite32be(freq_hz / 10000, &priv->regs->reload); | ||
| 174 | |||
| 175 | priv->io = kzalloc(sizeof(struct serio), GFP_KERNEL); | ||
| 176 | if (!priv->io) | ||
| 177 | return -ENOMEM; | ||
| 178 | |||
| 179 | priv->io->id.type = SERIO_8042; | ||
| 180 | priv->io->open = apbps2_open; | ||
| 181 | priv->io->close = apbps2_close; | ||
| 182 | priv->io->write = apbps2_write; | ||
| 183 | priv->io->port_data = priv; | ||
| 184 | strlcpy(priv->io->name, "APBPS2 PS/2", sizeof(priv->io->name)); | ||
| 185 | snprintf(priv->io->phys, sizeof(priv->io->phys), | ||
| 186 | "apbps2_%d", apbps2_idx++); | ||
| 187 | |||
| 188 | dev_info(&ofdev->dev, "irq = %d, base = 0x%p\n", irq, priv->regs); | ||
| 189 | |||
| 190 | serio_register_port(priv->io); | ||
| 191 | |||
| 192 | platform_set_drvdata(ofdev, priv); | ||
| 193 | |||
| 194 | return 0; | ||
| 195 | } | ||
| 196 | |||
| 197 | static int apbps2_of_remove(struct platform_device *of_dev) | ||
| 198 | { | ||
| 199 | struct apbps2_priv *priv = platform_get_drvdata(of_dev); | ||
| 200 | |||
| 201 | serio_unregister_port(priv->io); | ||
| 202 | |||
| 203 | return 0; | ||
| 204 | } | ||
| 205 | |||
| 206 | static struct of_device_id apbps2_of_match[] = { | ||
| 207 | { .name = "GAISLER_APBPS2", }, | ||
| 208 | { .name = "01_060", }, | ||
| 209 | {} | ||
| 210 | }; | ||
| 211 | |||
| 212 | MODULE_DEVICE_TABLE(of, apbps2_of_match); | ||
| 213 | |||
| 214 | static struct platform_driver apbps2_of_driver = { | ||
| 215 | .driver = { | ||
| 216 | .name = "grlib-apbps2", | ||
| 217 | .owner = THIS_MODULE, | ||
| 218 | .of_match_table = apbps2_of_match, | ||
| 219 | }, | ||
| 220 | .probe = apbps2_of_probe, | ||
| 221 | .remove = apbps2_of_remove, | ||
| 222 | }; | ||
| 223 | |||
| 224 | module_platform_driver(apbps2_of_driver); | ||
| 225 | |||
| 226 | MODULE_AUTHOR("Aeroflex Gaisler AB."); | ||
| 227 | MODULE_DESCRIPTION("GRLIB APBPS2 PS/2 serial I/O"); | ||
| 228 | MODULE_LICENSE("GPL"); | ||
diff --git a/drivers/input/serio/arc_ps2.c b/drivers/input/serio/arc_ps2.c index c52e3e589f72..3fb7727c8ea5 100644 --- a/drivers/input/serio/arc_ps2.c +++ b/drivers/input/serio/arc_ps2.c | |||
| @@ -14,6 +14,7 @@ | |||
| 14 | #include <linux/input.h> | 14 | #include <linux/input.h> |
| 15 | #include <linux/serio.h> | 15 | #include <linux/serio.h> |
| 16 | #include <linux/platform_device.h> | 16 | #include <linux/platform_device.h> |
| 17 | #include <linux/of.h> | ||
| 17 | #include <linux/io.h> | 18 | #include <linux/io.h> |
| 18 | #include <linux/kernel.h> | 19 | #include <linux/kernel.h> |
| 19 | #include <linux/slab.h> | 20 | #include <linux/slab.h> |
| @@ -259,10 +260,19 @@ static int arc_ps2_remove(struct platform_device *pdev) | |||
| 259 | return 0; | 260 | return 0; |
| 260 | } | 261 | } |
| 261 | 262 | ||
| 263 | #ifdef CONFIG_OF | ||
| 264 | static const struct of_device_id arc_ps2_match[] = { | ||
| 265 | { .compatible = "snps,arc_ps2" }, | ||
| 266 | { }, | ||
| 267 | }; | ||
| 268 | MODULE_DEVICE_TABLE(of, arc_ps2_match); | ||
| 269 | #endif | ||
| 270 | |||
| 262 | static struct platform_driver arc_ps2_driver = { | 271 | static struct platform_driver arc_ps2_driver = { |
| 263 | .driver = { | 272 | .driver = { |
| 264 | .name = "arc_ps2", | 273 | .name = "arc_ps2", |
| 265 | .owner = THIS_MODULE, | 274 | .owner = THIS_MODULE, |
| 275 | .of_match_table = of_match_ptr(arc_ps2_match), | ||
| 266 | }, | 276 | }, |
| 267 | .probe = arc_ps2_probe, | 277 | .probe = arc_ps2_probe, |
| 268 | .remove = arc_ps2_remove, | 278 | .remove = arc_ps2_remove, |
diff --git a/drivers/input/serio/at32psif.c b/drivers/input/serio/at32psif.c index 36e799c31f5e..190ce35af7df 100644 --- a/drivers/input/serio/at32psif.c +++ b/drivers/input/serio/at32psif.c | |||
| @@ -359,18 +359,7 @@ static struct platform_driver psif_driver = { | |||
| 359 | }, | 359 | }, |
| 360 | }; | 360 | }; |
| 361 | 361 | ||
| 362 | static int __init psif_init(void) | 362 | module_platform_driver_probe(psif_driver, psif_probe); |
| 363 | { | ||
| 364 | return platform_driver_probe(&psif_driver, psif_probe); | ||
| 365 | } | ||
| 366 | |||
| 367 | static void __exit psif_exit(void) | ||
| 368 | { | ||
| 369 | platform_driver_unregister(&psif_driver); | ||
| 370 | } | ||
| 371 | |||
| 372 | module_init(psif_init); | ||
| 373 | module_exit(psif_exit); | ||
| 374 | 363 | ||
| 375 | MODULE_AUTHOR("Hans-Christian Egtvedt <egtvedt@samfundet.no>"); | 364 | MODULE_AUTHOR("Hans-Christian Egtvedt <egtvedt@samfundet.no>"); |
| 376 | MODULE_DESCRIPTION("Atmel AVR32 PSIF PS/2 driver"); | 365 | MODULE_DESCRIPTION("Atmel AVR32 PSIF PS/2 driver"); |
diff --git a/drivers/input/serio/q40kbd.c b/drivers/input/serio/q40kbd.c index 70fe542839fb..436a3433f8e5 100644 --- a/drivers/input/serio/q40kbd.c +++ b/drivers/input/serio/q40kbd.c | |||
| @@ -193,15 +193,4 @@ static struct platform_driver q40kbd_driver = { | |||
| 193 | .remove = q40kbd_remove, | 193 | .remove = q40kbd_remove, |
| 194 | }; | 194 | }; |
| 195 | 195 | ||
| 196 | static int __init q40kbd_init(void) | 196 | module_platform_driver_probe(q40kbd_driver, q40kbd_probe); |
| 197 | { | ||
| 198 | return platform_driver_probe(&q40kbd_driver, q40kbd_probe); | ||
| 199 | } | ||
| 200 | |||
| 201 | static void __exit q40kbd_exit(void) | ||
| 202 | { | ||
| 203 | platform_driver_unregister(&q40kbd_driver); | ||
| 204 | } | ||
| 205 | |||
| 206 | module_init(q40kbd_init); | ||
| 207 | module_exit(q40kbd_exit); | ||
diff --git a/drivers/input/touchscreen/ad7877.c b/drivers/input/touchscreen/ad7877.c index 23fa829b869d..f3a174a83c82 100644 --- a/drivers/input/touchscreen/ad7877.c +++ b/drivers/input/touchscreen/ad7877.c | |||
| @@ -273,7 +273,7 @@ static int ad7877_write(struct spi_device *spi, u16 reg, u16 val) | |||
| 273 | 273 | ||
| 274 | static int ad7877_read_adc(struct spi_device *spi, unsigned command) | 274 | static int ad7877_read_adc(struct spi_device *spi, unsigned command) |
| 275 | { | 275 | { |
| 276 | struct ad7877 *ts = dev_get_drvdata(&spi->dev); | 276 | struct ad7877 *ts = spi_get_drvdata(spi); |
| 277 | struct ser_req *req; | 277 | struct ser_req *req; |
| 278 | int status; | 278 | int status; |
| 279 | int sample; | 279 | int sample; |
| @@ -720,7 +720,7 @@ static int ad7877_probe(struct spi_device *spi) | |||
| 720 | goto err_free_mem; | 720 | goto err_free_mem; |
| 721 | } | 721 | } |
| 722 | 722 | ||
| 723 | dev_set_drvdata(&spi->dev, ts); | 723 | spi_set_drvdata(spi, ts); |
| 724 | ts->spi = spi; | 724 | ts->spi = spi; |
| 725 | ts->input = input_dev; | 725 | ts->input = input_dev; |
| 726 | 726 | ||
| @@ -806,13 +806,13 @@ err_free_irq: | |||
| 806 | err_free_mem: | 806 | err_free_mem: |
| 807 | input_free_device(input_dev); | 807 | input_free_device(input_dev); |
| 808 | kfree(ts); | 808 | kfree(ts); |
| 809 | dev_set_drvdata(&spi->dev, NULL); | 809 | spi_set_drvdata(spi, NULL); |
| 810 | return err; | 810 | return err; |
| 811 | } | 811 | } |
| 812 | 812 | ||
| 813 | static int ad7877_remove(struct spi_device *spi) | 813 | static int ad7877_remove(struct spi_device *spi) |
| 814 | { | 814 | { |
| 815 | struct ad7877 *ts = dev_get_drvdata(&spi->dev); | 815 | struct ad7877 *ts = spi_get_drvdata(spi); |
| 816 | 816 | ||
| 817 | sysfs_remove_group(&spi->dev.kobj, &ad7877_attr_group); | 817 | sysfs_remove_group(&spi->dev.kobj, &ad7877_attr_group); |
| 818 | 818 | ||
| @@ -823,7 +823,7 @@ static int ad7877_remove(struct spi_device *spi) | |||
| 823 | kfree(ts); | 823 | kfree(ts); |
| 824 | 824 | ||
| 825 | dev_dbg(&spi->dev, "unregistered touchscreen\n"); | 825 | dev_dbg(&spi->dev, "unregistered touchscreen\n"); |
| 826 | dev_set_drvdata(&spi->dev, NULL); | 826 | spi_set_drvdata(spi, NULL); |
| 827 | 827 | ||
| 828 | return 0; | 828 | return 0; |
| 829 | } | 829 | } |
diff --git a/drivers/input/touchscreen/ads7846.c b/drivers/input/touchscreen/ads7846.c index 434c3df250ca..84ccf140c1bb 100644 --- a/drivers/input/touchscreen/ads7846.c +++ b/drivers/input/touchscreen/ads7846.c | |||
| @@ -1245,7 +1245,7 @@ static int ads7846_probe(struct spi_device *spi) | |||
| 1245 | goto err_free_mem; | 1245 | goto err_free_mem; |
| 1246 | } | 1246 | } |
| 1247 | 1247 | ||
| 1248 | dev_set_drvdata(&spi->dev, ts); | 1248 | spi_set_drvdata(spi, ts); |
| 1249 | 1249 | ||
| 1250 | ts->packet = packet; | 1250 | ts->packet = packet; |
| 1251 | ts->spi = spi; | 1251 | ts->spi = spi; |
| @@ -1397,7 +1397,7 @@ static int ads7846_probe(struct spi_device *spi) | |||
| 1397 | 1397 | ||
| 1398 | static int ads7846_remove(struct spi_device *spi) | 1398 | static int ads7846_remove(struct spi_device *spi) |
| 1399 | { | 1399 | { |
| 1400 | struct ads7846 *ts = dev_get_drvdata(&spi->dev); | 1400 | struct ads7846 *ts = spi_get_drvdata(spi); |
| 1401 | 1401 | ||
| 1402 | device_init_wakeup(&spi->dev, false); | 1402 | device_init_wakeup(&spi->dev, false); |
| 1403 | 1403 | ||
diff --git a/drivers/input/touchscreen/atmel-wm97xx.c b/drivers/input/touchscreen/atmel-wm97xx.c index c5c2dbb93869..2c1e46b7e45b 100644 --- a/drivers/input/touchscreen/atmel-wm97xx.c +++ b/drivers/input/touchscreen/atmel-wm97xx.c | |||
| @@ -432,17 +432,7 @@ static struct platform_driver atmel_wm97xx_driver = { | |||
| 432 | }, | 432 | }, |
| 433 | }; | 433 | }; |
| 434 | 434 | ||
| 435 | static int __init atmel_wm97xx_init(void) | 435 | module_platform_driver_probe(atmel_wm97xx_driver, atmel_wm97xx_probe); |
| 436 | { | ||
| 437 | return platform_driver_probe(&atmel_wm97xx_driver, atmel_wm97xx_probe); | ||
| 438 | } | ||
| 439 | module_init(atmel_wm97xx_init); | ||
| 440 | |||
| 441 | static void __exit atmel_wm97xx_exit(void) | ||
| 442 | { | ||
| 443 | platform_driver_unregister(&atmel_wm97xx_driver); | ||
| 444 | } | ||
| 445 | module_exit(atmel_wm97xx_exit); | ||
| 446 | 436 | ||
| 447 | MODULE_AUTHOR("Hans-Christian Egtvedt <egtvedt@samfundet.no>"); | 437 | MODULE_AUTHOR("Hans-Christian Egtvedt <egtvedt@samfundet.no>"); |
| 448 | MODULE_DESCRIPTION("wm97xx continuous touch driver for Atmel AT91 and AVR32"); | 438 | MODULE_DESCRIPTION("wm97xx continuous touch driver for Atmel AT91 and AVR32"); |
diff --git a/drivers/input/touchscreen/auo-pixcir-ts.c b/drivers/input/touchscreen/auo-pixcir-ts.c index c6e19a96348e..d3f9f6b0f9b7 100644 --- a/drivers/input/touchscreen/auo-pixcir-ts.c +++ b/drivers/input/touchscreen/auo-pixcir-ts.c | |||
| @@ -31,6 +31,8 @@ | |||
| 31 | #include <linux/delay.h> | 31 | #include <linux/delay.h> |
| 32 | #include <linux/gpio.h> | 32 | #include <linux/gpio.h> |
| 33 | #include <linux/input/auo-pixcir-ts.h> | 33 | #include <linux/input/auo-pixcir-ts.h> |
| 34 | #include <linux/of.h> | ||
| 35 | #include <linux/of_gpio.h> | ||
| 34 | 36 | ||
| 35 | /* | 37 | /* |
| 36 | * Coordinate calculation: | 38 | * Coordinate calculation: |
| @@ -111,6 +113,7 @@ | |||
| 111 | struct auo_pixcir_ts { | 113 | struct auo_pixcir_ts { |
| 112 | struct i2c_client *client; | 114 | struct i2c_client *client; |
| 113 | struct input_dev *input; | 115 | struct input_dev *input; |
| 116 | const struct auo_pixcir_ts_platdata *pdata; | ||
| 114 | char phys[32]; | 117 | char phys[32]; |
| 115 | 118 | ||
| 116 | /* special handling for touch_indicate interupt mode */ | 119 | /* special handling for touch_indicate interupt mode */ |
| @@ -132,7 +135,7 @@ static int auo_pixcir_collect_data(struct auo_pixcir_ts *ts, | |||
| 132 | struct auo_point_t *point) | 135 | struct auo_point_t *point) |
| 133 | { | 136 | { |
| 134 | struct i2c_client *client = ts->client; | 137 | struct i2c_client *client = ts->client; |
| 135 | const struct auo_pixcir_ts_platdata *pdata = client->dev.platform_data; | 138 | const struct auo_pixcir_ts_platdata *pdata = ts->pdata; |
| 136 | uint8_t raw_coord[8]; | 139 | uint8_t raw_coord[8]; |
| 137 | uint8_t raw_area[4]; | 140 | uint8_t raw_area[4]; |
| 138 | int i, ret; | 141 | int i, ret; |
| @@ -178,8 +181,7 @@ static int auo_pixcir_collect_data(struct auo_pixcir_ts *ts, | |||
| 178 | static irqreturn_t auo_pixcir_interrupt(int irq, void *dev_id) | 181 | static irqreturn_t auo_pixcir_interrupt(int irq, void *dev_id) |
| 179 | { | 182 | { |
| 180 | struct auo_pixcir_ts *ts = dev_id; | 183 | struct auo_pixcir_ts *ts = dev_id; |
| 181 | struct i2c_client *client = ts->client; | 184 | const struct auo_pixcir_ts_platdata *pdata = ts->pdata; |
| 182 | const struct auo_pixcir_ts_platdata *pdata = client->dev.platform_data; | ||
| 183 | struct auo_point_t point[AUO_PIXCIR_REPORT_POINTS]; | 185 | struct auo_point_t point[AUO_PIXCIR_REPORT_POINTS]; |
| 184 | int i; | 186 | int i; |
| 185 | int ret; | 187 | int ret; |
| @@ -290,7 +292,7 @@ static int auo_pixcir_int_config(struct auo_pixcir_ts *ts, | |||
| 290 | int int_setting) | 292 | int int_setting) |
| 291 | { | 293 | { |
| 292 | struct i2c_client *client = ts->client; | 294 | struct i2c_client *client = ts->client; |
| 293 | struct auo_pixcir_ts_platdata *pdata = client->dev.platform_data; | 295 | const struct auo_pixcir_ts_platdata *pdata = ts->pdata; |
| 294 | int ret; | 296 | int ret; |
| 295 | 297 | ||
| 296 | ret = i2c_smbus_read_byte_data(client, AUO_PIXCIR_REG_INT_SETTING); | 298 | ret = i2c_smbus_read_byte_data(client, AUO_PIXCIR_REG_INT_SETTING); |
| @@ -479,53 +481,105 @@ unlock: | |||
| 479 | } | 481 | } |
| 480 | #endif | 482 | #endif |
| 481 | 483 | ||
| 482 | static SIMPLE_DEV_PM_OPS(auo_pixcir_pm_ops, auo_pixcir_suspend, | 484 | static SIMPLE_DEV_PM_OPS(auo_pixcir_pm_ops, |
| 483 | auo_pixcir_resume); | 485 | auo_pixcir_suspend, auo_pixcir_resume); |
| 486 | |||
| 487 | #ifdef CONFIG_OF | ||
| 488 | static struct auo_pixcir_ts_platdata *auo_pixcir_parse_dt(struct device *dev) | ||
| 489 | { | ||
| 490 | struct auo_pixcir_ts_platdata *pdata; | ||
| 491 | struct device_node *np = dev->of_node; | ||
| 492 | |||
| 493 | if (!np) | ||
| 494 | return ERR_PTR(-ENOENT); | ||
| 495 | |||
| 496 | pdata = devm_kzalloc(dev, sizeof(*pdata), GFP_KERNEL); | ||
| 497 | if (!pdata) { | ||
| 498 | dev_err(dev, "failed to allocate platform data\n"); | ||
| 499 | return ERR_PTR(-ENOMEM); | ||
| 500 | } | ||
| 501 | |||
| 502 | pdata->gpio_int = of_get_gpio(np, 0); | ||
| 503 | if (!gpio_is_valid(pdata->gpio_int)) { | ||
| 504 | dev_err(dev, "failed to get interrupt gpio\n"); | ||
| 505 | return ERR_PTR(-EINVAL); | ||
| 506 | } | ||
| 507 | |||
| 508 | pdata->gpio_rst = of_get_gpio(np, 1); | ||
| 509 | if (!gpio_is_valid(pdata->gpio_rst)) { | ||
| 510 | dev_err(dev, "failed to get reset gpio\n"); | ||
| 511 | return ERR_PTR(-EINVAL); | ||
| 512 | } | ||
| 513 | |||
| 514 | if (of_property_read_u32(np, "x-size", &pdata->x_max)) { | ||
| 515 | dev_err(dev, "failed to get x-size property\n"); | ||
| 516 | return ERR_PTR(-EINVAL); | ||
| 517 | } | ||
| 518 | |||
| 519 | if (of_property_read_u32(np, "y-size", &pdata->y_max)) { | ||
| 520 | dev_err(dev, "failed to get y-size property\n"); | ||
| 521 | return ERR_PTR(-EINVAL); | ||
| 522 | } | ||
| 523 | |||
| 524 | /* default to asserting the interrupt when the screen is touched */ | ||
| 525 | pdata->int_setting = AUO_PIXCIR_INT_TOUCH_IND; | ||
| 526 | |||
| 527 | return pdata; | ||
| 528 | } | ||
| 529 | #else | ||
| 530 | static struct auo_pixcir_ts_platdata *auo_pixcir_parse_dt(struct device *dev) | ||
| 531 | { | ||
| 532 | return ERR_PTR(-EINVAL); | ||
| 533 | } | ||
| 534 | #endif | ||
| 535 | |||
| 536 | static void auo_pixcir_reset(void *data) | ||
| 537 | { | ||
| 538 | struct auo_pixcir_ts *ts = data; | ||
| 539 | |||
| 540 | gpio_set_value(ts->pdata->gpio_rst, 0); | ||
| 541 | } | ||
| 484 | 542 | ||
| 485 | static int auo_pixcir_probe(struct i2c_client *client, | 543 | static int auo_pixcir_probe(struct i2c_client *client, |
| 486 | const struct i2c_device_id *id) | 544 | const struct i2c_device_id *id) |
| 487 | { | 545 | { |
| 488 | const struct auo_pixcir_ts_platdata *pdata = client->dev.platform_data; | 546 | const struct auo_pixcir_ts_platdata *pdata; |
| 489 | struct auo_pixcir_ts *ts; | 547 | struct auo_pixcir_ts *ts; |
| 490 | struct input_dev *input_dev; | 548 | struct input_dev *input_dev; |
| 491 | int ret; | 549 | int version; |
| 492 | 550 | int error; | |
| 493 | if (!pdata) | 551 | |
| 494 | return -EINVAL; | 552 | pdata = dev_get_platdata(&client->dev); |
| 553 | if (!pdata) { | ||
| 554 | pdata = auo_pixcir_parse_dt(&client->dev); | ||
| 555 | if (IS_ERR(pdata)) | ||
| 556 | return PTR_ERR(pdata); | ||
| 557 | } | ||
| 495 | 558 | ||
| 496 | ts = kzalloc(sizeof(struct auo_pixcir_ts), GFP_KERNEL); | 559 | ts = devm_kzalloc(&client->dev, |
| 560 | sizeof(struct auo_pixcir_ts), GFP_KERNEL); | ||
| 497 | if (!ts) | 561 | if (!ts) |
| 498 | return -ENOMEM; | 562 | return -ENOMEM; |
| 499 | 563 | ||
| 500 | ret = gpio_request(pdata->gpio_int, "auo_pixcir_ts_int"); | 564 | input_dev = devm_input_allocate_device(&client->dev); |
| 501 | if (ret) { | 565 | if (!input_dev) { |
| 502 | dev_err(&client->dev, "request of gpio %d failed, %d\n", | 566 | dev_err(&client->dev, "could not allocate input device\n"); |
| 503 | pdata->gpio_int, ret); | 567 | return -ENOMEM; |
| 504 | goto err_gpio_int; | ||
| 505 | } | 568 | } |
| 506 | 569 | ||
| 507 | if (pdata->init_hw) | 570 | ts->pdata = pdata; |
| 508 | pdata->init_hw(client); | ||
| 509 | |||
| 510 | ts->client = client; | 571 | ts->client = client; |
| 572 | ts->input = input_dev; | ||
| 511 | ts->touch_ind_mode = 0; | 573 | ts->touch_ind_mode = 0; |
| 574 | ts->stopped = true; | ||
| 512 | init_waitqueue_head(&ts->wait); | 575 | init_waitqueue_head(&ts->wait); |
| 513 | 576 | ||
| 514 | snprintf(ts->phys, sizeof(ts->phys), | 577 | snprintf(ts->phys, sizeof(ts->phys), |
| 515 | "%s/input0", dev_name(&client->dev)); | 578 | "%s/input0", dev_name(&client->dev)); |
| 516 | 579 | ||
| 517 | input_dev = input_allocate_device(); | ||
| 518 | if (!input_dev) { | ||
| 519 | dev_err(&client->dev, "could not allocate input device\n"); | ||
| 520 | goto err_input_alloc; | ||
| 521 | } | ||
| 522 | |||
| 523 | ts->input = input_dev; | ||
| 524 | |||
| 525 | input_dev->name = "AUO-Pixcir touchscreen"; | 580 | input_dev->name = "AUO-Pixcir touchscreen"; |
| 526 | input_dev->phys = ts->phys; | 581 | input_dev->phys = ts->phys; |
| 527 | input_dev->id.bustype = BUS_I2C; | 582 | input_dev->id.bustype = BUS_I2C; |
| 528 | input_dev->dev.parent = &client->dev; | ||
| 529 | 583 | ||
| 530 | input_dev->open = auo_pixcir_input_open; | 584 | input_dev->open = auo_pixcir_input_open; |
| 531 | input_dev->close = auo_pixcir_input_close; | 585 | input_dev->close = auo_pixcir_input_close; |
| @@ -550,70 +604,70 @@ static int auo_pixcir_probe(struct i2c_client *client, | |||
| 550 | AUO_PIXCIR_MAX_AREA, 0, 0); | 604 | AUO_PIXCIR_MAX_AREA, 0, 0); |
| 551 | input_set_abs_params(input_dev, ABS_MT_ORIENTATION, 0, 1, 0, 0); | 605 | input_set_abs_params(input_dev, ABS_MT_ORIENTATION, 0, 1, 0, 0); |
| 552 | 606 | ||
| 553 | ret = i2c_smbus_read_byte_data(client, AUO_PIXCIR_REG_VERSION); | ||
| 554 | if (ret < 0) | ||
| 555 | goto err_fw_vers; | ||
| 556 | dev_info(&client->dev, "firmware version 0x%X\n", ret); | ||
| 557 | |||
| 558 | ret = auo_pixcir_int_config(ts, pdata->int_setting); | ||
| 559 | if (ret) | ||
| 560 | goto err_fw_vers; | ||
| 561 | |||
| 562 | input_set_drvdata(ts->input, ts); | 607 | input_set_drvdata(ts->input, ts); |
| 563 | ts->stopped = true; | ||
| 564 | 608 | ||
| 565 | ret = request_threaded_irq(client->irq, NULL, auo_pixcir_interrupt, | 609 | error = devm_gpio_request_one(&client->dev, pdata->gpio_int, |
| 566 | IRQF_TRIGGER_RISING | IRQF_ONESHOT, | 610 | GPIOF_DIR_IN, "auo_pixcir_ts_int"); |
| 567 | input_dev->name, ts); | 611 | if (error) { |
| 568 | if (ret) { | 612 | dev_err(&client->dev, "request of gpio %d failed, %d\n", |
| 569 | dev_err(&client->dev, "irq %d requested failed\n", client->irq); | 613 | pdata->gpio_int, error); |
| 570 | goto err_fw_vers; | 614 | return error; |
| 571 | } | 615 | } |
| 572 | 616 | ||
| 573 | /* stop device and put it into deep sleep until it is opened */ | 617 | error = devm_gpio_request_one(&client->dev, pdata->gpio_rst, |
| 574 | ret = auo_pixcir_stop(ts); | 618 | GPIOF_DIR_OUT | GPIOF_INIT_HIGH, |
| 575 | if (ret < 0) | 619 | "auo_pixcir_ts_rst"); |
| 576 | goto err_input_register; | 620 | if (error) { |
| 577 | 621 | dev_err(&client->dev, "request of gpio %d failed, %d\n", | |
| 578 | ret = input_register_device(input_dev); | 622 | pdata->gpio_rst, error); |
| 579 | if (ret) { | 623 | return error; |
| 580 | dev_err(&client->dev, "could not register input device\n"); | ||
| 581 | goto err_input_register; | ||
| 582 | } | 624 | } |
| 583 | 625 | ||
| 584 | i2c_set_clientdata(client, ts); | 626 | error = devm_add_action(&client->dev, auo_pixcir_reset, ts); |
| 585 | 627 | if (error) { | |
| 586 | return 0; | 628 | auo_pixcir_reset(ts); |
| 629 | dev_err(&client->dev, "failed to register reset action, %d\n", | ||
| 630 | error); | ||
| 631 | return error; | ||
| 632 | } | ||
| 587 | 633 | ||
| 588 | err_input_register: | 634 | msleep(200); |
| 589 | free_irq(client->irq, ts); | ||
| 590 | err_fw_vers: | ||
| 591 | input_free_device(input_dev); | ||
| 592 | err_input_alloc: | ||
| 593 | if (pdata->exit_hw) | ||
| 594 | pdata->exit_hw(client); | ||
| 595 | gpio_free(pdata->gpio_int); | ||
| 596 | err_gpio_int: | ||
| 597 | kfree(ts); | ||
| 598 | 635 | ||
| 599 | return ret; | 636 | version = i2c_smbus_read_byte_data(client, AUO_PIXCIR_REG_VERSION); |
| 600 | } | 637 | if (version < 0) { |
| 601 | 638 | error = version; | |
| 602 | static int auo_pixcir_remove(struct i2c_client *client) | 639 | return error; |
| 603 | { | 640 | } |
| 604 | struct auo_pixcir_ts *ts = i2c_get_clientdata(client); | ||
| 605 | const struct auo_pixcir_ts_platdata *pdata = client->dev.platform_data; | ||
| 606 | 641 | ||
| 607 | free_irq(client->irq, ts); | 642 | dev_info(&client->dev, "firmware version 0x%X\n", version); |
| 608 | 643 | ||
| 609 | input_unregister_device(ts->input); | 644 | error = auo_pixcir_int_config(ts, pdata->int_setting); |
| 645 | if (error) | ||
| 646 | return error; | ||
| 610 | 647 | ||
| 611 | if (pdata->exit_hw) | 648 | error = devm_request_threaded_irq(&client->dev, client->irq, |
| 612 | pdata->exit_hw(client); | 649 | NULL, auo_pixcir_interrupt, |
| 650 | IRQF_TRIGGER_RISING | IRQF_ONESHOT, | ||
| 651 | input_dev->name, ts); | ||
| 652 | if (error) { | ||
| 653 | dev_err(&client->dev, "irq %d requested failed, %d\n", | ||
| 654 | client->irq, error); | ||
| 655 | return error; | ||
| 656 | } | ||
| 613 | 657 | ||
| 614 | gpio_free(pdata->gpio_int); | 658 | /* stop device and put it into deep sleep until it is opened */ |
| 659 | error = auo_pixcir_stop(ts); | ||
| 660 | if (error) | ||
| 661 | return error; | ||
| 662 | |||
| 663 | error = input_register_device(input_dev); | ||
| 664 | if (error) { | ||
| 665 | dev_err(&client->dev, "could not register input device, %d\n", | ||
| 666 | error); | ||
| 667 | return error; | ||
| 668 | } | ||
| 615 | 669 | ||
| 616 | kfree(ts); | 670 | i2c_set_clientdata(client, ts); |
| 617 | 671 | ||
| 618 | return 0; | 672 | return 0; |
| 619 | } | 673 | } |
| @@ -624,14 +678,22 @@ static const struct i2c_device_id auo_pixcir_idtable[] = { | |||
| 624 | }; | 678 | }; |
| 625 | MODULE_DEVICE_TABLE(i2c, auo_pixcir_idtable); | 679 | MODULE_DEVICE_TABLE(i2c, auo_pixcir_idtable); |
| 626 | 680 | ||
| 681 | #ifdef CONFIG_OF | ||
| 682 | static struct of_device_id auo_pixcir_ts_dt_idtable[] = { | ||
| 683 | { .compatible = "auo,auo_pixcir_ts" }, | ||
| 684 | {}, | ||
| 685 | }; | ||
| 686 | MODULE_DEVICE_TABLE(of, auo_pixcir_ts_dt_idtable); | ||
| 687 | #endif | ||
| 688 | |||
| 627 | static struct i2c_driver auo_pixcir_driver = { | 689 | static struct i2c_driver auo_pixcir_driver = { |
| 628 | .driver = { | 690 | .driver = { |
| 629 | .owner = THIS_MODULE, | 691 | .owner = THIS_MODULE, |
| 630 | .name = "auo_pixcir_ts", | 692 | .name = "auo_pixcir_ts", |
| 631 | .pm = &auo_pixcir_pm_ops, | 693 | .pm = &auo_pixcir_pm_ops, |
| 694 | .of_match_table = of_match_ptr(auo_pixcir_ts_dt_idtable), | ||
| 632 | }, | 695 | }, |
| 633 | .probe = auo_pixcir_probe, | 696 | .probe = auo_pixcir_probe, |
| 634 | .remove = auo_pixcir_remove, | ||
| 635 | .id_table = auo_pixcir_idtable, | 697 | .id_table = auo_pixcir_idtable, |
| 636 | }; | 698 | }; |
| 637 | 699 | ||
diff --git a/drivers/input/touchscreen/edt-ft5x06.c b/drivers/input/touchscreen/edt-ft5x06.c index a9170157b442..83fa1b15a97f 100644 --- a/drivers/input/touchscreen/edt-ft5x06.c +++ b/drivers/input/touchscreen/edt-ft5x06.c | |||
| @@ -440,8 +440,7 @@ static int edt_ft5x06_work_mode(struct edt_ft5x06_ts_data *tsdata) | |||
| 440 | return -EIO; | 440 | return -EIO; |
| 441 | } | 441 | } |
| 442 | 442 | ||
| 443 | if (tsdata->raw_buffer) | 443 | kfree(tsdata->raw_buffer); |
| 444 | kfree(tsdata->raw_buffer); | ||
| 445 | tsdata->raw_buffer = NULL; | 444 | tsdata->raw_buffer = NULL; |
| 446 | 445 | ||
| 447 | /* restore parameters */ | 446 | /* restore parameters */ |
diff --git a/drivers/input/touchscreen/eeti_ts.c b/drivers/input/touchscreen/eeti_ts.c index 55255a940072..8fe5086c8d2e 100644 --- a/drivers/input/touchscreen/eeti_ts.c +++ b/drivers/input/touchscreen/eeti_ts.c | |||
| @@ -206,8 +206,7 @@ static int eeti_ts_probe(struct i2c_client *client, | |||
| 206 | if (err < 0) | 206 | if (err < 0) |
| 207 | goto err1; | 207 | goto err1; |
| 208 | 208 | ||
| 209 | if (pdata) | 209 | priv->irq_active_high = pdata->irq_active_high; |
| 210 | priv->irq_active_high = pdata->irq_active_high; | ||
| 211 | 210 | ||
| 212 | irq_flags = priv->irq_active_high ? | 211 | irq_flags = priv->irq_active_high ? |
| 213 | IRQF_TRIGGER_RISING : IRQF_TRIGGER_FALLING; | 212 | IRQF_TRIGGER_RISING : IRQF_TRIGGER_FALLING; |
diff --git a/drivers/input/touchscreen/mc13783_ts.c b/drivers/input/touchscreen/mc13783_ts.c index 02103b6abb39..89308fe38752 100644 --- a/drivers/input/touchscreen/mc13783_ts.c +++ b/drivers/input/touchscreen/mc13783_ts.c | |||
| @@ -250,17 +250,7 @@ static struct platform_driver mc13783_ts_driver = { | |||
| 250 | }, | 250 | }, |
| 251 | }; | 251 | }; |
| 252 | 252 | ||
| 253 | static int __init mc13783_ts_init(void) | 253 | module_platform_driver_probe(mc13783_ts_driver, mc13783_ts_probe); |
| 254 | { | ||
| 255 | return platform_driver_probe(&mc13783_ts_driver, &mc13783_ts_probe); | ||
| 256 | } | ||
| 257 | module_init(mc13783_ts_init); | ||
| 258 | |||
| 259 | static void __exit mc13783_ts_exit(void) | ||
| 260 | { | ||
| 261 | platform_driver_unregister(&mc13783_ts_driver); | ||
| 262 | } | ||
| 263 | module_exit(mc13783_ts_exit); | ||
| 264 | 254 | ||
| 265 | MODULE_DESCRIPTION("MC13783 input touchscreen driver"); | 255 | MODULE_DESCRIPTION("MC13783 input touchscreen driver"); |
| 266 | MODULE_AUTHOR("Sascha Hauer <s.hauer@pengutronix.de>"); | 256 | MODULE_AUTHOR("Sascha Hauer <s.hauer@pengutronix.de>"); |
diff --git a/drivers/input/touchscreen/st1232.c b/drivers/input/touchscreen/st1232.c index d9d05e222428..1740a2496371 100644 --- a/drivers/input/touchscreen/st1232.c +++ b/drivers/input/touchscreen/st1232.c | |||
| @@ -19,13 +19,16 @@ | |||
| 19 | */ | 19 | */ |
| 20 | 20 | ||
| 21 | #include <linux/delay.h> | 21 | #include <linux/delay.h> |
| 22 | #include <linux/gpio.h> | ||
| 22 | #include <linux/i2c.h> | 23 | #include <linux/i2c.h> |
| 23 | #include <linux/input.h> | 24 | #include <linux/input.h> |
| 24 | #include <linux/interrupt.h> | 25 | #include <linux/interrupt.h> |
| 25 | #include <linux/module.h> | 26 | #include <linux/module.h> |
| 27 | #include <linux/of_gpio.h> | ||
| 26 | #include <linux/pm_qos.h> | 28 | #include <linux/pm_qos.h> |
| 27 | #include <linux/slab.h> | 29 | #include <linux/slab.h> |
| 28 | #include <linux/types.h> | 30 | #include <linux/types.h> |
| 31 | #include <linux/platform_data/st1232_pdata.h> | ||
| 29 | 32 | ||
| 30 | #define ST1232_TS_NAME "st1232-ts" | 33 | #define ST1232_TS_NAME "st1232-ts" |
| 31 | 34 | ||
| @@ -48,6 +51,7 @@ struct st1232_ts_data { | |||
| 48 | struct input_dev *input_dev; | 51 | struct input_dev *input_dev; |
| 49 | struct st1232_ts_finger finger[MAX_FINGERS]; | 52 | struct st1232_ts_finger finger[MAX_FINGERS]; |
| 50 | struct dev_pm_qos_request low_latency_req; | 53 | struct dev_pm_qos_request low_latency_req; |
| 54 | int reset_gpio; | ||
| 51 | }; | 55 | }; |
| 52 | 56 | ||
| 53 | static int st1232_ts_read_data(struct st1232_ts_data *ts) | 57 | static int st1232_ts_read_data(struct st1232_ts_data *ts) |
| @@ -139,10 +143,17 @@ end: | |||
| 139 | return IRQ_HANDLED; | 143 | return IRQ_HANDLED; |
| 140 | } | 144 | } |
| 141 | 145 | ||
| 146 | static void st1232_ts_power(struct st1232_ts_data *ts, bool poweron) | ||
| 147 | { | ||
| 148 | if (gpio_is_valid(ts->reset_gpio)) | ||
| 149 | gpio_direction_output(ts->reset_gpio, poweron); | ||
| 150 | } | ||
| 151 | |||
| 142 | static int st1232_ts_probe(struct i2c_client *client, | 152 | static int st1232_ts_probe(struct i2c_client *client, |
| 143 | const struct i2c_device_id *id) | 153 | const struct i2c_device_id *id) |
| 144 | { | 154 | { |
| 145 | struct st1232_ts_data *ts; | 155 | struct st1232_ts_data *ts; |
| 156 | struct st1232_pdata *pdata = client->dev.platform_data; | ||
| 146 | struct input_dev *input_dev; | 157 | struct input_dev *input_dev; |
| 147 | int error; | 158 | int error; |
| 148 | 159 | ||
| @@ -156,17 +167,36 @@ static int st1232_ts_probe(struct i2c_client *client, | |||
| 156 | return -EINVAL; | 167 | return -EINVAL; |
| 157 | } | 168 | } |
| 158 | 169 | ||
| 170 | ts = devm_kzalloc(&client->dev, sizeof(*ts), GFP_KERNEL); | ||
| 171 | if (!ts) | ||
| 172 | return -ENOMEM; | ||
| 159 | 173 | ||
| 160 | ts = kzalloc(sizeof(struct st1232_ts_data), GFP_KERNEL); | 174 | input_dev = devm_input_allocate_device(&client->dev); |
| 161 | input_dev = input_allocate_device(); | 175 | if (!input_dev) |
| 162 | if (!ts || !input_dev) { | 176 | return -ENOMEM; |
| 163 | error = -ENOMEM; | ||
| 164 | goto err_free_mem; | ||
| 165 | } | ||
| 166 | 177 | ||
| 167 | ts->client = client; | 178 | ts->client = client; |
| 168 | ts->input_dev = input_dev; | 179 | ts->input_dev = input_dev; |
| 169 | 180 | ||
| 181 | if (pdata) | ||
| 182 | ts->reset_gpio = pdata->reset_gpio; | ||
| 183 | else if (client->dev.of_node) | ||
| 184 | ts->reset_gpio = of_get_gpio(client->dev.of_node, 0); | ||
| 185 | else | ||
| 186 | ts->reset_gpio = -ENODEV; | ||
| 187 | |||
| 188 | if (gpio_is_valid(ts->reset_gpio)) { | ||
| 189 | error = devm_gpio_request(&client->dev, ts->reset_gpio, NULL); | ||
| 190 | if (error) { | ||
| 191 | dev_err(&client->dev, | ||
| 192 | "Unable to request GPIO pin %d.\n", | ||
| 193 | ts->reset_gpio); | ||
| 194 | return error; | ||
| 195 | } | ||
| 196 | } | ||
| 197 | |||
| 198 | st1232_ts_power(ts, true); | ||
| 199 | |||
| 170 | input_dev->name = "st1232-touchscreen"; | 200 | input_dev->name = "st1232-touchscreen"; |
| 171 | input_dev->id.bustype = BUS_I2C; | 201 | input_dev->id.bustype = BUS_I2C; |
| 172 | input_dev->dev.parent = &client->dev; | 202 | input_dev->dev.parent = &client->dev; |
| @@ -179,31 +209,26 @@ static int st1232_ts_probe(struct i2c_client *client, | |||
| 179 | input_set_abs_params(input_dev, ABS_MT_POSITION_X, MIN_X, MAX_X, 0, 0); | 209 | input_set_abs_params(input_dev, ABS_MT_POSITION_X, MIN_X, MAX_X, 0, 0); |
| 180 | input_set_abs_params(input_dev, ABS_MT_POSITION_Y, MIN_Y, MAX_Y, 0, 0); | 210 | input_set_abs_params(input_dev, ABS_MT_POSITION_Y, MIN_Y, MAX_Y, 0, 0); |
| 181 | 211 | ||
| 182 | error = request_threaded_irq(client->irq, NULL, st1232_ts_irq_handler, | 212 | error = devm_request_threaded_irq(&client->dev, client->irq, |
| 183 | IRQF_ONESHOT, client->name, ts); | 213 | NULL, st1232_ts_irq_handler, |
| 214 | IRQF_ONESHOT, | ||
| 215 | client->name, ts); | ||
| 184 | if (error) { | 216 | if (error) { |
| 185 | dev_err(&client->dev, "Failed to register interrupt\n"); | 217 | dev_err(&client->dev, "Failed to register interrupt\n"); |
| 186 | goto err_free_mem; | 218 | return error; |
| 187 | } | 219 | } |
| 188 | 220 | ||
| 189 | error = input_register_device(ts->input_dev); | 221 | error = input_register_device(ts->input_dev); |
| 190 | if (error) { | 222 | if (error) { |
| 191 | dev_err(&client->dev, "Unable to register %s input device\n", | 223 | dev_err(&client->dev, "Unable to register %s input device\n", |
| 192 | input_dev->name); | 224 | input_dev->name); |
| 193 | goto err_free_irq; | 225 | return error; |
| 194 | } | 226 | } |
| 195 | 227 | ||
| 196 | i2c_set_clientdata(client, ts); | 228 | i2c_set_clientdata(client, ts); |
| 197 | device_init_wakeup(&client->dev, 1); | 229 | device_init_wakeup(&client->dev, 1); |
| 198 | 230 | ||
| 199 | return 0; | 231 | return 0; |
| 200 | |||
| 201 | err_free_irq: | ||
| 202 | free_irq(client->irq, ts); | ||
| 203 | err_free_mem: | ||
| 204 | input_free_device(input_dev); | ||
| 205 | kfree(ts); | ||
| 206 | return error; | ||
| 207 | } | 232 | } |
| 208 | 233 | ||
| 209 | static int st1232_ts_remove(struct i2c_client *client) | 234 | static int st1232_ts_remove(struct i2c_client *client) |
| @@ -211,9 +236,7 @@ static int st1232_ts_remove(struct i2c_client *client) | |||
| 211 | struct st1232_ts_data *ts = i2c_get_clientdata(client); | 236 | struct st1232_ts_data *ts = i2c_get_clientdata(client); |
| 212 | 237 | ||
| 213 | device_init_wakeup(&client->dev, 0); | 238 | device_init_wakeup(&client->dev, 0); |
| 214 | free_irq(client->irq, ts); | 239 | st1232_ts_power(ts, false); |
| 215 | input_unregister_device(ts->input_dev); | ||
| 216 | kfree(ts); | ||
| 217 | 240 | ||
| 218 | return 0; | 241 | return 0; |
| 219 | } | 242 | } |
| @@ -222,11 +245,14 @@ static int st1232_ts_remove(struct i2c_client *client) | |||
| 222 | static int st1232_ts_suspend(struct device *dev) | 245 | static int st1232_ts_suspend(struct device *dev) |
| 223 | { | 246 | { |
| 224 | struct i2c_client *client = to_i2c_client(dev); | 247 | struct i2c_client *client = to_i2c_client(dev); |
| 248 | struct st1232_ts_data *ts = i2c_get_clientdata(client); | ||
| 225 | 249 | ||
| 226 | if (device_may_wakeup(&client->dev)) | 250 | if (device_may_wakeup(&client->dev)) { |
| 227 | enable_irq_wake(client->irq); | 251 | enable_irq_wake(client->irq); |
| 228 | else | 252 | } else { |
| 229 | disable_irq(client->irq); | 253 | disable_irq(client->irq); |
| 254 | st1232_ts_power(ts, false); | ||
| 255 | } | ||
| 230 | 256 | ||
| 231 | return 0; | 257 | return 0; |
| 232 | } | 258 | } |
| @@ -234,11 +260,14 @@ static int st1232_ts_suspend(struct device *dev) | |||
| 234 | static int st1232_ts_resume(struct device *dev) | 260 | static int st1232_ts_resume(struct device *dev) |
| 235 | { | 261 | { |
| 236 | struct i2c_client *client = to_i2c_client(dev); | 262 | struct i2c_client *client = to_i2c_client(dev); |
| 263 | struct st1232_ts_data *ts = i2c_get_clientdata(client); | ||
| 237 | 264 | ||
| 238 | if (device_may_wakeup(&client->dev)) | 265 | if (device_may_wakeup(&client->dev)) { |
| 239 | disable_irq_wake(client->irq); | 266 | disable_irq_wake(client->irq); |
| 240 | else | 267 | } else { |
| 268 | st1232_ts_power(ts, true); | ||
| 241 | enable_irq(client->irq); | 269 | enable_irq(client->irq); |
| 270 | } | ||
| 242 | 271 | ||
| 243 | return 0; | 272 | return 0; |
| 244 | } | 273 | } |
diff --git a/drivers/input/touchscreen/wm9712.c b/drivers/input/touchscreen/wm9712.c index 6e743e3dfda4..16b52115c27f 100644 --- a/drivers/input/touchscreen/wm9712.c +++ b/drivers/input/touchscreen/wm9712.c | |||
| @@ -162,14 +162,14 @@ static void wm9712_phy_init(struct wm97xx *wm) | |||
| 162 | if (rpu) { | 162 | if (rpu) { |
| 163 | dig2 &= 0xffc0; | 163 | dig2 &= 0xffc0; |
| 164 | dig2 |= WM9712_RPU(rpu); | 164 | dig2 |= WM9712_RPU(rpu); |
| 165 | dev_dbg(wm->dev, "setting pen detect pull-up to %d Ohms", | 165 | dev_dbg(wm->dev, "setting pen detect pull-up to %d Ohms\n", |
| 166 | 64000 / rpu); | 166 | 64000 / rpu); |
| 167 | } | 167 | } |
| 168 | 168 | ||
| 169 | /* WM9712 five wire */ | 169 | /* WM9712 five wire */ |
| 170 | if (five_wire) { | 170 | if (five_wire) { |
| 171 | dig2 |= WM9712_45W; | 171 | dig2 |= WM9712_45W; |
| 172 | dev_dbg(wm->dev, "setting 5-wire touchscreen mode."); | 172 | dev_dbg(wm->dev, "setting 5-wire touchscreen mode.\n"); |
| 173 | 173 | ||
| 174 | if (pil) { | 174 | if (pil) { |
| 175 | dev_warn(wm->dev, "pressure measurement is not " | 175 | dev_warn(wm->dev, "pressure measurement is not " |
| @@ -182,21 +182,21 @@ static void wm9712_phy_init(struct wm97xx *wm) | |||
| 182 | if (pil == 2) { | 182 | if (pil == 2) { |
| 183 | dig2 |= WM9712_PIL; | 183 | dig2 |= WM9712_PIL; |
| 184 | dev_dbg(wm->dev, | 184 | dev_dbg(wm->dev, |
| 185 | "setting pressure measurement current to 400uA."); | 185 | "setting pressure measurement current to 400uA.\n"); |
| 186 | } else if (pil) | 186 | } else if (pil) |
| 187 | dev_dbg(wm->dev, | 187 | dev_dbg(wm->dev, |
| 188 | "setting pressure measurement current to 200uA."); | 188 | "setting pressure measurement current to 200uA.\n"); |
| 189 | if (!pil) | 189 | if (!pil) |
| 190 | pressure = 0; | 190 | pressure = 0; |
| 191 | 191 | ||
| 192 | /* polling mode sample settling delay */ | 192 | /* polling mode sample settling delay */ |
| 193 | if (delay < 0 || delay > 15) { | 193 | if (delay < 0 || delay > 15) { |
| 194 | dev_dbg(wm->dev, "supplied delay out of range."); | 194 | dev_dbg(wm->dev, "supplied delay out of range.\n"); |
| 195 | delay = 4; | 195 | delay = 4; |
| 196 | } | 196 | } |
| 197 | dig1 &= 0xff0f; | 197 | dig1 &= 0xff0f; |
| 198 | dig1 |= WM97XX_DELAY(delay); | 198 | dig1 |= WM97XX_DELAY(delay); |
| 199 | dev_dbg(wm->dev, "setting adc sample delay to %d u Secs.", | 199 | dev_dbg(wm->dev, "setting adc sample delay to %d u Secs.\n", |
| 200 | delay_table[delay]); | 200 | delay_table[delay]); |
| 201 | 201 | ||
| 202 | /* mask */ | 202 | /* mask */ |
| @@ -285,7 +285,7 @@ static int wm9712_poll_sample(struct wm97xx *wm, int adcsel, int *sample) | |||
| 285 | if (is_pden(wm)) | 285 | if (is_pden(wm)) |
| 286 | wm->pen_probably_down = 0; | 286 | wm->pen_probably_down = 0; |
| 287 | else | 287 | else |
| 288 | dev_dbg(wm->dev, "adc sample timeout"); | 288 | dev_dbg(wm->dev, "adc sample timeout\n"); |
| 289 | return RC_PENUP; | 289 | return RC_PENUP; |
| 290 | } | 290 | } |
| 291 | 291 | ||
| @@ -295,15 +295,19 @@ static int wm9712_poll_sample(struct wm97xx *wm, int adcsel, int *sample) | |||
| 295 | 295 | ||
| 296 | /* check we have correct sample */ | 296 | /* check we have correct sample */ |
| 297 | if ((*sample ^ adcsel) & WM97XX_ADCSEL_MASK) { | 297 | if ((*sample ^ adcsel) & WM97XX_ADCSEL_MASK) { |
| 298 | dev_dbg(wm->dev, "adc wrong sample, wanted %x got %x", | 298 | dev_dbg(wm->dev, "adc wrong sample, wanted %x got %x\n", |
| 299 | adcsel & WM97XX_ADCSEL_MASK, | 299 | adcsel & WM97XX_ADCSEL_MASK, |
| 300 | *sample & WM97XX_ADCSEL_MASK); | 300 | *sample & WM97XX_ADCSEL_MASK); |
| 301 | return RC_PENUP; | 301 | return RC_AGAIN; |
| 302 | } | 302 | } |
| 303 | 303 | ||
| 304 | if (wants_pen && !(*sample & WM97XX_PEN_DOWN)) { | 304 | if (wants_pen && !(*sample & WM97XX_PEN_DOWN)) { |
| 305 | wm->pen_probably_down = 0; | 305 | /* Sometimes it reads a wrong value the first time. */ |
| 306 | return RC_PENUP; | 306 | *sample = wm97xx_reg_read(wm, AC97_WM97XX_DIGITISER_RD); |
| 307 | if (!(*sample & WM97XX_PEN_DOWN)) { | ||
| 308 | wm->pen_probably_down = 0; | ||
| 309 | return RC_PENUP; | ||
| 310 | } | ||
| 307 | } | 311 | } |
| 308 | 312 | ||
| 309 | return RC_VALID; | 313 | return RC_VALID; |
| @@ -345,7 +349,7 @@ static int wm9712_poll_coord(struct wm97xx *wm, struct wm97xx_data *data) | |||
| 345 | if (is_pden(wm)) | 349 | if (is_pden(wm)) |
| 346 | wm->pen_probably_down = 0; | 350 | wm->pen_probably_down = 0; |
| 347 | else | 351 | else |
| 348 | dev_dbg(wm->dev, "adc sample timeout"); | 352 | dev_dbg(wm->dev, "adc sample timeout\n"); |
| 349 | return RC_PENUP; | 353 | return RC_PENUP; |
| 350 | } | 354 | } |
| 351 | 355 | ||
diff --git a/drivers/input/touchscreen/wm97xx-core.c b/drivers/input/touchscreen/wm97xx-core.c index 5dbe73af2f8f..7e45c9f6e6b7 100644 --- a/drivers/input/touchscreen/wm97xx-core.c +++ b/drivers/input/touchscreen/wm97xx-core.c | |||
| @@ -442,6 +442,16 @@ static int wm97xx_read_samples(struct wm97xx *wm) | |||
| 442 | "pen down: x=%x:%d, y=%x:%d, pressure=%x:%d\n", | 442 | "pen down: x=%x:%d, y=%x:%d, pressure=%x:%d\n", |
| 443 | data.x >> 12, data.x & 0xfff, data.y >> 12, | 443 | data.x >> 12, data.x & 0xfff, data.y >> 12, |
| 444 | data.y & 0xfff, data.p >> 12, data.p & 0xfff); | 444 | data.y & 0xfff, data.p >> 12, data.p & 0xfff); |
| 445 | |||
| 446 | if (abs_x[0] > (data.x & 0xfff) || | ||
| 447 | abs_x[1] < (data.x & 0xfff) || | ||
| 448 | abs_y[0] > (data.y & 0xfff) || | ||
| 449 | abs_y[1] < (data.y & 0xfff)) { | ||
| 450 | dev_dbg(wm->dev, "Measurement out of range, dropping it\n"); | ||
| 451 | rc = RC_AGAIN; | ||
| 452 | goto out; | ||
| 453 | } | ||
| 454 | |||
| 445 | input_report_abs(wm->input_dev, ABS_X, data.x & 0xfff); | 455 | input_report_abs(wm->input_dev, ABS_X, data.x & 0xfff); |
| 446 | input_report_abs(wm->input_dev, ABS_Y, data.y & 0xfff); | 456 | input_report_abs(wm->input_dev, ABS_Y, data.y & 0xfff); |
| 447 | input_report_abs(wm->input_dev, ABS_PRESSURE, data.p & 0xfff); | 457 | input_report_abs(wm->input_dev, ABS_PRESSURE, data.p & 0xfff); |
| @@ -455,6 +465,7 @@ static int wm97xx_read_samples(struct wm97xx *wm) | |||
| 455 | wm->ts_reader_interval = wm->ts_reader_min_interval; | 465 | wm->ts_reader_interval = wm->ts_reader_min_interval; |
| 456 | } | 466 | } |
| 457 | 467 | ||
| 468 | out: | ||
| 458 | mutex_unlock(&wm->codec_mutex); | 469 | mutex_unlock(&wm->codec_mutex); |
| 459 | return rc; | 470 | return rc; |
| 460 | } | 471 | } |
diff --git a/drivers/tty/sysrq.c b/drivers/tty/sysrq.c index 0a0de333c765..b51c15408ff3 100644 --- a/drivers/tty/sysrq.c +++ b/drivers/tty/sysrq.c | |||
| @@ -43,6 +43,7 @@ | |||
| 43 | #include <linux/input.h> | 43 | #include <linux/input.h> |
| 44 | #include <linux/uaccess.h> | 44 | #include <linux/uaccess.h> |
| 45 | #include <linux/moduleparam.h> | 45 | #include <linux/moduleparam.h> |
| 46 | #include <linux/jiffies.h> | ||
| 46 | 47 | ||
| 47 | #include <asm/ptrace.h> | 48 | #include <asm/ptrace.h> |
| 48 | #include <asm/irq_regs.h> | 49 | #include <asm/irq_regs.h> |
| @@ -51,6 +52,9 @@ | |||
| 51 | static int __read_mostly sysrq_enabled = SYSRQ_DEFAULT_ENABLE; | 52 | static int __read_mostly sysrq_enabled = SYSRQ_DEFAULT_ENABLE; |
| 52 | static bool __read_mostly sysrq_always_enabled; | 53 | static bool __read_mostly sysrq_always_enabled; |
| 53 | 54 | ||
| 55 | unsigned short platform_sysrq_reset_seq[] __weak = { KEY_RESERVED }; | ||
| 56 | int sysrq_reset_downtime_ms __weak; | ||
| 57 | |||
| 54 | static bool sysrq_on(void) | 58 | static bool sysrq_on(void) |
| 55 | { | 59 | { |
| 56 | return sysrq_enabled || sysrq_always_enabled; | 60 | return sysrq_enabled || sysrq_always_enabled; |
| @@ -586,6 +590,7 @@ struct sysrq_state { | |||
| 586 | int reset_seq_len; | 590 | int reset_seq_len; |
| 587 | int reset_seq_cnt; | 591 | int reset_seq_cnt; |
| 588 | int reset_seq_version; | 592 | int reset_seq_version; |
| 593 | struct timer_list keyreset_timer; | ||
| 589 | }; | 594 | }; |
| 590 | 595 | ||
| 591 | #define SYSRQ_KEY_RESET_MAX 20 /* Should be plenty */ | 596 | #define SYSRQ_KEY_RESET_MAX 20 /* Should be plenty */ |
| @@ -619,29 +624,51 @@ static void sysrq_parse_reset_sequence(struct sysrq_state *state) | |||
| 619 | state->reset_seq_version = sysrq_reset_seq_version; | 624 | state->reset_seq_version = sysrq_reset_seq_version; |
| 620 | } | 625 | } |
| 621 | 626 | ||
| 622 | static bool sysrq_detect_reset_sequence(struct sysrq_state *state, | 627 | static void sysrq_do_reset(unsigned long dummy) |
| 628 | { | ||
| 629 | __handle_sysrq(sysrq_xlate[KEY_B], false); | ||
| 630 | } | ||
| 631 | |||
| 632 | static void sysrq_handle_reset_request(struct sysrq_state *state) | ||
| 633 | { | ||
| 634 | if (sysrq_reset_downtime_ms) | ||
| 635 | mod_timer(&state->keyreset_timer, | ||
| 636 | jiffies + msecs_to_jiffies(sysrq_reset_downtime_ms)); | ||
| 637 | else | ||
| 638 | sysrq_do_reset(0); | ||
| 639 | } | ||
| 640 | |||
| 641 | static void sysrq_detect_reset_sequence(struct sysrq_state *state, | ||
| 623 | unsigned int code, int value) | 642 | unsigned int code, int value) |
| 624 | { | 643 | { |
| 625 | if (!test_bit(code, state->reset_keybit)) { | 644 | if (!test_bit(code, state->reset_keybit)) { |
| 626 | /* | 645 | /* |
| 627 | * Pressing any key _not_ in reset sequence cancels | 646 | * Pressing any key _not_ in reset sequence cancels |
| 628 | * the reset sequence. | 647 | * the reset sequence. Also cancelling the timer in |
| 648 | * case additional keys were pressed after a reset | ||
| 649 | * has been requested. | ||
| 629 | */ | 650 | */ |
| 630 | if (value && state->reset_seq_cnt) | 651 | if (value && state->reset_seq_cnt) { |
| 631 | state->reset_canceled = true; | 652 | state->reset_canceled = true; |
| 653 | del_timer(&state->keyreset_timer); | ||
| 654 | } | ||
| 632 | } else if (value == 0) { | 655 | } else if (value == 0) { |
| 633 | /* key release */ | 656 | /* |
| 657 | * Key release - all keys in the reset sequence need | ||
| 658 | * to be pressed and held for the reset timeout | ||
| 659 | * to hold. | ||
| 660 | */ | ||
| 661 | del_timer(&state->keyreset_timer); | ||
| 662 | |||
| 634 | if (--state->reset_seq_cnt == 0) | 663 | if (--state->reset_seq_cnt == 0) |
| 635 | state->reset_canceled = false; | 664 | state->reset_canceled = false; |
| 636 | } else if (value == 1) { | 665 | } else if (value == 1) { |
| 637 | /* key press, not autorepeat */ | 666 | /* key press, not autorepeat */ |
| 638 | if (++state->reset_seq_cnt == state->reset_seq_len && | 667 | if (++state->reset_seq_cnt == state->reset_seq_len && |
| 639 | !state->reset_canceled) { | 668 | !state->reset_canceled) { |
| 640 | return true; | 669 | sysrq_handle_reset_request(state); |
| 641 | } | 670 | } |
| 642 | } | 671 | } |
| 643 | |||
| 644 | return false; | ||
| 645 | } | 672 | } |
| 646 | 673 | ||
| 647 | static void sysrq_reinject_alt_sysrq(struct work_struct *work) | 674 | static void sysrq_reinject_alt_sysrq(struct work_struct *work) |
| @@ -748,10 +775,8 @@ static bool sysrq_handle_keypress(struct sysrq_state *sysrq, | |||
| 748 | if (was_active) | 775 | if (was_active) |
| 749 | schedule_work(&sysrq->reinject_work); | 776 | schedule_work(&sysrq->reinject_work); |
| 750 | 777 | ||
| 751 | if (sysrq_detect_reset_sequence(sysrq, code, value)) { | 778 | /* Check for reset sequence */ |
| 752 | /* Force emergency reboot */ | 779 | sysrq_detect_reset_sequence(sysrq, code, value); |
| 753 | __handle_sysrq(sysrq_xlate[KEY_B], false); | ||
| 754 | } | ||
| 755 | 780 | ||
| 756 | } else if (value == 0 && test_and_clear_bit(code, sysrq->key_down)) { | 781 | } else if (value == 0 && test_and_clear_bit(code, sysrq->key_down)) { |
| 757 | /* | 782 | /* |
| @@ -812,6 +837,7 @@ static int sysrq_connect(struct input_handler *handler, | |||
| 812 | sysrq->handle.handler = handler; | 837 | sysrq->handle.handler = handler; |
| 813 | sysrq->handle.name = "sysrq"; | 838 | sysrq->handle.name = "sysrq"; |
| 814 | sysrq->handle.private = sysrq; | 839 | sysrq->handle.private = sysrq; |
| 840 | setup_timer(&sysrq->keyreset_timer, sysrq_do_reset, 0); | ||
| 815 | 841 | ||
| 816 | error = input_register_handle(&sysrq->handle); | 842 | error = input_register_handle(&sysrq->handle); |
| 817 | if (error) { | 843 | if (error) { |
| @@ -841,6 +867,7 @@ static void sysrq_disconnect(struct input_handle *handle) | |||
| 841 | 867 | ||
| 842 | input_close_device(handle); | 868 | input_close_device(handle); |
| 843 | cancel_work_sync(&sysrq->reinject_work); | 869 | cancel_work_sync(&sysrq->reinject_work); |
| 870 | del_timer_sync(&sysrq->keyreset_timer); | ||
| 844 | input_unregister_handle(handle); | 871 | input_unregister_handle(handle); |
| 845 | kfree(sysrq); | 872 | kfree(sysrq); |
| 846 | } | 873 | } |
| @@ -870,8 +897,6 @@ static struct input_handler sysrq_handler = { | |||
| 870 | 897 | ||
| 871 | static bool sysrq_handler_registered; | 898 | static bool sysrq_handler_registered; |
| 872 | 899 | ||
| 873 | unsigned short platform_sysrq_reset_seq[] __weak = { KEY_RESERVED }; | ||
| 874 | |||
| 875 | static inline void sysrq_register_handler(void) | 900 | static inline void sysrq_register_handler(void) |
| 876 | { | 901 | { |
| 877 | unsigned short key; | 902 | unsigned short key; |
| @@ -931,6 +956,8 @@ static struct kernel_param_ops param_ops_sysrq_reset_seq = { | |||
| 931 | module_param_array_named(reset_seq, sysrq_reset_seq, sysrq_reset_seq, | 956 | module_param_array_named(reset_seq, sysrq_reset_seq, sysrq_reset_seq, |
| 932 | &sysrq_reset_seq_len, 0644); | 957 | &sysrq_reset_seq_len, 0644); |
| 933 | 958 | ||
| 959 | module_param_named(sysrq_downtime_ms, sysrq_reset_downtime_ms, int, 0644); | ||
| 960 | |||
| 934 | #else | 961 | #else |
| 935 | 962 | ||
| 936 | static inline void sysrq_register_handler(void) | 963 | static inline void sysrq_register_handler(void) |
diff --git a/drivers/usb/class/cdc-acm.c b/drivers/usb/class/cdc-acm.c index 171d7a9df3ae..9b1cbcf8fb7f 100644 --- a/drivers/usb/class/cdc-acm.c +++ b/drivers/usb/class/cdc-acm.c | |||
| @@ -962,6 +962,10 @@ static int acm_probe(struct usb_interface *intf, | |||
| 962 | 962 | ||
| 963 | /* normal quirks */ | 963 | /* normal quirks */ |
| 964 | quirks = (unsigned long)id->driver_info; | 964 | quirks = (unsigned long)id->driver_info; |
| 965 | |||
| 966 | if (quirks == IGNORE_DEVICE) | ||
| 967 | return -ENODEV; | ||
| 968 | |||
| 965 | num_rx_buf = (quirks == SINGLE_RX_URB) ? 1 : ACM_NR; | 969 | num_rx_buf = (quirks == SINGLE_RX_URB) ? 1 : ACM_NR; |
| 966 | 970 | ||
| 967 | /* handle quirks deadly to normal probing*/ | 971 | /* handle quirks deadly to normal probing*/ |
| @@ -1675,6 +1679,15 @@ static const struct usb_device_id acm_ids[] = { | |||
| 1675 | .driver_info = NO_DATA_INTERFACE, | 1679 | .driver_info = NO_DATA_INTERFACE, |
| 1676 | }, | 1680 | }, |
| 1677 | 1681 | ||
| 1682 | #if IS_ENABLED(CONFIG_INPUT_IMS_PCU) | ||
| 1683 | { USB_DEVICE(0x04d8, 0x0082), /* Application mode */ | ||
| 1684 | .driver_info = IGNORE_DEVICE, | ||
| 1685 | }, | ||
| 1686 | { USB_DEVICE(0x04d8, 0x0083), /* Bootloader mode */ | ||
| 1687 | .driver_info = IGNORE_DEVICE, | ||
| 1688 | }, | ||
| 1689 | #endif | ||
| 1690 | |||
| 1678 | /* control interfaces without any protocol set */ | 1691 | /* control interfaces without any protocol set */ |
| 1679 | { USB_INTERFACE_INFO(USB_CLASS_COMM, USB_CDC_SUBCLASS_ACM, | 1692 | { USB_INTERFACE_INFO(USB_CLASS_COMM, USB_CDC_SUBCLASS_ACM, |
| 1680 | USB_CDC_PROTO_NONE) }, | 1693 | USB_CDC_PROTO_NONE) }, |
diff --git a/drivers/usb/class/cdc-acm.h b/drivers/usb/class/cdc-acm.h index 35ef887b7417..0f76e4af600e 100644 --- a/drivers/usb/class/cdc-acm.h +++ b/drivers/usb/class/cdc-acm.h | |||
| @@ -128,3 +128,4 @@ struct acm { | |||
| 128 | #define NO_CAP_LINE 4 | 128 | #define NO_CAP_LINE 4 |
| 129 | #define NOT_A_MODEM 8 | 129 | #define NOT_A_MODEM 8 |
| 130 | #define NO_DATA_INTERFACE 16 | 130 | #define NO_DATA_INTERFACE 16 |
| 131 | #define IGNORE_DEVICE 32 | ||
diff --git a/include/linux/device.h b/include/linux/device.h index 711793b145ff..c0a126125325 100644 --- a/include/linux/device.h +++ b/include/linux/device.h | |||
| @@ -576,6 +576,10 @@ void __iomem *devm_ioremap_resource(struct device *dev, struct resource *res); | |||
| 576 | void __iomem *devm_request_and_ioremap(struct device *dev, | 576 | void __iomem *devm_request_and_ioremap(struct device *dev, |
| 577 | struct resource *res); | 577 | struct resource *res); |
| 578 | 578 | ||
| 579 | /* allows to add/remove a custom action to devres stack */ | ||
| 580 | int devm_add_action(struct device *dev, void (*action)(void *), void *data); | ||
| 581 | void devm_remove_action(struct device *dev, void (*action)(void *), void *data); | ||
| 582 | |||
| 579 | struct device_dma_parameters { | 583 | struct device_dma_parameters { |
| 580 | /* | 584 | /* |
| 581 | * a low level driver may set these to teach IOMMU code about | 585 | * a low level driver may set these to teach IOMMU code about |
diff --git a/include/linux/input/auo-pixcir-ts.h b/include/linux/input/auo-pixcir-ts.h index 75d4be717714..5049f21928e4 100644 --- a/include/linux/input/auo-pixcir-ts.h +++ b/include/linux/input/auo-pixcir-ts.h | |||
| @@ -43,12 +43,10 @@ | |||
| 43 | */ | 43 | */ |
| 44 | struct auo_pixcir_ts_platdata { | 44 | struct auo_pixcir_ts_platdata { |
| 45 | int gpio_int; | 45 | int gpio_int; |
| 46 | int gpio_rst; | ||
| 46 | 47 | ||
| 47 | int int_setting; | 48 | int int_setting; |
| 48 | 49 | ||
| 49 | void (*init_hw)(struct i2c_client *); | ||
| 50 | void (*exit_hw)(struct i2c_client *); | ||
| 51 | |||
| 52 | unsigned int x_max; | 50 | unsigned int x_max; |
| 53 | unsigned int y_max; | 51 | unsigned int y_max; |
| 54 | }; | 52 | }; |
diff --git a/include/linux/input/mt.h b/include/linux/input/mt.h index 2e86bd0bfba1..1b1dfa80d9ff 100644 --- a/include/linux/input/mt.h +++ b/include/linux/input/mt.h | |||
| @@ -19,6 +19,7 @@ | |||
| 19 | #define INPUT_MT_DIRECT 0x0002 /* direct device, e.g. touchscreen */ | 19 | #define INPUT_MT_DIRECT 0x0002 /* direct device, e.g. touchscreen */ |
| 20 | #define INPUT_MT_DROP_UNUSED 0x0004 /* drop contacts not seen in frame */ | 20 | #define INPUT_MT_DROP_UNUSED 0x0004 /* drop contacts not seen in frame */ |
| 21 | #define INPUT_MT_TRACK 0x0008 /* use in-kernel tracking */ | 21 | #define INPUT_MT_TRACK 0x0008 /* use in-kernel tracking */ |
| 22 | #define INPUT_MT_SEMI_MT 0x0010 /* semi-mt device, finger count handled manually */ | ||
| 22 | 23 | ||
| 23 | /** | 24 | /** |
| 24 | * struct input_mt_slot - represents the state of an input MT slot | 25 | * struct input_mt_slot - represents the state of an input MT slot |
diff --git a/include/linux/platform_data/st1232_pdata.h b/include/linux/platform_data/st1232_pdata.h new file mode 100644 index 000000000000..cac3e7b4c454 --- /dev/null +++ b/include/linux/platform_data/st1232_pdata.h | |||
| @@ -0,0 +1,13 @@ | |||
| 1 | #ifndef _LINUX_ST1232_PDATA_H | ||
| 2 | #define _LINUX_ST1232_PDATA_H | ||
| 3 | |||
| 4 | /* | ||
| 5 | * Optional platform data | ||
| 6 | * | ||
| 7 | * Use this if you want the driver to drive the reset pin. | ||
| 8 | */ | ||
| 9 | struct st1232_pdata { | ||
| 10 | int reset_gpio; | ||
| 11 | }; | ||
| 12 | |||
| 13 | #endif | ||
diff --git a/include/uapi/linux/input.h b/include/uapi/linux/input.h index 935119c698ac..4649ee35b605 100644 --- a/include/uapi/linux/input.h +++ b/include/uapi/linux/input.h | |||
| @@ -702,6 +702,11 @@ struct input_keymap_entry { | |||
| 702 | #define KEY_CAMERA_LEFT 0x219 | 702 | #define KEY_CAMERA_LEFT 0x219 |
| 703 | #define KEY_CAMERA_RIGHT 0x21a | 703 | #define KEY_CAMERA_RIGHT 0x21a |
| 704 | 704 | ||
| 705 | #define KEY_ATTENDANT_ON 0x21b | ||
| 706 | #define KEY_ATTENDANT_OFF 0x21c | ||
| 707 | #define KEY_ATTENDANT_TOGGLE 0x21d /* Attendant call on or off */ | ||
| 708 | #define KEY_LIGHTS_TOGGLE 0x21e /* Reading light on or off */ | ||
| 709 | |||
| 705 | #define BTN_TRIGGER_HAPPY 0x2c0 | 710 | #define BTN_TRIGGER_HAPPY 0x2c0 |
| 706 | #define BTN_TRIGGER_HAPPY1 0x2c0 | 711 | #define BTN_TRIGGER_HAPPY1 0x2c0 |
| 707 | #define BTN_TRIGGER_HAPPY2 0x2c1 | 712 | #define BTN_TRIGGER_HAPPY2 0x2c1 |
