Skip to contentSkip to conversation

Add vibrator driver support for Mediatek SoCs

PATCH New Fengping Yu 3 participants 9 messages Jun 15, 2020 – Jun 16, 2020

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Add vibrator driver support for Mediatek SoCs

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
Signature · 1 line
2.18.0
#1 lore raw

PATCH 1/3 dt-bindings:Add vibrator devicetree documentation

From: "fengping.yu" <[email protected]>

Add Mediatek regulator vibrator dt-bindings doc as yaml schema

---
 .../bindings/input/regulator-vibrator.yaml    | 65 +++++++++++++++++++
 1 file changed, 65 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/input/regulator-vibrator.yaml
Documentation/devicetree/bindings/input/regulator-vibrator.yaml new file +65 -0
new file mode 100644
index 000000000000..6511a8a80aff
@@ -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 <[email protected]>
+
+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>;
+  };
Signature · 5 lines
2.18.0
_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
#2 lore raw

Re: [PATCH v1 1/3] dt-bindings:Add vibrator devicetree documentation

Quoted 21 lines · Fengping Yu

From: "fengping.yu" <[email protected]>

Add Mediatek regulator vibrator dt-bindings doc as yaml schema

---
 .../bindings/input/regulator-vibrator.yaml    | 65 +++++++++++++++++++
 1 file changed, 65 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/input/regulator-vibrator.yaml
Documentation/devicetree/bindings/input/regulator-vibrator.yaml new file +5 -0
new file mode 100644
index 000000000000..6511a8a80aff
@@ -0,0 +1,65 @@
+# SPDX-License-Identifier: GPL-2.0
+%YAML 1.2
+---
+version: 1
+

Documentation/devicetree/bindings/input/regulator-vibrator.yaml line 15

Quoted 10 lines
Documentation/devicetree/bindings/input/regulator-vibrator.yaml new file +10 -0
+$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 <[email protected]>
+
+description: |
+  Registers a regulator device as vibrator, where the on/off capability is controlled by a regulator.

Line length?

Documentation/devicetree/bindings/input/regulator-vibrator.yaml line 28

Quoted 12 lines
Documentation/devicetree/bindings/input/regulator-vibrator.yaml new file +12 -0
+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?

Documentation/devicetree/bindings/input/regulator-vibrator.yaml line 37

Quoted 9 lines
Documentation/devicetree/bindings/input/regulator-vibrator.yaml new file +9 -0
+  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

Signature · 2 lines
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
#3 lore raw

PATCH 2/3 drivers: input: misc: Add mtk vibrator driver

In reply to Fengping Yu

From: "fengping.yu" <[email protected]>

This adds regulator vibrator driver for Mediatek SoCs.

---
 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
drivers/input/misc/Kconfig +10 -0
index 7e2e658d551c..71a0dd7a5271 100644
@@ -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
drivers/input/misc/Makefile +1 -0
index 8fd187f314bd..3329e5f12ad7 100644
@@ -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
drivers/input/misc/regulator-vibrator.c new file +422 -0

422 lines not on this page · raw message

Signature · 5 lines
2.18.0
_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
#4 lore raw

Re: [PATCH v1 2/3] drivers: input: misc: Add mtk vibrator driver

Thank you for the patch! Perhaps something to improve:

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

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(a)lists.01.org

#5 lore raw

Re: [PATCH v1 2/3] drivers: input: misc: Add mtk vibrator driver

In reply to Fengping Yu
Thank you for the patch! Perhaps something to improve:

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

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(a)lists.01.org

#6 lore raw

Re: [PATCH v1 2/3] drivers: input: misc: Add mtk vibrator driver

In reply to Fengping Yu

Hi!

Quoted 4 lines
drivers/input/misc/regulator-vibrator.c new file +4 -0
+static int mt_vibra_parse_dt(struct device *dev,
+		struct reg_vibr_config *vibr_conf)
+{
+	int ret;

drivers/input/misc/regulator-vibrator.c line 60

Quoted 10 lines
drivers/input/misc/regulator-vibrator.c new file +10 -0
+
+	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?

drivers/input/misc/regulator-vibrator.c line 66

Quoted 5 lines
drivers/input/misc/regulator-vibrator.c new file +5 -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;
+	}

Condition looks wrong.

Quoted 4 lines

+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

Signature · 2 lines
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
#7 lore raw

Re: [PATCH v1 2/3] drivers: input: misc: Add mtk vibrator driver

In reply to Fengping Yu
Quoted 17 lines · Fengping Yu

From: "fengping.yu" <[email protected]>

This adds regulator vibrator driver for Mediatek SoCs.

---
 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
drivers/input/misc/Kconfig +0 -0
index 7e2e658d551c..71a0dd7a5271 100644

drivers/input/misc/Kconfig config INPUT_REGULATOR_HAPTIC · line 462

Quoted 4 lines
drivers/input/misc/Kconfig +1 -0
@@ -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

#8 lore raw

PATCH 3/3 defconfig: Add CONFIG_INPUT_REGULATOR_VIBRATOR=m

In reply to Fengping Yu

From: "fengping.yu" <[email protected]>

Add Mediatek regulator vibrator support in defconfig.

---
 arch/arm64/configs/defconfig | 1 +
 1 file changed, 1 insertion(+)
arch/arm64/configs/defconfig +1 -0
index 112ced090b21..e89ad298dae5 100644
@@ -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
Signature · 5 lines
2.18.0
_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel