diff --git a/driver.py b/driver.py index 3e2a1bd..b8aeec3 100644 --- a/driver.py +++ b/driver.py @@ -378,8 +378,14 @@ def generate_probe(p: Panel, options: Options) -> str: if name == "reset": init = "GPIOD_OUT_HIGH" + if name == "reset" and options.optional_reset: + s += f''' + ctx->{name}_gpio = devm_gpiod_get_optional(dev, "{name}", {init});''' + else: + s += f''' + ctx->{name}_gpio = devm_gpiod_get(dev, "{name}", {init});''' + s += f''' - ctx->{name}_gpio = devm_gpiod_get(dev, "{name}", {init}); if (IS_ERR(ctx->{name}_gpio)) return dev_err_probe(dev, PTR_ERR(ctx->{name}_gpio), "Failed to get {name}-gpios\\n"); diff --git a/generator.py b/generator.py index 9480951..cabd8b6 100644 --- a/generator.py +++ b/generator.py @@ -20,6 +20,7 @@ class Options: dcs_get_brightness: bool ignore_wait: int dumb_dcs: bool + optional_reset: bool # Added by panel driver generator compatible: str diff --git a/lmdpdg.py b/lmdpdg.py index 5e26b17..e71c946 100755 --- a/lmdpdg.py +++ b/lmdpdg.py @@ -58,6 +58,9 @@ def generate(p: Panel, options: generator.Options) -> None: enter/exit_sleep_mode and set_display_on/off (which should be supported by any panel ideally). """) +parser.add_argument('--optional-reset-gpio', dest='optional_reset', action='store_true',help=""" + Use dev_gpiod_get_optional for reset GPIO. +""") args = parser.parse_args(namespace=generator.Options()) for f in args.dtb: