Skip to content

Commit

Permalink
dtsi: add pinctrl
Browse files Browse the repository at this point in the history
  • Loading branch information
wonderfulShrineMaidenOfParadise committed Aug 18, 2023
1 parent 51fa5c3 commit ac56df4
Showing 1 changed file with 49 additions and 0 deletions.
49 changes: 49 additions & 0 deletions dtsi.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@
from panel import Panel, BacklightControl


def has_gpio_backlight(options: Options):
return 'backlight' in options.gpios


def generate_backlight(p: Panel):
if p.backlight == BacklightControl.DCS:
return ""
Expand All @@ -14,6 +18,7 @@ def generate_supplies(options: Options):
if options.regulator:
for r in options.regulator:
s += f"\t\t{r}-supply = <&...>;\n"
s += f"\n"
return s


Expand All @@ -22,6 +27,43 @@ 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


def generate_tlmm(options: Options):
s = "&tlmm {"
if has_gpio_backlight(options):
s += '''
lcd_bl_en_default: lcd-bl-en-default-state {
pins = "gpioXY";
function = "gpio";
drive-strength = <2>;
bias-disable;
};
'''

s += '''
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;
};
};
'''
return s


Expand All @@ -35,6 +77,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>;
Expand All @@ -55,6 +101,7 @@ def generate_panel_dtsi(p: Panel, options: Options) -> None:
data-lanes = <{' '.join(map(str, p.lane_map.phys2log[:p.lanes]))}>;
remote-endpoint = <&panel_in>;
}};
''')

if p.ldo_mode:
Expand All @@ -69,3 +116,5 @@ def generate_panel_dtsi(p: Panel, options: Options) -> None:
phy-type = <PHY_TYPE_CPHY>;
};
''')

f.write(f'''{generate_tlmm(options)}''')

0 comments on commit ac56df4

Please sign in to comment.