Add support for MediaTek keypad
PATCH v3 1/1 Add support for MediaTek keypad
This patchset add support to MediaTek matrix keypad.
Change since v2:
- remove extra space and redundant line
- update keypad devicetree document debounce time unit
- change to use devm_platform_ioremap_resource() to simplify code
- use bitmap to store and check keypad state
fengping.yu (2):
add dt-binding document for MediaTek Keypad
add MediaTek keypad driver
.../devicetree/bindings/input/mtk-kpd.txt | 61 +++++ arch/arm64/configs/defconfig | 1 + drivers/input/keyboard/Kconfig | 7 + drivers/input/keyboard/Makefile | 1 + drivers/input/keyboard/mtk-kpd.c | 258 ++++++++++++++++++ 5 files changed, 328 insertions(+) create mode 100644 Documentation/devicetree/bindings/input/mtk-kpd.txt create mode 100644 drivers/input/keyboard/mtk-kpd.c
--
2.18.0
A message that is not in the archive (sent off-list or not yet received): [email protected]
Re: [PATCH v3 2/2] add MediaTek keypad driver
Quoted 1 line · Fengping yu
From: "fengping.yu" <[email protected]>
You have to give a proper commit message. Emptiness is not good enough.
Quoted 1 line
Signed-off-by fengping.yu <[email protected]>
...
Quoted 1 line
+#include <
linux/fs.h>
This is for..?
Quoted 1 line
+#include <
linux/gpio.h>
Wrong header.
Review
Quoted 2 lines
(quoted diff) +2
-0+#include <linux/of_address.h> +#include <linux/of_irq.h>
I hardly found any user of these two.
...
Quoted 1 line
+#define
BITS_TO_U32(nr)DIV_ROUND_UP(nr, BITS_PER_BYTE * sizeof(u32))
I believe this is in bits.h. But see below.
Review
Quoted 11 lines
(quoted diff) +10
-0+struct mtk_keypad { + struct input_dev *input_dev; + struct clk *clk; + void __iomem *base; + unsigned int irqnr; + bool wakeup; + u32 key_debounce; + u32 n_rows; + u32 n_cols; + DECLARE_BITMAP(keymap_state, KPD_NUM_BITS);
And where is bitmap.h?
Quoted 1 line
+};
...
Review
Quoted 7 lines
(quoted diff) +6
-0+ for_each_set_bit(bit_nr, change, KPD_NUM_BITS) { + pressed = test_bit(bit_nr, new_state) == 0U; + dev_dbg(&keypad->input_dev->dev, "%s", + pressed ? "pressed" : "released"); + + /* per 32bit register only use low 16bit as keypad mem register */
Indentation issue.
Review
Quoted 1 line
(quoted diff) +1
-0+ code = keycode[bit_nr - 16 * (BITS_TO_U32(bit_nr) - 1)];
For example,
128 - 16 * (4 - 1) = 80 135 - 16 * (5 - 1) = 71
Is this correct?
Quoted 6 lines
(quoted diff) +6
-0+ input_report_key(keypad->input_dev, code, pressed); + input_sync(keypad->input_dev); + + dev_dbg(&keypad->input_dev->dev, + "report Linux keycode = %d\n", code); + }
...
Review
Quoted 2 lines
(quoted diff) +2
-0+ ret = of_property_read_u32(node, "mediatek,debounce-us", + &keypad->key_debounce);
Can't you use device property API instead?
Review
Quoted 1 line
(quoted diff) +1
-0+ keypad->wakeup = of_property_read_bool(node, "wakeup-source");
Ditto.
...
Review
Quoted 4 lines
(quoted diff) +3
-0+ keypad_pinctrl = devm_pinctrl_get(dev); + if (IS_ERR(keypad_pinctrl)) { + dev_err(dev, "Cannot find keypad_pinctrl!\n");
Isn't it a duplicate and pin control actually does this for you?
Review
Quoted 7 lines
(quoted diff) +6
-0+ return PTR_ERR(keypad_pinctrl); + } + + kpd_default = pinctrl_lookup_state(keypad_pinctrl, "default"); + if (IS_ERR(kpd_default)) { + dev_err(dev, "Cannot find ecall_state!\n");
Ditto.
Review
Quoted 4 lines
(quoted diff) +3
-0+ return PTR_ERR(kpd_default); + } + return pinctrl_select_state(keypad_pinctrl, kpd_default);
Indentation issue.
Quoted 1 line
+}
...
Review
Quoted 4 lines
(quoted diff) +3
-0+ keypad->base = devm_platform_ioremap_resource(pdev, 0); + if (IS_ERR(keypad->base)) { + dev_err(&pdev->dev, "KP iomap failed\n");
Duplicate noise.
Quoted 2 lines
(quoted diff) +2
-0+ return PTR_ERR(keypad->base); + }
...
Review
Quoted 4 lines
(quoted diff) +3
-0+ keypad->irqnr = platform_get_irq(pdev, 0); + if (keypad->irqnr < 0) { + dev_err(&pdev->dev, "KP get irqnr failed\n");
Duplicate noise.
Review
Quoted 1 line
(quoted diff) +1
-0+ ret = -keypad->irqnr;
Why -?
Quoted 2 lines
(quoted diff) +2
-0+ goto disable_kpd_clk; + }
Signature · 2 lines
With Best Regards, Andy Shevchenko