Last active
December 22, 2023 08:34
-
-
Save pdp7/ab0344e4f0d6348e3ad3a7f834cbd3ca to your computer and use it in GitHub Desktop.
src/arm/BB-LCD-ADAFRUIT-18-SPI1-00A0.dts overlay for Adafruit 1.8" TFT LCD with tinydrm st7735 driver with PWM backlight
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* Copyright (C) 2013 CircuitCo | |
* Copyright (C) 2018 Drew Fustini <drew@beagleboard.org> | |
* | |
* Adafruit 1.8" TFT LCD on SPI1 bus using tinydrm st7735r driver | |
* | |
* LICENSE: | |
* -------- | |
* This program is free software; you can redistribute it and/or modify | |
* it under the terms of the GNU General Public License version 2 as | |
* published by the Free Software Foundation. | |
* | |
* DOCUMENTATION: | |
* -------------- | |
* This file was copied from src/arm/BB-SPIDEV1-00A0.dts and modified | |
* by Drew Fustini based on an exmample from David Lechner. | |
* | |
* This is the Adafruit 1.8" TFT LCD: | |
* https://www.adafruit.com/products/358 | |
* | |
* It should be connected to BeagleBone SPI1 bus: | |
* | |
* P9.12 <--> reset | |
* P9.14 <--> lite (pwm) | |
* P9.15 <--> dc | |
* P9.23 <--> lite (gpio) | |
* P9.28 <--> tft_cs | |
* P9.30 <--> mosi | |
* P9.31 <--> clk | |
* | |
* This overlay will load the mainline tinydrm st7735r driver by David Lechner: | |
* https://github.com/torvalds/linux/blob/master/drivers/gpu/drm/tinydrm/st7735r.c | |
* | |
* Tested with 4.16.0-rc2-bone3 kernel on Debian 9.3 image | |
* | |
* Run libdrm modetest for colorbar test based on instructions from: | |
* https://github.com/notro/tinydrm/wiki/Development#modetest | |
* | |
* modetest -M "st7735r" -c #this will display connector id | |
* modetest -M "st7735r" -s 28:128x160 #connector id and resolution | |
* # you should now see a color bar on the LCD | |
* | |
* Mailing list post with more information: | |
* https://groups.google.com/d/msg/beagleboard/GuMQIP_XCW0/b3lxbx_8AwAJ | |
* | |
* GitHub Gist with testing results: | |
* https://gist.github.com/pdp7/aee5664598059c9b9a9020f107957f80 | |
* | |
* Discussion with notro on how to test tinydrm driver: | |
* https://github.com/notro/tinydrm/issues/1#issuecomment-367279037 | |
*/ | |
#include <dt-bindings/board/am335x-bbw-bbb-base.h> | |
#include <dt-bindings/gpio/gpio.h> | |
#include <dt-bindings/pinctrl/am33xx.h> | |
/dts-v1/; | |
/plugin/; | |
/ { | |
fragment@0 { | |
target-path = "/"; | |
__overlay__ { | |
backlight_gpio: backlight_gpio { | |
compatible = "gpio-backlight"; | |
gpios = <&gpio1 17 GPIO_ACTIVE_HIGH>; | |
// connect lcd lite pin to P9.23 which is gpio1[17] | |
// refer to https://elinux.org/Beagleboard:Cape_Expansion_Headers | |
}; | |
backlight_pwm: backlight_pwm { | |
// P9.14 <--> lite (pwm-backlight EHRPWM1A) | |
pinctrl-names = "default"; | |
pinctrl-0 = <&backlight_pwm_pins>; | |
status = "okay"; | |
compatible = "pwm-backlight"; | |
pwms = <&ehrpwm1 1 500000 0>; | |
brightness-levels = < | |
0 1 2 3 4 5 6 7 8 9 | |
10 11 12 13 14 15 16 17 18 19 | |
20 21 22 23 24 25 26 27 28 29 | |
30 31 32 33 34 35 36 37 38 39 | |
40 41 42 43 44 45 46 47 48 49 | |
50 51 52 53 54 55 56 57 58 59 | |
60 61 62 63 64 65 66 67 68 69 | |
70 71 72 73 74 75 76 77 78 79 | |
80 81 82 83 84 85 86 87 88 89 | |
90 91 92 93 94 95 96 97 98 99 | |
100 | |
>; | |
default-brightness-level = <90>; | |
}; | |
}; | |
}; | |
/* | |
* Free up the pins used by the cape from the pinmux helpers. | |
*/ | |
fragment@1 { | |
target = <&ocp>; | |
__overlay__ { | |
P9_12_pinmux { status = "disabled"; }; /* lcd reset */ | |
P9_14_pinmux { status = "disabled"; }; /* lcd pwm backlight */ | |
P9_15_pinmux { status = "disabled"; }; /* lcd dc */ | |
P9_23_pinmux { status = "disabled"; }; /* lcd gpio backlight */ | |
P9_28_pinmux { status = "disabled"; }; /* spi1_cs0 */ | |
P9_29_pinmux { status = "disabled"; }; /* spi1_d0 */ | |
P9_30_pinmux { status = "disabled"; }; /* spi1_d1 */ | |
P9_31_pinmux { status = "disabled"; }; /* spi1_sclk */ | |
}; | |
}; | |
fragment@2 { | |
target = <&am33xx_pinmux>; | |
__overlay__ { | |
/* default state has all gpios released and mode set to uart1 */ | |
bb_spi1_pins: pinmux_bb_spi1_pins { | |
pinctrl-single,pins = < | |
0x190 0x33 /* mcasp0_aclkx.spi1_sclk, INPUT_PULLUP | MODE3 */ | |
0x194 0x33 /* mcasp0_fsx.spi1_d0, INPUT_PULLUP | MODE3 */ | |
0x198 0x13 /* mcasp0_axr0.spi1_d1, OUTPUT_PULLUP | MODE3 */ | |
0x19c 0x13 /* mcasp0_ahclkr.spi1_cs0, OUTPUT_PULLUP | MODE3 */ | |
// 0x164 0x12 /* eCAP0_in_PWM0_out.spi1_cs1 OUTPUT_PULLUP | MODE2 */ | |
>; | |
}; | |
backlight_pwm_pins: backlight_pwm_pins { | |
pinctrl-single,pins = < AM33XX_IOPAD(0x0848, PIN_OUTPUT_PULLDOWN | INPUT_EN | MUX_MODE6) >; | |
}; /* gpmc_a2.ehrpwm1a */ | |
}; | |
}; | |
fragment@3 { | |
target = <&ehrpwm1>; | |
__overlay__ { | |
pinctrl-names = "default"; | |
pinctrl-0 = <&backlight_pwm_pins>; | |
status = "okay"; | |
}; | |
}; | |
fragment@4 { | |
target = <&spi1>; | |
__overlay__ { | |
#address-cells = <1>; | |
#size-cells = <0>; | |
status = "okay"; | |
pinctrl-names = "default"; | |
pinctrl-0 = <&bb_spi1_pins>; | |
display@0{ | |
status = "okay"; | |
compatible = "jianda,jd-t18003-t01", "sitronix,st7735r"; | |
reg = <0>; | |
spi-max-frequency = <16000000>; | |
dc-gpios = <&gpio1 16 0>; // lcd dc P9.15 gpio1[16] | |
reset-gpios = <&gpio1 28 0>; // lcd reset P9.12 gpio1[28] | |
//backlight = <&backlight_gpio>; // lcd lite P9.23 gpio1[17] | |
backlight = <&backlight_pwm>; // lcd lite P9.14 | |
// refer to https://elinux.org/Beagleboard:Cape_Expansion_Headers | |
// rotation is optional | |
// rotation = <270>; | |
}; | |
}; | |
}; | |
}; |
Author
pdp7
commented
Feb 27, 2018
[ 17.596897] drivers/video/backlight/pwm_bl.c: pwm_backlight_probe(): line 345: (IS_ERR(pb->pwm))
printk(KERN_ERR "drivers/video/backlight/pwm_bl.c: pwm_backlight_probe(): devm_pwm_get()\n");
pb->pwm = devm_pwm_get(&pdev->dev, NULL);
if (IS_ERR(pb->pwm) && PTR_ERR(pb->pwm) != -EPROBE_DEFER && !node) {
printk(KERN_ERR "drivers/video/backlight/pwm_bl.c: pwm_backlight_probe(): unable to request PWM, trying legacy API\n");
dev_err(&pdev->dev, "unable to request PWM, trying legacy API\n");
pb->legacy = true;
printk(KERN_ERR "drivers/video/backlight/pwm_bl.c: pwm_backlight_probe(): pwm_request(data->pwm_id, pwm-backlight)\n");
pb->pwm = pwm_request(data->pwm_id, "pwm-backlight");
}
if (IS_ERR(pb->pwm)) {
printk(KERN_ERR "drivers/video/backlight/pwm_bl.c: pwm_backlight_probe(): line 345: (IS_ERR(pb->pwm))\n");
ret = PTR_ERR(pb->pwm);
if (ret != -EPROBE_DEFER)
dev_err(&pdev->dev, "unable to request PWM\n");
goto err_alloc;
}
dev_dbg(&pdev->dev, "got pwm for backlight\n");
backlight_pwm: backlight_pwm {
// P9.14 <--> lite (pwm-backlight EHRPWM1A)
pinctrl-names = "default";
pinctrl-0 = <&backlight_pwm_pins>;
status = "okay";
compatible = "pwm-backlight";
pwms = <&ehrpwm1 0 500000 0>;
brightness-levels = <
0 1 2 3 4 5 6 7 8 9
10 11 12 13 14 15 16 17 18 19
20 21 22 23 24 25 26 27 28 29
30 31 32 33 34 35 36 37 38 39
40 41 42 43 44 45 46 47 48 49
50 51 52 53 54 55 56 57 58 59
60 61 62 63 64 65 66 67 68 69
70 71 72 73 74 75 76 77 78 79
80 81 82 83 84 85 86 87 88 89
90 91 92 93 94 95 96 97 98 99
100
>;
default-brightness-level = <90>;
};
backlight = <&backlight_pwm>; // lcd lite P9.14
fragment@1 {
target = <&am33xx_pinmux>;
__overlay__ {
backlight_pwm_pins: backlight_pwm_pins {
pinctrl-single,pins = < AM33XX_IOPAD(0x0848, PIN_OUTPUT_PULLDOWN | INPUT_EN | MUX_MODE6) >;
}; /* gpmc_a2.ehrpwm1a */
};
};
fragment@2 {
target = <&epwmss1>;
__overlay__ {
status = "okay";
};
};
fragment@3 {
target = <&ehrpwm1>;
__overlay__ {
//pinctrl-names = "default";
//pinctrl-0 = <&backlight_pwm_pins>;
status = "okay";
};
};
* P9.14 <--> lite (pwm)
P9_14_pinmux { status = "disabled"; }; /* lcd pwm backlight */
[ 16.400252] drivers/video/backlight/pwm_bl.c: pwm_backlight_probe(): pdev=07153010
[ 16.407987] drivers/video/backlight/pwm_bl.c: pwm_backlight_probe(): data= (null)
[ 16.415626] drivers/video/backlight/pwm_bl.c: pwm_backlight_parse_dt()
[ 17.916504] drivers/video/backlight/pwm_bl.c: pwm_backlight_probe(): pwm_backlight_parse_dt(&pdev->dev, &defdata): ret=0
[ 17.927681] drivers/video/backlight/pwm_bl.c: pwm_backlight_probe(): data->init= (null)
[ 19.240617] drivers/video/backlight/pwm_bl.c: pwm_backlight_probe(): devm_kzalloc(): pb=a4406c53
[ 19.249529] drivers/video/backlight/pwm_bl.c: pwm_backlight_probe(): data->levels=25a76497
[ 20.036530] drivers/video/backlight/pwm_bl.c: pwm_backlight_probe(): devm_gpiod_get_optional(): pb->enable_gpio= (null)
[ 20.047533] drivers/video/backlight/pwm_bl.c: pwm_backlight_probe(): &pdev->dev=4a200f66
[ 20.055697] drivers/video/backlight/pwm_bl.c: pwm_backlight_probe(): devm_regulator_get(&pdev->dev, power)
[ 21.280567] pwm-backlight backlight: backlight supply power not found, using dummy regulator
[ 21.280702] drivers/video/backlight/pwm_bl.c: pwm_backlight_probe(): pb->power_supply=9cf20407
[ 21.289461] drivers/video/backlight/pwm_bl.c: pwm_backlight_probe(): devm_pwm_get(&pdev->dev, NULL)
[ 21.936911] drivers/video/backlight/pwm_bl.c: pwm_backlight_probe(): -EPROBE_DEFER=-517
[ 21.945064] drivers/video/backlight/pwm_bl.c: pwm_backlight_probe(): pb->pwm=a8c05c0d
[ 21.952962] drivers/video/backlight/pwm_bl.c: pwm_backlight_probe(): node=e033f126
[ 22.908770] drivers/video/backlight/pwm_bl.c: pwm_backlight_initial_power_state()
[ 23.023618] tinydrm/st7735r: st7735r_probe(): begin
[ 23.264495] drivers/video/backlight/pwm_bl.c: pwm_backlight_update_status()
[ 23.271750] drivers/video/backlight/pwm_bl.c: pwm_backlight_update_status(): (bl->props.power != FB_BLANK_UNBLANK || bl->props.fb_blank != FB_BLANK_UNBLANK || bl->props.state & BL_CORE_FBBLANK)
[ 23.289094] drivers/video/backlight/pwm_bl.c: pwm_backlight_update_status(): brightness = 0
[ 23.297499] drivers/video/backlight/pwm_bl.c: pwm_backlight_update_status(): OVERRIDE brightness = bl->props.brightness = 100
[ 23.308861] drivers/video/backlight/pwm_bl.c: pwm_backlight_update_status(): brightness=100
[ 23.317263] drivers/video/backlight/pwm_bl.c: pwm_backlight_update_status(): call compute_duty_cycle()
[ 23.326617] drivers/video/backlight/pwm_bl.c: compute_duty_cycle()
[ 23.332833] drivers/video/backlight/pwm_bl.c: pwm_backlight_update_status(): duty_cycle=500000
[ 23.341489] drivers/video/backlight/pwm_bl.c: pwm_backlight_update_status(): pwm_config(pb->pwm, duty_cycle, pb->period)
[ 23.588279] tinydrm/st7735r: st7735r_probe(): devm_kzalloc(dev, sizeof(*mipi), GFP_KERNEL): mipi=f379900b
[ 23.936572] tinydrm/st7735r: st7735r_probe(): devm_gpiod_get(dev, "reset", GPIOD_OUT_HIGH): mipi->reset=15546c55
[ 24.265430] random: crng init done
[ 24.340682] tinydrm/st7735r: st7735r_probe(): devm_gpiod_get(dev, "dc", GPIOD_OUT_LOW): dc=31402cc1
[ 24.349836] tinydrm/st7735r: st7735r_probe(): call tinydrm_of_find_backlight(dev=91f0fec6)
[ 24.358182] core/tinydrm-helpers: tinydrm_of_find_backlight(): dev=91f0fec6
[ 24.365203] core/tinydrm-helpers: tinydrm_of_find_backlight(): dev->of_node=504133ca
[ 24.372997] core/tinydrm-helpers: tinydrm_of_find_backlight(): of_parse_phandle(dev->of_node, "backlight", 0) np=e033f126
[ 24.384012] core/tinydrm-helpers: tinydrm_of_find_backlight(): np->name=backlight
[ 24.391536] core/tinydrm-helpers: tinydrm_of_find_backlight(): np->type=<NULL>
[ 24.398812] core/tinydrm-helpers: tinydrm_of_find_backlight(): np->full_name=backlight
[ 24.406774] core/tinydrm-helpers: tinydrm_of_find_backlight(): call of_find_backlight_by_node()
[ 24.415521] drivers/video/backlight/backlight.c: of_find_backlight_by_node(): node=e033f126
[ 24.423918] drivers/video/backlight/backlight.c: of_find_backlight_by_node(): backlight_class=af4f258b
[ 24.433274] drivers/video/backlight/backlight.c: of_find_backlight_by_node(): backlight_class->name=backlight
[ 24.443245] drivers/video/backlight/backlight.c: of_find_backlight_by_node(): call class_find_device(): backlight_class=af4f258b
[ 24.454869] drivers/video/backlight/backlight.c: of_find_backlight_by_node(): call class_find_device(): node=e033f126
[ 24.465534] drivers/video/backlight/backlight.c: of_find_backlight_by_node(): call class_find_device(): of_parent_match=d3089406
[ 24.477158] KERNEL/drivers/base/class.c: class_find_device(): class=af4f258b
[ 24.484263] KERNEL/drivers/base/class.c: class_find_device(): start= (null)
[ 24.491353] KERNEL/drivers/base/class.c: class_find_device(): data=e033f126
[ 24.498354] KERNEL/drivers/base/class.c: class_find_device(): match=d3089406
[ 24.505440] KERNEL/drivers/base/class.c: class_find_device(): class->name=backlight
[ 24.513138] KERNEL/drivers/base/class.c: class_find_device(): &iter=b3a5be18
[ 24.520228] KERNEL/drivers/base/class.c: class_find_device(): dev->init_name=(null)
[ 24.527927] KERNEL/drivers/base/class.c: class_find_device(): match(dev=71046fb6, data=e033f126)
[ 24.536759] drivers/video/backlight/backlight.c: of_parent_match(): dev=71046fb6 data=e033f126
[ 24.545416] drivers/video/backlight/backlight.c: of_parent_match(): data_of_node->name=backlight
[ 24.554247] drivers/video/backlight/backlight.c: of_parent_match(): dev=71046fb6 data=e033f126
[ 24.562904] drivers/video/backlight/backlight.c: of_parent_match(): dev->parent->of_node->name=backlight
[ 24.572434] drivers/video/backlight/backlight.c: of_parent_match(): dev->parent=4a200f66
[ 24.580578] drivers/video/backlight/backlight.c: of_parent_match(): dev->parent->of_node data=e033f126
[ 24.589934] drivers/video/backlight/backlight.c: of_parent_match(): data=e033f126
[ 24.597458] drivers/video/backlight/backlight.c: of_parent_match(): ret = 1
[ 24.604471] KERNEL/drivers/base/class.c: class_find_device(): if (match(dev, data)): match() true;
[ 24.613477] KERNEL/drivers/base/class.c: class_find_device(): get_device(dev);
[ 24.620738] KERNEL/drivers/base/class.c: class_find_device(): break;
[ 24.627129] drivers/video/backlight/backlight.c: of_find_backlight_by_node(): dev=71046fb6
[ 24.635437] drivers/video/backlight/backlight.c: of_find_backlight_by_node(): return ret=95c0220e
[ 24.644356] core/tinydrm-helpers: tinydrm_of_find_backlight(): of_find_backlight_by_node() returned backlight=95c0220e
[ 24.655106] core/tinydrm-helpers: tinydrm_of_find_backlight(): call of_node_put(np)
[ 24.662804] core/tinydrm-helpers: tinydrm_of_find_backlight(): backlight->props.brightness=100
[ 24.671459] core/tinydrm-helpers: tinydrm_of_find_backlight(): return backlight
[ 24.678808] tinydrm/st7735r: st7735r_probe(): tinydrm_of_find_backlight(dev): mipi->backlight=95c0220e
[ 24.688162] tinydrm/st7735r: st7735r_probe(): device_property_read_u32(dev, "rotation", &rotation)
[ 24.697172] tinydrm/st7735r: st7735r_probe(): call mipi_dbi_spi_init()
[ 24.703743] tinydrm/st7735r: st7735r_probe(): mipi_dbi_spi_init(): ret=0
[ 24.710480] tinydrm/st7735r: st7735r_probe(): call mipi_dbi_init()
[ 26.504315] drivers/video/backlight/pwm_bl.c: pwm_backlight_update_status(): pwm_backlight_power_on(pb, brightness)
[ 26.514882] drivers/video/backlight/pwm_bl.c: pwm_backlight_power_on()
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment