Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

dtsi: add pinctrl #35

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 44 additions & 1 deletion dtsi.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,44 @@ def generate_gpios(options: Options):
s = ""
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 = <&msmgpio XY {flags}>;\n"
s += f"\t\t{name}-gpios = <&tlmm XY {flags}>;\n"

if 'backlight' in options.gpios:
s += '''
pinctrl-0 = <&lcd_bl_en_default>;
pinctrl-names = "default";
'''
return s


def generate_tlmm(options: Options):
s = "&tlmm {"
if 'backlight' in options.gpios:
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 +72,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";
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hm, we also generate this if there is no reset in options.gpio. The reset gpio is usually there but this is not guaranteed. e.g. samsung-gtelwifiue in linux-panel-drivers.


panel@0 {{
compatible = "{options.compatible}";
reg = <0>;
Expand Down Expand Up @@ -69,3 +110,5 @@ def generate_panel_dtsi(p: Panel, options: Options) -> None:
phy-type = <PHY_TYPE_CPHY>;
};
''')

f.write(generate_tlmm(options))