Add support for nuvoton ma35d1 keypad controller
Subsystems (4)
v4 cover Add support for nuvoton ma35d1 keypad controller
This patch series adds keypad driver for the nuvoton ma35 ARMv8 SoC. It includes DT binding documentation and the ma35d1 keypad driver.
v4:
- Update nuvoton,ma35d1-keypad.yaml
- Kept the same order of properties as in the required block.
- Changed register addresses to lowercase.
v3:
- Update nuvoton,ma35d1-keypad.yaml
- Removed vendor-specific properties and replaced them with common properties
- Update ma35d1_keypad.c
- Modified the driver to reflect changes in the YAML properties
v2:
- Update nuvoton,ma35d1-keypad.yaml
- Fixed warnings and errors generated by running checkpatch.pl
- Removed the previous version's properties and rewrote the properties in the Device Tree schema.
- Renamed the Device Tree binding file to nuvoton,ma35d1-keypad.yaml
- Update Kconfig
- Added COMPILE_TEST to the depends on line in the Kconfig
- Update ma35d1_keypad.c
- Refactored error handling within the probe function.
- Fixed the mixed use of devm and non-devm resource management.
- Corrected alignment issues in the code.
- Updated suspend and resume handling methods.
- Fixed variable naming to remove camel casing.
- Used for_each_set_bit() to check key states.
- Modified the code to align with updates in the device tree binding
Ming-Jen Chen (2):
input: keypad: add new keypad driver for MA35D1
dt-bindings: input: Add Nuvoton MA35D1 keypad
.../bindings/input/nuvoton,ma35d1-keypad.yaml | 69 ++++ drivers/input/keyboard/Kconfig | 10 + drivers/input/keyboard/Makefile | 1 + drivers/input/keyboard/ma35d1_keypad.c | 386 ++++++++++++++++++ 4 files changed, 466 insertions(+) create mode 100644 Documentation/devicetree/bindings/input/nuvoton,ma35d1-keypad.yaml create mode 100644 drivers/input/keyboard/ma35d1_keypad.c
Signature · 1 line
2.25.1
PATCH v4 1/2 input: keypad: add new keypad driver for MA35D1
Adds a new keypad driver for the MA35D1 platform. The driver supports key scanning and interrupt handling.
--- drivers/input/keyboard/Kconfig | 10 + drivers/input/keyboard/Makefile | 1 + drivers/input/keyboard/ma35d1_keypad.c | 386 +++++++++++++++++++++++++ 3 files changed, 397 insertions(+) create mode 100644 drivers/input/keyboard/ma35d1_keypad.c
drivers/input/keyboard/Kconfig +10 -0
@@ -797,4 +797,14 @@ config KEYBOARD_CYPRESS_SF To compile this driver as a module, choose M here: the module will be called cypress-sf. +config KEYBOARD_MA35D1 + tristate "Nuvoton MA35D1 keypad driver" + depends on ARCH_MA35 || COMPILE_TEST + select INPUT_MATRIXKMAP + help + Say Y here if you want to use Nuvoton MA35D1 keypad. + + To compile this driver as a module, choose M here: the + module will be called ma35d1-keypad. + endif
drivers/input/keyboard/Makefile +1 -0
@@ -70,3 +70,4 @@ obj-$(CONFIG_KEYBOARD_TEGRA) += tegra-kbc.o obj-$(CONFIG_KEYBOARD_TM2_TOUCHKEY) += tm2-touchkey.o obj-$(CONFIG_KEYBOARD_TWL4030) += twl4030_keypad.o obj-$(CONFIG_KEYBOARD_XTKBD) += xtkbd.o +obj-$(CONFIG_KEYBOARD_MA35D1) += ma35d1_keypad.o
drivers/input/keyboard/ma35d1_keypad.c new file +386 -0
386 lines not on this page · raw message
Signature · 1 line
2.25.1
PATCH v4 2/2 dt-bindings: input: Add Nuvoton MA35D1 keypad
In reply to Ming-Jen ChenAdd YAML bindings for MA35D1 SoC keypad.
--- .../bindings/input/nuvoton,ma35d1-keypad.yaml | 69 +++++++++++++++++++ 1 file changed, 69 insertions(+) create mode 100644 Documentation/devicetree/bindings/input/nuvoton,ma35d1-keypad.yaml
Documentation/devicetree/bindings/input/nuvoton,ma35d1-keypad.yaml new file +69 -0
@@ -0,0 +1,69 @@ +# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/input/nuvoton,ma35d1-keypad.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Nuvoton MA35D1 Keypad + +maintainers: + - Ming-jen Chen <[email protected]> + +allOf: + - $ref: /schemas/input/matrix-keymap.yaml# + +properties: + compatible: + const: nuvoton,ma35d1-kpi + + reg: + maxItems: 1 + + interrupts: + maxItems: 1 + + clocks: + maxItems: 1 + + debounce-delay-ms: + description: Debounce delay time in milliseconds. + maxItems: 1 + + scan-interval-ms: + description: Scan interval time in milliseconds. + maxItems: 1 + +required: + - compatible + - reg + - interrupts + - clocks + - debounce-delay-ms + - scan-interval-ms + - linux,keymap + - keypad,num-rows + - keypad,num-columns + +unevaluatedProperties: false + +examples: + - | + #include <dt-bindings/input/input.h> + keypad@404a0000 { + compatible = "nuvoton,ma35d1-kpi"; + reg = <0x404a0000 0x10000>; + interrupts = <79>; + clocks = <&clk>; + keypad,num-rows = <2>; + keypad,num-columns = <2>; + + linux,keymap = < + MATRIX_KEY(0, 0, KEY_ENTER) + MATRIX_KEY(0, 1, KEY_ENTER) + MATRIX_KEY(1, 0, KEY_SPACE) + MATRIX_KEY(1, 1, KEY_Z) + >; + + debounce-delay-ms = <1>; + scan-interval-ms = <20>; + };
Signature · 1 line
2.25.1
Re: [PATCH v4 2/2] dt-bindings: input: Add Nuvoton MA35D1 keypad
Quoted 3 lines · Ming-Jen Chen
Add YAML bindings for MA35D1 SoC keypad.
Signed-off-by Ming-Jen Chen <[email protected]>
Repeating same comment third or fourth time is a waste of my time.
NAK.
It seems my or other reviewer's previous comments were not fully addressed. Maybe the feedback got lost between the quotes, maybe you just forgot to apply it. Please go back to the previous discussion and either implement all requested changes or keep discussing them.
Best regards,
Krzysztof
kernel test robot
build botRe: [PATCH v4 1/2] input: keypad: add new keypad driver for MA35D1
In reply to Ming-Jen Chenkernel test robot noticed the following build errors:
Hi Ming-Jen,
kernel test robot noticed the following build errors:
[auto build test ERROR on dtor-input/next]
[also build test ERROR on dtor-input/for-linus hid/for-next soc/for-next linus/master v6.13-rc1 next-20241203] [If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]
url: https://github.com/intel-lab-lkp/linux/commits/Ming-Jen-Chen/input-keypad-add-new-keypad-driver-for-MA35D1/20241204-123001 base: https://git.kernel.org/pub/scm/linux/kernel/git/dtor/input.git next patch link: https://lore.kernel.org/r/20241204021014.5083-2-mjchen0829%40gmail.com patch subject: [PATCH v4 1/2] input: keypad: add new keypad driver for MA35D1 config: s390-allyesconfig (https://download.01.org/0day-ci/archive/20241204/[email protected]/config) compiler: s390-linux-gcc (GCC) 14.2.0 reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20241204/[email protected]/reproduce)
If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/
All errors (new ones prefixed by >>):
drivers/input/keyboard/ma35d1_keypad.c: In function 'ma35d1_keypad_scan_matrix':
drivers/input/keyboard/ma35d1_keypad.c:83:24: error: implicit declaration of function 'readl' [-Wimplicit-function-declaration]
83 | key_event[0] = readl(keypad->mmio_base + KPI_KPE0);
| ^~~~~
>> drivers/input/keyboard/ma35d1_keypad.c:89:9: error: implicit declaration of function 'writel' [-Wimplicit-function-declaration]
89 | writel(key_event[0], (keypad->mmio_base + KPI_KPE0));
| ^~~~~~vim +/writel +89 drivers/input/keyboard/ma35d1_keypad.c
72
73 static void ma35d1_keypad_scan_matrix(struct ma35d1_keypad *keypad, unsigned int status)
74 {
75 struct input_dev *input_dev = keypad->input_dev;
76 u32 row_shift = get_count_order(keypad->kpi_col);
77 u32 *keymap = input_dev->keycode;
78 u32 code, key, index;
79 u32 key_event[4];
80 u64 pressed_keys = 0, released_keys = 0;
81
82 /* Read key event status */
83 key_event[0] = readl(keypad->mmio_base + KPI_KPE0);
84 key_event[1] = readl(keypad->mmio_base + KPI_KPE1);
85 key_event[2] = readl(keypad->mmio_base + KPI_KRE0);
86 key_event[3] = readl(keypad->mmio_base + KPI_KRE1);
87
88 /* Clear key event status */
> 89 writel(key_event[0], (keypad->mmio_base + KPI_KPE0));
90 writel(key_event[1], (keypad->mmio_base + KPI_KPE1));
91 writel(key_event[2], (keypad->mmio_base + KPI_KRE0));
92 writel(key_event[3], (keypad->mmio_base + KPI_KRE1));
93
94 pressed_keys = key_event[0] | ((u64)key_event[1] << 32);
95 released_keys = key_event[2] | ((u64)key_event[3] << 32);
96
97 /* Process pressed keys */
98 for_each_set_bit(index, (const unsigned long *)&pressed_keys, KEY_EVENT_BITS) {
99 code = MATRIX_SCAN_CODE(index / 8, (index % 8), row_shift); 100 key = keymap[code];
101
102 input_event(input_dev, EV_MSC, MSC_SCAN, code);
103 input_report_key(input_dev, key, 1);
104 }
105
106 /* Process released keys */
107 for_each_set_bit(index, (const unsigned long *)&released_keys, KEY_EVENT_BITS) {
108 code = MATRIX_SCAN_CODE(index / 8, (index % 8), row_shift);
109 key = keymap[code];
110
111 input_event(input_dev, EV_MSC, MSC_SCAN, code);
112 input_report_key(input_dev, key, 0);
113 }
114
115 input_sync(input_dev);
116 }
117
Signature · 2 lines
0-DAY CI Kernel Test Service https://github.com/intel/lkp-tests/wiki
kernel test robot
build botRe: [PATCH v4 1/2] input: keypad: add new keypad driver for MA35D1
In reply to Ming-Jen Chenkernel test robot noticed the following build errors:
Hi Ming-Jen,
kernel test robot noticed the following build errors:
[auto build test ERROR on dtor-input/next]
[also build test ERROR on dtor-input/for-linus hid/for-next soc/for-next linus/master v6.13-rc1 next-20241203] [If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]
url: https://github.com/intel-lab-lkp/linux/commits/Ming-Jen-Chen/input-keypad-add-new-keypad-driver-for-MA35D1/20241204-123001 base: https://git.kernel.org/pub/scm/linux/kernel/git/dtor/input.git next patch link: https://lore.kernel.org/r/20241204021014.5083-2-mjchen0829%40gmail.com patch subject: [PATCH v4 1/2] input: keypad: add new keypad driver for MA35D1 config: s390-allmodconfig (https://download.01.org/0day-ci/archive/20241205/[email protected]/config) compiler: clang version 20.0.0git (https://github.com/llvm/llvm-project 592c0fe55f6d9a811028b5f3507be91458ab2713) reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20241205/[email protected]/reproduce)
If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/
All errors (new ones prefixed by >>):
In file included from drivers/input/keyboard/ma35d1_keypad.c:9:
In file included from include/linux/input.h:19:
In file included from include/linux/device.h:32:
In file included from include/linux/device/driver.h:21:
In file included from include/linux/module.h:19:
In file included from include/linux/elf.h:6:
In file included from arch/s390/include/asm/elf.h:181:
In file included from arch/s390/include/asm/mmu_context.h:11:
In file included from arch/s390/include/asm/pgalloc.h:18:
In file included from include/linux/mm.h:2228:
include/linux/vmstat.h:503:43: warning: arithmetic between different enumeration types ('enum zone_stat_item' and 'enum numa_stat_item') [-Wenum-enum-conversion]
503 | return vmstat_text[NR_VM_ZONE_STAT_ITEMS +
| ~~~~~~~~~~~~~~~~~~~~~ ^
504 | item];
| ~~~~
include/linux/vmstat.h:510:43: warning: arithmetic between different enumeration types ('enum zone_stat_item' and 'enum numa_stat_item') [-Wenum-enum-conversion]
510 | return vmstat_text[NR_VM_ZONE_STAT_ITEMS +
| ~~~~~~~~~~~~~~~~~~~~~ ^
511 | NR_VM_NUMA_EVENT_ITEMS +
| ~~~~~~~~~~~~~~~~~~~~~~
include/linux/vmstat.h:517:36: warning: arithmetic between different enumeration types ('enum node_stat_item' and 'enum lru_list') [-Wenum-enum-conversion]
517 | return node_stat_name(NR_LRU_BASE + lru) + 3; // skip "nr_"
| ~~~~~~~~~~~ ^ ~~~
include/linux/vmstat.h:523:43: warning: arithmetic between different enumeration types ('enum zone_stat_item' and 'enum numa_stat_item') [-Wenum-enum-conversion]
523 | return vmstat_text[NR_VM_ZONE_STAT_ITEMS +
| ~~~~~~~~~~~~~~~~~~~~~ ^
524 | NR_VM_NUMA_EVENT_ITEMS +
| ~~~~~~~~~~~~~~~~~~~~~~
>> drivers/input/keyboard/ma35d1_keypad.c:83:17: error: call to undeclared function 'readl'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration]
83 | key_event[0] = readl(keypad->mmio_base + KPI_KPE0);
| ^
drivers/input/keyboard/ma35d1_keypad.c:89:2: error: call to undeclared function 'writel'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration]
89 | writel(key_event[0], (keypad->mmio_base + KPI_KPE0));
| ^
drivers/input/keyboard/ma35d1_keypad.c:123:12: error: call to undeclared function 'readl'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration]
123 | kstatus = readl(keypad->mmio_base + KPI_STATUS);
| ^
drivers/input/keyboard/ma35d1_keypad.c:129:4: error: call to undeclared function 'writel'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration]
129 | writel(PDWAKE, (keypad->mmio_base + KPI_STATUS));
| ^
drivers/input/keyboard/ma35d1_keypad.c:148:2: error: call to undeclared function 'writel'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration]
148 | writel(val, keypad->mmio_base + KPI_CONF);
| ^
drivers/input/keyboard/ma35d1_keypad.c:159:8: error: call to undeclared function 'readl'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration]
159 | val = readl(keypad->mmio_base + KPI_KPE0) & ~ENKP;
| ^
drivers/input/keyboard/ma35d1_keypad.c:160:2: error: call to undeclared function 'writel'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration]
160 | writel(val, keypad->mmio_base + KPI_CONF);
| ^
drivers/input/keyboard/ma35d1_keypad.c:166:17: warning: array index 12 is past the end of the array (that has type 'const unsigned int[12]') [-Warray-bounds]
166 | u32 min_diff = debounce_values[NUM_SETTINGS];
| ^ ~~~~~~~~~~~~
drivers/input/keyboard/ma35d1_keypad.c:53:1: note: array 'debounce_values' declared here
53 | static const unsigned int debounce_values[NUM_SETTINGS] = {
| ^
drivers/input/keyboard/ma35d1_keypad.c:173:25: warning: array index 12 is past the end of the array (that has type 'const unsigned int[12]') [-Warray-bounds]
173 | keypad->debounce_val = debounce_register[NUM_SETTINGS];
| ^ ~~~~~~~~~~~~
drivers/input/keyboard/ma35d1_keypad.c:57:1: note: array 'debounce_register' declared here
57 | static const unsigned int debounce_register[NUM_SETTINGS] = {
| ^
drivers/input/keyboard/ma35d1_keypad.c:349:3: error: call to undeclared function 'writel'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration]
349 | writel(readl(keypad->mmio_base + KPI_CONF) | WAKEUP, keypad->mmio_base + KPI_CONF);
| ^
drivers/input/keyboard/ma35d1_keypad.c:349:10: error: call to undeclared function 'readl'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration]
349 | writel(readl(keypad->mmio_base + KPI_CONF) | WAKEUP, keypad->mmio_base + KPI_CONF);
| ^
drivers/input/keyboard/ma35d1_keypad.c:359:3: error: call to undeclared function 'writel'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration]
359 | writel(readl(keypad->mmio_base + KPI_CONF) & ~(WAKEUP),
| ^
drivers/input/keyboard/ma35d1_keypad.c:359:10: error: call to undeclared function 'readl'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration]
359 | writel(readl(keypad->mmio_base + KPI_CONF) & ~(WAKEUP),
| ^6 warnings and 11 errors generated.
vim +/readl +83 drivers/input/keyboard/ma35d1_keypad.c
72
73 static void ma35d1_keypad_scan_matrix(struct ma35d1_keypad *keypad, unsigned int status)
74 {
75 struct input_dev *input_dev = keypad->input_dev;
76 u32 row_shift = get_count_order(keypad->kpi_col);
77 u32 *keymap = input_dev->keycode;
78 u32 code, key, index;
79 u32 key_event[4];
80 u64 pressed_keys = 0, released_keys = 0;
81
82 /* Read key event status */
> 83 key_event[0] = readl(keypad->mmio_base + KPI_KPE0);
84 key_event[1] = readl(keypad->mmio_base + KPI_KPE1);
85 key_event[2] = readl(keypad->mmio_base + KPI_KRE0);
86 key_event[3] = readl(keypad->mmio_base + KPI_KRE1);
87
88 /* Clear key event status */
89 writel(key_event[0], (keypad->mmio_base + KPI_KPE0));
90 writel(key_event[1], (keypad->mmio_base + KPI_KPE1));
91 writel(key_event[2], (keypad->mmio_base + KPI_KRE0));
92 writel(key_event[3], (keypad->mmio_base + KPI_KRE1));
93
94 pressed_keys = key_event[0] | ((u64)key_event[1] << 32);
95 released_keys = key_event[2] | ((u64)key_event[3] << 32);
96
97 /* Process pressed keys */
98 for_each_set_bit(index, (const unsigned long *)&pressed_keys, KEY_EVENT_BITS) {
99 code = MATRIX_SCAN_CODE(index / 8, (index % 8), row_shift); 100 key = keymap[code];
101
102 input_event(input_dev, EV_MSC, MSC_SCAN, code);
103 input_report_key(input_dev, key, 1);
104 }
105
106 /* Process released keys */
107 for_each_set_bit(index, (const unsigned long *)&released_keys, KEY_EVENT_BITS) {
108 code = MATRIX_SCAN_CODE(index / 8, (index % 8), row_shift);
109 key = keymap[code];
110
111 input_event(input_dev, EV_MSC, MSC_SCAN, code);
112 input_report_key(input_dev, key, 0);
113 }
114
115 input_sync(input_dev);
116 }
117
Signature · 2 lines
0-DAY CI Kernel Test Service https://github.com/intel/lkp-tests/wiki
Re: [PATCH v4 2/2] dt-bindings: input: Add Nuvoton MA35D1 keypad
In reply to Krzysztof KozlowskiQuoted 10 lines · Krzysztof Kozlowski
Quoted 3 lines · Ming-Jen Chen
Add YAML bindings for MA35D1 SoC keypad.
Signed-off-by Ming-Jen Chen <[email protected]>Repeating same comment third or fourth time is a waste of my time.
NAK.
Quoted 8 lines
It seems my or other reviewer's previous comments were not fully addressed. Maybe the feedback got lost between the quotes, maybe you just forgot to apply it. Please go back to the previous discussion and either implement all requested changes or keep discussing them.
Best regards,
Krzysztof
I will carefully review the v3 discussion thread to ensure that all feedback is properly implemented. Once I’ve addressed the issues, I’d like to confirm the next steps with you:
1. Should I drop v4 entirely and submit a revised patch as v5?
2. Alternatively, would you prefer me to resend v4 with the necessary corrections?
Please let me know your preference so I can proceed accordingly and ensure a smoother review process.
Thank you again for your guidance and understanding.
Best regards,
Ming-Jen Chen