1

I'm attempted to use a pwm output pin as a IR transmitter using a RAMIPS SoC and the PWM IR TX kernel module. I'm running linux 4.14.37 and have added the following entry to the dts file:

   pwm_ir_tx1: pwm-ir-transmitter1 {
    compatible = "pwm-ir-tx";
    pwms = <&pwm 1 100>;
  };

I'm loading the rc-core and pwm-ir-tx kernel modules:

lsmod | grep pwm
pwm_ir_tx               2032  0 
pwm_mediatek_ramips     1744  1 
rc_core                19348  2 pwm_ir_tx

When the pwm-ir-tx module loads, the kernel logs:

[ 3754.108259] rc rc0: PWM IR Transmitter as /devices/platform/pwm-ir-transmitter1/rc/rc0

The sysfs nodes appear to be loaded correctly:

ls -la /sys/class/rc/
drwxr-xr-x    2 root     root             0 May 29 00:18 .
drwxr-xr-x   23 root     root             0 Jan  1  1970 ..
lrwxrwxrwx    1 root     root             0 May 29 01:16 rc0 -> ../../devices/platform/pwm-ir-transmitter1/rc/rc0

But there is no userspace (chardev) lirc device listed in /dev so I'm not sure how I'm supposed to interact with the device. Ideally I'd like to use the Remote Controller API but this requires a chardev to be present in /dev.

ls /dev
autofs              mtd2ro              network_throughput
console             mtd3                null
cpu_dma_latency     mtd3ro              port
full                mtd4                ptmx
gpiochip0           mtd4ro              pts
gpiochip1           mtd5                random
gpiochip2           mtd5ro              shm
gpiochip3           mtd6                tty
i2c-0               mtd6ro              ttyS0
kmsg                mtdblock0           ttyS1
log                 mtdblock1           ttyS2
memory_bandwidth    mtdblock2           urandom
mtd0                mtdblock3           watchdog
mtd0ro              mtdblock4           watchdog0
mtd1                mtdblock5           zero
mtd1ro              mtdblock6
mtd2                network_latency

I've tried loading the lirc_dev module before and after the pwm-ir-tx module, but nothing appears in /dev still, the following output appears when I load the lirc_dev module:

[ 4775.367966] lirc_dev: IR Remote Control driver registered, major 251

But still no lirc userspace device in /dev... I'm thinking the lirc_dev module is required since it provides the lirc userspace api but there doesn't appear to be any connection between it and the pwm-ir-tx module, and it's not creating any lirc chardevs in /dev.

2 Answers2

1

The pwm_ir_tx module seems to be more or less a piggy-back to the pwm driver. And the pwm driver seems to be available at /sys/class/pwm/. See https://www.kernel.org/doc/Documentation/pwm.txt.

BTW, not having a lirc link in rc0/ is not uncommon - not all drivers implements this.

leamas
  • 151
  • 1
  • 6
  • My device has 4 pwm's available. I'm using one for the pwm-ir-tx (#1) and i can export the other 3 into sysfs. Trying to export the one used by the pwm-ir-tx via the pwm sysfs gives me `write error: Resource busy`. So I can't access the pwm-ir-tx 'device' via the pwm sysfs – Francois Herbert Jun 15 '18 at 18:33
1

After reading some of rc source files in the kernel, it became obvious the ir-lirc-codec module was also required. Basically, the pwm-ir-tx driver is defined as a type of RC_DRIVER_IR_RAW_TX. When the rc-core module registers a driver with a type of RC_DRIVER_IR_RAW or RC_DRIVER_IR_RAW_TX it calls the ir_raw_event_prepare function which in turn tries to load the ir-lirc-codec module. Once this module was available the following kernel logs appear:

[   10.004460] lirc_dev: IR Remote Control driver registered, major 251
[   10.131011] IR LIRC bridge handler initialized
[   10.471561] rc rc0: PWM IR Transmitter as /devices/platform/pwm-ir-transmitter1/rc/rc0
[   10.487456] rc rc0: lirc_dev: driver ir-lirc-codec (pwm-ir-tx) registered at minor = 0

And in /dev there is a lirc chardev device available:

 ls /dev/li*
/dev/lirc0