All of lore.kernel.org
 help / color / mirror / Atom feed
* Question about SC16IS752 device tree.
@ 2022-05-09 18:08 Zhou Yanjie
  2022-05-09 18:13 ` Paul Cercueil
  0 siblings, 1 reply; 9+ messages in thread
From: Zhou Yanjie @ 2022-05-09 18:08 UTC (permalink / raw)
  To: jringle, shc_work, Rob Herring, Paul Cercueil, Paul Boddie,
	H. Nikolaus Schaller, Jiaxun Yang, linux-serial, linux-mips,
	Linux Kernel Mailing List

Hi folks,

I encountered a problem when using the SC16IS752 to expand the serial port.
I connected two Bluetooth modules to the two serial ports extended by the
SC16IS752. The device tree is as follows:

&ssi0 {
     status = "okay";

     num-cs = <2>;

     pinctrl-names = "default";
     pinctrl-0 = <&pins_ssi0>;

     sc16is752: expander@0 {
         compatible = "nxp,sc16is752";
         reg = <0>; /* CE0 */

         spi-rx-bus-width = <1>;
         spi-tx-bus-width = <1>;
         spi-max-frequency = <6000000>;

         clocks = <&exclk_sc16is752>;

         interrupt-parent = <&gpb>;
         interrupts = <18 IRQ_TYPE_EDGE_FALLING>;

         gpio-controller;
         #gpio-cells = <2>;

         bluetooth@0 {
             compatible = "brcm,bcm43438-bt";
             max-speed = <1000000>;

             device-wakeup-gpios = <&gpc 26 GPIO_ACTIVE_HIGH>;
             reset-gpios = <&gpb 17 GPIO_ACTIVE_LOW>;
         };

         bluetooth@1 {
             compatible = "brcm,bcm43438-bt";

             device-wakeup-gpios = <&gpc 28 GPIO_ACTIVE_HIGH>;
             reset-gpios = <&gpb 19 GPIO_ACTIVE_LOW>;
         };
     };
};



There are the following error messages after startup:

[    0.548417] serial serial0-0: controller busy
[    0.553572] serial serial0-0: failure adding device. status -EBUSY
[    0.559764] serial serial0: tty port ttySC0 registered
[    0.565545] spi0.0: ttySC1 at I/O 0x1 (irq = 18, base_baud = 3000000) 
is a SC16IS752
[    0.573987] serial serial1-0: controller busy
[    0.578351] serial serial1-0: failure adding device. status -EBUSY
[    0.585003] serial serial1: tty port ttySC1 registered

And only the module connected to the first serial port (ttySC0) can work 
normally.



If I change the device tree to:

&ssi0 {
     status = "okay";

     num-cs = <2>;

     pinctrl-names = "default";
     pinctrl-0 = <&pins_ssi0>;

     sc16is752: expander@0 {
         compatible = "nxp,sc16is752";
         reg = <0>; /* CE0 */

         spi-rx-bus-width = <1>;
         spi-tx-bus-width = <1>;
         spi-max-frequency = <6000000>;

         clocks = <&exclk_sc16is752>;

         interrupt-parent = <&gpb>;
         interrupts = <18 IRQ_TYPE_EDGE_FALLING>;

         gpio-controller;
         #gpio-cells = <2>;

         bluetooth@0 {
             compatible = "brcm,bcm43438-bt";
             max-speed = <1000000>;

             device-wakeup-gpios = <&gpc 26 GPIO_ACTIVE_HIGH>;
             reset-gpios = <&gpb 17 GPIO_ACTIVE_LOW>;
         };
     };
};

Then there will be no error message, and the module connected to the first
serial port (ttySC0) can also work normally.



After tracing, the problem seems to be in "serdev_device_add()" (line 
111) of
"drivers/tty/serdev/core.c":

int serdev_device_add(struct serdev_device *serdev)
{
     struct serdev_controller *ctrl = serdev->ctrl;
     struct device *parent = serdev->dev.parent;
     int err;

     dev_set_name(&serdev->dev, "%s-%d", dev_name(parent), serdev->nr);

     /* Only a single slave device is currently supported. */
     if (ctrl->serdev) {
         dev_err(&serdev->dev, "controller busy\n");
         return -EBUSY;
     }
     ctrl->serdev = serdev;

     err = device_add(&serdev->dev);
     if (err < 0) {
         dev_err(&serdev->dev, "Can't add %s, status %pe\n",
             dev_name(&serdev->dev), ERR_PTR(err));
         goto err_clear_serdev;
     }

     dev_dbg(&serdev->dev, "device %s registered\n", 
dev_name(&serdev->dev));

     return 0;

err_clear_serdev:
     ctrl->serdev = NULL;
     return err;
}
EXPORT_SYMBOL_GPL(serdev_device_add);



Is there any way to correctly describe the device mounted on the second
serial port (ttySC1) in the device tree? Or how do I need to modify the
"drivers/tty/serdev/core.c" to make the SC16IS752 still work properly
with two child nodes mounted?

Thanks and beset regards!

^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2022-05-14 14:53 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-05-09 18:08 Question about SC16IS752 device tree Zhou Yanjie
2022-05-09 18:13 ` Paul Cercueil
2022-05-09 18:41   ` Zhou Yanjie
2022-05-09 20:19     ` H. Nikolaus Schaller
2022-05-10  2:29       ` Zhou Yanjie
2022-05-10 15:31         ` H. Nikolaus Schaller
2022-05-10 17:53           ` Zhou Yanjie
2022-05-12 14:49             ` Rob Herring
2022-05-14 14:52               ` Zhou Yanjie

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.