AnsweredAssumed Answered

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

Question asked by Dan Rittersdorf on May 18, 2020
Latest reply on May 18, 2020 by igorpadykov

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";
};

Outcomes