Marko Buršič Posted April 25, 2020 Share Posted April 25, 2020 Hi, I am doing some overlay for fbtft LCD driver - SSD1322. I did compile an add my patch, now I would like to load the LCD driver with DT overlay. This is what I have done: /dts-v1/; /plugin/; / { compatible = "rockchip,rk3399"; fragment@0 { target = <&spi1>; __overlay__ { status = "okay"; }; }; fragment@1 { target = <&spi1>; __overlay__ { /* needed to avoid dtc warning */ #address-cells = <1>; #size-cells = <0>; status = "okay"; mytft@0{ compatible = "solomon,ssd1322"; reg = <0>; spi-max-frequency = <1000000>; buswidth = <8>; rotate = <0>; bgr = <0>; fps = <20>; reset-gpios = <0>, <1 21 1 0xae>; dc-gpios = <0>, <1 21 1 0xae>; debug = <0>; status = "okay"; }; }; }; }; Now the problem is, that I haven't found any information on how those GPIOs are defined. I took pieces of code here and there, the gpio declaration comes from user @martinayotte cs-gpio = <0>, <1 21 1 0xae>; // csgpio = <&gpio1 21 1 0xae>; // csgpio = <&pinctrl/gpio1@ff730000 21 1 0xae>; He uses several ways to declare them, but what really means <0>, <1 21 1 0xae> ? How can I compute this kind of coding for arbitrary RK3399 Gpio? 0001-Signed-off-by-root-marko.bursic73-gmail.com.patch EDIT: I have found this https://forum.radxa.com/t/how-to-control-the-gpio/148/32 So my assumption is to control GPIO4_D5 it should be dc-gpios = <&gpio4 29 1 0xae>; Since D=3, then 3*8+5=29. Still don't know what 1 and 0xae means, but obviously is wrong. The dmesg reveals invalid GPIO . Call trace: [ 81.742210] gpio_to_desc+0xa8/0xf0 [ 81.742222] write_vmem+0x38/0x190 [ 81.742232] fbtft_update_display+0xd0/0x218 [ 81.742241] fbtft_deferred_io+0xc0/0xd8 [ 81.742250] fb_deferred_io_work+0xdc/0x158 [ 81.742261] process_one_work+0x1e0/0x338 [ 81.742270] worker_thread+0x40/0x440 [ 81.742282] kthread+0x120/0x128 [ 81.742294] ret_from_fork+0x10/0x18 [ 81.742301] ---[ end trace 8a7abacfafe1f15a ]--- [ 81.945879] ------------[ cut here ]------------ [ 81.945890] invalid GPIO -257459296 [ 81.945950] WARNING: CPU: 4 PID: 507 at drivers/gpio/gpiolib.c:126 gpio_to_desc+0xa8/0xf0 Link to comment Share on other sites More sharing options...
verplant23 Posted May 14, 2020 Share Posted May 14, 2020 Hello Marko Buršič there are some explaination on the page u linked: GPIO 4 D 5 = 157 4*32 + 3*8 + 5 = 157 i don´t know what "0xae" stands for but it could be something like pull up/down /activ low/high so wenn you see something like csgpio = <&gpio1 21 1 0xae> on rk3399 it would call translated to GPIO Number 1*32 + 2*8 + 5 = 53 32 + 16 + 5 = 53 32 + 21 = 53 GPIO 1 C 5 = 53 but on the 40 Pin Header i can't find a pin number corrospondending to GPIO number 53. so maybe you would like to call ?! Pin# GPIO Function1 GPIO number 24 GP1B2 SPI1_CSn 42 you would write something like ( whatever 0xae mean) csgpio = <&gpio1 10 1 0xae>; 1*32 + 1*8 + 2 = 42 32 + 8 + 2 = 42 32 + 10 = 42 GPIO 1 B 2 = 42 but i´m just guessing Link to comment Share on other sites More sharing options...
Recommended Posts