media: rc: fix Meson IR decoder
Subsystems (6)
Martin Blumenstingl
reviewerPATCH v2 1/1 media: rc: fix Meson IR decoder
The meson-ir driver uses the wrong offset (at least according to Amlogic's reference driver as well as the datasheets of the Meson8b/S805 and GXBB/S905).
This means that we are getting incorrect durations (REG1_TIME_IV) reported from the hardware.
This problem was also noticed by some people trying to use this on an ODROID-C1 and ODROID-C2 - the workaround there (probably because the datasheets were not publicy available yet at that time) was to switch to ir_raw_event_store_edge (which leaves it up to the kernel to measure the duration of a pulse). See [0] and [1] for the corresponding patches.
Please note that I was only able to test this on an GXBB/S905 based device (due to lack of other hardware).
[0] https://github.com/erdoukki/linux-amlogic-1/commit/969b2e2242fb14a13cb651f9a1cf771b599c958b
[1] http://forum.odroid.com/viewtopic.php?f=135&t=20504
Martin Blumenstingl
reviewerPATCH v2 1/2 media: rc: meson-ir: fix enabling raw/soft-decoding mode
According to the datasheet of Meson8b (S805) and GXBB (S905) the decoding mode is configured in AO_MF_IR_DEC_REG2 (offset 0x20) using bits 0-3.
The "duration" field may not be set correctly when any of the hardware decoding modes. This can happen while a "default" decoding mode (either set by the bootloader or the chip's default, which uses NEC as it's default) is used.
While here, I also added defines for the protocols which can be decoded by the hardware (more work is needed to be actually able to use them though).
---
changes in v1 -> v2:
- fixed subject of the patch to include meson-ir
- fixed double-shifting of the decoder mode values
drivers/media/rc/meson-ir.c | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-)
drivers/media/rc/meson-ir.c +18 -6
@@ -32,13 +32,10 @@#define IR_DEC_FRAME 0x14#define IR_DEC_STATUS 0x18#define IR_DEC_REG1 0x1c +#define IR_DEC_REG2 0x20#define REG0_RATE_MASK (BIT(11) - 1) -#define REG1_MODE_MASK (BIT(7) | BIT(8)) -#define REG1_MODE_NEC (0 << 7) -#define REG1_MODE_GENERAL (2 << 7) -#define REG1_TIME_IV_SHIFT 16#define REG1_TIME_IV_MASK ((BIT(13) - 1) << REG1_TIME_IV_SHIFT)
@@ -51,6 +48,20 @@#define REG1_RESET BIT(0)#define REG1_ENABLE BIT(15) +#define REG2_DEC_MODE_SHIFT 0 +#define REG2_DEC_MODE_MASK GENMASK(3, REG2_DEC_MODE_SHIFT) +#define REG2_DEC_MODE_NEC 0x0 +#define REG2_DEC_MODE_RAW 0x2 +#define REG2_DEC_MODE_THOMSON 0x4 +#define REG2_DEC_MODE_TOSHIBA 0x5 +#define REG2_DEC_MODE_SONY 0x6 +#define REG2_DEC_MODE_RC5 0x7 +#define REG2_DEC_MODE_RC6 0x9 +#define REG2_DEC_MODE_RCMM 0xa +#define REG2_DEC_MODE_DUOKAN 0xb +#define REG2_DEC_MODE_COMCAST 0xe +#define REG2_DEC_MODE_SANYO 0xf +#define STATUS_IR_DEC_IN BIT(8)#define MESON_TRATE 10/* us */
@@ -158,8 +169,9 @@ static int meson_ir_probe(struct platform_device *pdev)/* Reset the decoder */ meson_ir_set_mask (ir,IR_DEC_REG1 ,REG1_RESET ,REG1_RESET );meson_ir_set_mask (ir,IR_DEC_REG1 ,REG1_RESET ,0 ); -/* Set general operation mode */ -meson_ir_set_mask (ir,IR_DEC_REG1 ,REG1_MODE_MASK ,REG1_MODE_GENERAL ); +/* Enable raw/soft-decode mode */ +meson_ir_set_mask (ir,IR_DEC_REG2 ,REG2_DEC_MODE_MASK , +REG2_DEC_MODE_RAW <<REG2_DEC_MODE_SHIFT );/* Set rate */ meson_ir_set_mask (ir,IR_DEC_REG0 ,REG0_RATE_MASK ,MESON_TRATE -1 );/* IRQ on rising and falling edges */
Signature · 1 line
2.9.0
Martin Blumenstingl
reviewerPATCH v2 2/2 ARM: dts: meson: fixed size of the meson-ir registers
In reply to Martin BlumenstinglAccording to the reference driver (and the datasheet of the newer Meson8b/S805 and GXBB/S905 SoCs) there are 14 registers, each 32 bit wide.
Adjust the register size to reflect that, as register offset 0x20 is now also needed by the meson-ir driver.
---
changes in v1 -> v2:
- new patch, this is needed because we are now trying to read/write offset 0x20 which is beyond the space which was reserved previously
arch/arm/boot/dts/meson.dtsi | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/arm/boot/dts/meson.dtsi +1 -1
@@ -147,7 +147,7 @@ ir_receiver: ir-receiver at c8100480 { compatible= "amlogic,meson6-ir"; - reg = <0xc8100480 0x20>; + reg = <0xc8100480 0x34>; interrupts = <0 15 1>; status = "disabled"; };
Signature · 1 line
2.9.0
PATCH v2 2/2 ARM: dts: meson: fixed size of the meson-ir registers
Quoted 3 lines · Martin Blumenstingl
According to the reference driver (and the datasheet of the newer Meson8b/S805 and GXBB/S905 SoCs) there are 14 registers, each 32 bit wide.
Then why are you modifying the DTS for the Meson6? As Neil already suggested, it seems that the hardware has been slightly modified for the latest SoCs, so this approach is clearly wrong.
Add a new compatible and use of_device_get_match_data() to get the SoC specific data.
Quoted 2 lines
Adjust the register size to reflect that, as register offset
0x20is now also needed by the meson-ir driver.
According to the AML8726-MX (meson6) datasheet the value of 0x20 is correct, at least for that hardware.
Cheers,
Signature · 1 line
Carlo Caione
PATCH v2 1/1 media: rc: fix Meson IR decoder
In reply to Martin BlumenstinglQuoted 5 lines · Martin Blumenstingl
The meson-ir driver uses the wrong offset (at least according to Amlogic's reference driver as well as the datasheets of the Meson8b/S805 and GXBB/S905).
This means that we are getting incorrect durations (REG1_TIME_IV) reported from the hardware.
Hi,
I'm quite sure the registers are good for meson6 actually, and
it seems reasonable Amlogic made the HW evolve for the Meson8 and GXBB platforms.
Quoted 7 lines
This problem was also noticed by some people trying to use this on an ODROID-C1 and ODROID-C2 - the workaround there (probably because the datasheets were not publicy available yet at that time) was to switch to
ir_raw_event_store_edge(which leaves it up to the kernel to measure the duration of a pulse). See [0] and [1] for the corresponding patches.
Since we are using devicetree, the correct way to achieve this fix is not to drop support for meson6 (what you do) but add a logic to select the correct register for meson8 and gxbb if their compatible string are encountered.
Quoted 2 lines
Please note that I was only able to test this on an GXBB/S905 based device (due to lack of other hardware).
I made this fix already but lacked time to actually test it on HW :
https://github.com/torvalds/linux/compare/master...superna9999:amlogic/v4.7/ir
My patch is missing the meson8b support, and may need a supplementary compatible check or a separate dt match table.
Neil
Quoted 4 lines
[0] https://github.com/erdoukki/linux-amlogic-1/commit/969b2e2242fb14a13cb651f9a1cf771b599c958b
[1] http://forum.odroid.com/viewtopic.php?f=135&t=20504
PS: BTW could you format the cover letter using the git format-patch --cover-letter instead and add the v2 using the -subject-prefix like :
# git format-patch --cover-letter --signoff --subject-prefix "PATCH v2" -2
Quoted 5 lines
_______________________________________________
linux-amlogic mailing list
linux-amlogic at lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-amlogic
Martin Blumenstingl
reviewerPATCH v2 1/1 media: rc: fix Meson IR decoder
Quoted 2 lines · Neil Armstrong
I'm quite sure the registers are good for meson6 actually, and
it seems reasonable Amlogic made the HW evolve for the Meson8 and GXBB platforms.
OK, then from now on I will NOT assume anymore that the reference code also works on Meson6 platforms. Thanks for clarifying this.
Quoted 9 lines
Since we are using devicetree, the correct way to achieve this fix is not to drop support for meson6 (what you do) but add a logic to select the correct register for meson8 and gxbb if their compatible string are encountered.
I made this fix already but lacked time to actually test it on HW :
https://github.com/torvalds/linux/compare/master...superna9999:amlogic/v4.7/irMy patch is missing the meson8b support, and may need a supplementary compatible check or a separate dt match table.
I can test it on GXBB (only, I do not have Meson8b hardware, but according to the datasheet the registers are the same).
If you want I can start based on your patch series. Should we add only a binding for amlogic,meson8b and re-use that in meson-gxbb.dtsi or should we add both (8b and gxbb) bindings instead?
Quoted 3 lines
PS: BTW could you format the cover letter using the git format-patch --cover-letter instead and add the v2 using the -subject-prefix like :
# git format-patch --cover-letter --signoff --subject-prefix "PATCH v2" -2
sounds like this is what other devs are using as well - thanks for letting me know
PATCH v2 1/1 media: rc: fix Meson IR decoder
In reply to Martin BlumenstinglQuoted 5 lines · Martin Blumenstingl
The meson-ir driver uses the wrong offset (at least according to Amlogic's reference driver as well as the datasheets of the Meson8b/S805 and GXBB/S905).
This means that we are getting incorrect durations (REG1_TIME_IV) reported from the hardware.
Hi,
I'm quite sure the registers are good for meson6 actually, and
it seems reasonable Amlogic made the HW evolve for the Meson8 and GXBB platforms.
Quoted 7 lines
This problem was also noticed by some people trying to use this on an ODROID-C1 and ODROID-C2 - the workaround there (probably because the datasheets were not publicy available yet at that time) was to switch to
ir_raw_event_store_edge(which leaves it up to the kernel to measure the duration of a pulse). See [0] and [1] for the corresponding patches.
Since we are using devicetree, the correct way to achieve this fix is not to drop support for meson6 (what you do) but add a logic to select the correct register for meson8 and gxbb if their compatible string are encountered.
Quoted 2 lines
Please note that I was only able to test this on an GXBB/S905 based device (due to lack of other hardware).
I made this fix already but lacked time to actually test it on HW :
https://github.com/torvalds/linux/compare/master...superna9999:amlogic/v4.7/ir
My patch is missing the meson8b support, and may need a supplementary compatible check or a separate dt match table.
Neil
Quoted 4 lines
[0] https://github.com/erdoukki/linux-amlogic-1/commit/969b2e2242fb14a13cb651f9a1cf771b599c958b
[1] http://forum.odroid.com/viewtopic.php?f=135&t=20504
PS: BTW could you format the cover letter using the git format-patch --cover-letter instead and add the v2 using the -subject-prefix like :
# git format-patch --cover-letter --signoff --subject-prefix "PATCH v2" -2
Quoted 5 lines
_______________________________________________
linux-amlogic mailing list
linux-amlogic at lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-amlogic
PATCH v2 1/1 media: rc: fix Meson IR decoder
In reply to Martin BlumenstinglQuoted 5 lines · Martin Blumenstingl
Quoted 2 lines · Neil Armstrong
I'm quite sure the registers are good for meson6 actually, and
it seems reasonable Amlogic made the HW evolve for the Meson8 and GXBB platforms.OK, then from now on I will NOT assume anymore that the reference code also works on Meson6 platforms. Thanks for clarifying this.
Yes it's quite safer to assume this !
Quoted 7 lines
Quoted 7 lines
Since we are using devicetree, the correct way to achieve this fix is not to drop support for meson6 (what you do) but add a logic to select the correct register for meson8 and gxbb if their compatible string are encountered.
I made this fix already but lacked time to actually test it on HW :
https://github.com/torvalds/linux/compare/master...superna9999:amlogic/v4.7/ir
Quoted 7 lines
Quoted 2 lines
My patch is missing the meson8b support, and may need a supplementary compatible check or a separate dt match table.
I can test it on GXBB (only, I do not have Meson8b hardware, but according to the datasheet the registers are the same).
If you want I can start based on your patch series. Should we add only a binding for amlogic,meson8b and re-use that inmeson-gxbb.dtsior should we add both (8b and gxbb) bindings instead?
Yes, no problem !
Add the two bindings, it's a better practice and we can track more easily which hardware is really supported from the driver point of view.
Quoted 6 lines
Quoted 3 lines
PS: BTW could you format the cover letter using the git format-patch --cover-letter instead and add the v2 using the -subject-prefix like :
# git format-patch --cover-letter --signoff --subject-prefix "PATCH v2" -2sounds like this is what other devs are using as well - thanks for letting me know
Neil
Martin Blumenstingl
reviewerv3 cover Add Meson 8b / GXBB support to the IR driver
In reply to Martin BlumenstinglNewer Amlogic platforms (Meson 8b and GXBB) use a slightly different register layout for their Infrared Remoete Controller. The decoder mode is now configured in another register. Without the changes to the meson-ir driver we are simply getting incorrect "durations" reported from the hardware (because the hardware is not in time measurement aka software decode mode).
This problem was also noticed by some people trying to use this on an ODROID-C1 and ODROID-C2 - the workaround there (probably because the datasheets were not publicy available yet at that time) was to switch to ir_raw_event_store_edge (which leaves it up to the kernel to measure the duration of a pulse). See [0] and [1] for the corresponding patches.
Changes in v3:
- based on the patches of Neil Armstrong
- depending on the platform either the old (default) or new registers (this has to be enabled explicitly by using "amlogic,meson8b-ir" or "amlogic,meson-gxbb-ir")
- the changes to arch/arm/boot/dts/meson.dtsi are not part of this series anymore, because the size specified there is valid for the Meson 6b version of the IR decoder
- Add the IR decoder to meson-gxbb.dtsi and enable it on the supported boards
[0] https://github.com/erdoukki/linux-amlogic-1/commit/969b2e2242fb14a13cb651f9a1cf771b599c958b
[1] http://forum.odroid.com/viewtopic.php?f=135&t=20504
Martin Blumenstingl (1):
ARM64: dts: meson-gxbb: Enable the the IR decoder on supported boards
Neil Armstrong (3):
dt-bindings: media: meson-ir: Add Meson8b and GXBB compatible strings
media: rc: meson-ir: Add support for newer versions of the IR decoder
ARM64: meson-gxbb: Add Infrared Remote Controller decoder
.../devicetree/bindings/media/meson-ir.txt | 5 +++- .../arm64/boot/dts/amlogic/meson-gxbb-odroidc2.dts | 4 +++ arch/arm64/boot/dts/amlogic/meson-gxbb-p20x.dtsi | 4 +++ .../boot/dts/amlogic/meson-gxbb-vega-s95.dtsi | 4 +++ arch/arm64/boot/dts/amlogic/meson-gxbb.dtsi | 7 ++++++ drivers/media/rc/meson-ir.c | 29 ++++++++++++++++++---- 6 files changed, 47 insertions(+), 6 deletions(-)
Signature · 1 line
2.9.0
Martin Blumenstingl
reviewerPATCH v3 1/4 dt-bindings: media: meson-ir: Add Meson8b and GXBB compatible strings
From: Neil Armstrong <[email protected]>
New bindings are needed as the register layout on the newer platforms is slightly different compared to Meson6b.
--- Documentation/devicetree/bindings/media/meson-ir.txt | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
Documentation/devicetree/bindings/media/meson-ir.txt +4 -1
@@ -1,7 +1,10 @@ * Amlogic Meson IR remote control receiver Required properties: - - compatible : should be "amlogic,meson6-ir" + - compatible : depending on the platform this should be one of: + - "amlogic,meson6-ir" + - "amlogic,meson8b-ir" + - "amlogic,meson-gxbb-ir" - reg : physical base address and length of the device registers - interrupts : a single specifier for the interrupt from the device
Signature · 1 line
2.9.0
Rob Herring
maintainerPATCH v3 1/4 dt-bindings: media: meson-ir: Add Meson8b and GXBB compatible strings
Quoted 10 lines · Martin Blumenstingl
From: Neil Armstrong <[email protected]>
New bindings are needed as the register layout on the newer platforms is slightly different compared to Meson6b.
Signed-off-by Neil Armstrong <[email protected]>Signed-off-by Martin Blumenstingl <[email protected]>--- Documentation/devicetree/bindings/media/meson-ir.txt | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
Martin Blumenstingl
reviewerPATCH v3 2/4 media: rc: meson-ir: Add support for newer versions of the IR decoder
In reply to Martin BlumenstinglFrom: Neil Armstrong <[email protected]>
Newer SoCs (Meson 8b and GXBB) are using REG2 (offset 0x20) instead of REG1 to configure the decoder mode. This makes it necessary to introduce new bindings so the driver knows which register has to be used.
--- drivers/media/rc/meson-ir.c | 29 ++++++++++++++++++++++++----- 1 file changed, 24 insertions(+), 5 deletions(-)
drivers/media/rc/meson-ir.c +24 -5
@@ -24,6 +24,7 @@#define DRIVER_NAME "meson-ir" +/* valid on all Meson platforms */ #define IR_DEC_LDR_ACTIVE 0x00#define IR_DEC_LDR_IDLE 0x04#define IR_DEC_LDR_REPEAT 0x08
@@ -32,12 +33,21 @@#define IR_DEC_FRAME 0x14#define IR_DEC_STATUS 0x18#define IR_DEC_REG1 0x1c +/* only available on Meson 8b and newer */ +#define IR_DEC_REG2 0x20#define REG0_RATE_MASK (BIT(11) - 1) -#define REG1_MODE_MASK (BIT(7) | BIT(8)) -#define REG1_MODE_NEC (0 << 7) -#define REG1_MODE_GENERAL (2 << 7) +#define DECODE_MODE_NEC 0x0 +#define DECODE_MODE_RAW 0x2 + +/* Meson 6b uses REG1 to configure the mode */ +#define REG1_MODE_MASK GENMASK(8, 7) +#define REG1_MODE_SHIFT 7 + +/* Meson 8b / GXBB use REG2 to configure the mode */ +#define REG2_MODE_MASK GENMASK(3, 0) +#define REG2_MODE_SHIFT 0#define REG1_TIME_IV_SHIFT 16#define REG1_TIME_IV_MASK ((BIT(13) - 1) << REG1_TIME_IV_SHIFT)
@@ -158,8 +168,15 @@ static int meson_ir_probe(struct platform_device *pdev)/* Reset the decoder */ meson_ir_set_mask (ir,IR_DEC_REG1 ,REG1_RESET ,REG1_RESET );meson_ir_set_mask (ir,IR_DEC_REG1 ,REG1_RESET ,0 ); -/* Set general operation mode */ -meson_ir_set_mask (ir,IR_DEC_REG1 ,REG1_MODE_MASK ,REG1_MODE_GENERAL ); + +/* Set general operation mode (= raw/software decoding) */ +if (of_device_is_compatible (node,"amlogic,meson6-ir" )) +meson_ir_set_mask (ir,IR_DEC_REG1 ,REG1_MODE_MASK , +DECODE_MODE_RAW <<REG1_MODE_SHIFT ); +else +meson_ir_set_mask (ir,IR_DEC_REG2 ,REG2_MODE_MASK , +DECODE_MODE_RAW <<REG2_MODE_SHIFT ); +/* Set rate */ meson_ir_set_mask (ir,IR_DEC_REG0 ,REG0_RATE_MASK ,MESON_TRATE -1 );/* IRQ on rising and falling edges */
@@ -197,6 +214,8 @@ static int meson_ir_remove(struct platform_device *pdev)static const struct of_device_id meson_ir_match[] = { { .compatible ="amlogic,meson6-ir" }, + { .compatible ="amlogic,meson8b-ir" }, + { .compatible ="amlogic,meson-gxbb-ir" }, { }, };
Signature · 1 line
2.9.0
Martin Blumenstingl
reviewerPATCH v3 3/4 ARM64: meson-gxbb: Add Infrared Remote Controller decoder
In reply to Martin BlumenstinglFrom: Neil Armstrong <[email protected]>
This adds the Infrared Remote Controller node so boards with an IR remote can simply enable it.
--- arch/arm64/boot/dts/amlogic/meson-gxbb.dtsi | 7 +++++++ 1 file changed, 7 insertions(+)
arch/arm64/boot/dts/amlogic/meson-gxbb.dtsi +7 -0
@@ -213,6 +213,13 @@ clocks = <&xtal>; status = "disabled"; }; + + ir: ir at 580 { + compatible = "amlogic,meson-gxbb-ir"; + reg = <0x0 0x00580 0x0 0x40>; + interrupts = <GIC_SPI 196 IRQ_TYPE_EDGE_RISING>; + status = "disabled"; + }; }; periphs: periphs at c8834000 {
Signature · 1 line
2.9.0
Martin Blumenstingl
reviewerPATCH v3 4/4 ARM64: dts: meson-gxbb: Enable the the IR decoder on supported boards
In reply to Martin BlumenstinglEnable the Infrared Remote Controller on boards which have an Infrared receiver.
--- arch/arm64/boot/dts/amlogic/meson-gxbb-odroidc2.dts | 4 ++++ arch/arm64/boot/dts/amlogic/meson-gxbb-p20x.dtsi | 4 ++++ arch/arm64/boot/dts/amlogic/meson-gxbb-vega-s95.dtsi | 4 ++++ 3 files changed, 12 insertions(+)
arch/arm64/boot/dts/amlogic/meson-gxbb-odroidc2.dts +4 -0
@@ -120,3 +120,7 @@ vmmc-supply = <&mmc_iv>; voltage-ranges = <1800 3300>; }; + +&ir { + status = "okay"; +};
arch/arm64/boot/dts/amlogic/meson-gxbb-p20x.dtsi +4 -0
@@ -102,3 +102,7 @@ voltage-ranges = <1800 3300>; vmmc-supply = <&mmc_iv>; }; + +&ir { + status = "okay"; +};
arch/arm64/boot/dts/amlogic/meson-gxbb-vega-s95.dtsi +4 -0
@@ -60,3 +60,7 @@ pinctrl-names = "default"; }; + +&ir { + status = "okay"; +};
Signature · 1 line
2.9.0
Kevin Hilman
maintainerv3 cover Add Meson 8b / GXBB support to the IR driver
In reply to Martin BlumenstinglHi Martin,
Quoted 7 lines · Martin Blumenstingl
Newer Amlogic platforms (Meson 8b and GXBB) use a slightly different register layout for their Infrared Remoete Controller. The decoder mode is now configured in another register. Without the changes to the meson-ir driver we are simply getting incorrect "durations" reported from the hardware (because the hardware is not in time measurement aka software decode mode).
Quoted 6 lines
This problem was also noticed by some people trying to use this on an ODROID-C1 and ODROID-C2 - the workaround there (probably because the datasheets were not publicy available yet at that time) was to switch to
ir_raw_event_store_edge(which leaves it up to the kernel to measure the duration of a pulse). See [0] and [1] for the corresponding patches.
I tried this on meson-gxbb-p200 and I'm not seeing any button press events with evtest or ir-keytable when using the Amlogic remote that came with the board. Below is the register dump you requested on IRC:
[ 1.068347] Registered IR keymap rc-empty [ 1.072422] input: meson-ir as /devices/platform/soc/c8100000.aobus/c8100580.ir/rc/rc0/input0 [ 1.080814] rc rc0: meson-ir as /devices/platform/soc/c8100000.aobus/c8100580.ir/rc/rc0 [ 1.088839] input: MCE IR Keyboard/Mouse (meson-ir) as /devices/virtual/input/input1 [ 1.096519] rc rc0: lirc_dev: driver ir-lirc-codec (meson-ir) registered at minor = 0 [ 1.104119] meson-ir c8100580.ir: receiver initialized [ 1.109172] IR: reg 0x00 = 0x01d801ac [ 1.112795] IR: reg 0x04 = 0x00f800ca [ 1.116416] IR: reg 0x08 = 0x007a0066 [ 1.120037] IR: reg 0x0c = 0x0044002c [ 1.123660] IR: reg 0x10 = 0x70fa0009 [ 1.127278] IR: reg 0x14 = 0x00000000 [ 1.130907] IR: reg 0x18 = 0x08915c00 [ 1.134527] IR: reg 0x1c = 0x00009f44 [ 1.138152] IR: reg 0x20 = 0x00000002
Kevin
Martin Blumenstingl
reviewerv4 cover Add Meson 8b / GXBB support to the IR driver
In reply to Martin BlumenstinglNewer Amlogic platforms (Meson 8b and GXBB) use a slightly different register layout for their Infrared Remoete Controller. The decoder mode is now configured in another register. Without the changes to the meson-ir driver we are simply getting incorrect "durations" reported from the hardware (because the hardware is not in time measurement aka software decode mode).
This problem was also noticed by some people trying to use this on an ODROID-C1 and ODROID-C2 - the workaround there (probably because the datasheets were not publicy available yet at that time) was to switch to ir_raw_event_store_edge (which leaves it up to the kernel to measure the duration of a pulse). See [0] and [1] for the corresponding patches.
Changes in v4:
- added support for pinctrl configuration which makes it possible to use the IR decoder when doing a cold-boot. Without these pinctrl changes the IR decoder was only working when booting into stock Android, then rebooting and booting the mainline kernel (with the other patches from this series). Thanks to Kevin Hilman for spotting this issue.
- rebased dts changes to Kevin's v4.8/integ branch
As discussed on IRC (thanks Neil):
[0] https://github.com/erdoukki/linux-amlogic-1/commit/969b2e2242fb14a13cb651f9a1cf771b599c958b
[1] http://forum.odroid.com/viewtopic.php?f=135&t=20504
Martin Blumenstingl (3):
pinctrl: amlogic: gxbb: add the IR remote pin
ARM64: dts: amlogic: add the pin for the IR remote
ARM64: dts: meson-gxbb: Enable the the IR decoder on supported boards
Neil Armstrong (3):
dt-bindings: media: meson-ir: Add Meson8b and GXBB compatible strings
media: rc: meson-ir: Add support for newer versions of the IR decoder
ARM64: dts: meson-gxbb: Add Infrared Remote Controller decoder
.../devicetree/bindings/media/meson-ir.txt | 5 +++- .../arm64/boot/dts/amlogic/meson-gxbb-odroidc2.dts | 6 +++++ arch/arm64/boot/dts/amlogic/meson-gxbb-p20x.dtsi | 6 +++++ .../boot/dts/amlogic/meson-gxbb-vega-s95.dtsi | 6 +++++ arch/arm64/boot/dts/amlogic/meson-gxbb.dtsi | 14 +++++++++++ drivers/media/rc/meson-ir.c | 29 ++++++++++++++++++---- drivers/pinctrl/meson/pinctrl-meson-gxbb.c | 8 ++++++ 7 files changed, 68 insertions(+), 6 deletions(-)
Signature · 1 line
2.9.3
Martin Blumenstingl
reviewerPATCH v4 1/6 pinctrl: amlogic: gxbb: add the IR remote pin
This adds the IR remote receiver to the AO domain devices.
--- drivers/pinctrl/meson/pinctrl-meson-gxbb.c | 8 ++++++++ 1 file changed, 8 insertions(+)
drivers/pinctrl/meson/pinctrl-meson-gxbb.c +8 -0
@@ -225,6 +225,8 @@ static const unsigned int i2c_sda_ao_pins[] = {PIN(GPIOAO_5, 0) };static const unsigned int i2c_slave_sck_ao_pins[] = {PIN (GPIOAO_4 ,0 ) };static const unsigned int i2c_slave_sda_ao_pins[] = {PIN (GPIOAO_5 ,0 ) }; +static const unsigned int ir_in_ao_pins[] = {PIN (GPIOAO_7 ,0 ) }; +static struct meson_pmx_group meson_gxbb_periphs_groups[] = {GPIO_GROUP (GPIOZ_0 ,EE_OFF ),GPIO_GROUP (GPIOZ_1 ,EE_OFF ),
@@ -432,6 +434,7 @@ static struct meson_pmx_group meson_gxbb_aobus_groups[] = {GROUP (i2c_sda_ao,0 ,5 ),GROUP (i2c_slave_sck_ao,0 ,2 ),GROUP (i2c_slave_sda_ao,0 ,1 ), + GROUP(ir_in_ao, 0, 0), }; static const char * const gpio_periphs_groups[] = {
@@ -521,6 +524,10 @@ static const char * const i2c_slave_ao_groups[] = { "i2c_slave_sdk_ao", "i2c_slave_sda_ao", }; +static const char *const ir_in_ao_groups[] = { +"ir_in_ao" , +}; +static struct meson_pmx_func meson_gxbb_periphs_functions[] = {FUNCTION (gpio_periphs),FUNCTION (emmc),
@@ -537,6 +544,7 @@ static struct meson_pmx_func meson_gxbb_aobus_functions[] = {FUNCTION (uart_ao_b),FUNCTION (i2c_ao ),FUNCTION (i2c_slave_ao ), + FUNCTION(ir_in_ao), };static struct meson_bank meson_gxbb_periphs_banks[] = {
Signature · 1 line
2.9.3
Kevin Hilman
maintainerPATCH v4 1/6 pinctrl: amlogic: gxbb: add the IR remote pin
Quoted 1 line · Martin Blumenstingl
This adds the IR remote receiver to the AO domain devices.
nit Re: Subject: should specify IR remote *input* pin.
Quoted 10 lines
Signed-off-by Martin Blumenstingl <[email protected]>--- drivers/pinctrl/meson/pinctrl-meson-gxbb.c | 8 ++++++++ 1 file changed, 8 insertions(+)drivers/pinctrl/meson/pinctrl-meson-gxbb.c +0
-0
drivers/pinctrl/meson/pinctrl-meson-gxbb.c static const unsigned int i2c_sda_ao_pins[] = {PIN(GPIOAO_5, 0) }; · line 229
Quoted 5 lines
drivers/pinctrl/meson/pinctrl-meson-gxbb.c +2
-0@@ -225,6 +225,8 @@ static const unsigned int i2c_sda_ao_pins[] = {PIN(GPIOAO_5, 0) };static const unsigned int i2c_slave_sck_ao_pins[] = {PIN (GPIOAO_4 ,0 ) };static const unsigned int i2c_slave_sda_ao_pins[] = {PIN (GPIOAO_5 ,0 ) }; +static const unsigned int ir_in_ao_pins[] = {PIN (GPIOAO_7 ,0 ) }; +
I'm trying to keep the names here so they match the datasheet, which calls this remote_input_ao. Please update throughout the patch.
Otherwise looks good to me. Feel free to add
and Linus W can queue it up.
Thanks,
Kevin
Martin Blumenstingl
reviewerPATCH v4 2/6 ARM64: dts: amlogic: add the pin for the IR remote
In reply to Martin Blumenstingl--- arch/arm64/boot/dts/amlogic/meson-gxbb.dtsi | 7 +++++++ 1 file changed, 7 insertions(+)
arch/arm64/boot/dts/amlogic/meson-gxbb.dtsi +7 -0
@@ -210,6 +210,13 @@ function = "uart_ao"; }; }; + + ir_in_ao_pins: ir_in_ao { + mux { + groups = "ir_in_ao"; + function = "ir_in_ao"; + }; + }; }; uart_AO: serial at 4c0 {
Signature · 1 line
2.9.3
Martin Blumenstingl
reviewerPATCH v4 3/6 dt-bindings: media: meson-ir: Add Meson8b and GXBB compatible strings
In reply to Martin BlumenstinglFrom: Neil Armstrong <[email protected]>
New bindings are needed as the register layout on the newer platforms is slightly different compared to Meson6b.
--- Documentation/devicetree/bindings/media/meson-ir.txt | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
Documentation/devicetree/bindings/media/meson-ir.txt +4 -1
@@ -1,7 +1,10 @@ * Amlogic Meson IR remote control receiver Required properties: - - compatible : should be "amlogic,meson6-ir" + - compatible : depending on the platform this should be one of: + - "amlogic,meson6-ir" + - "amlogic,meson8b-ir" + - "amlogic,meson-gxbb-ir" - reg : physical base address and length of the device registers - interrupts : a single specifier for the interrupt from the device
Signature · 1 line
2.9.3
Martin Blumenstingl
reviewerPATCH v4 4/6 media: rc: meson-ir: Add support for newer versions of the IR decoder
In reply to Martin BlumenstinglFrom: Neil Armstrong <[email protected]>
Newer SoCs (Meson 8b and GXBB) are using REG2 (offset 0x20) instead of REG1 to configure the decoder mode. This makes it necessary to introduce new bindings so the driver knows which register has to be used.
--- drivers/media/rc/meson-ir.c | 29 ++++++++++++++++++++++++----- 1 file changed, 24 insertions(+), 5 deletions(-)
drivers/media/rc/meson-ir.c +24 -5
@@ -24,6 +24,7 @@#define DRIVER_NAME "meson-ir" +/* valid on all Meson platforms */ #define IR_DEC_LDR_ACTIVE 0x00#define IR_DEC_LDR_IDLE 0x04#define IR_DEC_LDR_REPEAT 0x08
@@ -32,12 +33,21 @@#define IR_DEC_FRAME 0x14#define IR_DEC_STATUS 0x18#define IR_DEC_REG1 0x1c +/* only available on Meson 8b and newer */ +#define IR_DEC_REG2 0x20#define REG0_RATE_MASK (BIT(11) - 1) -#define REG1_MODE_MASK (BIT(7) | BIT(8)) -#define REG1_MODE_NEC (0 << 7) -#define REG1_MODE_GENERAL (2 << 7) +#define DECODE_MODE_NEC 0x0 +#define DECODE_MODE_RAW 0x2 + +/* Meson 6b uses REG1 to configure the mode */ +#define REG1_MODE_MASK GENMASK(8, 7) +#define REG1_MODE_SHIFT 7 + +/* Meson 8b / GXBB use REG2 to configure the mode */ +#define REG2_MODE_MASK GENMASK(3, 0) +#define REG2_MODE_SHIFT 0#define REG1_TIME_IV_SHIFT 16#define REG1_TIME_IV_MASK ((BIT(13) - 1) << REG1_TIME_IV_SHIFT)
@@ -158,8 +168,15 @@ static int meson_ir_probe(struct platform_device *pdev)/* Reset the decoder */ meson_ir_set_mask (ir,IR_DEC_REG1 ,REG1_RESET ,REG1_RESET );meson_ir_set_mask (ir,IR_DEC_REG1 ,REG1_RESET ,0 ); -/* Set general operation mode */ -meson_ir_set_mask (ir,IR_DEC_REG1 ,REG1_MODE_MASK ,REG1_MODE_GENERAL ); + +/* Set general operation mode (= raw/software decoding) */ +if (of_device_is_compatible (node,"amlogic,meson6-ir" )) +meson_ir_set_mask (ir,IR_DEC_REG1 ,REG1_MODE_MASK , +DECODE_MODE_RAW <<REG1_MODE_SHIFT ); +else +meson_ir_set_mask (ir,IR_DEC_REG2 ,REG2_MODE_MASK , +DECODE_MODE_RAW <<REG2_MODE_SHIFT ); +/* Set rate */ meson_ir_set_mask (ir,IR_DEC_REG0 ,REG0_RATE_MASK ,MESON_TRATE -1 );/* IRQ on rising and falling edges */
@@ -197,6 +214,8 @@ static int meson_ir_remove(struct platform_device *pdev)static const struct of_device_id meson_ir_match[] = { { .compatible ="amlogic,meson6-ir" }, + { .compatible ="amlogic,meson8b-ir" }, + { .compatible ="amlogic,meson-gxbb-ir" }, { }, };
Signature · 1 line
2.9.3
Kevin Hilman
maintainerPATCH v4 4/6 media: rc: meson-ir: Add support for newer versions of the IR decoder
Quoted 9 lines · Martin Blumenstingl
From: Neil Armstrong <[email protected]>
Newer SoCs (Meson 8b and GXBB) are using REG2 (offset
0x20) instead of REG1 to configure the decoder mode. This makes it necessary to introduce new bindings so the driver knows which register has to be used.Signed-off-by Neil Armstrong <[email protected]>Signed-off-by Martin Blumenstingl <[email protected]>
Mauro, are you the one to pick up new media/rc drivers? Or if you prefer, with your ack, I'll take this along with the DT and submit via arm-soc.
Thanks,
Kevin
PATCH v4 4/6 media: rc: meson-ir: Add support for newer versions of the IR decoder
Em Fri, 19 Aug 2016 15:28:22 -0700
Kevin Hilman <[email protected]> escreveu:
Quoted 9 lines
Quoted 7 lines · Martin Blumenstingl
From: Neil Armstrong <[email protected]>
Newer SoCs (Meson 8b and GXBB) are using REG2 (offset
0x20) instead of REG1 to configure the decoder mode. This makes it necessary to introduce new bindings so the driver knows which register has to be used.
Quoted 8 lines
Quoted 2 lines
Signed-off-by Neil Armstrong <[email protected]>Signed-off-by Martin Blumenstingl <[email protected]>Acked-by Kevin Hilman <[email protected]>Mauro, are you the one to pick up new media/rc drivers? Or if you prefer, with your ack, I'll take this along with the DT and submit via arm-soc.
I generally pick new media rc drivers, but in the specific case of this patchset, it is just adding a few extra lines to existing drivers, and most of the work are actually at the ARM tree.
So, feel free to merge via arm-soc with my ack:
Quoted 8 lines
Thanks,
Kevin
--
To unsubscribe from this list: send the line "unsubscribe linux-media" in the body of a message to majordomo at vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Thanks,
Mauro
Martin Blumenstingl
reviewerPATCH v4 5/6 ARM64: dts: meson-gxbb: Add Infrared Remote Controller decoder
In reply to Martin BlumenstinglFrom: Neil Armstrong <[email protected]>
This adds the Infrared Remote Controller node so boards with an IR remote can simply enable it.
--- arch/arm64/boot/dts/amlogic/meson-gxbb.dtsi | 7 +++++++ 1 file changed, 7 insertions(+)
arch/arm64/boot/dts/amlogic/meson-gxbb.dtsi +7 -0
@@ -226,6 +226,13 @@ clocks = <&xtal>; status = "disabled"; }; + + ir: ir at 580 { + compatible = "amlogic,meson-gxbb-ir"; + reg = <0x0 0x00580 0x0 0x40>; + interrupts = <GIC_SPI 196 IRQ_TYPE_EDGE_RISING>; + status = "disabled"; + }; }; periphs: periphs at c8834000 {
Signature · 1 line
2.9.3
Martin Blumenstingl
reviewerPATCH v4 6/6 ARM64: dts: meson-gxbb: Enable the the IR decoder on supported boards
In reply to Martin BlumenstinglEnable the Infrared Remote Controller on boards which have an Infrared receiver.
--- arch/arm64/boot/dts/amlogic/meson-gxbb-odroidc2.dts | 6 ++++++ arch/arm64/boot/dts/amlogic/meson-gxbb-p20x.dtsi | 6 ++++++ arch/arm64/boot/dts/amlogic/meson-gxbb-vega-s95.dtsi | 6 ++++++ 3 files changed, 18 insertions(+)
arch/arm64/boot/dts/amlogic/meson-gxbb-odroidc2.dts +6 -0
@@ -161,3 +161,9 @@ vmmc-supply = <&vcc3v3>; vmmcq-sumpply = <&vcc1v8>; }; + +&ir { + status = "okay"; + pinctrl-0 = <&ir_in_ao_pins>; + pinctrl-names = "default"; +};
arch/arm64/boot/dts/amlogic/meson-gxbb-p20x.dtsi +6 -0
@@ -143,3 +143,9 @@ vmmc-supply = <&vcc_3v3>; vmmcq-sumpply = <&vddio_boot>; }; + +&ir { + status = "okay"; + pinctrl-0 = <&ir_in_ao_pins>; + pinctrl-names = "default"; +};
arch/arm64/boot/dts/amlogic/meson-gxbb-vega-s95.dtsi +6 -0
@@ -60,3 +60,9 @@ pinctrl-names = "default"; }; + +&ir { + status = "okay"; + pinctrl-0 = <&ir_in_ao_pins>; + pinctrl-names = "default"; +};
Signature · 1 line
2.9.3
Martin Blumenstingl
reviewerv5 cover Add Meson 8b / GXBB support to the IR driver
In reply to Martin BlumenstinglNewer Amlogic platforms (Meson 8b and GXBB) use a slightly different register layout for their Infrared Remoete Controller. The decoder mode is now configured in another register. Without the changes to the meson-ir driver we are simply getting incorrect "durations" reported from the hardware (because the hardware is not in time measurement aka software decode mode).
This problem was also noticed by some people trying to use this on an ODROID-C1 and ODROID-C2 - the workaround there (probably because the datasheets were not publicy available yet at that time) was to switch to ir_raw_event_store_edge (which leaves it up to the kernel to measure the duration of a pulse). See [0] and [1] for the corresponding patches.
Changes in v5:
- changed pin function and group names to remote_input_ao so they match with the datasheet
[0] https://github.com/erdoukki/linux-amlogic-1/commit/969b2e2242fb14a13cb651f9a1cf771b599c958b
[1] http://forum.odroid.com/viewtopic.php?f=135&t=20504
Martin Blumenstingl (3):
pinctrl: amlogic: gxbb: add the IR remote input pin
ARM64: dts: amlogic: add the input pin for the IR remote
ARM64: dts: meson-gxbb: Enable the the IR decoder on supported boards
Neil Armstrong (3):
dt-bindings: media: meson-ir: Add Meson8b and GXBB compatible strings
media: rc: meson-ir: Add support for newer versions of the IR decoder
ARM64: dts: meson-gxbb: Add Infrared Remote Controller decoder
.../devicetree/bindings/media/meson-ir.txt | 5 +++- .../arm64/boot/dts/amlogic/meson-gxbb-odroidc2.dts | 6 +++++ arch/arm64/boot/dts/amlogic/meson-gxbb-p20x.dtsi | 6 +++++ .../boot/dts/amlogic/meson-gxbb-vega-s95.dtsi | 6 +++++ arch/arm64/boot/dts/amlogic/meson-gxbb.dtsi | 14 +++++++++++ drivers/media/rc/meson-ir.c | 29 ++++++++++++++++++---- drivers/pinctrl/meson/pinctrl-meson-gxbb.c | 8 ++++++ 7 files changed, 68 insertions(+), 6 deletions(-)
Signature · 1 line
2.9.3
Martin Blumenstingl
reviewerPATCH v5 1/6 pinctrl: amlogic: gxbb: add the IR remote input pin
This adds the IR remote receiver to the AO domain devices.
--- drivers/pinctrl/meson/pinctrl-meson-gxbb.c | 8 ++++++++ 1 file changed, 8 insertions(+)
drivers/pinctrl/meson/pinctrl-meson-gxbb.c +8 -0
@@ -225,6 +225,8 @@ static const unsigned int i2c_sda_ao_pins[] = {PIN(GPIOAO_5, 0) };static const unsigned int i2c_slave_sck_ao_pins[] = {PIN (GPIOAO_4 ,0 ) };static const unsigned int i2c_slave_sda_ao_pins[] = {PIN (GPIOAO_5 ,0 ) }; +static const unsigned int remote_input_ao_pins[] = {PIN (GPIOAO_7 ,0 ) }; +static struct meson_pmx_group meson_gxbb_periphs_groups[] = {GPIO_GROUP (GPIOZ_0 ,EE_OFF ),GPIO_GROUP (GPIOZ_1 ,EE_OFF ),
@@ -432,6 +434,7 @@ static struct meson_pmx_group meson_gxbb_aobus_groups[] = {GROUP (i2c_sda_ao,0 ,5 ),GROUP (i2c_slave_sck_ao,0 ,2 ),GROUP (i2c_slave_sda_ao,0 ,1 ), + GROUP(remote_input_ao, 0, 0), }; static const char * const gpio_periphs_groups[] = {
@@ -521,6 +524,10 @@ static const char * const i2c_slave_ao_groups[] = { "i2c_slave_sdk_ao", "i2c_slave_sda_ao", }; +static const char *const remote_input_ao_groups[] = { +"remote_input_ao" , +}; +static struct meson_pmx_func meson_gxbb_periphs_functions[] = {FUNCTION (gpio_periphs),FUNCTION (emmc),
@@ -537,6 +544,7 @@ static struct meson_pmx_func meson_gxbb_aobus_functions[] = {FUNCTION (uart_ao_b),FUNCTION (i2c_ao ),FUNCTION (i2c_slave_ao ), + FUNCTION(remote_input_ao), };static struct meson_bank meson_gxbb_periphs_banks[] = {
Signature · 1 line
2.9.3
PATCH v5 1/6 pinctrl: amlogic: gxbb: add the IR remote input pin
Quoted 4 lines · Martin Blumenstingl
This adds the IR remote receiver to the AO domain devices.
Signed-off-by Martin Blumenstingl <[email protected]>Reviewed-by Kevin Hilman <[email protected]>
Patch applied.
Yours,
Linus Walleij
Martin Blumenstingl
reviewerPATCH v5 2/6 ARM64: dts: amlogic: add the input pin for the IR remote
In reply to Martin Blumenstingl--- arch/arm64/boot/dts/amlogic/meson-gxbb.dtsi | 7 +++++++ 1 file changed, 7 insertions(+)
arch/arm64/boot/dts/amlogic/meson-gxbb.dtsi +7 -0
@@ -210,6 +210,13 @@ function = "uart_ao"; }; }; + + remote_input_ao_pins: remote_input_ao { + mux { + groups = "remote_input_ao"; + function = "remote_input_ao"; + }; + }; }; uart_AO: serial at 4c0 {
Signature · 1 line
2.9.3
PATCH v5 2/6 ARM64: dts: amlogic: add the input pin for the IR remote
Quoted 1 line · Martin Blumenstingl
Signed-off-by Martin Blumenstingl <[email protected]>
Merge this through the ARM SoC tree.
Yours,
Linus Walleij
Martin Blumenstingl
reviewerPATCH v5 3/6 dt-bindings: media: meson-ir: Add Meson8b and GXBB compatible strings
In reply to Martin BlumenstinglFrom: Neil Armstrong <[email protected]>
New bindings are needed as the register layout on the newer platforms is slightly different compared to Meson6b.
--- Documentation/devicetree/bindings/media/meson-ir.txt | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
Documentation/devicetree/bindings/media/meson-ir.txt +4 -1
@@ -1,7 +1,10 @@ * Amlogic Meson IR remote control receiver Required properties: - - compatible : should be "amlogic,meson6-ir" + - compatible : depending on the platform this should be one of: + - "amlogic,meson6-ir" + - "amlogic,meson8b-ir" + - "amlogic,meson-gxbb-ir" - reg : physical base address and length of the device registers - interrupts : a single specifier for the interrupt from the device
Signature · 1 line
2.9.3
Martin Blumenstingl
reviewerPATCH v5 4/6 media: rc: meson-ir: Add support for newer versions of the IR decoder
In reply to Martin BlumenstinglFrom: Neil Armstrong <[email protected]>
Newer SoCs (Meson 8b and GXBB) are using REG2 (offset 0x20) instead of REG1 to configure the decoder mode. This makes it necessary to introduce new bindings so the driver knows which register has to be used.
--- drivers/media/rc/meson-ir.c | 29 ++++++++++++++++++++++++----- 1 file changed, 24 insertions(+), 5 deletions(-)
drivers/media/rc/meson-ir.c +24 -5
@@ -24,6 +24,7 @@#define DRIVER_NAME "meson-ir" +/* valid on all Meson platforms */ #define IR_DEC_LDR_ACTIVE 0x00#define IR_DEC_LDR_IDLE 0x04#define IR_DEC_LDR_REPEAT 0x08
@@ -32,12 +33,21 @@#define IR_DEC_FRAME 0x14#define IR_DEC_STATUS 0x18#define IR_DEC_REG1 0x1c +/* only available on Meson 8b and newer */ +#define IR_DEC_REG2 0x20#define REG0_RATE_MASK (BIT(11) - 1) -#define REG1_MODE_MASK (BIT(7) | BIT(8)) -#define REG1_MODE_NEC (0 << 7) -#define REG1_MODE_GENERAL (2 << 7) +#define DECODE_MODE_NEC 0x0 +#define DECODE_MODE_RAW 0x2 + +/* Meson 6b uses REG1 to configure the mode */ +#define REG1_MODE_MASK GENMASK(8, 7) +#define REG1_MODE_SHIFT 7 + +/* Meson 8b / GXBB use REG2 to configure the mode */ +#define REG2_MODE_MASK GENMASK(3, 0) +#define REG2_MODE_SHIFT 0#define REG1_TIME_IV_SHIFT 16#define REG1_TIME_IV_MASK ((BIT(13) - 1) << REG1_TIME_IV_SHIFT)
@@ -158,8 +168,15 @@ static int meson_ir_probe(struct platform_device *pdev)/* Reset the decoder */ meson_ir_set_mask (ir,IR_DEC_REG1 ,REG1_RESET ,REG1_RESET );meson_ir_set_mask (ir,IR_DEC_REG1 ,REG1_RESET ,0 ); -/* Set general operation mode */ -meson_ir_set_mask (ir,IR_DEC_REG1 ,REG1_MODE_MASK ,REG1_MODE_GENERAL ); + +/* Set general operation mode (= raw/software decoding) */ +if (of_device_is_compatible (node,"amlogic,meson6-ir" )) +meson_ir_set_mask (ir,IR_DEC_REG1 ,REG1_MODE_MASK , +DECODE_MODE_RAW <<REG1_MODE_SHIFT ); +else +meson_ir_set_mask (ir,IR_DEC_REG2 ,REG2_MODE_MASK , +DECODE_MODE_RAW <<REG2_MODE_SHIFT ); +/* Set rate */ meson_ir_set_mask (ir,IR_DEC_REG0 ,REG0_RATE_MASK ,MESON_TRATE -1 );/* IRQ on rising and falling edges */
@@ -197,6 +214,8 @@ static int meson_ir_remove(struct platform_device *pdev)static const struct of_device_id meson_ir_match[] = { { .compatible ="amlogic,meson6-ir" }, + { .compatible ="amlogic,meson8b-ir" }, + { .compatible ="amlogic,meson-gxbb-ir" }, { }, };
Signature · 1 line
2.9.3
Martin Blumenstingl
reviewerPATCH v5 5/6 ARM64: dts: meson-gxbb: Add Infrared Remote Controller decoder
In reply to Martin BlumenstinglFrom: Neil Armstrong <[email protected]>
This adds the Infrared Remote Controller node so boards with an IR remote can simply enable it.
--- arch/arm64/boot/dts/amlogic/meson-gxbb.dtsi | 7 +++++++ 1 file changed, 7 insertions(+)
arch/arm64/boot/dts/amlogic/meson-gxbb.dtsi +7 -0
@@ -226,6 +226,13 @@ clocks = <&xtal>; status = "disabled"; }; + + ir: ir at 580 { + compatible = "amlogic,meson-gxbb-ir"; + reg = <0x0 0x00580 0x0 0x40>; + interrupts = <GIC_SPI 196 IRQ_TYPE_EDGE_RISING>; + status = "disabled"; + }; }; periphs: periphs at c8834000 {
Signature · 1 line
2.9.3
Martin Blumenstingl
reviewerPATCH v5 6/6 ARM64: dts: meson-gxbb: Enable the the IR decoder on supported boards
In reply to Martin BlumenstinglEnable the Infrared Remote Controller on boards which have an Infrared receiver.
--- arch/arm64/boot/dts/amlogic/meson-gxbb-odroidc2.dts | 6 ++++++ arch/arm64/boot/dts/amlogic/meson-gxbb-p20x.dtsi | 6 ++++++ arch/arm64/boot/dts/amlogic/meson-gxbb-vega-s95.dtsi | 6 ++++++ 3 files changed, 18 insertions(+)
arch/arm64/boot/dts/amlogic/meson-gxbb-odroidc2.dts +6 -0
@@ -161,3 +161,9 @@ vmmc-supply = <&vcc3v3>; vmmcq-sumpply = <&vcc1v8>; }; + +&ir { + status = "okay"; + pinctrl-0 = <&remote_input_ao_pins>; + pinctrl-names = "default"; +};
arch/arm64/boot/dts/amlogic/meson-gxbb-p20x.dtsi +6 -0
@@ -143,3 +143,9 @@ vmmc-supply = <&vcc_3v3>; vmmcq-sumpply = <&vddio_boot>; }; + +&ir { + status = "okay"; + pinctrl-0 = <&remote_input_ao_pins>; + pinctrl-names = "default"; +};
arch/arm64/boot/dts/amlogic/meson-gxbb-vega-s95.dtsi +6 -0
@@ -60,3 +60,9 @@ pinctrl-names = "default"; }; + +&ir { + status = "okay"; + pinctrl-0 = <&remote_input_ao_pins>; + pinctrl-names = "default"; +};
Signature · 1 line
2.9.3
Kevin Hilman
maintainerv5 cover Add Meson 8b / GXBB support to the IR driver
In reply to Martin BlumenstinglQuoted 14 lines · Martin Blumenstingl
Newer Amlogic platforms (Meson 8b and GXBB) use a slightly different register layout for their Infrared Remoete Controller. The decoder mode is now configured in another register. Without the changes to the meson-ir driver we are simply getting incorrect "durations" reported from the hardware (because the hardware is not in time measurement aka software decode mode).
This problem was also noticed by some people trying to use this on an ODROID-C1 and ODROID-C2 - the workaround there (probably because the datasheets were not publicy available yet at that time) was to switch to
ir_raw_event_store_edge(which leaves it up to the kernel to measure the duration of a pulse). See [0] and [1] for the corresponding patches.
Quoted 5 lines
Changes in v5:
- changed pin function and group names toremote_input_aoso they match with the datasheetTested-by Neil Armstrong <[email protected]>
Thanks for the respin. I'll take the driver and DT/bindings through the arm-soc tree and Linus has taken the pinctrl patch.
Kevin
Martin Blumenstingl
reviewerv5 cover Add Meson 8b / GXBB support to the IR driver
In reply to Martin BlumenstinglNewer Amlogic platforms (Meson 8b and GXBB) use a slightly different register layout for their Infrared Remoete Controller. The decoder mode is now configured in another register. Without the changes to the meson-ir driver we are simply getting incorrect "durations" reported from the hardware (because the hardware is not in time measurement aka software decode mode).
This problem was also noticed by some people trying to use this on an ODROID-C1 and ODROID-C2 - the workaround there (probably because the datasheets were not publicy available yet at that time) was to switch to ir_raw_event_store_edge (which leaves it up to the kernel to measure the duration of a pulse). See [0] and [1] for the corresponding patches.
Changes in v5:
- changed pin function and group names to remote_input_ao so they match with the datasheet
[0] https://github.com/erdoukki/linux-amlogic-1/commit/969b2e2242fb14a13cb651f9a1cf771b599c958b
[1] http://forum.odroid.com/viewtopic.php?f=135&t=20504
Martin Blumenstingl (3):
pinctrl: amlogic: gxbb: add the IR remote input pin
ARM64: dts: amlogic: add the input pin for the IR remote
ARM64: dts: meson-gxbb: Enable the the IR decoder on supported boards
Neil Armstrong (3):
dt-bindings: media: meson-ir: Add Meson8b and GXBB compatible strings
media: rc: meson-ir: Add support for newer versions of the IR decoder
ARM64: dts: meson-gxbb: Add Infrared Remote Controller decoder
.../devicetree/bindings/media/meson-ir.txt | 5 +++- .../arm64/boot/dts/amlogic/meson-gxbb-odroidc2.dts | 6 +++++ arch/arm64/boot/dts/amlogic/meson-gxbb-p20x.dtsi | 6 +++++ .../boot/dts/amlogic/meson-gxbb-vega-s95.dtsi | 6 +++++ arch/arm64/boot/dts/amlogic/meson-gxbb.dtsi | 14 +++++++++++ drivers/media/rc/meson-ir.c | 29 ++++++++++++++++++---- drivers/pinctrl/meson/pinctrl-meson-gxbb.c | 8 ++++++ 7 files changed, 68 insertions(+), 6 deletions(-)
Signature · 1 line
2.9.3