From: Miquel Raynal <miquel.raynal@bootlin.com> To: Thierry Reding <thierry.reding@gmail.com>, Sam Ravnborg <sam@ravnborg.org>, David Airlie <airlied@linux.ie>, Daniel Vetter <daniel@ffwll.ch> Cc: <linux-kernel@vger.kernel.org>, dri-devel@lists.freedesktop.org, Paul Kocialkowski <paul.kocialkowski@bootlin.com>, Maxime Chevallier <maxime.chevallier@bootlin.com>, Thomas Petazzoni <thomas.petazzoni@bootlin.com>, Miquel Raynal <miquel.raynal@bootlin.com> Subject: [PATCH v2] drm/panel: simple: Support reset GPIOs Date: Tue, 24 Dec 2019 15:21:34 +0100 [thread overview] Message-ID: <20191224142134.22902-1-miquel.raynal@bootlin.com> (raw) The panel common bindings provide a gpios-reset property. Let's support it in the simple driver. Two fields are added to the panel description structure: the time to assert the reset and the time to wait right after before starting to interact with it in any manner. In case these default values are not filled but the GPIO is present in the DT, default values are applied. Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com> --- Changes since v1: * Add two parameters in the panel description structure. * Ensure the reset is asserted the right amount of time and the deasserted before continuing if a reset GPIO is given. drivers/gpu/drm/panel/panel-simple.c | 32 +++++++++++++++++++++++++++- 1 file changed, 31 insertions(+), 1 deletion(-) diff --git a/drivers/gpu/drm/panel/panel-simple.c b/drivers/gpu/drm/panel/panel-simple.c index 28fa6ba7b767..ac6f6b5d200d 100644 --- a/drivers/gpu/drm/panel/panel-simple.c +++ b/drivers/gpu/drm/panel/panel-simple.c @@ -38,6 +38,9 @@ #include <drm/drm_mipi_dsi.h> #include <drm/drm_panel.h> +#define MIN_DEFAULT_RESET_US 10 +#define MIN_DEFAULT_WAIT_US 10 + /** * @modes: Pointer to array of fixed modes appropriate for this panel. If * only one mode then this can just be the address of this the mode. @@ -94,6 +97,10 @@ struct panel_desc { u32 bus_format; u32 bus_flags; + + /* Minimum reset duration and wait period after it in us */ + u32 reset_time; + u32 reset_wait; }; struct panel_simple { @@ -109,6 +116,7 @@ struct panel_simple { struct i2c_adapter *ddc; struct gpio_desc *enable_gpio; + struct gpio_desc *reset_gpio; struct drm_display_mode override_mode; }; @@ -432,12 +440,34 @@ static int panel_simple_probe(struct device *dev, const struct panel_desc *desc) if (IS_ERR(panel->supply)) return PTR_ERR(panel->supply); + panel->reset_gpio = devm_gpiod_get_optional(dev, "reset", + GPIOD_OUT_HIGH); + if (IS_ERR(panel->reset_gpio)) { + err = PTR_ERR(panel->reset_gpio); + if (err != -EPROBE_DEFER) + dev_err(dev, "failed to request reset pin: %d\n", err); + return err; + } else if (panel->reset_gpio) { + u32 reset_time = panel->desc->reset_time; + u32 reset_wait = panel->desc->reset_wait; + + if (!reset_time) + reset_time = MIN_DEFAULT_RESET_US; + + if (!reset_wait) + reset_wait = MIN_DEFAULT_WAIT_US; + + usleep_range(reset_time, 2 * reset_time); + gpiod_set_value_cansleep(panel->reset_gpio, 0); + usleep_range(reset_wait, 2 * reset_wait); + } + panel->enable_gpio = devm_gpiod_get_optional(dev, "enable", GPIOD_OUT_LOW); if (IS_ERR(panel->enable_gpio)) { err = PTR_ERR(panel->enable_gpio); if (err != -EPROBE_DEFER) - dev_err(dev, "failed to request GPIO: %d\n", err); + dev_err(dev, "failed to request enable pin: %d\n", err); return err; } -- 2.20.1
WARNING: multiple messages have this Message-ID (diff)
From: Miquel Raynal <miquel.raynal@bootlin.com> To: Thierry Reding <thierry.reding@gmail.com>, Sam Ravnborg <sam@ravnborg.org>, David Airlie <airlied@linux.ie>, Daniel Vetter <daniel@ffwll.ch> Cc: linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, Maxime Chevallier <maxime.chevallier@bootlin.com>, Paul Kocialkowski <paul.kocialkowski@bootlin.com>, Thomas Petazzoni <thomas.petazzoni@bootlin.com>, Miquel Raynal <miquel.raynal@bootlin.com> Subject: [PATCH v2] drm/panel: simple: Support reset GPIOs Date: Tue, 24 Dec 2019 15:21:34 +0100 [thread overview] Message-ID: <20191224142134.22902-1-miquel.raynal@bootlin.com> (raw) The panel common bindings provide a gpios-reset property. Let's support it in the simple driver. Two fields are added to the panel description structure: the time to assert the reset and the time to wait right after before starting to interact with it in any manner. In case these default values are not filled but the GPIO is present in the DT, default values are applied. Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com> --- Changes since v1: * Add two parameters in the panel description structure. * Ensure the reset is asserted the right amount of time and the deasserted before continuing if a reset GPIO is given. drivers/gpu/drm/panel/panel-simple.c | 32 +++++++++++++++++++++++++++- 1 file changed, 31 insertions(+), 1 deletion(-) diff --git a/drivers/gpu/drm/panel/panel-simple.c b/drivers/gpu/drm/panel/panel-simple.c index 28fa6ba7b767..ac6f6b5d200d 100644 --- a/drivers/gpu/drm/panel/panel-simple.c +++ b/drivers/gpu/drm/panel/panel-simple.c @@ -38,6 +38,9 @@ #include <drm/drm_mipi_dsi.h> #include <drm/drm_panel.h> +#define MIN_DEFAULT_RESET_US 10 +#define MIN_DEFAULT_WAIT_US 10 + /** * @modes: Pointer to array of fixed modes appropriate for this panel. If * only one mode then this can just be the address of this the mode. @@ -94,6 +97,10 @@ struct panel_desc { u32 bus_format; u32 bus_flags; + + /* Minimum reset duration and wait period after it in us */ + u32 reset_time; + u32 reset_wait; }; struct panel_simple { @@ -109,6 +116,7 @@ struct panel_simple { struct i2c_adapter *ddc; struct gpio_desc *enable_gpio; + struct gpio_desc *reset_gpio; struct drm_display_mode override_mode; }; @@ -432,12 +440,34 @@ static int panel_simple_probe(struct device *dev, const struct panel_desc *desc) if (IS_ERR(panel->supply)) return PTR_ERR(panel->supply); + panel->reset_gpio = devm_gpiod_get_optional(dev, "reset", + GPIOD_OUT_HIGH); + if (IS_ERR(panel->reset_gpio)) { + err = PTR_ERR(panel->reset_gpio); + if (err != -EPROBE_DEFER) + dev_err(dev, "failed to request reset pin: %d\n", err); + return err; + } else if (panel->reset_gpio) { + u32 reset_time = panel->desc->reset_time; + u32 reset_wait = panel->desc->reset_wait; + + if (!reset_time) + reset_time = MIN_DEFAULT_RESET_US; + + if (!reset_wait) + reset_wait = MIN_DEFAULT_WAIT_US; + + usleep_range(reset_time, 2 * reset_time); + gpiod_set_value_cansleep(panel->reset_gpio, 0); + usleep_range(reset_wait, 2 * reset_wait); + } + panel->enable_gpio = devm_gpiod_get_optional(dev, "enable", GPIOD_OUT_LOW); if (IS_ERR(panel->enable_gpio)) { err = PTR_ERR(panel->enable_gpio); if (err != -EPROBE_DEFER) - dev_err(dev, "failed to request GPIO: %d\n", err); + dev_err(dev, "failed to request enable pin: %d\n", err); return err; } -- 2.20.1 _______________________________________________ dri-devel mailing list dri-devel@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/dri-devel
next reply other threads:[~2019-12-24 14:21 UTC|newest] Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top 2019-12-24 14:21 Miquel Raynal [this message] 2019-12-24 14:21 ` [PATCH v2] drm/panel: simple: Support reset GPIOs Miquel Raynal 2020-01-02 17:27 ` Sam Ravnborg 2020-01-02 17:27 ` Sam Ravnborg 2020-01-06 9:10 ` Miquel Raynal 2020-01-06 9:10 ` Miquel Raynal 2020-04-29 13:45 ` Wadim Egorov 2020-04-29 13:45 ` Wadim Egorov
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=20191224142134.22902-1-miquel.raynal@bootlin.com \ --to=miquel.raynal@bootlin.com \ --cc=airlied@linux.ie \ --cc=daniel@ffwll.ch \ --cc=dri-devel@lists.freedesktop.org \ --cc=linux-kernel@vger.kernel.org \ --cc=maxime.chevallier@bootlin.com \ --cc=paul.kocialkowski@bootlin.com \ --cc=sam@ravnborg.org \ --cc=thierry.reding@gmail.com \ --cc=thomas.petazzoni@bootlin.com \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.