summaryrefslogtreecommitdiff
path: root/drivers/input
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2026-10-22 07:56:27 -1000
committerLinus Torvalds <torvalds@linux-foundation.org>2026-10-22 07:56:27 -1000
commitaad73b807cd1a5bff9c5277e8a42e75bbdc8adab (patch)
tree8c1f0864efd1be92f97e2d804a7bf619173922db /drivers/input
parent4e092c2be4320f06dde1206652746ce0d83540b7 (diff)
parentcfe69169c03e71e2a22870317ef4cffb51f6f06d (diff)
Merge tag 'soc-arm-7.4' of git://git.kernel.org/pub/scm/linux/kernel/git/soc/soc
Pull ARM SoC board file updates from Arnd Bergmann: "These are mostly smaller cleanups for the remaining platform code in arch/arm/, the most notable one being the conversion of the s3c/crag6410 board to use software nodes for GPIO references in place of plain GPIO numbers. The earlier plan was to drop the deprecated (since 7.3) board files here, which would have been a much larger set of changes, but that is now deferred to 7.5" * tag 'soc-arm-7.4' of git://git.kernel.org/pub/scm/linux/kernel/git/soc/soc: MAINTAINERS: Drop arm64 dts/intel path from ARM/SOCFPGA ARCHITECTURE ARM: tegra: Fix Trun -> Turn typo ARM: vexpress: fix device_node refcount leak in vexpress_smp_dt_prepare_cpus() ARM: vexpress: fix device_node refcount leak in vexpress_flags_set() MAINTAINERS: Change ARM Visconti5 architecture maintenance status to Odd Fixes ARM: mvebu: fix Cortex-A9 errata selection for Armada 38x ARM: OMAP2+: remove unused ctrl_module_wkup_44xx.h header ARM: EXYNOS: Replace __ASSEMBLY__ with __ASSEMBLER__ ARM: s3c: crag6410: use software nodes/properties to set up GPIO keys Input: samsung-keypad - remove support for platform data ARM: s3c: crag6410: switch keypad device to software properties ARM: s3c: register and attach software nodes for Samsung gpio_chips Input: samsung-keypad - handle compact binding dt-bindings: input: samsung,s3c6410-keypad: introduce compact binding ARM: imx6q: remove KSZ9021 PHY fixup ARM: imx: Fix suspend/resume crash with Clang CFI ARM: OMAP2+: Replace __ASSEMBLY__ with __ASSEMBLER__ soc: imx: Replace __ASSEMBLY__ with __ASSEMBLER__ in header file ARM: imx: Replace __ASSEMBLY__ with __ASSEMBLER__ MAINTAINERS: Add git tree for TI K3 ARCHITECTURE
Diffstat (limited to 'drivers/input')
-rw-r--r--drivers/input/keyboard/samsung-keypad.c200
1 files changed, 84 insertions, 116 deletions
diff --git a/drivers/input/keyboard/samsung-keypad.c b/drivers/input/keyboard/samsung-keypad.c
index deffa98749c0..f56c5249401d 100644
--- a/drivers/input/keyboard/samsung-keypad.c
+++ b/drivers/input/keyboard/samsung-keypad.c
@@ -12,6 +12,7 @@
#include <linux/delay.h>
#include <linux/err.h>
#include <linux/input.h>
+#include <linux/input/matrix_keypad.h>
#include <linux/interrupt.h>
#include <linux/io.h>
#include <linux/module.h>
@@ -21,7 +22,9 @@
#include <linux/slab.h>
#include <linux/of.h>
#include <linux/sched.h>
-#include <linux/input/samsung-keypad.h>
+
+#define SAMSUNG_MAX_ROWS 8
+#define SAMSUNG_MAX_COLS 8
#define SAMSUNG_KEYIFCON 0x00
#define SAMSUNG_KEYIFSTSCLR 0x04
@@ -221,145 +224,92 @@ static void samsung_keypad_close(struct input_dev *input_dev)
samsung_keypad_stop(keypad);
}
-#ifdef CONFIG_OF
-static struct samsung_keypad_platdata *
-samsung_keypad_parse_dt(struct device *dev)
+static int samsung_parse_verbose_keymap(struct samsung_keypad *keypad)
{
- struct samsung_keypad_platdata *pdata;
- struct matrix_keymap_data *keymap_data;
- uint32_t *keymap, num_rows = 0, num_cols = 0;
- struct device_node *np = dev->of_node, *key_np;
- unsigned int key_count;
-
- if (!np) {
- dev_err(dev, "missing device tree data\n");
- return ERR_PTR(-EINVAL);
- }
-
- pdata = devm_kzalloc(dev, sizeof(*pdata), GFP_KERNEL);
- if (!pdata) {
- dev_err(dev, "could not allocate memory for platform data\n");
- return ERR_PTR(-ENOMEM);
- }
+ struct matrix_keymap_data keymap_data = { 0 };
+ struct device *dev = &keypad->pdev->dev;
+ struct fwnode_handle *child;
+ unsigned int key_count = device_get_child_node_count(dev);
+ unsigned int i;
+
+ u32 *keymap __free(kfree) = kcalloc(key_count, sizeof(*keymap), GFP_KERNEL);
+ if (!keymap)
+ return -ENOMEM;
- of_property_read_u32(np, "samsung,keypad-num-rows", &num_rows);
- of_property_read_u32(np, "samsung,keypad-num-columns", &num_cols);
- if (!num_rows || !num_cols) {
- dev_err(dev, "number of keypad rows/columns not specified\n");
- return ERR_PTR(-EINVAL);
- }
- pdata->rows = num_rows;
- pdata->cols = num_cols;
+ keymap_data.keymap_size = key_count;
+ keymap_data.keymap = keymap;
- keymap_data = devm_kzalloc(dev, sizeof(*keymap_data), GFP_KERNEL);
- if (!keymap_data) {
- dev_err(dev, "could not allocate memory for keymap data\n");
- return ERR_PTR(-ENOMEM);
- }
- pdata->keymap_data = keymap_data;
-
- key_count = of_get_child_count(np);
- keymap_data->keymap_size = key_count;
- keymap = devm_kcalloc(dev, key_count, sizeof(uint32_t), GFP_KERNEL);
- if (!keymap) {
- dev_err(dev, "could not allocate memory for keymap\n");
- return ERR_PTR(-ENOMEM);
- }
- keymap_data->keymap = keymap;
-
- for_each_child_of_node(np, key_np) {
+ i = 0;
+ device_for_each_child_node(dev, child) {
u32 row, col, key_code;
- of_property_read_u32(key_np, "keypad,row", &row);
- of_property_read_u32(key_np, "keypad,column", &col);
- of_property_read_u32(key_np, "linux,code", &key_code);
- *keymap++ = KEY(row, col, key_code);
- }
- pdata->no_autorepeat = of_property_read_bool(np, "linux,input-no-autorepeat");
-
- pdata->wakeup = of_property_read_bool(np, "wakeup-source") ||
- /* legacy name */
- of_property_read_bool(np, "linux,input-wakeup");
+ fwnode_property_read_u32(child, "keypad,row", &row);
+ fwnode_property_read_u32(child, "keypad,column", &col);
+ fwnode_property_read_u32(child, "linux,code", &key_code);
+ keymap[i++] = KEY(row, col, key_code);
+ }
- return pdata;
+ return matrix_keypad_build_keymap(&keymap_data, NULL,
+ keypad->rows, keypad->cols,
+ keypad->keycodes,
+ keypad->input_dev);
}
-#else
-static struct samsung_keypad_platdata *
-samsung_keypad_parse_dt(struct device *dev)
+
+static int samsung_keypad_parse_keymap(struct samsung_keypad *keypad)
{
- dev_err(dev, "no platform data defined\n");
+ struct device *dev = &keypad->pdev->dev;
+
+ if (device_property_present(dev, "linux,keymap"))
+ return matrix_keypad_build_keymap(NULL, NULL,
+ keypad->rows, keypad->cols,
+ keypad->keycodes,
+ keypad->input_dev);
- return ERR_PTR(-EINVAL);
+ return samsung_parse_verbose_keymap(keypad);
}
-#endif
static int samsung_keypad_probe(struct platform_device *pdev)
{
- const struct samsung_keypad_platdata *pdata;
- const struct matrix_keymap_data *keymap_data;
const struct platform_device_id *id;
+ struct device *dev = &pdev->dev;
struct samsung_keypad *keypad;
struct resource *res;
struct input_dev *input_dev;
unsigned int row_shift;
+ u32 num_rows = 0, num_cols = 0;
+ bool wakeup;
int error;
- pdata = dev_get_platdata(&pdev->dev);
- if (!pdata) {
- pdata = samsung_keypad_parse_dt(&pdev->dev);
- if (IS_ERR(pdata))
- return PTR_ERR(pdata);
- }
-
- keymap_data = pdata->keymap_data;
- if (!keymap_data) {
- dev_err(&pdev->dev, "no keymap data defined\n");
- return -EINVAL;
+ if (device_property_present(dev, "linux,keymap")) {
+ error = matrix_keypad_parse_properties(dev, &num_rows, &num_cols);
+ if (error)
+ return error;
+ } else {
+ device_property_read_u32(dev, "samsung,keypad-num-rows", &num_rows);
+ device_property_read_u32(dev, "samsung,keypad-num-columns", &num_cols);
+ if (!num_rows || !num_cols) {
+ dev_err(dev, "number of keypad rows/columns not specified\n");
+ return -EINVAL;
+ }
}
- if (!pdata->rows || pdata->rows > SAMSUNG_MAX_ROWS)
+ if (num_rows > SAMSUNG_MAX_ROWS || num_cols > SAMSUNG_MAX_COLS)
return -EINVAL;
- if (!pdata->cols || pdata->cols > SAMSUNG_MAX_COLS)
- return -EINVAL;
-
- /* initialize the gpio */
- if (pdata->cfg_gpio)
- pdata->cfg_gpio(pdata->rows, pdata->cols);
-
- row_shift = get_count_order(pdata->cols);
+ row_shift = get_count_order(num_cols);
keypad = devm_kzalloc(&pdev->dev,
struct_size(keypad, keycodes,
- pdata->rows << row_shift),
+ num_rows << row_shift),
GFP_KERNEL);
if (!keypad)
return -ENOMEM;
- input_dev = devm_input_allocate_device(&pdev->dev);
- if (!input_dev)
- return -ENOMEM;
-
- res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
- if (!res)
- return -ENODEV;
-
- keypad->base = devm_ioremap(&pdev->dev, res->start, resource_size(res));
- if (!keypad->base)
- return -EBUSY;
-
- keypad->clk = devm_clk_get_prepared(&pdev->dev, "keypad");
- if (IS_ERR(keypad->clk)) {
- dev_err(&pdev->dev, "failed to get keypad clk\n");
- return PTR_ERR(keypad->clk);
- }
-
- keypad->input_dev = input_dev;
keypad->pdev = pdev;
keypad->row_shift = row_shift;
- keypad->rows = pdata->rows;
- keypad->cols = pdata->cols;
+ keypad->rows = num_rows;
+ keypad->cols = num_cols;
keypad->stopped = true;
init_waitqueue_head(&keypad->wait);
@@ -375,26 +325,45 @@ static int samsung_keypad_probe(struct platform_device *pdev)
return -EINVAL;
}
+ input_dev = devm_input_allocate_device(&pdev->dev);
+ if (!input_dev)
+ return -ENOMEM;
+
+ keypad->input_dev = input_dev;
+
input_dev->name = pdev->name;
input_dev->id.bustype = BUS_HOST;
input_dev->open = samsung_keypad_open;
input_dev->close = samsung_keypad_close;
- error = matrix_keypad_build_keymap(keymap_data, NULL,
- pdata->rows, pdata->cols,
- keypad->keycodes, input_dev);
+ error = samsung_keypad_parse_keymap(keypad);
if (error) {
dev_err(&pdev->dev, "failed to build keymap\n");
return error;
}
input_set_capability(input_dev, EV_MSC, MSC_SCAN);
- if (!pdata->no_autorepeat)
+
+ if (!device_property_read_bool(&pdev->dev, "linux,input-no-autorepeat"))
__set_bit(EV_REP, input_dev->evbit);
input_set_drvdata(input_dev, keypad);
+ res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
+ if (!res)
+ return -ENODEV;
+
+ keypad->base = devm_ioremap(&pdev->dev, res->start, resource_size(res));
+ if (!keypad->base)
+ return -EBUSY;
+
+ keypad->clk = devm_clk_get_prepared(&pdev->dev, "keypad");
+ if (IS_ERR(keypad->clk)) {
+ dev_err(&pdev->dev, "failed to get keypad clk\n");
+ return PTR_ERR(keypad->clk);
+ }
+
keypad->irq = platform_get_irq(pdev, 0);
if (keypad->irq < 0) {
error = keypad->irq;
@@ -410,7 +379,11 @@ static int samsung_keypad_probe(struct platform_device *pdev)
return error;
}
- device_init_wakeup(&pdev->dev, pdata->wakeup);
+ wakeup = device_property_read_bool(dev, "wakeup-source") ||
+ /* legacy name */
+ device_property_read_bool(dev, "linux,input-wakeup");
+ device_init_wakeup(&pdev->dev, wakeup);
+
platform_set_drvdata(pdev, keypad);
error = devm_pm_runtime_enable(&pdev->dev);
@@ -421,11 +394,6 @@ static int samsung_keypad_probe(struct platform_device *pdev)
if (error)
return error;
- if (pdev->dev.of_node) {
- devm_kfree(&pdev->dev, (void *)pdata->keymap_data->keymap);
- devm_kfree(&pdev->dev, (void *)pdata->keymap_data);
- devm_kfree(&pdev->dev, (void *)pdata);
- }
return 0;
}