Allwinner A83T R_LRADC support
Subsystems (4)
v2 cover Allwinner A83T R_LRADC support
From: Ziping Chen <[email protected]>
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(-)
Signature · 6 lines
2.11.0 -- To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
PATCH v2 1/3 input: sun4i-a10-lradc-keys: Add support for A83T
From: Ziping Chen <[email protected]>
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.
--- drivers/input/keyboard/sun4i-lradc-keys.c | 39 +++++++++++++++++++++++++++---- 1 file changed, 35 insertions(+), 4 deletions(-)
drivers/input/keyboard/sun4i-lradc-keys.c +35 -4
@@ -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);
Signature · 1 line
2.11.0
PATCH v2 2/3 dt-bindings: input: Add DT bindings documentation for Allwinner A83T R_LRADC
In reply to Ziping ChenFrom: Ziping Chen <[email protected]>
Allwinner A83T SoC has a low res adc like the one
in Allwinner A10 SoC.
Add binding for it.
--- Documentation/devicetree/bindings/input/sun4i-lradc-keys.txt | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
Documentation/devicetree/bindings/input/sun4i-lradc-keys.txt +4 -2
@@ -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.
Signature · 1 line
2.11.0
PATCH v2 3/3 ARM: dts: sunxi: add R_LRADC support for A83T
In reply to Ziping ChenFrom: Ziping Chen <[email protected]>
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.
--- arch/arm/boot/dts/sun8i-a83t.dtsi | 7 +++++++ 1 file changed, 7 insertions(+)
arch/arm/boot/dts/sun8i-a83t.dtsi +7 -0
@@ -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"; + }; }; };
Signature · 1 line
2.11.0
Re: [PATCH v2 1/3] input: sun4i-a10-lradc-keys: Add support for A83T
In reply to a message not in the archive2017-06-20 21:44 GMT+08:00 Ziping Chen <[email protected]>:
Quoted 64 lines
From: Ziping Chen <[email protected]>
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 <[email protected]>--- drivers/input/keyboard/sun4i-lradc-keys.c | 39 +++++++++++++++++++++++++++---- 1 file changed, 35 insertions(+), 4 deletions(-)drivers/input/keyboard/sun4i-lradc-keys.c +3
-0@@ -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
+ */drivers/input/keyboard/sun4i-lradc-keys.c +16
-0+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;
drivers/input/keyboard/sun4i-lradc-keys.c static irqreturn_t sun4i_lradc_irq(int irq, void · line 125
Quoted 6 lines
drivers/input/keyboard/sun4i-lradc-keys.c +1
-0@@ -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);
Oh.....sorry, this is excess....
Quoted 48 lines
drivers/input/keyboard/sun4i-lradc-keys.c +0
-0for (i =0 ; i < lradc->chan0_map_count; i++) {diff = abs(lradc->chan0_map[i].voltage - voltage);drivers/input/keyboard/sun4i-lradc-keys.c +9
-3@@ -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);drivers/input/keyboard/sun4i-lradc-keys.c +4
-1@@ -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
Signature · 3 lines
You received this message because you are subscribed to the Google Groups "linux-sunxi" group. To unsubscribe from this group and stop receiving emails from it, send an email to linux-sunxi+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/[email protected] For more options, visit https://groups.google.com/d/optout.
Re: [PATCH v2 1/3] input: sun4i-a10-lradc-keys: Add support for A83T
In reply to Ziping ChenQuoted 7 lines · Ziping Chen
From: Ziping Chen <[email protected]>
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
Signature · 10 lines
Maxime Ripard, Free Electrons Embedded Linux and Kernel engineering http://free-electrons.com -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 801 bytes Desc: not available URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20170621/19305b2d/attachment-0001.sig>
Re: [PATCH v2 1/3] input: sun4i-a10-lradc-keys: Add support for A83T
In reply to a message not in the archive2017-06-22 4:35 GMT+08:00 Maxime Ripard <maxime.ripard-wi1+55ScJUtKEb57/[email protected]>:
Quoted 9 lines · Ziping Chen
Quoted 7 lines
From: Ziping Chen <[email protected]>
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.
Quoted 5 lines
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
Quoted 7 lines
Maxime
--
Maxime Ripard, Free Electrons
Embedded Linux and Kernel engineering
http://free-electrons.com
Signature · 3 lines
You received this message because you are subscribed to the Google Groups "linux-sunxi" group. To unsubscribe from this group and stop receiving emails from it, send an email to linux-sunxi+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/[email protected] For more options, visit https://groups.google.com/d/optout.
Re: [PATCH v2 1/3] input: sun4i-a10-lradc-keys: Add support for A83T
In reply to Maxime Ripard2017-06-22 4:35 GMT+08:00 Maxime Ripard <[email protected]>:
Quoted 9 lines · Ziping Chen
Quoted 7 lines
From: Ziping Chen <[email protected]>
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.
Quoted 4 lines
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
Quoted 7 lines
Maxime
--
Maxime Ripard, Free Electrons
Embedded Linux and Kernel engineering
http://free-electrons.com
Re: [PATCH v2 1/3] input: sun4i-a10-lradc-keys: Add support for A83T
In reply to Ziping ChenQuoted 20 lines · Ziping Chen
2017-06-22 4:35 GMT+08:00 Maxime Ripard <[email protected]>:
Quoted 9 lines · Ziping Chen
Quoted 7 lines
From: Ziping Chen <[email protected]>
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.
Quoted 5 lines
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.
Quoted 8 lines
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_REFis 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
Signature · 10 lines
Maxime Ripard, Free Electrons Embedded Linux and Kernel engineering http://free-electrons.com -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 801 bytes Desc: not available URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20170623/8526bed6/attachment.sig>
Re: [PATCH v2 1/3] input: sun4i-a10-lradc-keys: Add support for A83T
2017-06-23 22:46 GMT+08:00 Maxime Ripard <[email protected]>:
Quoted 25 lines · Ziping Chen
Quoted 24 lines
2017-06-22 4:35 GMT+08:00 Maxime Ripard <[email protected]>:
Quoted 9 lines · Ziping Chen
Quoted 7 lines
From: Ziping Chen <[email protected]>
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.
Quoted 5 lines
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_REFis fixed at 1.8V).
Quoted 6 lines
Quoted 4 lines
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.
Quoted 7 lines
Maxime
--
Maxime Ripard, Free Electrons
Embedded Linux and Kernel engineering
http://free-electrons.com
Re: [PATCH v2 2/3] dt-bindings: input: Add DT bindings documentation for Allwinner A83T R_LRADC
In reply to Ziping ChenQuoted 1 line · Ziping Chen
From: Ziping Chen <[email protected]>
Your subject could be more concise. "DT bindings documentation" is redundant.
Quoted 10 lines
Allwinner A83T SoC has a low res adc like the one
in Allwinner A10 SoC.Add binding for it.
Signed-off-by Ziping Chen <[email protected]>--- Documentation/devicetree/bindings/input/sun4i-lradc-keys.txt | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
Otherwise,
Re: [PATCH v2 2/3] dt-bindings: input: Add DT bindings documentation for Allwinner A83T R_LRADC
Hi
2017-06-24 5:51 GMT+08:00 Rob Herring <[email protected]>:
Quoted 12 lines · Ziping Chen
Quoted 1 line
From: Ziping Chen <[email protected]>
Your subject could be more concise. "DT bindings documentation" is redundant.
Quoted 6 lines
Allwinner A83T SoC has a low res adc like the one
in Allwinner A10 SoC.Add binding for it.
Quoted 8 lines
Quoted 4 lines
Signed-off-by Ziping Chen <[email protected]>--- Documentation/devicetree/bindings/input/sun4i-lradc-keys.txt | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)Otherwise,
Acked-by Rob Herring <[email protected]>
OK.
Thanks,
Ziping