Skip to content

Commit 3f31337

Browse files
lategoodbyeUlf Hansson
authored andcommitted
mmc: pwrseq_simple: Handle !RESET_CONTROLLER properly
The recent introduction of reset control in pwrseq_simple introduced a regression for platforms without RESET_CONTROLLER support, because devm_reset_control_get_optional_shared() would return NULL and make all resets no-ops. Instead of enforcing this dependency, rely on this behavior to determine reset support. As a benefit we can get the rid of the use_reset flag. Fixes: 73bf4b7 ("mmc: pwrseq_simple: add support for one reset control") Signed-off-by: Stefan Wahren <wahrenst@gmx.net> Reviewed-by: Florian Fainelli <florian.fainelli@broadcom.com> Message-ID: <20241108130647.8281-1-wahrenst@gmx.net> Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
1 parent 2508925 commit 3f31337

1 file changed

Lines changed: 11 additions & 9 deletions

File tree

drivers/mmc/core/pwrseq_simple.c

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@ struct mmc_pwrseq_simple {
3232
struct clk *ext_clk;
3333
struct gpio_descs *reset_gpios;
3434
struct reset_control *reset_ctrl;
35-
bool use_reset;
3635
};
3736

3837
#define to_pwrseq_simple(p) container_of(p, struct mmc_pwrseq_simple, pwrseq)
@@ -71,7 +70,7 @@ static void mmc_pwrseq_simple_pre_power_on(struct mmc_host *host)
7170
pwrseq->clk_enabled = true;
7271
}
7372

74-
if (pwrseq->use_reset) {
73+
if (pwrseq->reset_ctrl) {
7574
reset_control_deassert(pwrseq->reset_ctrl);
7675
reset_control_assert(pwrseq->reset_ctrl);
7776
} else
@@ -82,7 +81,7 @@ static void mmc_pwrseq_simple_post_power_on(struct mmc_host *host)
8281
{
8382
struct mmc_pwrseq_simple *pwrseq = to_pwrseq_simple(host->pwrseq);
8483

85-
if (pwrseq->use_reset)
84+
if (pwrseq->reset_ctrl)
8685
reset_control_deassert(pwrseq->reset_ctrl);
8786
else
8887
mmc_pwrseq_simple_set_gpios_value(pwrseq, 0);
@@ -95,7 +94,7 @@ static void mmc_pwrseq_simple_power_off(struct mmc_host *host)
9594
{
9695
struct mmc_pwrseq_simple *pwrseq = to_pwrseq_simple(host->pwrseq);
9796

98-
if (pwrseq->use_reset)
97+
if (pwrseq->reset_ctrl)
9998
reset_control_assert(pwrseq->reset_ctrl);
10099
else
101100
mmc_pwrseq_simple_set_gpios_value(pwrseq, 1);
@@ -137,15 +136,18 @@ static int mmc_pwrseq_simple_probe(struct platform_device *pdev)
137136
return dev_err_probe(dev, PTR_ERR(pwrseq->ext_clk), "external clock not ready\n");
138137

139138
ngpio = of_count_phandle_with_args(dev->of_node, "reset-gpios", "#gpio-cells");
140-
if (ngpio == 1)
141-
pwrseq->use_reset = true;
142-
143-
if (pwrseq->use_reset) {
139+
if (ngpio == 1) {
144140
pwrseq->reset_ctrl = devm_reset_control_get_optional_shared(dev, NULL);
145141
if (IS_ERR(pwrseq->reset_ctrl))
146142
return dev_err_probe(dev, PTR_ERR(pwrseq->reset_ctrl),
147143
"reset control not ready\n");
148-
} else {
144+
}
145+
146+
/*
147+
* Fallback to GPIO based reset control in case of multiple reset lines
148+
* are specified or the platform doesn't have support for RESET at all.
149+
*/
150+
if (!pwrseq->reset_ctrl) {
149151
pwrseq->reset_gpios = devm_gpiod_get_array(dev, "reset", GPIOD_OUT_HIGH);
150152
if (IS_ERR(pwrseq->reset_gpios) &&
151153
PTR_ERR(pwrseq->reset_gpios) != -ENOENT &&

0 commit comments

Comments
 (0)