Code: Select all
// Overlay for the SC16IS752 I2C-connected UART
/dts-v1/;
/plugin/;
/ {
compatible = "brcm,bcm2708";
[email protected] {
target = <&i2c_arm>;
__overlay__ {
#address-cells = <1>;
#size-cells = <0>;
status = "okay";
sc16is752: [email protected] {
compatible = "nxp,sc16is752";
reg = <0x51>;
clocks = <&sc16is752_clock>;
interrupt-parent = <&gpio>;
interrupts = <255 2>; /* high-to-low edge triggered */
gpio-controller;
#gpio-cells = <2>;
};
};
};
[email protected] {
target = <&clocks>;
__overlay__ {
#address-cells = <1>;
#size-cells = <0>;
status = "okay";
sc16is752_clock: [email protected] {
compatible = "fixed-clock";
reg = <10>;
#clock-cells = <0>;
clock-output-name = "sc16is752";
clock-frequency = <0>;
};
};
};
[email protected] {
target = <&gpio>;
__overlay__ {
sc16is752_pins: sc16is752_pins {
brcm,pins = <255>;
brcm,function = <0>; /* in */
};
};
};
__overrides__ {
clkrate = <&sc16is752_clock>,"clock-frequency:0";
irqpin = <&sc16is752>,"interrupts:0",
<&sc16is752_pins>,"brcm,pins:0";
};
};
Code: Select all
dtc [email protected] -I dts -O dtb -o sc16is752-i2c-overlay.dtb sc16is752-i2c-overlay.dts
Code: Select all
dtoverlay=sc16is752-i2c,clkrate=48000000,irqpin=21
Code: Select all
GNU nano 2.4.2 File: sc16is752-overlay.dts
// Definitions for SC16IS752 UART
/dts-v1/;
/plugin/;
/ {
compatible = "brcm,bcm2708";
[email protected] {
target = <&i2c1>;
__overlay__ {
#address-cells = <1>;
#size-cells = <0>;
status = "okay";
sc16is752: [email protected] {
compatible = "nxp,sc16is752";
reg = <0x4D>;
clocks = <&klok>;
interrupt-parent = <&gpio>;
interrupts = <23 0x2>; /* falling edge */
klok: klok {
compatible = "fixed-clock";
#clock-cells = <0>;
clock-frequency = <14745600>;
};
};
};
};
};
Was your module compiled correct? I mean without warnings. If so you should load it with dependencies (read about depmod, modprobe commands).Is it needed to load the model sc16is7xx.ko and/or configure the device tree (one, other or both, we believe both)?.
Code: Select all
KDIR = /lib/modules/$(shell uname -r)/build
PWD = $(shell pwd)
obj-m:= sc16is7xx.o
CFLAGS_sc16is7xx.o := -DCONFIG_SERIAL_SC16IS7XX_I2C
default:
$(MAKE) -C $(KDIR) M=$(PWD) modules
No, the module works good without any changes. I created new device tree overlay sc16is750-tom-i2c-overlay.dts, compiled it and add to /boot/overlays/. I used code which was posted by tomd (but with little changes).Is it needed to configure/adapt the sc16is7xx.c somehow? Specially dealing with the access to /dev/ttySC0 and /dev/ttySC1. This is really our problem: we are not able to find these devices in our system. Is it needed to consider the sc16is7xx.c code to generate the .dts file for the device tree?. Do we need to change anything in .dts file?
Code: Select all
/dts-v1/;
/plugin/;
/ {
compatible = "brcm,bcm2709";
[email protected] {
target = <&i2c1>;
__overlay__ {
#address-cells = <1>;
#size-cells = <0>;
status = "okay";
sc16is750:
[email protected] {
compatible = "nxp,sc16is750";
reg = <0x4D>;
clocks = <&klok>;//<&clk_uart0>;
interrupt-parent = <&gpio>;
interrupts = <24 0x2>; /* falling edge */
klok:
klok {
compatible = "fixed-clock";
#clock-cells = <0>;
clock-frequency = <14745600>;
};
};
};
};
};
Code: Select all
dtoverlay=sc16is750-tom-i2c
dtparam=i2c1=on
dtparam=i2c1_baudrate=400000
Code: Select all
0 1 2 3 4 5 6 7 8 9 a b c d e f
00: -- -- -- -- -- -- -- -- -- -- -- -- --
10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
40: -- -- -- -- -- -- -- -- -- -- -- -- -- UU -- --
50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
70: -- -- -- -- -- -- -- --
Did you update kernel / firmware to 4.4.y?jaf wrote:[email protected]:~$ sudo vcdbg log msg
012860.706: dtdebug: Failed to open overlay file 'overlays/sc16is752-tom-i2c.dtbo'
012860.721: Failed to load overlay 'sc16is752-tom-i2c'
012860.751: dtparam: i2c1=on
I don't understand why puts ...dtbo, because I put into the overlays directory "overlays/sc16is752-tom-i2c.dtb"
I've enabled the sc16is7xx driver editing my config.txt as follows:The biggest issue with using this chip with Raspberry Pi is that the driver that is packaged with the latest Pi kernel is broken, and seems to allow sending but not receiving data. This has been updated in the mainline Linux kernel, but it looks like the Pi kernel isn't going to get updated any time soon.
What reasoning are you giving for it being invalid? The obvious one I see is that you appear to have allocated rs485conf on the stack and not initialised it. Setting/clearing individual bits after that point is likely to leave a mess in the rest of the structure.percramer wrote: ↑Wed Jul 26, 2017 7:11 pmDid anybody get any further with this? We have got the uart part working for an SC16IS762. Both uarts show and transmit data. But we want to use them in RS485 mode also and we can't get that working. If we write a little program to test it and use something like (which is invalid, i know, it is just to test the driver) :
struct serial_rs485 rs485conf;
rs485conf.flags |= SER_RS485_ENABLED;
//rs485conf.flags |= SER_RS485_RTS_ON_SEND;
//rs485conf.flags &= ~(SER_RS485_RTS_ON_SEND);
if (ioctl (fd, TIOCSRS485, &rs485conf) < 0) {
/* Error handling. See errno. */
}
the driver does respond. It tells us :
unsupported RTS signalling on_send:%d after_send:%d - exactly one of RS485 RTS flags should be set
Code: Select all
struct serial_rs485 rs485conf = {0};
Code: Select all
rs485conf.flags = SER_RS485_ENABLED; //Note =, not |=
rs485conf.delay_rts_after_send = 0;
rs485conf.delay_rts_before_send = 0
Code: Select all
bool rts_during_rx, rts_during_tx;
rts_during_rx = rs485->flags & SER_RS485_RTS_AFTER_SEND;
rts_during_tx = rs485->flags & SER_RS485_RTS_ON_SEND;
if (rts_during_rx == rts_during_tx)
dev_err(port->dev,
"unsupported RTS signalling on_send:%d after_send:%d - exactly one of RS485 RTS flags should be set\n",
rts_during_tx, rts_during_rx);
Code: Select all
rts_during_rx = !!(rs485->flags & SER_RS485_RTS_AFTER_SEND);
rts_during_tx = !!(rs485->flags & SER_RS485_RTS_ON_SEND);
Code: Select all
linux,rs485-enabled-at-boot-time;
rs485-rts-delay = <0 0>; // in milliseconds
Code: Select all
host:~/Pi/linux$ ./scripts/get_maintainer.pl drivers/tty/serial/sc16is7xx.c
Greg Kroah-Hartman <[email protected]> (maintainer:SERIAL DRIVERS)
Jiri Slaby <[email protected]> (supporter:TTY LAYER)
[email protected] (open list:SERIAL DRIVERS)
[email protected] (open list)