* [PATCH v2 0/3] Allwinner A83T R_LRADC support
@ 2017-06-20 13:44 Ziping Chen
2017-06-20 13:44 ` [PATCH v2 1/3] input: sun4i-a10-lradc-keys: Add support for A83T Ziping Chen
` (2 more replies)
0 siblings, 3 replies; 10+ messages in thread
From: Ziping Chen @ 2017-06-20 13:44 UTC (permalink / raw)
To: maxime.ripard, wens, robh+dt, mark.rutland
Cc: devicetree, linux-arm-kernel, linux-kernel, linux-sunxi, Ziping Chen
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
^ permalink raw reply [flat|nested] 10+ messages in thread
* [PATCH v2 1/3] input: sun4i-a10-lradc-keys: Add support for A83T
2017-06-20 13:44 [PATCH v2 0/3] Allwinner A83T R_LRADC support Ziping Chen
@ 2017-06-20 13:44 ` Ziping Chen
2017-06-21 20:35 ` Maxime Ripard
2017-06-20 13:44 ` [PATCH v2 2/3] dt-bindings: input: Add DT bindings documentation for Allwinner A83T R_LRADC Ziping Chen
2017-06-20 13:44 ` [PATCH v2 3/3] ARM: dts: sunxi: add R_LRADC support for A83T Ziping Chen
2 siblings, 1 reply; 10+ messages in thread
From: Ziping Chen @ 2017-06-20 13:44 UTC (permalink / raw)
To: maxime.ripard, wens, robh+dt, mark.rutland
Cc: devicetree, linux-arm-kernel, linux-kernel, linux-sunxi, Ziping Chen
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
^ permalink raw reply related [flat|nested] 10+ messages in thread
* [PATCH v2 2/3] dt-bindings: input: Add DT bindings documentation for Allwinner A83T R_LRADC
2017-06-20 13:44 [PATCH v2 0/3] Allwinner A83T R_LRADC support Ziping Chen
2017-06-20 13:44 ` [PATCH v2 1/3] input: sun4i-a10-lradc-keys: Add support for A83T Ziping Chen
@ 2017-06-20 13:44 ` Ziping Chen
2017-06-23 21:51 ` Rob Herring
2017-06-20 13:44 ` [PATCH v2 3/3] ARM: dts: sunxi: add R_LRADC support for A83T Ziping Chen
2 siblings, 1 reply; 10+ messages in thread
From: Ziping Chen @ 2017-06-20 13:44 UTC (permalink / raw)
To: maxime.ripard, wens, robh+dt, mark.rutland
Cc: devicetree, linux-arm-kernel, linux-kernel, linux-sunxi, Ziping Chen
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
^ permalink raw reply related [flat|nested] 10+ messages in thread
* [PATCH v2 3/3] ARM: dts: sunxi: add R_LRADC support for A83T
2017-06-20 13:44 [PATCH v2 0/3] Allwinner A83T R_LRADC support Ziping Chen
2017-06-20 13:44 ` [PATCH v2 1/3] input: sun4i-a10-lradc-keys: Add support for A83T Ziping Chen
2017-06-20 13:44 ` [PATCH v2 2/3] dt-bindings: input: Add DT bindings documentation for Allwinner A83T R_LRADC Ziping Chen
@ 2017-06-20 13:44 ` Ziping Chen
2 siblings, 0 replies; 10+ messages in thread
From: Ziping Chen @ 2017-06-20 13:44 UTC (permalink / raw)
To: maxime.ripard, wens, robh+dt, mark.rutland
Cc: devicetree, linux-arm-kernel, linux-kernel, linux-sunxi, Ziping Chen
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
^ permalink raw reply related [flat|nested] 10+ messages in thread
* Re: [PATCH v2 1/3] input: sun4i-a10-lradc-keys: Add support for A83T
2017-06-20 13:44 ` [PATCH v2 1/3] input: sun4i-a10-lradc-keys: Add support for A83T Ziping Chen
@ 2017-06-21 20:35 ` Maxime Ripard
2017-06-22 5:44 ` Ziping Chen
[not found] ` <CAAST=9zK8CjpEwy1rSjwnaSrpoQor-NkjWcX8kFSM-o=qP8OWQ@mail.gmail.com>
0 siblings, 2 replies; 10+ messages in thread
From: Maxime Ripard @ 2017-06-21 20:35 UTC (permalink / raw)
To: Ziping Chen
Cc: wens, robh+dt, mark.rutland, devicetree, linux-arm-kernel,
linux-kernel, linux-sunxi
[-- Attachment #1: Type: text/plain, Size: 625 bytes --]
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
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 801 bytes --]
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH v2 1/3] input: sun4i-a10-lradc-keys: Add support for A83T
2017-06-21 20:35 ` Maxime Ripard
@ 2017-06-22 5:44 ` Ziping Chen
[not found] ` <CAAST=9zK8CjpEwy1rSjwnaSrpoQor-NkjWcX8kFSM-o=qP8OWQ@mail.gmail.com>
1 sibling, 0 replies; 10+ messages in thread
From: Ziping Chen @ 2017-06-22 5:44 UTC (permalink / raw)
To: Maxime Ripard
Cc: Chen-Yu Tsai, robh+dt, mark.rutland, devicetree,
linux-arm-kernel, linux-kernel, linux-sunxi
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
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH v2 1/3] input: sun4i-a10-lradc-keys: Add support for A83T
[not found] ` <CAAST=9zK8CjpEwy1rSjwnaSrpoQor-NkjWcX8kFSM-o=qP8OWQ@mail.gmail.com>
@ 2017-06-23 14:46 ` Maxime Ripard
2017-06-23 15:12 ` Ziping Chen
0 siblings, 1 reply; 10+ messages in thread
From: Maxime Ripard @ 2017-06-23 14:46 UTC (permalink / raw)
To: Ziping Chen
Cc: Chen-Yu Tsai, robh+dt, mark.rutland, devicetree,
linux-arm-kernel, linux-kernel, linux-sunxi
[-- Attachment #1: Type: text/plain, Size: 1348 bytes --]
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
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 801 bytes --]
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH v2 1/3] input: sun4i-a10-lradc-keys: Add support for A83T
2017-06-23 14:46 ` Maxime Ripard
@ 2017-06-23 15:12 ` Ziping Chen
0 siblings, 0 replies; 10+ messages in thread
From: Ziping Chen @ 2017-06-23 15:12 UTC (permalink / raw)
To: Maxime Ripard
Cc: Chen-Yu Tsai, robh+dt, mark.rutland, devicetree,
linux-arm-kernel, linux-kernel, linux-sunxi
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
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH v2 2/3] dt-bindings: input: Add DT bindings documentation for Allwinner A83T R_LRADC
2017-06-20 13:44 ` [PATCH v2 2/3] dt-bindings: input: Add DT bindings documentation for Allwinner A83T R_LRADC Ziping Chen
@ 2017-06-23 21:51 ` Rob Herring
2017-06-24 2:12 ` Ziping Chen
0 siblings, 1 reply; 10+ messages in thread
From: Rob Herring @ 2017-06-23 21:51 UTC (permalink / raw)
To: Ziping Chen
Cc: maxime.ripard, wens, mark.rutland, devicetree, linux-arm-kernel,
linux-kernel, linux-sunxi
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>
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH v2 2/3] dt-bindings: input: Add DT bindings documentation for Allwinner A83T R_LRADC
2017-06-23 21:51 ` Rob Herring
@ 2017-06-24 2:12 ` Ziping Chen
0 siblings, 0 replies; 10+ messages in thread
From: Ziping Chen @ 2017-06-24 2:12 UTC (permalink / raw)
To: Rob Herring
Cc: Maxime Ripard, Chen-Yu Tsai, mark.rutland, devicetree,
linux-arm-kernel, linux-kernel, linux-sunxi
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
^ permalink raw reply [flat|nested] 10+ messages in thread
end of thread, other threads:[~2017-06-24 2:12 UTC | newest]
Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-06-20 13:44 [PATCH v2 0/3] Allwinner A83T R_LRADC support Ziping Chen
2017-06-20 13:44 ` [PATCH v2 1/3] input: sun4i-a10-lradc-keys: Add support for A83T Ziping Chen
2017-06-21 20:35 ` Maxime Ripard
2017-06-22 5:44 ` Ziping Chen
[not found] ` <CAAST=9zK8CjpEwy1rSjwnaSrpoQor-NkjWcX8kFSM-o=qP8OWQ@mail.gmail.com>
2017-06-23 14:46 ` Maxime Ripard
2017-06-23 15:12 ` Ziping Chen
2017-06-20 13:44 ` [PATCH v2 2/3] dt-bindings: input: Add DT bindings documentation for Allwinner A83T R_LRADC Ziping Chen
2017-06-23 21:51 ` Rob Herring
2017-06-24 2:12 ` Ziping Chen
2017-06-20 13:44 ` [PATCH v2 3/3] ARM: dts: sunxi: add R_LRADC support for A83T Ziping Chen
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).