linux-input.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2 0/3] Add support for sc2730 and sc2721
@ 2020-11-17  3:49 Chunyan Zhang
  2020-11-17  3:49 ` [PATCH v2 1/3] input: sc27xx: " Chunyan Zhang
                   ` (2 more replies)
  0 siblings, 3 replies; 9+ messages in thread
From: Chunyan Zhang @ 2020-11-17  3:49 UTC (permalink / raw)
  To: Dmitry Torokhov, Rob Herring
  Cc: linux-input, devicetree, linux-kernel, Orson Zhai, Baolin Wang,
	Chunyan Zhang, Chunyan Zhang, Nemo Han

This patchset add new compatible strings and match data to support sc2730 and sc2721,
also convert the bindings to yaml schema.

Changes since v1:
* fixed the error when running dt_binding_check;

Chunyan Zhang (2):
  dt-bindings: input: Convert sc27xx-vibra.txt to json-schema
  dt-bindings: input: Add compatible string for SC2721 and SC2730

Nemo Han (1):
  input: sc27xx: Add support for sc2730 and sc2721

 .../bindings/input/sprd,sc27xx-vibra.txt      | 23 -------
 .../bindings/input/sprd,sc27xx-vibrator.yaml  | 48 ++++++++++++++
 drivers/input/misc/sc27xx-vibra.c             | 64 ++++++++++++++++---
 3 files changed, 102 insertions(+), 33 deletions(-)
 delete mode 100644 Documentation/devicetree/bindings/input/sprd,sc27xx-vibra.txt
 create mode 100644 Documentation/devicetree/bindings/input/sprd,sc27xx-vibrator.yaml

-- 
2.25.1


^ permalink raw reply	[flat|nested] 9+ messages in thread

* [PATCH v2 1/3] input: sc27xx: Add support for sc2730 and sc2721
  2020-11-17  3:49 [PATCH v2 0/3] Add support for sc2730 and sc2721 Chunyan Zhang
@ 2020-11-17  3:49 ` Chunyan Zhang
  2020-12-12  3:04   ` Dmitry Torokhov
  2020-11-17  3:49 ` [PATCH v2 2/3] dt-bindings: input: Convert sc27xx-vibra.txt to json-schema Chunyan Zhang
  2020-11-17  3:49 ` [PATCH v2 3/3] dt-bindings: input: Add compatible string for SC2721 and SC2730 Chunyan Zhang
  2 siblings, 1 reply; 9+ messages in thread
From: Chunyan Zhang @ 2020-11-17  3:49 UTC (permalink / raw)
  To: Dmitry Torokhov, Rob Herring
  Cc: linux-input, devicetree, linux-kernel, Orson Zhai, Baolin Wang,
	Chunyan Zhang, Chunyan Zhang, Nemo Han

From: Nemo Han <nemo.han@unisoc.com>

Add new compatible strings and match data to support sc2730 and sc2721
which are two varieties of SC27XX family.

Signed-off-by: Nemo Han <nemo.han@unisoc.com>
Signed-off-by: Chunyan Zhang <chunyan.zhang@unisoc.com>
---
 drivers/input/misc/sc27xx-vibra.c | 64 ++++++++++++++++++++++++++-----
 1 file changed, 54 insertions(+), 10 deletions(-)

diff --git a/drivers/input/misc/sc27xx-vibra.c b/drivers/input/misc/sc27xx-vibra.c
index 295251abbdac..b4adb826db56 100644
--- a/drivers/input/misc/sc27xx-vibra.c
+++ b/drivers/input/misc/sc27xx-vibra.c
@@ -5,43 +5,77 @@
 
 #include <linux/module.h>
 #include <linux/of_address.h>
+#include <linux/of_device.h>
 #include <linux/platform_device.h>
 #include <linux/regmap.h>
 #include <linux/input.h>
 #include <linux/workqueue.h>
 
-#define CUR_DRV_CAL_SEL		GENMASK(13, 12)
-#define SLP_LDOVIBR_PD_EN	BIT(9)
-#define LDO_VIBR_PD		BIT(8)
+#define CUR_DRV_CAL_SEL			GENMASK(13, 12)
+#define SLP_LDOVIBR_PD_EN		BIT(9)
+#define LDO_VIBR_PD			BIT(8)
+#define SC2730_CUR_DRV_CAL_SEL		0
+#define SC2730_SLP_LDOVIBR_PD_EN	BIT(14)
+#define SC2730_LDO_VIBR_PD		BIT(13)
+
+struct sc27xx_vibra_data {
+	u32 cur_drv_cal_sel;
+	u32 slp_pd_en;
+	u32 ldo_pd;
+};
 
 struct vibra_info {
 	struct input_dev	*input_dev;
 	struct work_struct	play_work;
 	struct regmap		*regmap;
+	const struct sc27xx_vibra_data *data;
 	u32			base;
 	u32			strength;
 	bool			enabled;
 };
 
+static const struct sc27xx_vibra_data sc2731_data = {
+	.cur_drv_cal_sel = CUR_DRV_CAL_SEL,
+	.slp_pd_en = SLP_LDOVIBR_PD_EN,
+	.ldo_pd = LDO_VIBR_PD,
+};
+
+static const struct sc27xx_vibra_data sc2730_data = {
+	.cur_drv_cal_sel = SC2730_CUR_DRV_CAL_SEL,
+	.slp_pd_en = SC2730_SLP_LDOVIBR_PD_EN,
+	.ldo_pd = SC2730_LDO_VIBR_PD,
+};
+
+static const struct sc27xx_vibra_data sc2721_data = {
+	.cur_drv_cal_sel = CUR_DRV_CAL_SEL,
+	.slp_pd_en = SLP_LDOVIBR_PD_EN,
+	.ldo_pd = LDO_VIBR_PD,
+};
+
 static void sc27xx_vibra_set(struct vibra_info *info, bool on)
 {
+	const struct sc27xx_vibra_data *data = info->data;
 	if (on) {
-		regmap_update_bits(info->regmap, info->base, LDO_VIBR_PD, 0);
+		regmap_update_bits(info->regmap, info->base, data->ldo_pd, 0);
 		regmap_update_bits(info->regmap, info->base,
-				   SLP_LDOVIBR_PD_EN, 0);
+				   data->slp_pd_en, 0);
 		info->enabled = true;
 	} else {
-		regmap_update_bits(info->regmap, info->base, LDO_VIBR_PD,
-				   LDO_VIBR_PD);
+		regmap_update_bits(info->regmap, info->base, data->ldo_pd,
+				   data->ldo_pd);
 		regmap_update_bits(info->regmap, info->base,
-				   SLP_LDOVIBR_PD_EN, SLP_LDOVIBR_PD_EN);
+				   data->slp_pd_en, data->slp_pd_en);
 		info->enabled = false;
 	}
 }
 
 static int sc27xx_vibra_hw_init(struct vibra_info *info)
 {
-	return regmap_update_bits(info->regmap, info->base, CUR_DRV_CAL_SEL, 0);
+	const struct sc27xx_vibra_data *data = info->data;
+
+	if (!data->cur_drv_cal_sel)
+		return 0;
+	return regmap_update_bits(info->regmap, info->base, data->cur_drv_cal_sel, 0);
 }
 
 static void sc27xx_vibra_play_work(struct work_struct *work)
@@ -78,8 +112,15 @@ static void sc27xx_vibra_close(struct input_dev *input)
 static int sc27xx_vibra_probe(struct platform_device *pdev)
 {
 	struct vibra_info *info;
+	const struct sc27xx_vibra_data *data;
 	int error;
 
+	data = of_device_get_match_data(&pdev->dev);
+	if (!data) {
+		dev_err(&pdev->dev, "no matching driver data found\n");
+		return -EINVAL;
+	}
+
 	info = devm_kzalloc(&pdev->dev, sizeof(*info), GFP_KERNEL);
 	if (!info)
 		return -ENOMEM;
@@ -105,6 +146,7 @@ static int sc27xx_vibra_probe(struct platform_device *pdev)
 	info->input_dev->name = "sc27xx:vibrator";
 	info->input_dev->id.version = 0;
 	info->input_dev->close = sc27xx_vibra_close;
+	info->data = data;
 
 	input_set_drvdata(info->input_dev, info);
 	input_set_capability(info->input_dev, EV_FF, FF_RUMBLE);
@@ -134,7 +176,9 @@ static int sc27xx_vibra_probe(struct platform_device *pdev)
 }
 
 static const struct of_device_id sc27xx_vibra_of_match[] = {
-	{ .compatible = "sprd,sc2731-vibrator", },
+	{ .compatible = "sprd,sc2721-vibrator", .data = &sc2721_data },
+	{ .compatible = "sprd,sc2730-vibrator", .data = &sc2730_data },
+	{ .compatible = "sprd,sc2731-vibrator", .data = &sc2731_data },
 	{}
 };
 MODULE_DEVICE_TABLE(of, sc27xx_vibra_of_match);
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [PATCH v2 2/3] dt-bindings: input: Convert sc27xx-vibra.txt to json-schema
  2020-11-17  3:49 [PATCH v2 0/3] Add support for sc2730 and sc2721 Chunyan Zhang
  2020-11-17  3:49 ` [PATCH v2 1/3] input: sc27xx: " Chunyan Zhang
@ 2020-11-17  3:49 ` Chunyan Zhang
  2020-12-07 19:35   ` Rob Herring
  2020-12-12  3:00   ` Dmitry Torokhov
  2020-11-17  3:49 ` [PATCH v2 3/3] dt-bindings: input: Add compatible string for SC2721 and SC2730 Chunyan Zhang
  2 siblings, 2 replies; 9+ messages in thread
From: Chunyan Zhang @ 2020-11-17  3:49 UTC (permalink / raw)
  To: Dmitry Torokhov, Rob Herring
  Cc: linux-input, devicetree, linux-kernel, Orson Zhai, Baolin Wang,
	Chunyan Zhang, Chunyan Zhang, Nemo Han

From: Chunyan Zhang <chunyan.zhang@unisoc.com>

Convert the sprd sc27xx vibrator binding to DT schema using json-schema.

Signed-off-by: Chunyan Zhang <chunyan.zhang@unisoc.com>
---
 .../bindings/input/sprd,sc27xx-vibra.txt      | 23 ----------
 .../bindings/input/sprd,sc27xx-vibrator.yaml  | 46 +++++++++++++++++++
 2 files changed, 46 insertions(+), 23 deletions(-)
 delete mode 100644 Documentation/devicetree/bindings/input/sprd,sc27xx-vibra.txt
 create mode 100644 Documentation/devicetree/bindings/input/sprd,sc27xx-vibrator.yaml

diff --git a/Documentation/devicetree/bindings/input/sprd,sc27xx-vibra.txt b/Documentation/devicetree/bindings/input/sprd,sc27xx-vibra.txt
deleted file mode 100644
index f2ec0d4f2dff..000000000000
--- a/Documentation/devicetree/bindings/input/sprd,sc27xx-vibra.txt
+++ /dev/null
@@ -1,23 +0,0 @@
-Spreadtrum SC27xx PMIC Vibrator
-
-Required properties:
-- compatible: should be "sprd,sc2731-vibrator".
-- reg: address of vibrator control register.
-
-Example :
-
-	sc2731_pmic: pmic@0 {
-		compatible = "sprd,sc2731";
-		reg = <0>;
-		spi-max-frequency = <26000000>;
-		interrupts = <GIC_SPI 31 IRQ_TYPE_LEVEL_HIGH>;
-		interrupt-controller;
-		#interrupt-cells = <2>;
-		#address-cells = <1>;
-		#size-cells = <0>;
-
-		vibrator@eb4 {
-			compatible = "sprd,sc2731-vibrator";
-			reg = <0xeb4>;
-		};
-	};
diff --git a/Documentation/devicetree/bindings/input/sprd,sc27xx-vibrator.yaml b/Documentation/devicetree/bindings/input/sprd,sc27xx-vibrator.yaml
new file mode 100644
index 000000000000..b8a3f23ee3dd
--- /dev/null
+++ b/Documentation/devicetree/bindings/input/sprd,sc27xx-vibrator.yaml
@@ -0,0 +1,46 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+# Copyright 2020 Unisoc Inc.
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/input/sprd,sc27xx-vibrator.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Spreadtrum SC27xx PMIC Vibrator Device Tree Bindings
+
+maintainers:
+  - Orson Zhai <orsonzhai@gmail.com>
+  - Baolin Wang <baolin.wang7@gmail.com>
+  - Chunyan Zhang <zhang.lyra@gmail.com>
+
+properties:
+  compatible:
+    enum:
+      - sprd,sc2731-vibrator
+
+  reg:
+    maxItems: 1
+
+required:
+  - compatible
+  - reg
+
+additionalProperties: false
+
+examples:
+  - |
+    #include <dt-bindings/interrupt-controller/arm-gic.h>
+    sc2731_pmic: pmic@0 {
+      compatible = "sprd,sc2731";
+      reg = <0 0>;
+      spi-max-frequency = <26000000>;
+      interrupts = <GIC_SPI 31 IRQ_TYPE_LEVEL_HIGH>;
+      interrupt-controller;
+      #interrupt-cells = <2>;
+      #address-cells = <1>;
+      #size-cells = <0>;
+
+      vibrator@eb4 {
+        compatible = "sprd,sc2731-vibrator";
+        reg = <0xeb4>;
+      };
+    };
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [PATCH v2 3/3] dt-bindings: input: Add compatible string for SC2721 and SC2730
  2020-11-17  3:49 [PATCH v2 0/3] Add support for sc2730 and sc2721 Chunyan Zhang
  2020-11-17  3:49 ` [PATCH v2 1/3] input: sc27xx: " Chunyan Zhang
  2020-11-17  3:49 ` [PATCH v2 2/3] dt-bindings: input: Convert sc27xx-vibra.txt to json-schema Chunyan Zhang
@ 2020-11-17  3:49 ` Chunyan Zhang
  2020-12-07 19:35   ` Rob Herring
  2020-12-12  3:01   ` Dmitry Torokhov
  2 siblings, 2 replies; 9+ messages in thread
From: Chunyan Zhang @ 2020-11-17  3:49 UTC (permalink / raw)
  To: Dmitry Torokhov, Rob Herring
  Cc: linux-input, devicetree, linux-kernel, Orson Zhai, Baolin Wang,
	Chunyan Zhang, Chunyan Zhang, Nemo Han

From: Chunyan Zhang <chunyan.zhang@unisoc.com>

Add new compatible strings to support sc2730 and sc2721 which are
two varieties of SC27XX family.

Signed-off-by: Chunyan Zhang <chunyan.zhang@unisoc.com>
---
 .../devicetree/bindings/input/sprd,sc27xx-vibrator.yaml         | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/Documentation/devicetree/bindings/input/sprd,sc27xx-vibrator.yaml b/Documentation/devicetree/bindings/input/sprd,sc27xx-vibrator.yaml
index b8a3f23ee3dd..5d67fc8ebc18 100644
--- a/Documentation/devicetree/bindings/input/sprd,sc27xx-vibrator.yaml
+++ b/Documentation/devicetree/bindings/input/sprd,sc27xx-vibrator.yaml
@@ -15,6 +15,8 @@ maintainers:
 properties:
   compatible:
     enum:
+      - sprd,sc2721-vibrator
+      - sprd,sc2730-vibrator
       - sprd,sc2731-vibrator
 
   reg:
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 9+ messages in thread

* Re: [PATCH v2 2/3] dt-bindings: input: Convert sc27xx-vibra.txt to json-schema
  2020-11-17  3:49 ` [PATCH v2 2/3] dt-bindings: input: Convert sc27xx-vibra.txt to json-schema Chunyan Zhang
@ 2020-12-07 19:35   ` Rob Herring
  2020-12-12  3:00   ` Dmitry Torokhov
  1 sibling, 0 replies; 9+ messages in thread
From: Rob Herring @ 2020-12-07 19:35 UTC (permalink / raw)
  To: Chunyan Zhang
  Cc: linux-input, devicetree, Orson Zhai, Baolin Wang, Chunyan Zhang,
	Dmitry Torokhov, linux-kernel, Nemo Han, Rob Herring

On Tue, 17 Nov 2020 11:49:48 +0800, Chunyan Zhang wrote:
> From: Chunyan Zhang <chunyan.zhang@unisoc.com>
> 
> Convert the sprd sc27xx vibrator binding to DT schema using json-schema.
> 
> Signed-off-by: Chunyan Zhang <chunyan.zhang@unisoc.com>
> ---
>  .../bindings/input/sprd,sc27xx-vibra.txt      | 23 ----------
>  .../bindings/input/sprd,sc27xx-vibrator.yaml  | 46 +++++++++++++++++++
>  2 files changed, 46 insertions(+), 23 deletions(-)
>  delete mode 100644 Documentation/devicetree/bindings/input/sprd,sc27xx-vibra.txt
>  create mode 100644 Documentation/devicetree/bindings/input/sprd,sc27xx-vibrator.yaml
> 

Reviewed-by: Rob Herring <robh@kernel.org>

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH v2 3/3] dt-bindings: input: Add compatible string for SC2721 and SC2730
  2020-11-17  3:49 ` [PATCH v2 3/3] dt-bindings: input: Add compatible string for SC2721 and SC2730 Chunyan Zhang
@ 2020-12-07 19:35   ` Rob Herring
  2020-12-12  3:01   ` Dmitry Torokhov
  1 sibling, 0 replies; 9+ messages in thread
From: Rob Herring @ 2020-12-07 19:35 UTC (permalink / raw)
  To: Chunyan Zhang
  Cc: linux-input, Rob Herring, devicetree, linux-kernel, Nemo Han,
	Dmitry Torokhov, Chunyan Zhang, Baolin Wang, Orson Zhai

On Tue, 17 Nov 2020 11:49:49 +0800, Chunyan Zhang wrote:
> From: Chunyan Zhang <chunyan.zhang@unisoc.com>
> 
> Add new compatible strings to support sc2730 and sc2721 which are
> two varieties of SC27XX family.
> 
> Signed-off-by: Chunyan Zhang <chunyan.zhang@unisoc.com>
> ---
>  .../devicetree/bindings/input/sprd,sc27xx-vibrator.yaml         | 2 ++
>  1 file changed, 2 insertions(+)
> 

Reviewed-by: Rob Herring <robh@kernel.org>

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH v2 2/3] dt-bindings: input: Convert sc27xx-vibra.txt to json-schema
  2020-11-17  3:49 ` [PATCH v2 2/3] dt-bindings: input: Convert sc27xx-vibra.txt to json-schema Chunyan Zhang
  2020-12-07 19:35   ` Rob Herring
@ 2020-12-12  3:00   ` Dmitry Torokhov
  1 sibling, 0 replies; 9+ messages in thread
From: Dmitry Torokhov @ 2020-12-12  3:00 UTC (permalink / raw)
  To: Chunyan Zhang
  Cc: Rob Herring, linux-input, devicetree, linux-kernel, Orson Zhai,
	Baolin Wang, Chunyan Zhang, Nemo Han

On Tue, Nov 17, 2020 at 11:49:48AM +0800, Chunyan Zhang wrote:
> From: Chunyan Zhang <chunyan.zhang@unisoc.com>
> 
> Convert the sprd sc27xx vibrator binding to DT schema using json-schema.
> 
> Signed-off-by: Chunyan Zhang <chunyan.zhang@unisoc.com>

Applied, thank you.

-- 
Dmitry

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH v2 3/3] dt-bindings: input: Add compatible string for SC2721 and SC2730
  2020-11-17  3:49 ` [PATCH v2 3/3] dt-bindings: input: Add compatible string for SC2721 and SC2730 Chunyan Zhang
  2020-12-07 19:35   ` Rob Herring
@ 2020-12-12  3:01   ` Dmitry Torokhov
  1 sibling, 0 replies; 9+ messages in thread
From: Dmitry Torokhov @ 2020-12-12  3:01 UTC (permalink / raw)
  To: Chunyan Zhang
  Cc: Rob Herring, linux-input, devicetree, linux-kernel, Orson Zhai,
	Baolin Wang, Chunyan Zhang, Nemo Han

On Tue, Nov 17, 2020 at 11:49:49AM +0800, Chunyan Zhang wrote:
> From: Chunyan Zhang <chunyan.zhang@unisoc.com>
> 
> Add new compatible strings to support sc2730 and sc2721 which are
> two varieties of SC27XX family.
> 
> Signed-off-by: Chunyan Zhang <chunyan.zhang@unisoc.com>

Applied, thank you.

-- 
Dmitry

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH v2 1/3] input: sc27xx: Add support for sc2730 and sc2721
  2020-11-17  3:49 ` [PATCH v2 1/3] input: sc27xx: " Chunyan Zhang
@ 2020-12-12  3:04   ` Dmitry Torokhov
  0 siblings, 0 replies; 9+ messages in thread
From: Dmitry Torokhov @ 2020-12-12  3:04 UTC (permalink / raw)
  To: Chunyan Zhang
  Cc: Rob Herring, linux-input, devicetree, linux-kernel, Orson Zhai,
	Baolin Wang, Chunyan Zhang, Nemo Han

Hi Chunyan,

On Tue, Nov 17, 2020 at 11:49:47AM +0800, Chunyan Zhang wrote:
> @@ -78,8 +112,15 @@ static void sc27xx_vibra_close(struct input_dev *input)
>  static int sc27xx_vibra_probe(struct platform_device *pdev)
>  {
>  	struct vibra_info *info;
> +	const struct sc27xx_vibra_data *data;
>  	int error;
>  
> +	data = of_device_get_match_data(&pdev->dev);
> +	if (!data) {
> +		dev_err(&pdev->dev, "no matching driver data found\n");
> +		return -EINVAL;
> +	}

This does not have to be OF-specific, so I changed it to
device_get_match_data() and applied, thank you.

-- 
Dmitry

^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2020-12-12  3:05 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-11-17  3:49 [PATCH v2 0/3] Add support for sc2730 and sc2721 Chunyan Zhang
2020-11-17  3:49 ` [PATCH v2 1/3] input: sc27xx: " Chunyan Zhang
2020-12-12  3:04   ` Dmitry Torokhov
2020-11-17  3:49 ` [PATCH v2 2/3] dt-bindings: input: Convert sc27xx-vibra.txt to json-schema Chunyan Zhang
2020-12-07 19:35   ` Rob Herring
2020-12-12  3:00   ` Dmitry Torokhov
2020-11-17  3:49 ` [PATCH v2 3/3] dt-bindings: input: Add compatible string for SC2721 and SC2730 Chunyan Zhang
2020-12-07 19:35   ` Rob Herring
2020-12-12  3:01   ` Dmitry Torokhov

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).