diff --git a/dtsi.py b/dtsi.py index e82dceb..db9bdef 100644 --- a/dtsi.py +++ b/dtsi.py @@ -2,6 +2,9 @@ from generator import Options, GpioFlag from panel import Panel, BacklightControl +def has_gpio_backlight(options): + return 'backlight' in options.gpios + def generate_backlight(p: Panel): if p.backlight == BacklightControl.DCS: @@ -22,6 +25,12 @@ def generate_gpios(options: Options): for name, flags in options.gpios.items(): flags = "GPIO_ACTIVE_LOW" if flags & GpioFlag.ACTIVE_LOW else "GPIO_ACTIVE_HIGH" s += f"\t\t{name}-gpios = <&tlmm XY {flags}>;\n" + + if has_gpio_backlight(options): + s += ''' + pinctrl-0 = <&lcd_bl_en_default>; + pinctrl-names = "default"; +''' return s @@ -35,6 +44,10 @@ def generate_panel_dtsi(p: Panel, options: Options) -> None: ''') f.write(f'''\ &mdss_dsi0 {{ + pinctrl-0 = <&mdss_default>; + pinctrl-1 = <&mdss_sleep>; + pinctrl-names = "default", "sleep"; + panel@0 {{ compatible = "{options.compatible}"; reg = <0>; @@ -68,4 +81,32 @@ def generate_panel_dtsi(p: Panel, options: Options) -> None: &mdss_dsi0_phy { phy-type = ; }; +''') + + f.write(''' +&tlmm {''') + if has_gpio_backlight(options): + f.write(''' + lcd_bl_en_default: lcd-bl-en-default-state { + pins = "gpioXY"; + function = "gpio"; + drive-strength = <2>; + bias-disable; + }; +''') + f.write(''' + mdss_default: mdss-default-state { + pins = "gpioXY"; + function = "gpio"; + drive-strength = <8>; + bias-disable; + }; + + mdss_sleep: mdss-sleep-state { + pins = "gpioXY"; + function = "gpio"; + drive-strength = <2>; + bias-pull-down; + }; +}; ''')