I would like to pass linux,rs485-enabled-at-boot-time;
flag/parameter to serial port driver configuration for sc16is752
device defined by this device tree overlay (unmodified file from Raspbian):
/dts-v1/;
/plugin/;
/ {
compatible = "brcm,bcm2835";
fragment@0 {
target = <&gpio>;
__overlay__ {
spi1_pins: spi1_pins {
brcm,pins = <19 20 21>;
brcm,function = <3>; /* alt4 */
};
spi1_cs_pins: spi1_cs_pins {
brcm,pins = <18>;
brcm,function = <1>; /* output */
};
};
};
fragment@1 {
target = <&spi1>;
frag1: __overlay__ {
#address-cells = <1>;
#size-cells = <0>;
pinctrl-names = "default";
pinctrl-0 = <&spi1_pins &spi1_cs_pins>;
cs-gpios = <&gpio 18 1>;
status = "okay";
sc16is752: sc16is752@0 {
compatible = "nxp,sc16is752";
reg = <0>; /* CE0 */
clocks = <&sc16is752_clk>;
interrupt-parent = <&gpio>;
interrupts = <24 2>; /* IRQ_TYPE_EDGE_FALLING */
gpio-controller;
gpio-cells = <2>;
spi-max-frequency = <4000000>;
sc16is752_clk: sc16is752_clk {
compatible = "fixed-clock";
#clock-cells = <0>;
clock-frequency = <14745600>;
};
};
};
};
fragment@2 {
target = <&aux>;
__overlay__ {
status = "okay";
};
};
__overrides__ {
int_pin = <&sc16is752>,"interrupts:0";
};
};
SC16IS752 is a chip with few GPIO pins and two UART interfaces with hardware RS485 support, and Linux driver for SC16IS752 can enable it:
https://github.com/raspberrypi/linux/blob/04c8e47067d4873c584395e5cb260b4f170a99ea/drivers/tty/serial/sc16is7xx.c#L729 (see line 729).
Device tree bindings for SC16IS752 have no such parameter, so I guess I can't just add linux,rs485-enabled-at-boot-time;
inside sc16is752: sc16is752@0
node.
How can I pass that?
Edit:
I have some progress (thanks @Philippos).
I copied original sc16is752-spi1 overlay source from RPi kernel sources (it was somewhere in linux/arch/arm/boot/dts/overlays/).
I have added linux,rs485-enabled-at-boot-time;
to frag1 like this:
(...)
frag1: __overlay__ {
#address-cells = <1>;
#size-cells = <0>;
pinctrl-names = "default";
pinctrl-0 = <&spi1_pins &spi1_cs_pins>;
cs-gpios = <&gpio 18 1>;
status = "okay";
linux,rs485-enabled-at-boot-time; /* HERE */
(...)
I compiled it like this:
dtc -O dtb -o sc16is752-ses.dtbo -b 0 -@ sc16is752-spi1-overlay-edited.dts
I copied output file to /boot/overlays and I put this line dtoverlay=sc16is752-ses,int_pin=24
instead of dtoverlay=sc16is752-spi1,int_pin=24
(original overlay from Raspbian) in /boot/config.txt.
After reboot I checked sudo vcdbg log msg
to see if my overlay was loaded:
017319.445: brfs: File read: 1810 bytes
017327.250: brfs: File read: /mfs/sd/overlays/sc16is752-ses.dtbo
017346.010: Loaded overlay 'sc16is752-ses'
017346.065: dtparam: int_pin=24
019273.102: Device tree loaded to 0x2eff9400 (size 0x6b27)
I noticed that:
- my crystal clock change worked (my baud rates were messed up and now it is fine), but I see no RTS signal on logic analyzer)
- RTS line is LOW (it was HIGH with original overlay), but it does not change when I'm sending data
Yesterday I have tried to enable this feature in C++ by changing port flags and it worked, so my hardware is OK.
frag1
? – Philippos Sep 11 '19 at 06:23