IR transmit with PWM

I’d like to use the IR remote functionality of the S905Y2. The S905Y2 quick reference says that there’s both IR_REMOTE_IN and IR_REMOTE_OUT signals that are mapped to gpio pins, and the datasheet (section 12.5) has a lot of information about receiving IR signals, though none about transmitting. But maybe the PWM functionality could be used for that?

I see the linux kernel has drivers for these things too. I can modprobe meson-ir and pwm-meson successfully, but no device files appear. Trying to modprobe meson-ir-tx gives an error, though (“No such device”).

Do I need a devicetree overlay to use these? Is it even possible on the Zero? Any tips would be appreciated.

(I know there are no IR sensors or leds on the board, I just want to hook them up to gpio pins)

I don’t think you need PWM per this post and that should give you some hint about how to implement the dt overlay. However, only IR out pin is exposed on the 40-pin header so that might not suit what you were trying to do in the first place.

Actually I really just need transmit for now.

I mostly figured out how to write a devicetree overlay, but I’m missing the base address. The datasheet pdf doesn’t even mention ir transmit, only receive (at 0xff808000). What address is the transmit functionality at?

The documentation from the person who wrote the meson-ir-tx module is here: https://github.com/torvalds/linux/blob/master/Documentation/devicetree/bindings/media/amlogic%2Cmeson-ir-tx.yaml and it has an example with address 0xff80014c, but it looks like that overlaps with ao-secure@140 in the radxa zero dts so that probably isn’t right for this soc.

(Also, are the other things in that example correct for this soc? The interrupt 198 and clocks?)

You should set this device’s status to okay in overlay. Then you should see a new ir device.

That driver (meson-ir) is for receive. I want to transmit, so I want to use meson-ir-tx. There are no devices in any dts files in the kernel tree that are compatible with it, strangely enough. And I haven’t seen any evidence that the S905Y2 actually has a dedicated IR transmit device.

———

So now I’m trying to use PWM instead. I’m using this overlay to turn it on and add a pwm-based IR device:

/dts-v1/;
/plugin/;
/ { 
        compatible = "radxa,zero", "amlogic,g12a";

        fragment@1 {
                target = <&pwm_AO_ab>;
                __overlay__ {
                        status = "okay";
                        pinctrl-0 = <&pwm_ao_a_pins>;
                        pinctrl-names = "default";
                        clocks = <&xtal>;
                        clock-names = "clkin3";
                };
        };

        fragment@2 {
                target-path = "/";
                __overlay__ {
                        // GPIOAO_11 / pin 40
                        irtx0 {
                                compatible = "pwm-ir-tx";
                                pwms = <&pwm_AO_ab 0 26316 0>;
                        };
                };
        };
};

This shows up in boot now:

[    8.059321] rc rc0: PWM IR Transmitter as /devices/platform/irtx0/rc/rc0
[    8.075367] rc rc0: lirc_dev: driver pwm-ir-tx registered at minor = 0, no receiver, raw IR transmitter

I can use ir-ctl to send scancodes.

It looks like the output should appear on pin 40, but when I hook it up to my IR led, it’s always on. And if I measure the pin with a multimeter it looks like it’s stuck on high. Am I doing this right? Is the output supposed to be inverted? Any other tips for using PWM output?

Alright, I got IR transmit working on PWM C (pin 18). I still have no idea why PWMAO_A didn’t work, and it would be good to figure that out.

It would also be good to get an answer to whether there is a dedicated IR transmit device (compatible with meson-ir-tx) on the S905Y2 or not.