How to port OAK8x module to Jetson Nano

I want to use OAK8x module on the 40-pin header of Jetson Nano. The OAK8X module is an 8-port FXO using the SPI/I2S bus architecture.

As far as I know , I need to modify the DAHDI dirver. In the pidma.c file, how do I modify the start_i2s_tx(), setup_i2s(), stop_i2s() functions, and which I2S registers do I need to set for Jetson Nano.

oak8x/software/drivers/dahdi/oak8x/pidma.c
oak8x/software/drivers/dahdi/oak8x/pitdm.c

OAK8X module specifications

Manual of install OAK8X module

oak8x driver

Hi will_lin,

I had a look at DAHDI drivers you referenced. In the current shape, these drivers seem to be tightly coupled with Rasperry Pi HW. However it looks like you would need following operations to get OAK8X module working.

  1. SPI based control interface. This I would assume is required to get OAK8X module up and running. I did not find SPI device details in " Manual of install OAK8X module". I am thinking the details are hardcoded in the driver itself.
  2. The I2S configuration from SoC side. I guess you are also expecting to configure FXS/FXO lines on OAK8x side.

The driver architecture is bit different on Jetson [0]. There are separate drivers for DMA and I2S unlike the references you have pointed above. But before proceeding I would like to understand bit more about your requirement and have couple of questions.

  1. Is your application uses (or can use) ALSA/ASoC? or you are looking for a standalone driver module?
  2. What are the I2S configuration (like sample rate, channels, bits per sample) you would need? Do you need static I2S configurations or it depends on the application at runtime?

Thanks,
Sameer.

[0] https://docs.nvidia.com/jetson/l4t/index.html#page/Tegra%20Linux%20Driver%20Package%20Development%20Guide/asoc_driver.19.2.html#wwpID0E0FGB0HA

Hi Sameer:

Thanks for your reply.

  1. Asterisk is the application layer, Asterisk uses DAHDI to read/write SPI/PCM data. The official DAHDI only supports PCI interface, but what we need is SPI/PCM interface.
    The oak8x source code use the official Dahdi-2.11.1 and add pitdm.c pidma.c to support SPI/PCM interface 8 port Si3050, so we want to add nano_tdm.c nano_dma.c for Jetson Nano to support 8 port Si3050.
    If ALSA/ASoC can do it, we can try too. Our goal is how to read/write SPI/PCM data from DAHDI driver on Jetson Nano.
  2. 8000 sample rate, 8 channels, 16 bits

Actually, I can read/write the GPIO/SPI data by DAHDI on Jetson Nano now, but PCM not yet, I think the key point is how to read/write PCM data by DAHDI on Jetson Nano PCM DTX/DRX pin.

This is Si3050 Spec, page 48 is the multiple port Si3050 schematic.

The pitdm.c wctdm_init_proslic( ) is the Si3050 initialization.

Hi will_lin,

I had a look at Si3050 Spec. It appears to me that Jetson Nano I2S interface needs to be configured in FSYNC master mode to exchange PCM data (corresponding lines PCLK, FSYNC, DTX and DRX on Si3050).

Currently Jetson Nano uses ASoC drivers to setup DMA and I2S interfaces that would be required to read/write PCM data. I think this would be the simplest option to try first. For understanding you can refer to the “Audio Setup and Development” section in the BSP doc and you can specifically refer below for a quick glance.

  • ADMAIF in Platform driver section (PCM driver interface)
    source code: kernel/nvidia/sound/soc/tegra-alt/tegra210_admaif_alt.c
  • I2S in Codec driver section (Applying necessary configurations for I2S)
    source code: kernel/nvidia/sound/soc/tegra-alt/tegra210_i2s_alt.c
  • I2S mode setting
  • Usage and examples

The Jetson Nano I2S interface on 40-pin header by default is connected dummy codec endpoint. Generally depending on the audio cards that are connected to 40-pin header, specific ASoC codec driver (if available) can be plugged in. In your case I assume there is no ASoC codec driver available for Si3050. But that should not stop you from using ASoC framework. Let Jetson Nano I2S drive dummy codec endpoint. What you would need to ensure is, Si3050 is initialized properly and ready for use.

Check if following steps/commands work for you on the Jetson Nano.

  1. Update DT with following
    diff --git a/tegra210-porg-p3448-common.dtsi b/tegra210-porg-p3448-common.dtsi
    index 2a7d844…689437a 100644
    — a/tegra210-porg-p3448-common.dtsi
    +++ b/tegra210-porg-p3448-common.dtsi
    @@ -414,7 +414,8 @@
    codec-dai = <&spdif_dit0>;
    cpu-dai-name = “I2S4”;
    codec-dai-name = “dit-hifi”;
    - format = “i2s”;
    + format = “dsp_a”;
    + fsync-width = <0>;
    bitclock-slave;
    frame-slave;
    bitclock-noninversion;

  2. Ensure if pinmux for I2S on 40-pin header is configured properly

  3. amixer -c tegrasndt210ref cset name=“I2S4 Mux” “ADMAIF1” (for sending data to Si3050)

  4. amixer -c tegrasndt210ref cset name=“ADMAIF1 Mux” “I2S4” (for receiving data from Si3050)

  5. Initialize Si3050

  6. Data send/receive commands
    aplay -D hw:tegrasndt210ref,0 <send.wav>
    arecord -Dhw:tegrasndt210ref,0 -c 8 -r 8000 -f S16_LE -d 15 <receive.wav>

In case you face any difficulties please refer to “Troubleshooting” section or reach out to us.

Thanks,
Sameer.

Hi Sameer:

Yes, this way is no problem, we have already implemented it before. Si3050 can be initialized correctly and work normally.

But I don’t know how to integrate it to DAHDI? Do you have any suggestions?

Thanks,
Will

Hi Will,

If I understand this correctly you have following driver files for configuration and data transfers.
oak8x/software/drivers/dahdi/oak8x/pidma.c
oak8x/software/drivers/dahdi/oak8x/pitdm.c
And apart from this there are other DAHDI drivers which support the HW you have. So you have Asterisk application layer which relies on the DAHDI drivers for telephonic application.

  1. I am not sure if Asterisk application can make use of ASoC. May be Asterisk support portal should be able to comment if some one has tried something similar (I think it will be good to check this). If it is possible, then your DAHDI driver can just be another linux driver to configure your HW and you can make use of ASoC to configure Jetson Nano and control data.

  2. If this is not possible, then it may not leave much choice other than combining all functionalities in one driver, like what you have for RPi and for this you have to refer to multiple drivers on Jetson Nano. This may be the last option when [1] does not work.

Thanks,
Sameer.