Linux device tree for the SAI device used as a UART (bluetooth)

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Linux device tree for the SAI device used as a UART (bluetooth)

1,918 Views
-dan_l
Contributor I

I have a custom i.mx7d target with a wl1837mod wifi/bluetooth module connected to sai12, muxed (ALT2) to uart4.

I'm running a linux 4.9 buildroot kernel

My device tree has defined the pinmux for uart4 to map the sai2 pins.   The wifi radio (driven by as SDHC module) is working well, so power to the wl1837mod, sdkc1, and the wifi enable management are correct.

However hciattach is unable to communciate with the bluetooth radio.   I'm not sure how to debug it from here.

My concern is that the power is not being enabled for the sai module.   It is disabled by default in the imx7d device tree.

Question is, how should I define the sai2 device tree for use as a uart?    The sai2 audio node would make no sense.

This is a place where device tree content is a bit of a dark art.

Is there a definition somewhere of how to configure an sai device for use as a uart (alt2 mode)?

The SAI device tree documentation doesn't address this variant, and all the wl1837mod docs I can find describe the use of the SDHC interface, which I can't use, as the sdhc modules are in use.   
As if nobody would ever have a conflict with the sdhc device.

Relevant device tree nodes:

pinctrl_uart4: uart4grp {
   fsl,pins = <
      /* 100K PU | Pull Enabled | Hysteresis Enabled | Fast Slew Rate | DSE X4 */
      MX7D_PAD_SAI2_TX_SYNC__UART4_DCE_RX 0x79 
      MX7D_PAD_SAI2_TX_BCLK__UART4_DCE_TX 0x79
      MX7D_PAD_SAI2_RX_DATA__UART4_DCE_CTS 0x79
      MX7D_PAD_SAI2_TX_DATA__UART4_DCE_RTS 0x79
   >;
};

pinctrl_usdhc1: usdhc1grp {
   fsl,pins = <
      MX7D_PAD_SD1_CLK__SD1_CLK 0x0a
      MX7D_PAD_SD1_CMD__SD1_CMD 0x5a   
      MX7D_PAD_SD1_DATA0__SD1_DATA0 0x5a
      MX7D_PAD_SD1_DATA1__SD1_DATA1 0x5a
      MX7D_PAD_SD1_DATA2__SD1_DATA2 0x5a
      MX7D_PAD_SD1_DATA3__SD1_DATA3 0x5a
      MX7D_PAD_SD1_CD_B__GPIO5_IO0 0x5a /* WL IRQ */
      MX7D_PAD_SD1_RESET_B__GPIO5_IO2 0x5a /* BT EN */
      MX7D_PAD_SD1_WP__GPIO5_IO1 0x5a /* WL EN */
   >;
};

...

reg_wlan: regulator@5 {
   compatible = "regulator-fixed";
   regulator-min-microvolt = <1800000>;
   regulator-max-microvolt = <1800000>;
   regulator-name = "reg_wlan";
   startup-delay-us = <70000>;
   gpio = <&gpio5 1 GPIO_ACTIVE_HIGH>;
   enable-active-high;
};

...

/ {
   usdhc1_pwrseq: usdhc1_pwrseq {
      compatible = "mmc-pwrseq-simple";
      clocks = <&clks IMX7D_CLKO2_ROOT_DIV>;
      clock-names = "ext_clock";
   };
};

...

&usdhc1 {
   pinctrl-names = "default";
   pinctrl-0 = <&pinctrl_usdhc1>;
   keep-power-in-suspend;
   enable-sdio-wakeup;
   bus-width = <4>;
   no-1-8-v;
   wifi-host;
   ti,non-removable;
   ti,needs-special-hs-handling;
   vmmc-supply = <&reg_wlan>;
   mmc-pwrseq = <&usdhc1_pwrseq>;
   status = "okay";

   max-frequency = <10000000>;
   #address-cells = <1>;
   #size-cells = <0>;

   wlcore: wlcore@0 {
      compatible = "ti,wl1837";
      reg = <2>;
      interrupt-parent = <&gpio5>;
      interrupts = <0 IRQ_TYPE_LEVEL_HIGH>;
   };
};

...

/* ************************************************************************* */
/* bluetooth: tell uart4 to use rts/cts */
/* ************************************************************************* */
&uart4 {
   pinctrl-names = "default";
   pinctrl-0 = <&pinctrl_uart4>;
   assigned-clocks = <&clks IMX7D_UART4_ROOT_SRC>;
   assigned-clock-parents = <&clks IMX7D_PLL_SYS_MAIN_240M_CLK>;
   fsl,uart-has-rtscts;
   status = "okay";
};

...

/delete-node/ &sai2;

&sai2 {
   /* WHAT ELSE? */
   status = "okay";
};

Labels (4)
0 Kudos
1 Reply

1,803 Views
igorpadykov
NXP Employee
NXP Employee

Hi Dan

>My concern is that the power is not being enabled for the sai module.  

>It is disabled by default in the imx7d device tree.

>Question is, how should I define the sai2 device tree for use as a uart?   

>The sai2 audio node would make no sense.

when sai pins are configured as uarts, no need to pay attention to sai.

One can verify that uart is enabed in dts and check Table 102. i.MX 7Dual 19 x 19 mm

functional contact assignments column "Power Group"

i.MX 7Dual Family of Applications Processors Datasheet

For sai multiplexed as a uart one can look at example pinctrl_uart5: uart5grp:
MX7D_PAD_SAI1_RX_DATA__UART5_DCE_RX
https://source.codeaurora.org/external/imx/linux-imx/tree/arch/arm/boot/dts/imx7d-sdb.dts?h=imx_5.4....

imx7d-sdb.dts\dts\boot\arm\arch - linux-imx - i.MX Linux kernel 

Also may be helpful help AN5125 Introduction to Device Trees

https://www.nxp.com/docs/en/application-note/AN5125.pdf 

for hciattach one can look at murata linux wifi/bt documentation:

wireless.murata.com/eng/products/rf-modules-1/wi-fi-bluetooth-for-freescale-i-mx.html

Best regards
igor
-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

0 Kudos