diff options
| author | Linus Torvalds <torvalds@linux-foundation.org> | 2018-08-23 16:44:43 -0400 |
|---|---|---|
| committer | Linus Torvalds <torvalds@linux-foundation.org> | 2018-08-23 16:44:43 -0400 |
| commit | 9e259f9352d52053058a234f7c062c4e4f56dc85 (patch) | |
| tree | bfb1c442e27f95ddb9a04bae2a44ca9e3dd69a85 /drivers/input | |
| parent | 5563ae9b39c5ba492be1b18f2d72fd43ba549915 (diff) | |
| parent | f0fc40aff6fee100ffbed8328a0df88f8aa75fce (diff) | |
Merge tag 'armsoc-soc' of git://git.kernel.org/pub/scm/linux/kernel/git/arm/arm-soc
Pull ARM 32-bit SoC platform updates from Olof Johansson:
"Most of the SoC updates in this cycle are cleanups and moves to more
modern infrastructure:
- Davinci was moved to common clock framework
- OMAP1-based Amstrad E3 "Superphone" saw a bunch of cleanups to the
keyboard interface (bitbanged AT keyboard via GPIO).
- Removal of some stale code for Renesas platforms
- Power management improvements for i.MX6LL"
* tag 'armsoc-soc' of git://git.kernel.org/pub/scm/linux/kernel/git/arm/arm-soc: (112 commits)
ARM: uniphier: select RESET_CONTROLLER
arm64: uniphier: select RESET_CONTROLLER
ARM: uniphier: remove empty Makefile
ARM: exynos: Clear global variable on init error path
ARM: exynos: Remove outdated maintainer information
ARM: shmobile: Always enable ARCH_TIMER on SoCs with A7 and/or A15
ARM: shmobile: r8a7779: hide unused r8a7779_platform_cpu_kill
soc: r9a06g032: don't build SMP files for non-SMP config
ARM: shmobile: Add the R9A06G032 SMP enabler driver
ARM: at91: pm: configure wakeup sources for ULP1 mode
ARM: at91: pm: add PMC fast startup registers defines
ARM: at91: pm: Add ULP1 mode support
ARM: at91: pm: Use ULP0 naming instead of slow clock
ARM: hisi: handle of_iomap and fix missing of_node_put
ARM: hisi: check of_iomap and fix missing of_node_put
ARM: hisi: fix error handling and missing of_node_put
ARM: mx5: Set the DBGEN bit in ARM_GPC register
ARM: imx51: Configure M4IF to avoid visual artifacts
ARM: imx: call imx6sx_cpuidle_init() conditionally for 6sll
ARM: imx: fix i.MX6SLL build
...
Diffstat (limited to 'drivers/input')
| -rw-r--r-- | drivers/input/serio/ams_delta_serio.c | 198 |
1 files changed, 101 insertions, 97 deletions
diff --git a/drivers/input/serio/ams_delta_serio.c b/drivers/input/serio/ams_delta_serio.c index 3df501c3421b..f8663d7891f2 100644 --- a/drivers/input/serio/ams_delta_serio.c +++ b/drivers/input/serio/ams_delta_serio.c | |||
| @@ -20,32 +20,33 @@ | |||
| 20 | * However, when used with the E3 mailboard that producecs non-standard | 20 | * However, when used with the E3 mailboard that producecs non-standard |
| 21 | * scancodes, a custom key table must be prepared and loaded from userspace. | 21 | * scancodes, a custom key table must be prepared and loaded from userspace. |
| 22 | */ | 22 | */ |
| 23 | #include <linux/gpio.h> | ||
| 24 | #include <linux/irq.h> | 23 | #include <linux/irq.h> |
| 24 | #include <linux/platform_data/ams-delta-fiq.h> | ||
| 25 | #include <linux/platform_device.h> | ||
| 26 | #include <linux/regulator/consumer.h> | ||
| 25 | #include <linux/serio.h> | 27 | #include <linux/serio.h> |
| 26 | #include <linux/slab.h> | 28 | #include <linux/slab.h> |
| 27 | #include <linux/module.h> | 29 | #include <linux/module.h> |
| 28 | 30 | ||
| 29 | #include <asm/mach-types.h> | 31 | #define DRIVER_NAME "ams-delta-serio" |
| 30 | #include <mach/board-ams-delta.h> | ||
| 31 | |||
| 32 | #include <mach/ams-delta-fiq.h> | ||
| 33 | 32 | ||
| 34 | MODULE_AUTHOR("Matt Callow"); | 33 | MODULE_AUTHOR("Matt Callow"); |
| 35 | MODULE_DESCRIPTION("AMS Delta (E3) keyboard port driver"); | 34 | MODULE_DESCRIPTION("AMS Delta (E3) keyboard port driver"); |
| 36 | MODULE_LICENSE("GPL"); | 35 | MODULE_LICENSE("GPL"); |
| 37 | 36 | ||
| 38 | static struct serio *ams_delta_serio; | 37 | struct ams_delta_serio { |
| 38 | struct serio *serio; | ||
| 39 | struct regulator *vcc; | ||
| 40 | unsigned int *fiq_buffer; | ||
| 41 | }; | ||
| 39 | 42 | ||
| 40 | static int check_data(int data) | 43 | static int check_data(struct serio *serio, int data) |
| 41 | { | 44 | { |
| 42 | int i, parity = 0; | 45 | int i, parity = 0; |
| 43 | 46 | ||
| 44 | /* check valid stop bit */ | 47 | /* check valid stop bit */ |
| 45 | if (!(data & 0x400)) { | 48 | if (!(data & 0x400)) { |
| 46 | dev_warn(&ams_delta_serio->dev, | 49 | dev_warn(&serio->dev, "invalid stop bit, data=0x%X\n", data); |
| 47 | "invalid stop bit, data=0x%X\n", | ||
| 48 | data); | ||
| 49 | return SERIO_FRAME; | 50 | return SERIO_FRAME; |
| 50 | } | 51 | } |
| 51 | /* calculate the parity */ | 52 | /* calculate the parity */ |
| @@ -55,9 +56,9 @@ static int check_data(int data) | |||
| 55 | } | 56 | } |
| 56 | /* it should be odd */ | 57 | /* it should be odd */ |
| 57 | if (!(parity & 0x01)) { | 58 | if (!(parity & 0x01)) { |
| 58 | dev_warn(&ams_delta_serio->dev, | 59 | dev_warn(&serio->dev, |
| 59 | "parity check failed, data=0x%X parity=0x%X\n", | 60 | "parity check failed, data=0x%X parity=0x%X\n", data, |
| 60 | data, parity); | 61 | parity); |
| 61 | return SERIO_PARITY; | 62 | return SERIO_PARITY; |
| 62 | } | 63 | } |
| 63 | return 0; | 64 | return 0; |
| @@ -65,127 +66,130 @@ static int check_data(int data) | |||
| 65 | 66 | ||
| 66 | static irqreturn_t ams_delta_serio_interrupt(int irq, void *dev_id) | 67 | static irqreturn_t ams_delta_serio_interrupt(int irq, void *dev_id) |
| 67 | { | 68 | { |
| 68 | int *circ_buff = &fiq_buffer[FIQ_CIRC_BUFF]; | 69 | struct ams_delta_serio *priv = dev_id; |
| 70 | int *circ_buff = &priv->fiq_buffer[FIQ_CIRC_BUFF]; | ||
| 69 | int data, dfl; | 71 | int data, dfl; |
| 70 | u8 scancode; | 72 | u8 scancode; |
| 71 | 73 | ||
| 72 | fiq_buffer[FIQ_IRQ_PEND] = 0; | 74 | priv->fiq_buffer[FIQ_IRQ_PEND] = 0; |
| 73 | 75 | ||
| 74 | /* | 76 | /* |
| 75 | * Read data from the circular buffer, check it | 77 | * Read data from the circular buffer, check it |
| 76 | * and then pass it on the serio | 78 | * and then pass it on the serio |
| 77 | */ | 79 | */ |
| 78 | while (fiq_buffer[FIQ_KEYS_CNT] > 0) { | 80 | while (priv->fiq_buffer[FIQ_KEYS_CNT] > 0) { |
| 79 | 81 | ||
| 80 | data = circ_buff[fiq_buffer[FIQ_HEAD_OFFSET]++]; | 82 | data = circ_buff[priv->fiq_buffer[FIQ_HEAD_OFFSET]++]; |
| 81 | fiq_buffer[FIQ_KEYS_CNT]--; | 83 | priv->fiq_buffer[FIQ_KEYS_CNT]--; |
| 82 | if (fiq_buffer[FIQ_HEAD_OFFSET] == fiq_buffer[FIQ_BUF_LEN]) | 84 | if (priv->fiq_buffer[FIQ_HEAD_OFFSET] == |
| 83 | fiq_buffer[FIQ_HEAD_OFFSET] = 0; | 85 | priv->fiq_buffer[FIQ_BUF_LEN]) |
| 86 | priv->fiq_buffer[FIQ_HEAD_OFFSET] = 0; | ||
| 84 | 87 | ||
| 85 | dfl = check_data(data); | 88 | dfl = check_data(priv->serio, data); |
| 86 | scancode = (u8) (data >> 1) & 0xFF; | 89 | scancode = (u8) (data >> 1) & 0xFF; |
| 87 | serio_interrupt(ams_delta_serio, scancode, dfl); | 90 | serio_interrupt(priv->serio, scancode, dfl); |
| 88 | } | 91 | } |
| 89 | return IRQ_HANDLED; | 92 | return IRQ_HANDLED; |
| 90 | } | 93 | } |
| 91 | 94 | ||
| 92 | static int ams_delta_serio_open(struct serio *serio) | 95 | static int ams_delta_serio_open(struct serio *serio) |
| 93 | { | 96 | { |
| 94 | /* enable keyboard */ | 97 | struct ams_delta_serio *priv = serio->port_data; |
| 95 | gpio_set_value(AMS_DELTA_GPIO_PIN_KEYBRD_PWR, 1); | ||
| 96 | 98 | ||
| 97 | return 0; | 99 | /* enable keyboard */ |
| 100 | return regulator_enable(priv->vcc); | ||
| 98 | } | 101 | } |
| 99 | 102 | ||
| 100 | static void ams_delta_serio_close(struct serio *serio) | 103 | static void ams_delta_serio_close(struct serio *serio) |
| 101 | { | 104 | { |
| 105 | struct ams_delta_serio *priv = serio->port_data; | ||
| 106 | |||
| 102 | /* disable keyboard */ | 107 | /* disable keyboard */ |
| 103 | gpio_set_value(AMS_DELTA_GPIO_PIN_KEYBRD_PWR, 0); | 108 | regulator_disable(priv->vcc); |
| 104 | } | 109 | } |
| 105 | 110 | ||
| 106 | static const struct gpio ams_delta_gpios[] __initconst_or_module = { | 111 | static int ams_delta_serio_init(struct platform_device *pdev) |
| 107 | { | ||
| 108 | .gpio = AMS_DELTA_GPIO_PIN_KEYBRD_DATA, | ||
| 109 | .flags = GPIOF_DIR_IN, | ||
| 110 | .label = "serio-data", | ||
| 111 | }, | ||
| 112 | { | ||
| 113 | .gpio = AMS_DELTA_GPIO_PIN_KEYBRD_CLK, | ||
| 114 | .flags = GPIOF_DIR_IN, | ||
| 115 | .label = "serio-clock", | ||
| 116 | }, | ||
| 117 | { | ||
| 118 | .gpio = AMS_DELTA_GPIO_PIN_KEYBRD_PWR, | ||
| 119 | .flags = GPIOF_OUT_INIT_LOW, | ||
| 120 | .label = "serio-power", | ||
| 121 | }, | ||
| 122 | { | ||
| 123 | .gpio = AMS_DELTA_GPIO_PIN_KEYBRD_DATAOUT, | ||
| 124 | .flags = GPIOF_OUT_INIT_LOW, | ||
| 125 | .label = "serio-dataout", | ||
| 126 | }, | ||
| 127 | }; | ||
| 128 | |||
| 129 | static int __init ams_delta_serio_init(void) | ||
| 130 | { | 112 | { |
| 131 | int err; | 113 | struct ams_delta_serio *priv; |
| 132 | 114 | struct serio *serio; | |
| 133 | if (!machine_is_ams_delta()) | 115 | int irq, err; |
| 134 | return -ENODEV; | ||
| 135 | 116 | ||
| 136 | ams_delta_serio = kzalloc(sizeof(struct serio), GFP_KERNEL); | 117 | priv = devm_kzalloc(&pdev->dev, sizeof(*priv), GFP_KERNEL); |
| 137 | if (!ams_delta_serio) | 118 | if (!priv) |
| 138 | return -ENOMEM; | 119 | return -ENOMEM; |
| 139 | 120 | ||
| 140 | ams_delta_serio->id.type = SERIO_8042; | 121 | priv->fiq_buffer = pdev->dev.platform_data; |
| 141 | ams_delta_serio->open = ams_delta_serio_open; | 122 | if (!priv->fiq_buffer) |
| 142 | ams_delta_serio->close = ams_delta_serio_close; | 123 | return -EINVAL; |
| 143 | strlcpy(ams_delta_serio->name, "AMS DELTA keyboard adapter", | 124 | |
| 144 | sizeof(ams_delta_serio->name)); | 125 | priv->vcc = devm_regulator_get(&pdev->dev, "vcc"); |
| 145 | strlcpy(ams_delta_serio->phys, "GPIO/serio0", | 126 | if (IS_ERR(priv->vcc)) { |
| 146 | sizeof(ams_delta_serio->phys)); | 127 | err = PTR_ERR(priv->vcc); |
| 147 | 128 | dev_err(&pdev->dev, "regulator request failed (%d)\n", err); | |
| 148 | err = gpio_request_array(ams_delta_gpios, | 129 | /* |
| 149 | ARRAY_SIZE(ams_delta_gpios)); | 130 | * When running on a non-dt platform and requested regulator |
| 150 | if (err) { | 131 | * is not available, devm_regulator_get() never returns |
| 151 | pr_err("ams_delta_serio: Couldn't request gpio pins\n"); | 132 | * -EPROBE_DEFER as it is not able to justify if the regulator |
| 152 | goto serio; | 133 | * may still appear later. On the other hand, the board can |
| 134 | * still set full constriants flag at late_initcall in order | ||
| 135 | * to instruct devm_regulator_get() to returnn a dummy one | ||
| 136 | * if sufficient. Hence, if we get -ENODEV here, let's convert | ||
| 137 | * it to -EPROBE_DEFER and wait for the board to decide or | ||
| 138 | * let Deferred Probe infrastructure handle this error. | ||
| 139 | */ | ||
| 140 | if (err == -ENODEV) | ||
| 141 | err = -EPROBE_DEFER; | ||
| 142 | return err; | ||
| 153 | } | 143 | } |
| 154 | 144 | ||
| 155 | err = request_irq(gpio_to_irq(AMS_DELTA_GPIO_PIN_KEYBRD_CLK), | 145 | irq = platform_get_irq(pdev, 0); |
| 156 | ams_delta_serio_interrupt, IRQ_TYPE_EDGE_RISING, | 146 | if (irq < 0) |
| 157 | "ams-delta-serio", 0); | 147 | return -ENXIO; |
| 148 | |||
| 149 | err = devm_request_irq(&pdev->dev, irq, ams_delta_serio_interrupt, | ||
| 150 | IRQ_TYPE_EDGE_RISING, DRIVER_NAME, priv); | ||
| 158 | if (err < 0) { | 151 | if (err < 0) { |
| 159 | pr_err("ams_delta_serio: couldn't request gpio interrupt %d\n", | 152 | dev_err(&pdev->dev, "IRQ request failed (%d)\n", err); |
| 160 | gpio_to_irq(AMS_DELTA_GPIO_PIN_KEYBRD_CLK)); | 153 | return err; |
| 161 | goto gpio; | ||
| 162 | } | 154 | } |
| 163 | /* | ||
| 164 | * Since GPIO register handling for keyboard clock pin is performed | ||
| 165 | * at FIQ level, switch back from edge to simple interrupt handler | ||
| 166 | * to avoid bad interaction. | ||
| 167 | */ | ||
| 168 | irq_set_handler(gpio_to_irq(AMS_DELTA_GPIO_PIN_KEYBRD_CLK), | ||
| 169 | handle_simple_irq); | ||
| 170 | 155 | ||
| 171 | serio_register_port(ams_delta_serio); | 156 | serio = kzalloc(sizeof(*serio), GFP_KERNEL); |
| 172 | dev_info(&ams_delta_serio->dev, "%s\n", ams_delta_serio->name); | 157 | if (!serio) |
| 158 | return -ENOMEM; | ||
| 159 | |||
| 160 | priv->serio = serio; | ||
| 161 | |||
| 162 | serio->id.type = SERIO_8042; | ||
| 163 | serio->open = ams_delta_serio_open; | ||
| 164 | serio->close = ams_delta_serio_close; | ||
| 165 | strlcpy(serio->name, "AMS DELTA keyboard adapter", sizeof(serio->name)); | ||
| 166 | strlcpy(serio->phys, dev_name(&pdev->dev), sizeof(serio->phys)); | ||
| 167 | serio->dev.parent = &pdev->dev; | ||
| 168 | serio->port_data = priv; | ||
| 169 | |||
| 170 | serio_register_port(serio); | ||
| 171 | |||
| 172 | platform_set_drvdata(pdev, priv); | ||
| 173 | |||
| 174 | dev_info(&serio->dev, "%s\n", serio->name); | ||
| 173 | 175 | ||
| 174 | return 0; | 176 | return 0; |
| 175 | gpio: | ||
| 176 | gpio_free_array(ams_delta_gpios, | ||
| 177 | ARRAY_SIZE(ams_delta_gpios)); | ||
| 178 | serio: | ||
| 179 | kfree(ams_delta_serio); | ||
| 180 | return err; | ||
| 181 | } | 177 | } |
| 182 | module_init(ams_delta_serio_init); | ||
| 183 | 178 | ||
| 184 | static void __exit ams_delta_serio_exit(void) | 179 | static int ams_delta_serio_exit(struct platform_device *pdev) |
| 185 | { | 180 | { |
| 186 | serio_unregister_port(ams_delta_serio); | 181 | struct ams_delta_serio *priv = platform_get_drvdata(pdev); |
| 187 | free_irq(gpio_to_irq(AMS_DELTA_GPIO_PIN_KEYBRD_CLK), 0); | 182 | |
| 188 | gpio_free_array(ams_delta_gpios, | 183 | serio_unregister_port(priv->serio); |
| 189 | ARRAY_SIZE(ams_delta_gpios)); | 184 | |
| 185 | return 0; | ||
| 190 | } | 186 | } |
| 191 | module_exit(ams_delta_serio_exit); | 187 | |
| 188 | static struct platform_driver ams_delta_serio_driver = { | ||
| 189 | .probe = ams_delta_serio_init, | ||
| 190 | .remove = ams_delta_serio_exit, | ||
| 191 | .driver = { | ||
| 192 | .name = DRIVER_NAME | ||
| 193 | }, | ||
| 194 | }; | ||
| 195 | module_platform_driver(ams_delta_serio_driver); | ||
