* [PATCH v1] Add vibrator driver support for Mediatek SoCs
@ 2020-06-15 11:42 Fengping Yu
2020-06-15 11:42 ` [PATCH v1 1/3] dt-bindings:Add vibrator devicetree documentation Fengping Yu
` (2 more replies)
0 siblings, 3 replies; 9+ messages in thread
From: Fengping Yu @ 2020-06-15 11:42 UTC (permalink / raw)
To: Dmitry Torokhov, Matthias Brugger, Catalin Marinas, Yingjoe Chen,
Pavel Machek, Jacek Anaszewski
Cc: linux-mediatek, linux-arm-kernel, linux-input
This serials adds regulator vibrator driver for Mediatek SoCs.
fengping.yu (3):
dt-bindings:Add vibrator devicetree documentation
drivers: input: misc: Add mtk vibrator driver
defconfig: Add CONFIG_INPUT_REGULATOR_VIBRATOR=m
.../bindings/input/regulator-vibrator.yaml | 65 +++
arch/arm64/configs/defconfig | 1 +
drivers/input/misc/Kconfig | 10 +
drivers/input/misc/Makefile | 1 +
drivers/input/misc/regulator-vibrator.c | 422 ++++++++++++++++++
5 files changed, 499 insertions(+)
create mode 100644 Documentation/devicetree/bindings/input/regulator-vibrator.yaml
create mode 100644 drivers/input/misc/regulator-vibrator.c
--
2.18.0
_______________________________________________
Linux-mediatek mailing list
Linux-mediatek@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-mediatek
^ permalink raw reply [flat|nested] 9+ messages in thread
* [PATCH v1 1/3] dt-bindings:Add vibrator devicetree documentation
2020-06-15 11:42 [PATCH v1] Add vibrator driver support for Mediatek SoCs Fengping Yu
@ 2020-06-15 11:42 ` Fengping Yu
2020-06-16 10:58 ` Pavel Machek
2020-06-15 11:42 ` [PATCH v1 2/3] drivers: input: misc: Add mtk vibrator driver Fengping Yu
2020-06-15 11:42 ` [PATCH v1 3/3] defconfig: Add CONFIG_INPUT_REGULATOR_VIBRATOR=m Fengping Yu
2 siblings, 1 reply; 9+ messages in thread
From: Fengping Yu @ 2020-06-15 11:42 UTC (permalink / raw)
To: Dmitry Torokhov, Matthias Brugger, Catalin Marinas, Yingjoe Chen,
Pavel Machek, Jacek Anaszewski
Cc: fengping.yu, linux-mediatek, linux-arm-kernel, linux-input
From: "fengping.yu" <fengping.yu@mediatek.com>
Add Mediatek regulator vibrator dt-bindings doc as yaml schema
Signed-off-by: fengping.yu <fengping.yu@mediatek.com>
---
.../bindings/input/regulator-vibrator.yaml | 65 +++++++++++++++++++
1 file changed, 65 insertions(+)
create mode 100644 Documentation/devicetree/bindings/input/regulator-vibrator.yaml
diff --git a/Documentation/devicetree/bindings/input/regulator-vibrator.yaml b/Documentation/devicetree/bindings/input/regulator-vibrator.yaml
new file mode 100644
index 000000000000..6511a8a80aff
--- /dev/null
+++ b/Documentation/devicetree/bindings/input/regulator-vibrator.yaml
@@ -0,0 +1,65 @@
+# SPDX-License-Identifier: GPL-2.0
+%YAML 1.2
+---
+version: 1
+
+$id: http://devicetree.org/schemas/input/regulator-vibrator.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Mediatek's regulator vibrator device tree bindings
+
+maintainer:
+ - Fengping Yu <fengping.yu@mediatek.com>
+
+description: |
+ Registers a regulator device as vibrator, where the on/off capability is controlled by a regulator.
+
+properties:
+ compatible:
+ const: "regulator-vibrator"
+
+ vibr-supply:
+ description: Power supply to the vibrator.
+ refs:Documentation/devicetree/bindings/regulator/regulator.txt for details.
+
+ max-volt:
+ description: The maximum voltage value supplied to the vibrator regulator.
+ The unit of the voltage is micro.
+
+ min-volt:
+ description: The minimum voltage value supplied to the vibrator regulator.
+ The unit of the voltage is micro.
+
+ min-limit:
+ description: The minimum duration time in ms for vibrator, default is 15ms.
+ If user request smaller duration, the default value will be used
+ instead. The default value comes from the smallest unit that can
+ be sensored.
+
+ max-limit:
+ description: The maximum duration time in ms for vibrator. If not set, it means
+ no max limitation.
+
+required:
+ - compatible
+ - min-volt
+ - max-volt
+
+examples:
+ - |
+
+ mt6359_vibr_ldo_reg: ldo_vibr {
+ regulator-name = "vibr";
+ regulator-min-microvolt = <1200000>;
+ regulator-max-microvolt = <3300000>;
+ regulator-enable-ramp-delay = <240>;
+ };
+
+ regulator_vibrator {
+ compatible = "regulator-vibrator";
+ min-volt = <2300000>;
+ max-volt = <3200000>;
+ min-limit = <25>;
+ max-limit = <15000>;
+ vib-supply = <&mt6359_vibr_ldo_reg>;
+ };
--
2.18.0
_______________________________________________
Linux-mediatek mailing list
Linux-mediatek@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-mediatek
^ permalink raw reply related [flat|nested] 9+ messages in thread
* [PATCH v1 2/3] drivers: input: misc: Add mtk vibrator driver
2020-06-15 11:42 [PATCH v1] Add vibrator driver support for Mediatek SoCs Fengping Yu
2020-06-15 11:42 ` [PATCH v1 1/3] dt-bindings:Add vibrator devicetree documentation Fengping Yu
@ 2020-06-15 11:42 ` Fengping Yu
2020-06-15 15:07 ` kernel test robot
` (3 more replies)
2020-06-15 11:42 ` [PATCH v1 3/3] defconfig: Add CONFIG_INPUT_REGULATOR_VIBRATOR=m Fengping Yu
2 siblings, 4 replies; 9+ messages in thread
From: Fengping Yu @ 2020-06-15 11:42 UTC (permalink / raw)
To: Dmitry Torokhov, Matthias Brugger, Catalin Marinas, Yingjoe Chen,
Pavel Machek, Jacek Anaszewski
Cc: fengping.yu, linux-mediatek, linux-arm-kernel, linux-input
From: "fengping.yu" <fengping.yu@mediatek.com>
This adds regulator vibrator driver for Mediatek SoCs.
Signed-off-by: fengping.yu <fengping.yu@mediatek.com>
---
drivers/input/misc/Kconfig | 10 +
drivers/input/misc/Makefile | 1 +
drivers/input/misc/regulator-vibrator.c | 422 ++++++++++++++++++++++++
3 files changed, 433 insertions(+)
create mode 100644 drivers/input/misc/regulator-vibrator.c
diff --git a/drivers/input/misc/Kconfig b/drivers/input/misc/Kconfig
index 7e2e658d551c..71a0dd7a5271 100644
--- a/drivers/input/misc/Kconfig
+++ b/drivers/input/misc/Kconfig
@@ -459,6 +459,16 @@ config INPUT_REGULATOR_HAPTIC
To compile this driver as a module, choose M here: the
module will be called regulator-haptic.
+config INPUT_REGULATOR_VIBRATOR
+ tristate "Regulator vibrator support"
+ depends on REGULATOR
+ help
+ This option enables device driver support vibrator by a regulator.
+ Say Y here if you want to enable this.
+
+ To compile this driver as a module, choose M here: the module will
+ be called regulator-vibrator.
+
config INPUT_RETU_PWRBUTTON
tristate "Retu Power button Driver"
depends on MFD_RETU
diff --git a/drivers/input/misc/Makefile b/drivers/input/misc/Makefile
index 8fd187f314bd..3329e5f12ad7 100644
--- a/drivers/input/misc/Makefile
+++ b/drivers/input/misc/Makefile
@@ -65,6 +65,7 @@ obj-$(CONFIG_INPUT_PWM_VIBRA) += pwm-vibra.o
obj-$(CONFIG_INPUT_RAVE_SP_PWRBUTTON) += rave-sp-pwrbutton.o
obj-$(CONFIG_INPUT_RB532_BUTTON) += rb532_button.o
obj-$(CONFIG_INPUT_REGULATOR_HAPTIC) += regulator-haptic.o
+obj-$(CONFIG_INPUT_REGULATOR_VIBRATOR) += regulator-vibrator.o
obj-$(CONFIG_INPUT_RETU_PWRBUTTON) += retu-pwrbutton.o
obj-$(CONFIG_INPUT_AXP20X_PEK) += axp20x-pek.o
obj-$(CONFIG_INPUT_GPIO_ROTARY_ENCODER) += rotary_encoder.o
diff --git a/drivers/input/misc/regulator-vibrator.c b/drivers/input/misc/regulator-vibrator.c
new file mode 100644
index 000000000000..03a0c71b55a4
--- /dev/null
+++ b/drivers/input/misc/regulator-vibrator.c
@@ -0,0 +1,422 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * Copyright (C) 2019 MediaTek Inc.
+ *
+ */
+
+#include <linux/device.h>
+#include <linux/hrtimer.h>
+#include <linux/init.h>
+#include <linux/input.h>
+#include <linux/kernel.h>
+#include <linux/module.h>
+#include <linux/of_platform.h>
+#include <linux/platform_device.h>
+#include <linux/regulator/consumer.h>
+#include <linux/spinlock.h>
+#include <linux/timer.h>
+#include <linux/workqueue.h>
+
+#define VIB_DEVICE "regulator_vibrator"
+
+#define DEFAULT_MIN_LIMIT 15
+
+struct reg_vibr_config {
+ unsigned int min_limit;
+ unsigned int max_limit;
+ unsigned int min_volt;
+ unsigned int max_volt;
+ struct regulator *reg;
+};
+
+struct reg_vibr {
+ struct input_dev *vibr_input_dev;
+ struct workqueue_struct *vibr_queue;
+ struct work_struct vibr_work;
+ struct hrtimer vibr_timer;
+ spinlock_t vibr_lock; /* hrtimer lock */
+ unsigned int vibr_dur;
+ bool vibr_active;
+ bool vibr_state;
+ bool reg_status;
+ bool vibr_shutdown;
+ struct reg_vibr_config vibr_conf;
+ struct notifier_block oc_handle;
+};
+
+static int mt_vibra_parse_dt(struct device *dev,
+ struct reg_vibr_config *vibr_conf)
+{
+ int ret;
+
+ if (device_property_read_u32(dev, "min-limit",
+ &vibr_conf->min_limit))
+ vibr_conf->min_limit = DEFAULT_MIN_LIMIT;
+ vibr_conf->min_limit = max_t(unsigned int,
+ vibr_conf->min_limit, DEFAULT_MIN_LIMIT);
+
+ if (device_property_read_u32(dev, "max-limit",
+ &vibr_conf->max_limit))
+ vibr_conf->max_limit = 0;
+
+ if (!vibr_conf->max_limit &&
+ vibr_conf->max_limit < vibr_conf->min_limit) {
+ dev_err(dev, "error load dts: get error limitation(min > max)\n");
+ return -EINVAL;
+ }
+
+ vibr_conf->reg = devm_regulator_get(dev, "vib");
+ if (IS_ERR(vibr_conf->reg)) {
+ dev_err(dev, "error load dts: get regulator return %d\n",
+ PTR_ERR(vibr_conf->reg));
+ vibr_conf->reg = NULL;
+ return PTR_ERR(vibr_conf->reg);
+ }
+
+ if (device_property_read_u32(dev, "max-volt",
+ &vibr_conf->max_volt)) {
+ dev_err(dev, "error load dts: get max-volt failed\n");
+ return -EINVAL;
+ }
+
+ if (device_property_read_u32(dev, "min-volt",
+ &vibr_conf->min_volt)) {
+ dev_err(dev, "error load dts: get min-volt failed!\n");
+ return -EINVAL;
+ }
+
+ if (vibr_conf->min_volt > vibr_conf->max_volt) {
+ dev_err(dev, "error load dts: get error voltage(min > max)\n");
+ return -EINVAL;
+ }
+
+ dev_info(dev, "vibr_conf = %u, %u, %u-%u\n",
+ vibr_conf->min_limit, vibr_conf->max_limit,
+ vibr_conf->min_volt, vibr_conf->max_volt);
+
+ return ret;
+}
+
+static int vibr_power_set(struct reg_vibr *vibr)
+{
+ int ret;
+
+ ret = regulator_set_voltage(vibr->vibr_conf.reg,
+ vibr->vibr_conf.min_volt,
+ vibr->vibr_conf.max_volt);
+ if (ret < 0)
+ dev_err(&vibr->vibr_input_dev->dev,
+ "set voltage fail, ret = %d\n", ret);
+
+ return ret;
+}
+
+static void vibr_enable(struct reg_vibr *vibr)
+{
+ if (!vibr->reg_status) {
+ if (regulator_enable(vibr->vibr_conf.reg))
+ dev_err(&vibr->vibr_input_dev->dev, "set vibr_reg enable failed!\n");
+ else
+ vibr->reg_status = 1;
+ } else {
+ dev_info(&vibr->vibr_input_dev->dev, "vibr_reg already enabled.\n");
+ }
+}
+
+static void vibr_disable(struct reg_vibr *vibr)
+{
+ if (vibr->reg_status) {
+ if (regulator_disable(vibr->vibr_conf.reg))
+ dev_err(&vibr->vibr_input_dev->dev, "set vibr_reg disable failed!\n");
+ else
+ vibr->reg_status = 0;
+ } else {
+ dev_info(&vibr->vibr_input_dev->dev, "vibr_reg already disabled.\n");
+ }
+}
+
+static void update_vibrator(struct work_struct *work)
+{
+ struct reg_vibr *vibr = container_of(work, struct reg_vibr, vibr_work);
+
+ if (!vibr->vibr_state)
+ vibr_disable(vibr);
+ else
+ vibr_enable(vibr);
+}
+
+static void vibrator_enable(struct reg_vibr *vibr,
+ unsigned int dur, unsigned int activate)
+{
+ unsigned long flags;
+
+ spin_lock_irqsave(&vibr->vibr_lock, flags);
+ hrtimer_cancel(&vibr->vibr_timer);
+
+ if (!activate || vibr->vibr_shutdown || !dur) {
+ vibr->vibr_state = 0;
+ } else {
+ dur = max(vibr->vibr_conf.min_limit, dur);
+ if (vibr->vibr_conf.max_limit)
+ dur = min(dur, vibr->vibr_conf.max_limit);
+ vibr->vibr_state = 1;
+ hrtimer_start(&vibr->vibr_timer,
+ ktime_set(dur / 1000, (dur % 1000) * 1000000),
+ HRTIMER_MODE_REL);
+ }
+ spin_unlock_irqrestore(&vibr->vibr_lock, flags);
+ queue_work(vibr->vibr_queue, &vibr->vibr_work);
+}
+
+static enum hrtimer_restart vibrator_timer_func(struct hrtimer *timer)
+{
+ struct reg_vibr *vibr = container_of(timer,
+ struct reg_vibr, vibr_timer);
+
+ vibr->vibr_state = 0;
+ queue_work(vibr->vibr_queue, &vibr->vibr_work);
+ return HRTIMER_NORESTART;
+}
+
+static const struct of_device_id vibr_of_ids[] = {
+ { .compatible = "regulator-vibrator", },
+ { /* sentienel */ }
+};
+
+static ssize_t activate_show(struct device *dev,
+ struct device_attribute *attr,
+ char *buf)
+{
+ struct reg_vibr *vibr = dev_get_drvdata(dev->parent);
+
+ return sprintf(buf, "%d\n", vibr->vibr_active);
+}
+
+static ssize_t activate_store(struct device *dev,
+ struct device_attribute *attr, const char *buf, size_t size)
+{
+ unsigned int activate, duration;
+ ssize_t ret;
+ struct reg_vibr *vibr = dev_get_drvdata(dev->parent);
+
+ ret = kstrtouint(buf, 10, &activate);
+ if (ret) {
+ dev_err(dev, "set activate fail\n");
+ return ret;
+ }
+ duration = vibr->vibr_dur;
+ dev_info(dev, "set activate duration = %u, %u\n",
+ activate, duration);
+ vibrator_enable(vibr, duration, activate);
+
+ ret = size;
+ return ret;
+}
+
+static ssize_t state_show(struct device *dev,
+ struct device_attribute *attr, char *buf)
+{
+ struct reg_vibr *vibr = dev_get_drvdata(dev->parent);
+
+ return sprintf(buf, "%d\n", vibr->vibr_state);
+}
+
+static ssize_t state_store(struct device *dev,
+ struct device_attribute *attr,
+ const char *buf, size_t size)
+{
+ unsigned int state;
+ ssize_t ret;
+ struct reg_vibr *vibr = dev_get_drvdata(dev->parent);
+
+ ret = kstrtouint(buf, 10, &state);
+ if (ret) {
+ dev_err(dev, "set state fail\n");
+ return ret;
+ }
+
+ vibr->vibr_state = state;
+ ret = size;
+ return ret;
+}
+
+static ssize_t duration_show(struct device *dev,
+ struct device_attribute *attr,
+ char *buf)
+{
+ struct reg_vibr *vibr = dev_get_drvdata(dev->parent);
+
+ return sprintf(buf, "%u\n", vibr->vibr_dur);
+}
+
+static ssize_t duration_store(struct device *dev,
+ struct device_attribute *attr,
+ const char *buf, size_t size)
+{
+ unsigned int duration;
+ ssize_t ret;
+ struct reg_vibr *vibr;
+
+ ret = kstrtouint(buf, 10, &duration);
+ if (ret) {
+ dev_err(dev, "set duration fail!\n");
+ return ret;
+ }
+ vibr = dev_get_drvdata(dev->parent);
+ vibr->vibr_dur = duration;
+
+ dev_dbg(dev, "set activate duration = %u\n",
+ duration);
+
+ ret = size;
+ return ret;
+}
+
+static DEVICE_ATTR_RW(activate);
+static DEVICE_ATTR_RW(state);
+static DEVICE_ATTR_RW(duration);
+
+static struct attribute *sysfs_attrs[] = {
+ &dev_attr_activate.attr,
+ &dev_attr_state.attr,
+ &dev_attr_duration.attr,
+ NULL,
+};
+
+static struct attribute_group vibr_group = {
+ .attrs = sysfs_attrs,
+};
+
+static int regulator_oc_event(struct notifier_block *nb,
+ unsigned long event, void *data)
+{
+ struct reg_vibr *vibr = container_of(nb, struct reg_vibr, oc_handle);
+
+ switch (event) {
+ case REGULATOR_EVENT_OVER_CURRENT:
+ case REGULATOR_EVENT_FAIL:
+ vibr_disable(vibr);
+ break;
+
+ default:
+ break;
+ }
+
+ return NOTIFY_OK;
+}
+
+static int vib_probe(struct platform_device *pdev)
+{
+ int ret;
+ struct reg_vibr *m_vibr;
+
+ m_vibr = devm_kzalloc(&pdev->dev, sizeof(struct reg_vibr), GFP_KERNEL);
+ if (!m_vibr)
+ return -ENOMEM;
+
+ m_vibr->vibr_input_dev = devm_input_allocate_device(&pdev->dev);
+ if (!m_vibr->vibr_input_dev) {
+ dev_err(&pdev->dev, "failed to allocate input dev\n");
+ return -ENOMEM;
+ }
+
+ m_vibr->vibr_input_dev->name = VIB_DEVICE;
+ m_vibr->vibr_input_dev->id.bustype = BUS_HOST;
+ m_vibr->vibr_input_dev->dev.parent = &pdev->dev;
+
+ m_vibr->vibr_queue = create_singlethread_workqueue(VIB_DEVICE);
+ if (!m_vibr->vibr_queue) {
+ dev_err(&pdev->dev, "unable to create workqueue\n");
+ return -ENOMEM;
+ }
+
+ ret = mt_vibra_parse_dt(&pdev->dev, &m_vibr->vibr_conf);
+ if (ret) {
+ dev_err(&pdev->dev, "failed to parse devicetree(%d)\n", ret);
+ return ret;
+ }
+
+ INIT_WORK(&m_vibr->vibr_work, update_vibrator);
+ spin_lock_init(&m_vibr->vibr_lock);
+ m_vibr->vibr_shutdown = 0;
+ if (regulator_is_enabled(m_vibr->vibr_conf.reg))
+ m_vibr->reg_status = 1;
+ else
+ m_vibr->reg_status = 0;
+
+ hrtimer_init(&m_vibr->vibr_timer, CLOCK_MONOTONIC, HRTIMER_MODE_REL);
+ m_vibr->vibr_timer.function = vibrator_timer_func;
+
+ ret = input_register_device(m_vibr->vibr_input_dev);
+ if (ret < 0) {
+ dev_dbg(&pdev->dev, "couldn't register input device\n");
+ return ret;
+ }
+
+ /* register oc notification for this regulator */
+ m_vibr->oc_handle.notifier_call = regulator_oc_event;
+ ret = devm_regulator_register_notifier(m_vibr->vibr_conf.reg,
+ &m_vibr->oc_handle);
+ if (ret)
+ dev_info(&pdev->dev, "regulator notifier request failed\n");
+
+ ret = sysfs_create_group(&pdev->dev.kobj, &vibr_group);
+ if (ret)
+ dev_warn(&pdev->dev, "cannot allocate sysfs group for %s\n",
+ VIB_DEVICE);
+
+ platform_set_drvdata(pdev, m_vibr);
+ ret = vibr_power_set(m_vibr);
+ if (ret < 0) {
+ dev_info(&pdev->dev, "set voltage for regulator fail\n");
+ return ret;
+ }
+
+ return 0;
+}
+
+static int vib_remove(struct platform_device *pdev)
+{
+ struct reg_vibr *vibr = platform_get_drvdata(pdev);
+
+ cancel_work_sync(&vibr->vibr_work);
+ hrtimer_cancel(&vibr->vibr_timer);
+
+ sysfs_remove_group(&pdev->dev.kobj, &vibr_group);
+
+ input_unregister_device(vibr->vibr_input_dev);
+
+ return 0;
+}
+
+static void vib_shutdown(struct platform_device *pdev)
+{
+ unsigned long flags;
+ struct reg_vibr *vibr = platform_get_drvdata(pdev);
+
+ spin_lock_irqsave(&vibr->vibr_lock, flags);
+ vibr->vibr_shutdown = 1;
+
+ if (vibr->vibr_state) {
+ vibr->vibr_state = 0;
+ spin_unlock_irqrestore(&vibr->vibr_lock, flags);
+ vibr_disable(vibr);
+ } else {
+ spin_unlock_irqrestore(&vibr->vibr_lock, flags);
+ }
+}
+
+static struct platform_driver vibrator_driver = {
+ .probe = vib_probe,
+ .remove = vib_remove,
+ .shutdown = vib_shutdown,
+ .driver = {
+ .name = VIB_DEVICE,
+ .of_match_table = vibr_of_ids,
+ },
+};
+module_platform_driver(vibrator_driver);
+
+MODULE_AUTHOR("Mediatek Corporation");
+MODULE_DESCRIPTION("Regulator Vibrator Driver (VIB)");
+MODULE_LICENSE("GPL");
--
2.18.0
_______________________________________________
Linux-mediatek mailing list
Linux-mediatek@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-mediatek
^ permalink raw reply related [flat|nested] 9+ messages in thread
* [PATCH v1 3/3] defconfig: Add CONFIG_INPUT_REGULATOR_VIBRATOR=m
2020-06-15 11:42 [PATCH v1] Add vibrator driver support for Mediatek SoCs Fengping Yu
2020-06-15 11:42 ` [PATCH v1 1/3] dt-bindings:Add vibrator devicetree documentation Fengping Yu
2020-06-15 11:42 ` [PATCH v1 2/3] drivers: input: misc: Add mtk vibrator driver Fengping Yu
@ 2020-06-15 11:42 ` Fengping Yu
2 siblings, 0 replies; 9+ messages in thread
From: Fengping Yu @ 2020-06-15 11:42 UTC (permalink / raw)
To: Dmitry Torokhov, Matthias Brugger, Catalin Marinas, Yingjoe Chen,
Pavel Machek, Jacek Anaszewski
Cc: fengping.yu, linux-mediatek, linux-arm-kernel, linux-input
From: "fengping.yu" <fengping.yu@mediatek.com>
Add Mediatek regulator vibrator support in defconfig.
Signed-off-by: fengping.yu <fengping.yu@mediatek.com>
---
arch/arm64/configs/defconfig | 1 +
1 file changed, 1 insertion(+)
diff --git a/arch/arm64/configs/defconfig b/arch/arm64/configs/defconfig
index 112ced090b21..e89ad298dae5 100644
--- a/arch/arm64/configs/defconfig
+++ b/arch/arm64/configs/defconfig
@@ -356,6 +356,7 @@ CONFIG_INPUT_MISC=y
CONFIG_INPUT_PM8941_PWRKEY=y
CONFIG_INPUT_PM8XXX_VIBRATOR=m
CONFIG_INPUT_HISI_POWERKEY=y
+CONFIG_INPUT_REGULATOR_VIBRATOR=m
# CONFIG_SERIO_SERPORT is not set
CONFIG_SERIO_AMBAKMI=y
CONFIG_LEGACY_PTY_COUNT=16
--
2.18.0
_______________________________________________
Linux-mediatek mailing list
Linux-mediatek@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-mediatek
^ permalink raw reply related [flat|nested] 9+ messages in thread
* Re: [PATCH v1 2/3] drivers: input: misc: Add mtk vibrator driver
2020-06-15 11:42 ` [PATCH v1 2/3] drivers: input: misc: Add mtk vibrator driver Fengping Yu
@ 2020-06-15 15:07 ` kernel test robot
2020-06-15 15:51 ` kernel test robot
` (2 subsequent siblings)
3 siblings, 0 replies; 9+ messages in thread
From: kernel test robot @ 2020-06-15 15:07 UTC (permalink / raw)
To: Fengping Yu, Dmitry Torokhov, Matthias Brugger, Catalin Marinas,
Yingjoe Chen, Pavel Machek, Jacek Anaszewski
Cc: linux-mediatek, fengping.yu, kbuild-all, linux-arm-kernel, linux-input
[-- Attachment #1: Type: text/plain, Size: 4577 bytes --]
Hi Fengping,
Thank you for the patch! Perhaps something to improve:
[auto build test WARNING on arm64/for-next/core]
[also build test WARNING on pavel-linux-leds/for-next v5.8-rc1 next-20200615]
[cannot apply to input/next]
[if your patch is applied to the wrong git tree, please drop us a note to help
improve the system. BTW, we also suggest to use '--base' option to specify the
base tree in git format-patch, please see https://stackoverflow.com/a/37406982]
url: https://github.com/0day-ci/linux/commits/Fengping-Yu/dt-bindings-Add-vibrator-devicetree-documentation/20200615-204209
base: https://git.kernel.org/pub/scm/linux/kernel/git/arm64/linux.git for-next/core
config: m68k-allmodconfig (attached as .config)
compiler: m68k-linux-gcc (GCC) 9.3.0
reproduce (this is a W=1 build):
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
chmod +x ~/bin/make.cross
# save the attached .config to linux build tree
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-9.3.0 make.cross ARCH=m68k
If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@intel.com>
All warnings (new ones prefixed by >>, old ones prefixed by <<):
In file included from include/linux/device.h:15,
from drivers/input/misc/regulator-vibrator.c:7:
drivers/input/misc/regulator-vibrator.c: In function 'mt_vibra_parse_dt':
>> drivers/input/misc/regulator-vibrator.c:70:16: warning: format '%d' expects argument of type 'int', but argument 3 has type 'long int' [-Wformat=]
70 | dev_err(dev, "error load dts: get regulator return %dn",
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
include/linux/dev_printk.h:19:22: note: in definition of macro 'dev_fmt'
19 | #define dev_fmt(fmt) fmt
| ^~~
>> drivers/input/misc/regulator-vibrator.c:70:3: note: in expansion of macro 'dev_err'
70 | dev_err(dev, "error load dts: get regulator return %dn",
| ^~~~~~~
drivers/input/misc/regulator-vibrator.c:70:55: note: format string is defined here
70 | dev_err(dev, "error load dts: get regulator return %dn",
| ~^
| |
| int
| %ld
drivers/input/misc/regulator-vibrator.c: In function 'vib_probe':
drivers/input/misc/regulator-vibrator.c:334:5: warning: 'ret' may be used uninitialized in this function [-Wmaybe-uninitialized]
334 | if (ret) {
| ^
vim +70 drivers/input/misc/regulator-vibrator.c
46
47 static int mt_vibra_parse_dt(struct device *dev,
48 struct reg_vibr_config *vibr_conf)
49 {
50 int ret;
51
52 if (device_property_read_u32(dev, "min-limit",
53 &vibr_conf->min_limit))
54 vibr_conf->min_limit = DEFAULT_MIN_LIMIT;
55 vibr_conf->min_limit = max_t(unsigned int,
56 vibr_conf->min_limit, DEFAULT_MIN_LIMIT);
57
58 if (device_property_read_u32(dev, "max-limit",
59 &vibr_conf->max_limit))
60 vibr_conf->max_limit = 0;
61
62 if (!vibr_conf->max_limit &&
63 vibr_conf->max_limit < vibr_conf->min_limit) {
64 dev_err(dev, "error load dts: get error limitation(min > max)\n");
65 return -EINVAL;
66 }
67
68 vibr_conf->reg = devm_regulator_get(dev, "vib");
69 if (IS_ERR(vibr_conf->reg)) {
> 70 dev_err(dev, "error load dts: get regulator return %d\n",
71 PTR_ERR(vibr_conf->reg));
72 vibr_conf->reg = NULL;
73 return PTR_ERR(vibr_conf->reg);
74 }
75
76 if (device_property_read_u32(dev, "max-volt",
77 &vibr_conf->max_volt)) {
78 dev_err(dev, "error load dts: get max-volt failed\n");
79 return -EINVAL;
80 }
81
82 if (device_property_read_u32(dev, "min-volt",
83 &vibr_conf->min_volt)) {
84 dev_err(dev, "error load dts: get min-volt failed!\n");
85 return -EINVAL;
86 }
87
88 if (vibr_conf->min_volt > vibr_conf->max_volt) {
89 dev_err(dev, "error load dts: get error voltage(min > max)\n");
90 return -EINVAL;
91 }
92
93 dev_info(dev, "vibr_conf = %u, %u, %u-%u\n",
94 vibr_conf->min_limit, vibr_conf->max_limit,
95 vibr_conf->min_volt, vibr_conf->max_volt);
96
97 return ret;
98 }
99
---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org
[-- Attachment #2: .config.gz --]
[-- Type: application/gzip, Size: 54017 bytes --]
[-- Attachment #3: Type: text/plain, Size: 170 bytes --]
_______________________________________________
Linux-mediatek mailing list
Linux-mediatek@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-mediatek
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH v1 2/3] drivers: input: misc: Add mtk vibrator driver
2020-06-15 11:42 ` [PATCH v1 2/3] drivers: input: misc: Add mtk vibrator driver Fengping Yu
2020-06-15 15:07 ` kernel test robot
@ 2020-06-15 15:51 ` kernel test robot
2020-06-16 11:02 ` Pavel Machek
2020-06-16 11:03 ` Pavel Machek
3 siblings, 0 replies; 9+ messages in thread
From: kernel test robot @ 2020-06-15 15:51 UTC (permalink / raw)
To: Fengping Yu, Dmitry Torokhov, Matthias Brugger, Catalin Marinas,
Yingjoe Chen, Pavel Machek, Jacek Anaszewski
Cc: kbuild-all, clang-built-linux, linux-mediatek, linux-input,
fengping.yu, linux-arm-kernel
[-- Attachment #1: Type: text/plain, Size: 4019 bytes --]
Hi Fengping,
Thank you for the patch! Perhaps something to improve:
[auto build test WARNING on arm64/for-next/core]
[also build test WARNING on pavel-linux-leds/for-next v5.8-rc1 next-20200615]
[cannot apply to input/next]
[if your patch is applied to the wrong git tree, please drop us a note to help
improve the system. BTW, we also suggest to use '--base' option to specify the
base tree in git format-patch, please see https://stackoverflow.com/a/37406982]
url: https://github.com/0day-ci/linux/commits/Fengping-Yu/dt-bindings-Add-vibrator-devicetree-documentation/20200615-204209
base: https://git.kernel.org/pub/scm/linux/kernel/git/arm64/linux.git for-next/core
config: x86_64-allyesconfig (attached as .config)
compiler: clang version 11.0.0 (https://github.com/llvm/llvm-project 3d8149c2a1228609fd7d7c91a04681304a2f0ca9)
reproduce (this is a W=1 build):
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
chmod +x ~/bin/make.cross
# install x86_64 cross compiling tool for clang build
# apt-get install binutils-x86-64-linux-gnu
# save the attached .config to linux build tree
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross ARCH=x86_64
If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@intel.com>
All warnings (new ones prefixed by >>, old ones prefixed by <<):
>> drivers/input/misc/regulator-vibrator.c:71:4: warning: format specifies type 'int' but the argument has type 'long' [-Wformat]
PTR_ERR(vibr_conf->reg));
^~~~~~~~~~~~~~~~~~~~~~~
include/linux/dev_printk.h:104:32: note: expanded from macro 'dev_err'
_dev_err(dev, dev_fmt(fmt), ##__VA_ARGS__)
~~~ ^~~~~~~~~~~
>> drivers/input/misc/regulator-vibrator.c:97:9: warning: variable 'ret' is uninitialized when used here [-Wuninitialized]
return ret;
^~~
drivers/input/misc/regulator-vibrator.c:50:9: note: initialize the variable 'ret' to silence this warning
int ret;
^
= 0
2 warnings generated.
vim +71 drivers/input/misc/regulator-vibrator.c
46
47 static int mt_vibra_parse_dt(struct device *dev,
48 struct reg_vibr_config *vibr_conf)
49 {
50 int ret;
51
52 if (device_property_read_u32(dev, "min-limit",
53 &vibr_conf->min_limit))
54 vibr_conf->min_limit = DEFAULT_MIN_LIMIT;
55 vibr_conf->min_limit = max_t(unsigned int,
56 vibr_conf->min_limit, DEFAULT_MIN_LIMIT);
57
58 if (device_property_read_u32(dev, "max-limit",
59 &vibr_conf->max_limit))
60 vibr_conf->max_limit = 0;
61
62 if (!vibr_conf->max_limit &&
63 vibr_conf->max_limit < vibr_conf->min_limit) {
64 dev_err(dev, "error load dts: get error limitation(min > max)\n");
65 return -EINVAL;
66 }
67
68 vibr_conf->reg = devm_regulator_get(dev, "vib");
69 if (IS_ERR(vibr_conf->reg)) {
70 dev_err(dev, "error load dts: get regulator return %d\n",
> 71 PTR_ERR(vibr_conf->reg));
72 vibr_conf->reg = NULL;
73 return PTR_ERR(vibr_conf->reg);
74 }
75
76 if (device_property_read_u32(dev, "max-volt",
77 &vibr_conf->max_volt)) {
78 dev_err(dev, "error load dts: get max-volt failed\n");
79 return -EINVAL;
80 }
81
82 if (device_property_read_u32(dev, "min-volt",
83 &vibr_conf->min_volt)) {
84 dev_err(dev, "error load dts: get min-volt failed!\n");
85 return -EINVAL;
86 }
87
88 if (vibr_conf->min_volt > vibr_conf->max_volt) {
89 dev_err(dev, "error load dts: get error voltage(min > max)\n");
90 return -EINVAL;
91 }
92
93 dev_info(dev, "vibr_conf = %u, %u, %u-%u\n",
94 vibr_conf->min_limit, vibr_conf->max_limit,
95 vibr_conf->min_volt, vibr_conf->max_volt);
96
> 97 return ret;
98 }
99
---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org
[-- Attachment #2: .config.gz --]
[-- Type: application/gzip, Size: 73471 bytes --]
[-- Attachment #3: Type: text/plain, Size: 170 bytes --]
_______________________________________________
Linux-mediatek mailing list
Linux-mediatek@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-mediatek
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH v1 1/3] dt-bindings:Add vibrator devicetree documentation
2020-06-15 11:42 ` [PATCH v1 1/3] dt-bindings:Add vibrator devicetree documentation Fengping Yu
@ 2020-06-16 10:58 ` Pavel Machek
0 siblings, 0 replies; 9+ messages in thread
From: Pavel Machek @ 2020-06-16 10:58 UTC (permalink / raw)
To: Fengping Yu
Cc: Catalin Marinas, Dmitry Torokhov, linux-mediatek,
Jacek Anaszewski, linux-input, Matthias Brugger, Yingjoe Chen,
linux-arm-kernel
On Mon 2020-06-15 19:42:02, Fengping Yu wrote:
> From: "fengping.yu" <fengping.yu@mediatek.com>
>
> Add Mediatek regulator vibrator dt-bindings doc as yaml schema
>
> Signed-off-by: fengping.yu <fengping.yu@mediatek.com>
> ---
> .../bindings/input/regulator-vibrator.yaml | 65 +++++++++++++++++++
> 1 file changed, 65 insertions(+)
> create mode 100644 Documentation/devicetree/bindings/input/regulator-vibrator.yaml
>
> diff --git a/Documentation/devicetree/bindings/input/regulator-vibrator.yaml b/Documentation/devicetree/bindings/input/regulator-vibrator.yaml
> new file mode 100644
> index 000000000000..6511a8a80aff
> --- /dev/null
> +++ b/Documentation/devicetree/bindings/input/regulator-vibrator.yaml
> @@ -0,0 +1,65 @@
> +# SPDX-License-Identifier: GPL-2.0
> +%YAML 1.2
> +---
> +version: 1
> +
> +$id: http://devicetree.org/schemas/input/regulator-vibrator.yaml#
> +$schema: http://devicetree.org/meta-schemas/core.yaml#
> +
> +title: Mediatek's regulator vibrator device tree bindings
> +
> +maintainer:
> + - Fengping Yu <fengping.yu@mediatek.com>
> +
> +description: |
> + Registers a regulator device as vibrator, where the on/off capability is controlled by a regulator.
Line length?
> +properties:
> + compatible:
> + const: "regulator-vibrator"
> +
> + vibr-supply:
> + description: Power supply to the vibrator.
> + refs:Documentation/devicetree/bindings/regulator/regulator.txt for details.
> +
> + max-volt:
> + description: The maximum voltage value supplied to the vibrator regulator.
> + The unit of the voltage is micro.
> +
should be -microvolt?
> + min-volt:
> + description: The minimum voltage value supplied to the vibrator regulator.
> + The unit of the voltage is micro.
> +
> + min-limit:
> + description: The minimum duration time in ms for vibrator, default is 15ms.
> + If user request smaller duration, the default value will be used
> + instead. The default value comes from the smallest unit that can
> + be sensored.
English?
Add -usec or something?
Pavel
--
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
_______________________________________________
Linux-mediatek mailing list
Linux-mediatek@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-mediatek
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH v1 2/3] drivers: input: misc: Add mtk vibrator driver
2020-06-15 11:42 ` [PATCH v1 2/3] drivers: input: misc: Add mtk vibrator driver Fengping Yu
2020-06-15 15:07 ` kernel test robot
2020-06-15 15:51 ` kernel test robot
@ 2020-06-16 11:02 ` Pavel Machek
2020-06-16 11:03 ` Pavel Machek
3 siblings, 0 replies; 9+ messages in thread
From: Pavel Machek @ 2020-06-16 11:02 UTC (permalink / raw)
To: Fengping Yu
Cc: Catalin Marinas, Dmitry Torokhov, linux-mediatek,
Jacek Anaszewski, linux-input, Matthias Brugger, Yingjoe Chen,
linux-arm-kernel
Hi!
> +static int mt_vibra_parse_dt(struct device *dev,
> + struct reg_vibr_config *vibr_conf)
> +{
> + int ret;
> +
> + if (device_property_read_u32(dev, "min-limit",
> + &vibr_conf->min_limit))
> + vibr_conf->min_limit = DEFAULT_MIN_LIMIT;
> + vibr_conf->min_limit = max_t(unsigned int,
> + vibr_conf->min_limit, DEFAULT_MIN_LIMIT);
> +
> + if (device_property_read_u32(dev, "max-limit",
> + &vibr_conf->max_limit))
> + vibr_conf->max_limit = 0;
Is max_limit useful? Do you enforce it in useful way?
> + if (!vibr_conf->max_limit &&
> + vibr_conf->max_limit < vibr_conf->min_limit) {
> + dev_err(dev, "error load dts: get error limitation(min > max)\n");
> + return -EINVAL;
> + }
Condition looks wrong.
> +static struct attribute *sysfs_attrs[] = { + &dev_attr_activate.attr, +
> &dev_attr_state.attr, + &dev_attr_duration.attr, + NULL, +}; + +static struct
> attribute_group vibr_group = { + .attrs = sysfs_attrs, +}; + +static int
> regulator_oc_event(struct notifier_block *nb, + unsigned long event, void *data) +{ +
Do you need custom attributes? Why? Where is their documentation?
Pavel
--
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
_______________________________________________
Linux-mediatek mailing list
Linux-mediatek@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-mediatek
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH v1 2/3] drivers: input: misc: Add mtk vibrator driver
2020-06-15 11:42 ` [PATCH v1 2/3] drivers: input: misc: Add mtk vibrator driver Fengping Yu
` (2 preceding siblings ...)
2020-06-16 11:02 ` Pavel Machek
@ 2020-06-16 11:03 ` Pavel Machek
3 siblings, 0 replies; 9+ messages in thread
From: Pavel Machek @ 2020-06-16 11:03 UTC (permalink / raw)
To: Fengping Yu
Cc: Catalin Marinas, Dmitry Torokhov, linux-mediatek,
Jacek Anaszewski, linux-input, Matthias Brugger, Yingjoe Chen,
linux-arm-kernel
On Mon 2020-06-15 19:42:04, Fengping Yu wrote:
> From: "fengping.yu" <fengping.yu@mediatek.com>
>
> This adds regulator vibrator driver for Mediatek SoCs.
>
> Signed-off-by: fengping.yu <fengping.yu@mediatek.com>
> ---
> drivers/input/misc/Kconfig | 10 +
> drivers/input/misc/Makefile | 1 +
> drivers/input/misc/regulator-vibrator.c | 422 ++++++++++++++++++++++++
> 3 files changed, 433 insertions(+)
> create mode 100644 drivers/input/misc/regulator-vibrator.c
>
> diff --git a/drivers/input/misc/Kconfig b/drivers/input/misc/Kconfig
> index 7e2e658d551c..71a0dd7a5271 100644
> --- a/drivers/input/misc/Kconfig
> +++ b/drivers/input/misc/Kconfig
> @@ -459,6 +459,16 @@ config INPUT_REGULATOR_HAPTIC
> To compile this driver as a module, choose M here: the
> module will be called regulator-haptic.
>
> +config INPUT_REGULATOR_VIBRATOR
Can you look at input_regulator_haptic, and explain why you need separate driver?
Pavel
_______________________________________________
Linux-mediatek mailing list
Linux-mediatek@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-mediatek
^ permalink raw reply [flat|nested] 9+ messages in thread
end of thread, other threads:[~2020-06-16 11:03 UTC | newest]
Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-06-15 11:42 [PATCH v1] Add vibrator driver support for Mediatek SoCs Fengping Yu
2020-06-15 11:42 ` [PATCH v1 1/3] dt-bindings:Add vibrator devicetree documentation Fengping Yu
2020-06-16 10:58 ` Pavel Machek
2020-06-15 11:42 ` [PATCH v1 2/3] drivers: input: misc: Add mtk vibrator driver Fengping Yu
2020-06-15 15:07 ` kernel test robot
2020-06-15 15:51 ` kernel test robot
2020-06-16 11:02 ` Pavel Machek
2020-06-16 11:03 ` Pavel Machek
2020-06-15 11:42 ` [PATCH v1 3/3] defconfig: Add CONFIG_INPUT_REGULATOR_VIBRATOR=m Fengping Yu
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).