Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1670774 > unrolled thread

[PATCH v2 0/3] Allwinner A83T R_LRADC support

Started byZiping Chen <techping.chan@gmail.com>
First post2017-06-20 15:50 +0200
Last post2017-06-24 04:20 +0200
Articles 10 — 3 participants

Back to article view | Back to linux.kernel


Contents

  [PATCH v2 0/3] Allwinner A83T R_LRADC support Ziping Chen <techping.chan@gmail.com> - 2017-06-20 15:50 +0200
    [PATCH v2 1/3] input: sun4i-a10-lradc-keys: Add support for A83T Ziping Chen <techping.chan@gmail.com> - 2017-06-20 15:50 +0200
      Re: [PATCH v2 1/3] input: sun4i-a10-lradc-keys: Add support for A83T Maxime Ripard <maxime.ripard@free-electrons.com> - 2017-06-21 22:40 +0200
        Re: [PATCH v2 1/3] input: sun4i-a10-lradc-keys: Add support for A83T Ziping Chen <techping.chan@gmail.com> - 2017-06-22 07:50 +0200
        Re: [PATCH v2 1/3] input: sun4i-a10-lradc-keys: Add support for A83T Maxime Ripard <maxime.ripard@free-electrons.com> - 2017-06-23 16:50 +0200
          Re: [PATCH v2 1/3] input: sun4i-a10-lradc-keys: Add support for A83T Ziping Chen <techping.chan@gmail.com> - 2017-06-23 17:20 +0200
    [PATCH v2 3/3] ARM: dts: sunxi: add R_LRADC support for A83T Ziping Chen <techping.chan@gmail.com> - 2017-06-20 15:50 +0200
    [PATCH v2 2/3] dt-bindings: input: Add DT bindings documentation for Allwinner A83T R_LRADC Ziping Chen <techping.chan@gmail.com> - 2017-06-20 15:50 +0200
      Re: [PATCH v2 2/3] dt-bindings: input: Add DT bindings documentation  for Allwinner A83T R_LRADC Rob Herring <robh@kernel.org> - 2017-06-24 00:00 +0200
        Re: [PATCH v2 2/3] dt-bindings: input: Add DT bindings documentation  for Allwinner A83T R_LRADC Ziping Chen <techping.chan@gmail.com> - 2017-06-24 04:20 +0200

#1670774 — [PATCH v2 0/3] Allwinner A83T R_LRADC support

FromZiping Chen <techping.chan@gmail.com>
Date2017-06-20 15:50 +0200
Subject[PATCH v2 0/3] Allwinner A83T R_LRADC support
Message-ID<tUrHz-Q2-3@gated-at.bofh.it>
From: Ziping Chen <techping.chan@gmail.com>

Hi,

This is the remaining parts of my A83T R_LRADC support series

Allwinner A83T SoC has a low res adc like the one in Allwinner
A10 SoC.

Add support for it. 

Changes for v2:
- Add an A83T specific compatible.

Ziping Chen (3):
  input: sun4i-a10-lradc-keys: Add support for A83T
  dt-bindings: input: Add DT bindings documentation for Allwinner A83T
    R_LRADC
  ARM: dts: sunxi: add R_LRADC support for A83T

 .../devicetree/bindings/input/sun4i-lradc-keys.txt |  6 ++--
 arch/arm/boot/dts/sun8i-a83t.dtsi                  |  7 ++++
 drivers/input/keyboard/sun4i-lradc-keys.c          | 39 +++++++++++++++++++---
 3 files changed, 46 insertions(+), 6 deletions(-)

-- 
2.11.0

[toc] | [next] | [standalone]


#1670776 — [PATCH v2 1/3] input: sun4i-a10-lradc-keys: Add support for A83T

FromZiping Chen <techping.chan@gmail.com>
Date2017-06-20 15:50 +0200
Subject[PATCH v2 1/3] input: sun4i-a10-lradc-keys: Add support for A83T
Message-ID<tUrHA-Q2-11@gated-at.bofh.it>
In reply to#1670774
From: Ziping Chen <techping.chan@gmail.com>

Allwinner A83T SoC has a low res adc like the one
in Allwinner A10 SoC, however, the A10 SoC's vref
of lradc internally is divided by 2/3 and the A83T
SoC's isn't, thus add a hardware variant for it to
be compatible with various devices.

Signed-off-by: Ziping Chen <techping.chan@gmail.com>
---
 drivers/input/keyboard/sun4i-lradc-keys.c | 39 +++++++++++++++++++++++++++----
 1 file changed, 35 insertions(+), 4 deletions(-)

diff --git a/drivers/input/keyboard/sun4i-lradc-keys.c b/drivers/input/keyboard/sun4i-lradc-keys.c
index a37c172452e6..3cd981138efc 100644
--- a/drivers/input/keyboard/sun4i-lradc-keys.c
+++ b/drivers/input/keyboard/sun4i-lradc-keys.c
@@ -46,6 +46,7 @@
 #define CONTINUE_TIME_SEL(x)	((x) << 16) /* 4 bits */
 #define KEY_MODE_SEL(x)		((x) << 12) /* 2 bits */
 #define LEVELA_B_CNT(x)		((x) << 8)  /* 4 bits */
+#define HOLD_KEY_EN(x)		((x) << 7)
 #define HOLD_EN(x)		((x) << 6)
 #define LEVELB_VOL(x)		((x) << 4)  /* 2 bits */
 #define SAMPLE_RATE(x)		((x) << 2)  /* 2 bits */
@@ -63,6 +64,25 @@
 #define	CHAN0_KEYDOWN_IRQ	BIT(1)
 #define CHAN0_DATA_IRQ		BIT(0)
 
+/* struct lradc_variant - Describe sun4i-a10-lradc-keys hardware variant
+ * @divisor_numerator:		The numerator of lradc Vref internally divisor
+ * @divisor_denominator:	The denominator of lradc Vref internally divisor
+ */
+struct lradc_variant {
+	u8 divisor_numerator;
+	u8 divisor_denominator;
+};
+
+static const struct lradc_variant lradc_variant_a10 = {
+	.divisor_numerator = 2,
+	.divisor_denominator = 3
+};
+
+static const struct lradc_variant r_lradc_variant_a83t = {
+	.divisor_numerator = 1,
+	.divisor_denominator = 1
+};
+
 struct sun4i_lradc_keymap {
 	u32 voltage;
 	u32 keycode;
@@ -74,6 +94,7 @@ struct sun4i_lradc_data {
 	void __iomem *base;
 	struct regulator *vref_supply;
 	struct sun4i_lradc_keymap *chan0_map;
+	const struct lradc_variant *variant;
 	u32 chan0_map_count;
 	u32 chan0_keycode;
 	u32 vref;
@@ -99,6 +120,7 @@ static irqreturn_t sun4i_lradc_irq(int irq, void *dev_id)
 	if ((ints & CHAN0_KEYDOWN_IRQ) && lradc->chan0_keycode == 0) {
 		val = readl(lradc->base + LRADC_DATA0) & 0x3f;
 		voltage = val * lradc->vref / 63;
+		printk("voltage %d\n", voltage);
 
 		for (i = 0; i < lradc->chan0_map_count; i++) {
 			diff = abs(lradc->chan0_map[i].voltage - voltage);
@@ -128,9 +150,9 @@ static int sun4i_lradc_open(struct input_dev *dev)
 	if (error)
 		return error;
 
-	/* lradc Vref internally is divided by 2/3 */
-	lradc->vref = regulator_get_voltage(lradc->vref_supply) * 2 / 3;
-
+	lradc->vref = regulator_get_voltage(lradc->vref_supply) *
+		      lradc->variant->divisor_numerator /
+		      lradc->variant->divisor_denominator;
 	/*
 	 * Set sample time to 4 ms / 250 Hz. Wait 2 * 4 ms for key to
 	 * stabilize on press, wait (1 + 1) * 4 ms for key release
@@ -222,6 +244,12 @@ static int sun4i_lradc_probe(struct platform_device *pdev)
 	if (error)
 		return error;
 
+	lradc->variant = of_device_get_match_data(&pdev->dev);
+	if (!lradc->variant) {
+		dev_err(&pdev->dev, "Missing sun4i-a10-lradc-keys variant\n");
+		return -EINVAL;
+	}
+
 	lradc->vref_supply = devm_regulator_get(dev, "vref");
 	if (IS_ERR(lradc->vref_supply))
 		return PTR_ERR(lradc->vref_supply);
@@ -265,7 +293,10 @@ static int sun4i_lradc_probe(struct platform_device *pdev)
 }
 
 static const struct of_device_id sun4i_lradc_of_match[] = {
-	{ .compatible = "allwinner,sun4i-a10-lradc-keys", },
+	{ .compatible = "allwinner,sun4i-a10-lradc-keys",
+		.data = &lradc_variant_a10 },
+	{ .compatible = "allwinner,sun8i-a83t-r-lradc-keys",
+		.data = &r_lradc_variant_a83t },
 	{ /* sentinel */ }
 };
 MODULE_DEVICE_TABLE(of, sun4i_lradc_of_match);
-- 
2.11.0

[toc] | [prev] | [next] | [standalone]


#1672013 — Re: [PATCH v2 1/3] input: sun4i-a10-lradc-keys: Add support for A83T

FromMaxime Ripard <maxime.ripard@free-electrons.com>
Date2017-06-21 22:40 +0200
SubjectRe: [PATCH v2 1/3] input: sun4i-a10-lradc-keys: Add support for A83T
Message-ID<tUUzU-2OU-9@gated-at.bofh.it>
In reply to#1670776

[Multipart message — attachments visible in raw view] — view raw

On Tue, Jun 20, 2017 at 09:44:43PM +0800, Ziping Chen wrote:
> From: Ziping Chen <techping.chan@gmail.com>
> 
> Allwinner A83T SoC has a low res adc like the one
> in Allwinner A10 SoC, however, the A10 SoC's vref
> of lradc internally is divided by 2/3 and the A83T
> SoC's isn't, thus add a hardware variant for it to
> be compatible with various devices.

Where did you get that info from?

Judging from the user manual, the threshold is actually set to 3/4,
and not 2/3, but there's still one.

Maxime

-- 
Maxime Ripard, Free Electrons
Embedded Linux and Kernel engineering
http://free-electrons.com

[toc] | [prev] | [next] | [standalone]


#1672313 — Re: [PATCH v2 1/3] input: sun4i-a10-lradc-keys: Add support for A83T

FromZiping Chen <techping.chan@gmail.com>
Date2017-06-22 07:50 +0200
SubjectRe: [PATCH v2 1/3] input: sun4i-a10-lradc-keys: Add support for A83T
Message-ID<tV3a9-kd-5@gated-at.bofh.it>
In reply to#1672013
2017-06-22 4:35 GMT+08:00 Maxime Ripard <maxime.ripard@free-electrons.com>:
> On Tue, Jun 20, 2017 at 09:44:43PM +0800, Ziping Chen wrote:
>> From: Ziping Chen <techping.chan@gmail.com>
>>
>> Allwinner A83T SoC has a low res adc like the one
>> in Allwinner A10 SoC, however, the A10 SoC's vref
>> of lradc internally is divided by 2/3 and the A83T
>> SoC's isn't, thus add a hardware variant for it to
>> be compatible with various devices.
>
> Where did you get that info from?
>
> Judging from the user manual, the threshold is actually set to 3/4,
> and not 2/3, but there's still one.


In the top of page 266 of the A10 User Manual V1.50, it said "2/3
ADC_REF (Level A)" which mean Level A is 2/3 of the vref.

In the bottom of page 230 of the A83T User Manual V1.5.1, it said
"1.35V (Level A)" meaning that Level A is 1.35V. Oh, it's my fault...
It's 3/4 of the vref (A83T's ADC_REF is fixed at 1.8V).

So... i will change r_lradc_variant_a83t.divisor_numerator to 3 and
r_lradc_variant_a83t.divisor_denominator to 4...

Is there any other problems?

Thanks,
Ziping

>
> Maxime
>
> --
> Maxime Ripard, Free Electrons
> Embedded Linux and Kernel engineering
> http://free-electrons.com

[toc] | [prev] | [next] | [standalone]


#1673616 — Re: [PATCH v2 1/3] input: sun4i-a10-lradc-keys: Add support for A83T

FromMaxime Ripard <maxime.ripard@free-electrons.com>
Date2017-06-23 16:50 +0200
SubjectRe: [PATCH v2 1/3] input: sun4i-a10-lradc-keys: Add support for A83T
Message-ID<tVy4i-3pQ-11@gated-at.bofh.it>
In reply to#1672013

[Multipart message — attachments visible in raw view] — view raw

On Thu, Jun 22, 2017 at 12:50:47PM +0800, Ziping Chen wrote:
> 2017-06-22 4:35 GMT+08:00 Maxime Ripard <maxime.ripard@free-electrons.com>:
> 
> > On Tue, Jun 20, 2017 at 09:44:43PM +0800, Ziping Chen wrote:
> > > From: Ziping Chen <techping.chan@gmail.com>
> > >
> > > Allwinner A83T SoC has a low res adc like the one
> > > in Allwinner A10 SoC, however, the A10 SoC's vref
> > > of lradc internally is divided by 2/3 and the A83T
> > > SoC's isn't, thus add a hardware variant for it to
> > > be compatible with various devices.
> >
> > Where did you get that info from?
> >
> > Judging from the user manual, the threshold is actually set to 3/4,
> > and not 2/3, but there's still one.
> >
> 
> In the top of page 266 of the A10 User Manual V1.50, it said "2/3 ADC_REF
> (Level A)" which mean Level A is 2/3 of the vref.
> 
> In the bottom of page 230 of the A83T User Manual V1.5.1, it said "1.35V
> (Level A)" meaning that Level A is 1.35V. Oh, it's my fault... It's 3/4 of
> the vref (A83T's ADC_REF is fixed at 1.8V).
> 
> So... i will change r_lradc_variant_a83t.divisor_numerator to 3
> and r_lradc_variant_a83t.divisor_denominator to 4...
> 
> Is there any other problems?

I don't see any :)

Maxime

-- 
Maxime Ripard, Free Electrons
Embedded Linux and Kernel engineering
http://free-electrons.com

[toc] | [prev] | [next] | [standalone]


#1673630 — Re: [PATCH v2 1/3] input: sun4i-a10-lradc-keys: Add support for A83T

FromZiping Chen <techping.chan@gmail.com>
Date2017-06-23 17:20 +0200
SubjectRe: [PATCH v2 1/3] input: sun4i-a10-lradc-keys: Add support for A83T
Message-ID<tVyxl-3OP-33@gated-at.bofh.it>
In reply to#1673616
2017-06-23 22:46 GMT+08:00 Maxime Ripard <maxime.ripard@free-electrons.com>:
> On Thu, Jun 22, 2017 at 12:50:47PM +0800, Ziping Chen wrote:
>> 2017-06-22 4:35 GMT+08:00 Maxime Ripard <maxime.ripard@free-electrons.com>:
>>
>> > On Tue, Jun 20, 2017 at 09:44:43PM +0800, Ziping Chen wrote:
>> > > From: Ziping Chen <techping.chan@gmail.com>
>> > >
>> > > Allwinner A83T SoC has a low res adc like the one
>> > > in Allwinner A10 SoC, however, the A10 SoC's vref
>> > > of lradc internally is divided by 2/3 and the A83T
>> > > SoC's isn't, thus add a hardware variant for it to
>> > > be compatible with various devices.
>> >
>> > Where did you get that info from?
>> >
>> > Judging from the user manual, the threshold is actually set to 3/4,
>> > and not 2/3, but there's still one.
>> >
>>
>> In the top of page 266 of the A10 User Manual V1.50, it said "2/3 ADC_REF
>> (Level A)" which mean Level A is 2/3 of the vref.
>>
>> In the bottom of page 230 of the A83T User Manual V1.5.1, it said "1.35V
>> (Level A)" meaning that Level A is 1.35V. Oh, it's my fault... It's 3/4 of
>> the vref (A83T's ADC_REF is fixed at 1.8V).
>>
>> So... i will change r_lradc_variant_a83t.divisor_numerator to 3
>> and r_lradc_variant_a83t.divisor_denominator to 4...
>>
>> Is there any other problems?
>
> I don't see any :)

OK! Thanks. I will send v3 soon.

>
> Maxime
>
> --
> Maxime Ripard, Free Electrons
> Embedded Linux and Kernel engineering
> http://free-electrons.com

[toc] | [prev] | [next] | [standalone]


#1670780 — [PATCH v2 3/3] ARM: dts: sunxi: add R_LRADC support for A83T

FromZiping Chen <techping.chan@gmail.com>
Date2017-06-20 15:50 +0200
Subject[PATCH v2 3/3] ARM: dts: sunxi: add R_LRADC support for A83T
Message-ID<tUrHA-Q2-27@gated-at.bofh.it>
In reply to#1670774
From: Ziping Chen <techping.chan@gmail.com>

Allwinner A83T SoC has a low res adc like the one
in Allwinner A10 SoC. Now the driver has been
modified to support it.

Add support for it.

Signed-off-by: Ziping Chen <techping.chan@gmail.com>
---
 arch/arm/boot/dts/sun8i-a83t.dtsi | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/arch/arm/boot/dts/sun8i-a83t.dtsi b/arch/arm/boot/dts/sun8i-a83t.dtsi
index 8923ba625b76..ccee83cc0610 100644
--- a/arch/arm/boot/dts/sun8i-a83t.dtsi
+++ b/arch/arm/boot/dts/sun8i-a83t.dtsi
@@ -301,5 +301,12 @@
 			interrupt-controller;
 			#interrupt-cells = <3>;
 		};
+
+		r_lradc: lradc@01f03c00 {
+			compatible = "allwinner,sun8i-a83t-r-lradc-keys";
+			reg = <0x01f03c00 0x100>;
+			interrupts = <GIC_SPI 42 IRQ_TYPE_LEVEL_HIGH>;
+			status = "disabled";
+		};
 	};
 };
-- 
2.11.0

[toc] | [prev] | [next] | [standalone]


#1670784 — [PATCH v2 2/3] dt-bindings: input: Add DT bindings documentation for Allwinner A83T R_LRADC

FromZiping Chen <techping.chan@gmail.com>
Date2017-06-20 15:50 +0200
Subject[PATCH v2 2/3] dt-bindings: input: Add DT bindings documentation for Allwinner A83T R_LRADC
Message-ID<tUrHB-Q2-39@gated-at.bofh.it>
In reply to#1670774
From: Ziping Chen <techping.chan@gmail.com>

Allwinner A83T SoC has a low res adc like the one
in Allwinner A10 SoC.

Add binding for it.

Signed-off-by: Ziping Chen <techping.chan@gmail.com>
---
 Documentation/devicetree/bindings/input/sun4i-lradc-keys.txt | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/Documentation/devicetree/bindings/input/sun4i-lradc-keys.txt b/Documentation/devicetree/bindings/input/sun4i-lradc-keys.txt
index 4357e498ef04..525d85e3043f 100644
--- a/Documentation/devicetree/bindings/input/sun4i-lradc-keys.txt
+++ b/Documentation/devicetree/bindings/input/sun4i-lradc-keys.txt
@@ -2,12 +2,14 @@ Allwinner sun4i low res adc attached tablet keys
 ------------------------------------------------
 
 Required properties:
- - compatible: "allwinner,sun4i-a10-lradc-keys"
+ - compatible: should be one of the following string:
+		"allwinner,sun4i-a10-lradc-keys"
+		"allwinner,sun8i-a83t-r-lradc-keys"
  - reg: mmio address range of the chip
  - interrupts: interrupt to which the chip is connected
  - vref-supply: powersupply for the lradc reference voltage
 
-Each key is represented as a sub-node of "allwinner,sun4i-a10-lradc-keys":
+Each key is represented as a sub-node of the compatible mentioned above:
 
 Required subnode-properties:
 	- label: Descriptive name of the key.
-- 
2.11.0

[toc] | [prev] | [next] | [standalone]


#1673907 — Re: [PATCH v2 2/3] dt-bindings: input: Add DT bindings documentation for Allwinner A83T R_LRADC

FromRob Herring <robh@kernel.org>
Date2017-06-24 00:00 +0200
SubjectRe: [PATCH v2 2/3] dt-bindings: input: Add DT bindings documentation for Allwinner A83T R_LRADC
Message-ID<tVEMq-7yC-21@gated-at.bofh.it>
In reply to#1670784
On Tue, Jun 20, 2017 at 09:44:44PM +0800, Ziping Chen wrote:
> From: Ziping Chen <techping.chan@gmail.com>

Your subject could be more concise. "DT bindings documentation" is 
redundant.

> 
> Allwinner A83T SoC has a low res adc like the one
> in Allwinner A10 SoC.
> 
> Add binding for it.
> 
> Signed-off-by: Ziping Chen <techping.chan@gmail.com>
> ---
>  Documentation/devicetree/bindings/input/sun4i-lradc-keys.txt | 6 ++++--
>  1 file changed, 4 insertions(+), 2 deletions(-)

Otherwise,

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

[toc] | [prev] | [next] | [standalone]


#1673975 — Re: [PATCH v2 2/3] dt-bindings: input: Add DT bindings documentation for Allwinner A83T R_LRADC

FromZiping Chen <techping.chan@gmail.com>
Date2017-06-24 04:20 +0200
SubjectRe: [PATCH v2 2/3] dt-bindings: input: Add DT bindings documentation for Allwinner A83T R_LRADC
Message-ID<tVIQ1-1SY-5@gated-at.bofh.it>
In reply to#1673907
Hi

2017-06-24 5:51 GMT+08:00 Rob Herring <robh@kernel.org>:
> On Tue, Jun 20, 2017 at 09:44:44PM +0800, Ziping Chen wrote:
>> From: Ziping Chen <techping.chan@gmail.com>
>
> Your subject could be more concise. "DT bindings documentation" is
> redundant.
>
>>
>> Allwinner A83T SoC has a low res adc like the one
>> in Allwinner A10 SoC.
>>
>> Add binding for it.
>>
>> Signed-off-by: Ziping Chen <techping.chan@gmail.com>
>> ---
>>  Documentation/devicetree/bindings/input/sun4i-lradc-keys.txt | 6 ++++--
>>  1 file changed, 4 insertions(+), 2 deletions(-)
>
> Otherwise,
>
> Acked-by: Rob Herring <robh@kernel.org>

OK.

Thanks,
Ziping

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web