Merge tag 'v6.3-rc2' into next
authorDmitry Torokhov <dmitry.torokhov@gmail.com>
Fri, 17 Mar 2023 11:01:30 +0000 (04:01 -0700)
committerDmitry Torokhov <dmitry.torokhov@gmail.com>
Fri, 17 Mar 2023 11:01:30 +0000 (04:01 -0700)
Merge with mainline to get of_property_present() and other newer APIs.

Documentation/devicetree/bindings/input/google,cros-ec-keyb.yaml
arch/arm/mach-pxa/spitz.c
drivers/input/keyboard/gpio_keys.c
drivers/input/misc/Kconfig
drivers/input/misc/Makefile
drivers/input/misc/hp_sdc_rtc.c
drivers/input/misc/nxp-bbnsm-pwrkey.c [new file with mode: 0644]
drivers/input/touchscreen/hideep.c
include/linux/input/matrix_keypad.h

index e05690b..a8abdb3 100644 (file)
@@ -45,7 +45,7 @@ properties:
       when the keyboard has a custom design for the top row keys.
 
 dependencies:
-  function-row-phsymap: [ 'linux,keymap' ]
+  function-row-physmap: [ 'linux,keymap' ]
   google,needs-ghost-filter: [ 'linux,keymap' ]
 
 required:
index 26f0ebc..4325bdc 100644 (file)
@@ -25,6 +25,7 @@
 #include <linux/spi/pxa2xx_spi.h>
 #include <linux/mtd/sharpsl.h>
 #include <linux/mtd/physmap.h>
+#include <linux/input-event-codes.h>
 #include <linux/input/matrix_keypad.h>
 #include <linux/regulator/machine.h>
 #include <linux/io.h>
index 5496482..c42f86a 100644 (file)
@@ -770,6 +770,9 @@ gpio_keys_get_devtree_pdata(struct device *dev)
                                             &button->type))
                        button->type = EV_KEY;
 
+               fwnode_property_read_u32(child, "linux,input-value",
+                                        (u32 *)&button->value);
+
                button->wakeup =
                        fwnode_property_read_bool(child, "wakeup-source") ||
                        /* legacy name */
index 5c2d0c0..81a54a5 100644 (file)
@@ -119,6 +119,17 @@ config INPUT_ATMEL_CAPTOUCH
          To compile this driver as a module, choose M here: the
          module will be called atmel_captouch.
 
+config INPUT_BBNSM_PWRKEY
+       tristate "NXP BBNSM Power Key Driver"
+       depends on ARCH_MXC || COMPILE_TEST
+       depends on OF
+       help
+         This is the bbnsm powerkey driver for the NXP i.MX application
+         processors.
+
+         To compile this driver as a module, choose M here; the
+         module will be called bbnsm_pwrkey.
+
 config INPUT_BMA150
        tristate "BMA150/SMB380 acceleration sensor support"
        depends on I2C
index 6194926..04296a4 100644 (file)
@@ -21,6 +21,7 @@ obj-$(CONFIG_INPUT_ATC260X_ONKEY)     += atc260x-onkey.o
 obj-$(CONFIG_INPUT_ATI_REMOTE2)                += ati_remote2.o
 obj-$(CONFIG_INPUT_ATLAS_BTNS)         += atlas_btns.o
 obj-$(CONFIG_INPUT_ATMEL_CAPTOUCH)     += atmel_captouch.o
+obj-$(CONFIG_INPUT_BBNSM_PWRKEY)       += nxp-bbnsm-pwrkey.o
 obj-$(CONFIG_INPUT_BMA150)             += bma150.o
 obj-$(CONFIG_INPUT_CM109)              += cm109.o
 obj-$(CONFIG_INPUT_CMA3000)            += cma3000_d0x.o
index 199bc17..afc0d6d 100644 (file)
@@ -265,7 +265,7 @@ static inline int hp_sdc_rtc_read_ct(struct timespec64 *res) {
        return 0;
 }
 
-static int hp_sdc_rtc_proc_show(struct seq_file *m, void *v)
+static int __maybe_unused hp_sdc_rtc_proc_show(struct seq_file *m, void *v)
 {
 #define YN(bit) ("no")
 #define NY(bit) ("yes")
diff --git a/drivers/input/misc/nxp-bbnsm-pwrkey.c b/drivers/input/misc/nxp-bbnsm-pwrkey.c
new file mode 100644 (file)
index 0000000..1d99206
--- /dev/null
@@ -0,0 +1,193 @@
+// SPDX-License-Identifier: GPL-2.0+
+//
+// Copyright 2022 NXP.
+
+#include <linux/device.h>
+#include <linux/err.h>
+#include <linux/init.h>
+#include <linux/input.h>
+#include <linux/interrupt.h>
+#include <linux/io.h>
+#include <linux/jiffies.h>
+#include <linux/kernel.h>
+#include <linux/mfd/syscon.h>
+#include <linux/module.h>
+#include <linux/of.h>
+#include <linux/of_address.h>
+#include <linux/platform_device.h>
+#include <linux/pm_wakeirq.h>
+#include <linux/regmap.h>
+
+#define BBNSM_CTRL             0x8
+#define BBNSM_INT_EN           0x10
+#define BBNSM_EVENTS           0x14
+#define BBNSM_PAD_CTRL         0x24
+
+#define BBNSM_BTN_PRESSED      BIT(7)
+#define BBNSM_PWR_ON           BIT(6)
+#define BBNSM_BTN_OFF          BIT(5)
+#define BBNSM_EMG_OFF          BIT(4)
+#define BBNSM_PWRKEY_EVENTS    (BBNSM_PWR_ON | BBNSM_BTN_OFF | BBNSM_EMG_OFF)
+#define BBNSM_DP_EN            BIT(24)
+
+#define DEBOUNCE_TIME          30
+#define REPEAT_INTERVAL                60
+
+struct bbnsm_pwrkey {
+       struct regmap *regmap;
+       int irq;
+       int keycode;
+       int keystate;  /* 1:pressed */
+       struct timer_list check_timer;
+       struct input_dev *input;
+};
+
+static void bbnsm_pwrkey_check_for_events(struct timer_list *t)
+{
+       struct bbnsm_pwrkey *bbnsm = from_timer(bbnsm, t, check_timer);
+       struct input_dev *input = bbnsm->input;
+       u32 state;
+
+       regmap_read(bbnsm->regmap, BBNSM_EVENTS, &state);
+
+       state = state & BBNSM_BTN_PRESSED ? 1 : 0;
+
+       /* only report new event if status changed */
+       if (state ^ bbnsm->keystate) {
+               bbnsm->keystate = state;
+               input_event(input, EV_KEY, bbnsm->keycode, state);
+               input_sync(input);
+               pm_relax(bbnsm->input->dev.parent);
+       }
+
+       /* repeat check if pressed long */
+       if (state)
+               mod_timer(&bbnsm->check_timer,
+                         jiffies + msecs_to_jiffies(REPEAT_INTERVAL));
+}
+
+static irqreturn_t bbnsm_pwrkey_interrupt(int irq, void *dev_id)
+{
+       struct platform_device *pdev = dev_id;
+       struct bbnsm_pwrkey *bbnsm = platform_get_drvdata(pdev);
+       u32 event;
+
+       regmap_read(bbnsm->regmap, BBNSM_EVENTS, &event);
+       if (!(event & BBNSM_BTN_OFF))
+               return IRQ_NONE;
+
+       pm_wakeup_event(bbnsm->input->dev.parent, 0);
+
+       mod_timer(&bbnsm->check_timer,
+                  jiffies + msecs_to_jiffies(DEBOUNCE_TIME));
+
+       /* clear PWR OFF */
+       regmap_write(bbnsm->regmap, BBNSM_EVENTS, BBNSM_BTN_OFF);
+
+       return IRQ_HANDLED;
+}
+
+static void bbnsm_pwrkey_act(void *pdata)
+{
+       struct bbnsm_pwrkey *bbnsm = pdata;
+
+       timer_shutdown_sync(&bbnsm->check_timer);
+}
+
+static int bbnsm_pwrkey_probe(struct platform_device *pdev)
+{
+       struct bbnsm_pwrkey *bbnsm;
+       struct input_dev *input;
+       struct device_node *np = pdev->dev.of_node;
+       int error;
+
+       bbnsm = devm_kzalloc(&pdev->dev, sizeof(*bbnsm), GFP_KERNEL);
+       if (!bbnsm)
+               return -ENOMEM;
+
+       bbnsm->regmap = syscon_node_to_regmap(np->parent);
+       if (IS_ERR(bbnsm->regmap)) {
+               dev_err(&pdev->dev, "bbnsm pwerkey get regmap failed\n");
+               return PTR_ERR(bbnsm->regmap);
+       }
+
+       if (device_property_read_u32(&pdev->dev, "linux,code",
+                                    &bbnsm->keycode)) {
+               bbnsm->keycode = KEY_POWER;
+               dev_warn(&pdev->dev, "key code is not specified, using default KEY_POWER\n");
+       }
+
+       bbnsm->irq = platform_get_irq(pdev, 0);
+       if (bbnsm->irq < 0)
+               return -EINVAL;
+
+       /* config the BBNSM power related register */
+       regmap_update_bits(bbnsm->regmap, BBNSM_CTRL, BBNSM_DP_EN, BBNSM_DP_EN);
+
+       /* clear the unexpected interrupt before driver ready */
+       regmap_write_bits(bbnsm->regmap, BBNSM_EVENTS, BBNSM_PWRKEY_EVENTS,
+                         BBNSM_PWRKEY_EVENTS);
+
+       timer_setup(&bbnsm->check_timer, bbnsm_pwrkey_check_for_events, 0);
+
+       input = devm_input_allocate_device(&pdev->dev);
+       if (!input) {
+               dev_err(&pdev->dev, "failed to allocate the input device\n");
+               return -ENOMEM;
+       }
+
+       input->name = pdev->name;
+       input->phys = "bbnsm-pwrkey/input0";
+       input->id.bustype = BUS_HOST;
+
+       input_set_capability(input, EV_KEY, bbnsm->keycode);
+
+       /* input customer action to cancel release timer */
+       error = devm_add_action(&pdev->dev, bbnsm_pwrkey_act, bbnsm);
+       if (error) {
+               dev_err(&pdev->dev, "failed to register remove action\n");
+               return error;
+       }
+
+       bbnsm->input = input;
+       platform_set_drvdata(pdev, bbnsm);
+
+       error = devm_request_irq(&pdev->dev, bbnsm->irq, bbnsm_pwrkey_interrupt,
+                                IRQF_SHARED, pdev->name, pdev);
+       if (error) {
+               dev_err(&pdev->dev, "interrupt not available.\n");
+               return error;
+       }
+
+       error = input_register_device(input);
+       if (error) {
+               dev_err(&pdev->dev, "failed to register input device\n");
+               return error;
+       }
+
+       device_init_wakeup(&pdev->dev, true);
+       error = dev_pm_set_wake_irq(&pdev->dev, bbnsm->irq);
+       if (error)
+               dev_warn(&pdev->dev, "irq wake enable failed.\n");
+
+       return 0;
+}
+
+static const struct of_device_id bbnsm_pwrkey_ids[] = {
+       { .compatible = "nxp,imx93-bbnsm-pwrkey" },
+       { /* sentinel */ }
+};
+MODULE_DEVICE_TABLE(of, bbnsm_pwrkey_ids);
+
+static struct platform_driver bbnsm_pwrkey_driver = {
+       .driver = {
+               .name = "bbnsm_pwrkey",
+               .of_match_table = bbnsm_pwrkey_ids,
+       },
+       .probe = bbnsm_pwrkey_probe,
+};
+module_platform_driver(bbnsm_pwrkey_driver);
+
+MODULE_AUTHOR("Jacky Bai <ping.bai@nxp.com>");
+MODULE_DESCRIPTION("NXP bbnsm power key Driver");
+MODULE_LICENSE("GPL");
index bd454d9..7c70200 100644 (file)
@@ -35,6 +35,7 @@
 #define HIDEEP_EVENT_ADDR              0x240
 
 /* command list */
+#define HIDEEP_WORK_MODE               0x081e
 #define HIDEEP_RESET_CMD               0x9800
 
 /* event bit */
@@ -271,9 +272,14 @@ static int hideep_pgm_w_reg(struct hideep_ts *ts, u32 addr, u32 val)
 
 #define SW_RESET_IN_PGM(clk)                                   \
 {                                                              \
+       __be32 data = cpu_to_be32(0x01);                        \
        hideep_pgm_w_reg(ts, HIDEEP_SYSCON_WDT_CNT, (clk));     \
        hideep_pgm_w_reg(ts, HIDEEP_SYSCON_WDT_CON, 0x03);      \
-       hideep_pgm_w_reg(ts, HIDEEP_SYSCON_WDT_CON, 0x01);      \
+       /*                                                      \
+        * The first write may already cause a reset, use a raw \
+        * write for the second write to avoid error logging.   \
+        */                                                     \
+       hideep_pgm_w_mem(ts, HIDEEP_SYSCON_WDT_CON, &data, 1);  \
 }
 
 #define SET_FLASH_PIO(ce)                                      \
@@ -467,9 +473,9 @@ static int hideep_program_nvm(struct hideep_ts *ts,
        u32 addr = 0;
        int error;
 
-       error = hideep_nvm_unlock(ts);
-       if (error)
-               return error;
+       error = hideep_nvm_unlock(ts);
+       if (error)
+               return error;
 
        while (ucode_len > 0) {
                xfer_len = min_t(size_t, ucode_len, HIDEEP_NVM_PAGE_SIZE);
@@ -959,6 +965,21 @@ static const struct attribute_group hideep_ts_attr_group = {
        .attrs = hideep_ts_sysfs_entries,
 };
 
+static void hideep_set_work_mode(struct hideep_ts *ts)
+{
+       /*
+        * Reset touch report format to the native HiDeep 20 protocol if requested.
+        * This is necessary to make touchscreens which come up in I2C-HID mode
+        * work with this driver.
+        *
+        * Note this is a kernel internal device-property set by x86 platform code,
+        * this MUST not be used in devicetree files without first adding it to
+        * the DT bindings.
+        */
+       if (device_property_read_bool(&ts->client->dev, "hideep,force-native-protocol"))
+               regmap_write(ts->reg, HIDEEP_WORK_MODE, 0x00);
+}
+
 static int hideep_suspend(struct device *dev)
 {
        struct i2c_client *client = to_i2c_client(dev);
@@ -982,6 +1003,8 @@ static int hideep_resume(struct device *dev)
                return error;
        }
 
+       hideep_set_work_mode(ts);
+
        enable_irq(client->irq);
 
        return 0;
@@ -1058,6 +1081,8 @@ static int hideep_probe(struct i2c_client *client)
                return error;
        }
 
+       hideep_set_work_mode(ts);
+
        error = hideep_init_input(ts);
        if (error)
                return error;
index 9476768..b8d8d69 100644 (file)
@@ -3,8 +3,9 @@
 #define _MATRIX_KEYPAD_H
 
 #include <linux/types.h>
-#include <linux/input.h>
-#include <linux/of.h>
+
+struct device;
+struct input_dev;
 
 #define MATRIX_MAX_ROWS                32
 #define MATRIX_MAX_COLS                32