mmc: pwrseq: add op reset to struct mmc_pwrseq_ops
A message that is not in the archive (sent off-list or not yet received): [email protected]
PATCH 1/4 mmc: pwrseq: add op reset to struct mmc_pwrseq_ops
Add an operation reset to struct mmc_pwrseq_ops and related wrappers.
Don't expose the pwrseq-internal reset function directly to kernel users but just to the mmc core.
--- drivers/mmc/core/core.c | 6 ++++++ drivers/mmc/core/pwrseq.c | 8 ++++++++ drivers/mmc/core/pwrseq.h | 3 +++ include/linux/mmc/core.h | 1 + 4 files changed, 18 insertions(+)
drivers/mmc/core/core.c +6 -0
@@ -1869,6 +1869,12 @@ void mmc_power_cycle(struct mmc_host *host, u32 ocr)mmc_power_up (host, ocr); } +void mmc_hw_reset_pwrseq (struct mmc_host *host) +{ +mmc_pwrseq_reset (host); +} +EXPORT_SYMBOL (mmc_hw_reset_pwrseq); +/* * Cleanup when the last reference to the bus operator is dropped. */
drivers/mmc/core/pwrseq.c +8 -0
@@ -76,6 +76,14 @@ void mmc_pwrseq_power_off(struct mmc_host *host) pwrseq->ops->power_off (host); } +void mmc_pwrseq_reset (struct mmc_host *host) +{ +struct mmc_pwrseq *pwrseq = host->pwrseq; + +if (pwrseq && pwrseq->ops->reset) + pwrseq->ops->reset (host); +} +void mmc_pwrseq_free (struct mmc_host *host) {struct mmc_pwrseq *pwrseq = host->pwrseq;
drivers/mmc/core/pwrseq.h +3 -0
@@ -18,6 +18,7 @@ struct mmc_pwrseq_ops {void (*pre_power_on)(struct mmc_host *host);void (*post_power_on)(struct mmc_host *host);void (*power_off)(struct mmc_host *host); +void (*reset)(struct mmc_host *host); };struct mmc_pwrseq {
@@ -36,6 +37,7 @@ int mmc_pwrseq_alloc(struct mmc_host *host);void mmc_pwrseq_pre_power_on (struct mmc_host *host);void mmc_pwrseq_post_power_on (struct mmc_host *host);void mmc_pwrseq_power_off (struct mmc_host *host); +void mmc_pwrseq_reset (struct mmc_host *host);void mmc_pwrseq_free (struct mmc_host *host);#else
@@ -49,6 +51,7 @@ static inline int mmc_pwrseq_alloc(struct mmc_host *host) { return 0; }static inline void mmc_pwrseq_pre_power_on (struct mmc_host *host) {}static inline void mmc_pwrseq_post_power_on (struct mmc_host *host) {}static inline void mmc_pwrseq_power_off (struct mmc_host *host) {} +static inline void mmc_pwrseq_reset (struct mmc_host *host) {}static inline void mmc_pwrseq_free (struct mmc_host *host) {}#endif
include/linux/mmc/core.h +1 -0
@@ -166,6 +166,7 @@ int mmc_wait_for_cmd(struct mmc_host *host, struct mmc_command *cmd, int retries);int mmc_hw_reset (struct mmc_host *host); +void mmc_hw_reset_pwrseq (struct mmc_host *host);void mmc_set_data_timeout (struct mmc_data *data,const struct mmc_card *card);#endif /* LINUX_MMC_CORE_H */
Signature · 1 line
2.11.0
PATCH 1/4 mmc: pwrseq: add op reset to struct mmc_pwrseq_ops
Quoted 82 lines · Heiner Kallweit
Add an operation reset to struct
mmc_pwrseq_opsand related wrappers.Don't expose the pwrseq-internal reset function directly to kernel users but just to the mmc core.
Signed-off-by Heiner Kallweit <[email protected]>--- drivers/mmc/core/core.c | 6 ++++++ drivers/mmc/core/pwrseq.c | 8 ++++++++ drivers/mmc/core/pwrseq.h | 3 +++ include/linux/mmc/core.h | 1 + 4 files changed, 18 insertions(+)drivers/mmc/core/core.c +6
-0@@ -1869,6 +1869,12 @@ void mmc_power_cycle(struct mmc_host *host, u32 ocr)mmc_power_up (host, ocr); } +void mmc_hw_reset_pwrseq (struct mmc_host *host) +{ +mmc_pwrseq_reset (host); +} +EXPORT_SYMBOL (mmc_hw_reset_pwrseq); +/* * Cleanup when the last reference to the bus operator is dropped. */ drivers/mmc/core/pwrseq.c +8
-0@@ -76,6 +76,14 @@ void mmc_pwrseq_power_off(struct mmc_host *host) pwrseq->ops->power_off (host); } +void mmc_pwrseq_reset (struct mmc_host *host) +{ +struct mmc_pwrseq *pwrseq = host->pwrseq; + +if (pwrseq && pwrseq->ops->reset) + pwrseq->ops->reset (host); +} +void mmc_pwrseq_free (struct mmc_host *host) {struct mmc_pwrseq *pwrseq = host->pwrseq;drivers/mmc/core/pwrseq.h +3
-0@@ -18,6 +18,7 @@ struct mmc_pwrseq_ops {void (*pre_power_on)(struct mmc_host *host);void (*post_power_on)(struct mmc_host *host);void (*power_off)(struct mmc_host *host); +void (*reset)(struct mmc_host *host); };struct mmc_pwrseq {@@ -36,6 +37,7 @@ int mmc_pwrseq_alloc(struct mmc_host *host);void mmc_pwrseq_pre_power_on (struct mmc_host *host);void mmc_pwrseq_post_power_on (struct mmc_host *host);void mmc_pwrseq_power_off (struct mmc_host *host); +void mmc_pwrseq_reset (struct mmc_host *host);void mmc_pwrseq_free (struct mmc_host *host);#else @@ -49,6 +51,7 @@ static inline int mmc_pwrseq_alloc(struct mmc_host *host) { return 0; }static inline void mmc_pwrseq_pre_power_on (struct mmc_host *host) {}static inline void mmc_pwrseq_post_power_on (struct mmc_host *host) {}static inline void mmc_pwrseq_power_off (struct mmc_host *host) {} +static inline void mmc_pwrseq_reset (struct mmc_host *host) {}static inline void mmc_pwrseq_free (struct mmc_host *host) {}#endif include/linux/mmc/core.h +0
-0
include/linux/mmc/core.h int mmc_wait_for_cmd(struct mmc_host *host, struct mmc_command *cmd, · line 169
Quoted 4 lines
include/linux/mmc/core.h +1
-0@@ -166,6 +166,7 @@ int mmc_wait_for_cmd(struct mmc_host *host, struct mmc_command *cmd, int retries);int mmc_hw_reset (struct mmc_host *host); +void mmc_hw_reset_pwrseq (struct mmc_host *host);
Don't you think we can make this transparent to mmc host drivers, instead of them having to assign their host_ops->hw_reset() callback to this new API? Because I guess that's the though!?
In principle the mmc core already have all the information it needs, as to understand when the eMMC pwrseq should be invoked. Or perhaps the code may become a bit too messy for that?
Quoted 7 lines
include/linux/mmc/core.h +0
-1void mmc_set_data_timeout (struct mmc_data *data,const struct mmc_card *card);#endif /* LINUX_MMC_CORE_H */ --2.11.0
Kind regards
Uffe
PATCH 1/4 mmc: pwrseq: add op reset to struct mmc_pwrseq_ops
Am 15.03.2017 um 11:50 schrieb Ulf Hansson:
Quoted 92 lines · Heiner Kallweit
Quoted 82 lines
Add an operation reset to struct
mmc_pwrseq_opsand related wrappers.Don't expose the pwrseq-internal reset function directly to kernel users but just to the mmc core.
Signed-off-by Heiner Kallweit <[email protected]>--- drivers/mmc/core/core.c | 6 ++++++ drivers/mmc/core/pwrseq.c | 8 ++++++++ drivers/mmc/core/pwrseq.h | 3 +++ include/linux/mmc/core.h | 1 + 4 files changed, 18 insertions(+)drivers/mmc/core/core.c +6
-0@@ -1869,6 +1869,12 @@ void mmc_power_cycle(struct mmc_host *host, u32 ocr)mmc_power_up (host, ocr); } +void mmc_hw_reset_pwrseq (struct mmc_host *host) +{ +mmc_pwrseq_reset (host); +} +EXPORT_SYMBOL (mmc_hw_reset_pwrseq); +/* * Cleanup when the last reference to the bus operator is dropped. */ drivers/mmc/core/pwrseq.c +8
-0@@ -76,6 +76,14 @@ void mmc_pwrseq_power_off(struct mmc_host *host) pwrseq->ops->power_off (host); } +void mmc_pwrseq_reset (struct mmc_host *host) +{ +struct mmc_pwrseq *pwrseq = host->pwrseq; + +if (pwrseq && pwrseq->ops->reset) + pwrseq->ops->reset (host); +} +void mmc_pwrseq_free (struct mmc_host *host) {struct mmc_pwrseq *pwrseq = host->pwrseq;drivers/mmc/core/pwrseq.h +3
-0@@ -18,6 +18,7 @@ struct mmc_pwrseq_ops {void (*pre_power_on)(struct mmc_host *host);void (*post_power_on)(struct mmc_host *host);void (*power_off)(struct mmc_host *host); +void (*reset)(struct mmc_host *host); };struct mmc_pwrseq {@@ -36,6 +37,7 @@ int mmc_pwrseq_alloc(struct mmc_host *host);void mmc_pwrseq_pre_power_on (struct mmc_host *host);void mmc_pwrseq_post_power_on (struct mmc_host *host);void mmc_pwrseq_power_off (struct mmc_host *host); +void mmc_pwrseq_reset (struct mmc_host *host);void mmc_pwrseq_free (struct mmc_host *host);#else @@ -49,6 +51,7 @@ static inline int mmc_pwrseq_alloc(struct mmc_host *host) { return 0; }static inline void mmc_pwrseq_pre_power_on (struct mmc_host *host) {}static inline void mmc_pwrseq_post_power_on (struct mmc_host *host) {}static inline void mmc_pwrseq_power_off (struct mmc_host *host) {} +static inline void mmc_pwrseq_reset (struct mmc_host *host) {}static inline void mmc_pwrseq_free (struct mmc_host *host) {}#endif include/linux/mmc/core.h +0
-0include/linux/mmc/core.h int mmc_wait_for_cmd(struct mmc_host *host, struct mmc_command *cmd, · line 169
Quoted 4 lines
include/linux/mmc/core.h +1
-0@@ -166,6 +166,7 @@ int mmc_wait_for_cmd(struct mmc_host *host, struct mmc_command *cmd, int retries);int mmc_hw_reset (struct mmc_host *host); +void mmc_hw_reset_pwrseq (struct mmc_host *host);Don't you think we can make this transparent to mmc host drivers, instead of them having to assign their
host_ops->hw_reset()callback to this new API? Because I guess that's the though!?
Quoted 4 lines
In principle the mmc core already have all the information it needs, as to understand when the eMMC pwrseq should be invoked. Or perhaps the code may become a bit too messy for that?
The easiest way I could think of:
If host->ops->hw_reset is NULL overwrite it with pwrseq->ops->reset in mmc_add_host. But host->ops is defined es being const, so the compiler won't allow us to do this. Of course we could do some casting but usually I try to avoid hacks like casting away const qualifiers.
Quoted 11 lines
Quoted 7 lines
include/linux/mmc/core.h +0
-1void mmc_set_data_timeout (struct mmc_data *data,const struct mmc_card *card);#endif /* LINUX_MMC_CORE_H */ --2.11.0
Kind regards
Uffe
PATCH 1/4 mmc: pwrseq: add op reset to struct mmc_pwrseq_ops
Am 15.03.2017 um 22:42 schrieb Heiner Kallweit:
Quoted 97 lines
Am 15.03.2017 um 11:50 schrieb Ulf Hansson:
Quoted 92 lines · Heiner Kallweit
Quoted 82 lines
Add an operation reset to struct
mmc_pwrseq_opsand related wrappers.Don't expose the pwrseq-internal reset function directly to kernel users but just to the mmc core.
Signed-off-by Heiner Kallweit <[email protected]>--- drivers/mmc/core/core.c | 6 ++++++ drivers/mmc/core/pwrseq.c | 8 ++++++++ drivers/mmc/core/pwrseq.h | 3 +++ include/linux/mmc/core.h | 1 + 4 files changed, 18 insertions(+)drivers/mmc/core/core.c +6
-0@@ -1869,6 +1869,12 @@ void mmc_power_cycle(struct mmc_host *host, u32 ocr)mmc_power_up (host, ocr); } +void mmc_hw_reset_pwrseq (struct mmc_host *host) +{ +mmc_pwrseq_reset (host); +} +EXPORT_SYMBOL (mmc_hw_reset_pwrseq); +/* * Cleanup when the last reference to the bus operator is dropped. */ drivers/mmc/core/pwrseq.c +8
-0@@ -76,6 +76,14 @@ void mmc_pwrseq_power_off(struct mmc_host *host) pwrseq->ops->power_off (host); } +void mmc_pwrseq_reset (struct mmc_host *host) +{ +struct mmc_pwrseq *pwrseq = host->pwrseq; + +if (pwrseq && pwrseq->ops->reset) + pwrseq->ops->reset (host); +} +void mmc_pwrseq_free (struct mmc_host *host) {struct mmc_pwrseq *pwrseq = host->pwrseq;drivers/mmc/core/pwrseq.h +3
-0@@ -18,6 +18,7 @@ struct mmc_pwrseq_ops {void (*pre_power_on)(struct mmc_host *host);void (*post_power_on)(struct mmc_host *host);void (*power_off)(struct mmc_host *host); +void (*reset)(struct mmc_host *host); };struct mmc_pwrseq {@@ -36,6 +37,7 @@ int mmc_pwrseq_alloc(struct mmc_host *host);void mmc_pwrseq_pre_power_on (struct mmc_host *host);void mmc_pwrseq_post_power_on (struct mmc_host *host);void mmc_pwrseq_power_off (struct mmc_host *host); +void mmc_pwrseq_reset (struct mmc_host *host);void mmc_pwrseq_free (struct mmc_host *host);#else @@ -49,6 +51,7 @@ static inline int mmc_pwrseq_alloc(struct mmc_host *host) { return 0; }static inline void mmc_pwrseq_pre_power_on (struct mmc_host *host) {}static inline void mmc_pwrseq_post_power_on (struct mmc_host *host) {}static inline void mmc_pwrseq_power_off (struct mmc_host *host) {} +static inline void mmc_pwrseq_reset (struct mmc_host *host) {}static inline void mmc_pwrseq_free (struct mmc_host *host) {}#endif include/linux/mmc/core.h +0
-0include/linux/mmc/core.h int mmc_wait_for_cmd(struct mmc_host *host, struct mmc_command *cmd, · line 169
Quoted 4 lines
include/linux/mmc/core.h +1
-0@@ -166,6 +166,7 @@ int mmc_wait_for_cmd(struct mmc_host *host, struct mmc_command *cmd, int retries);int mmc_hw_reset (struct mmc_host *host); +void mmc_hw_reset_pwrseq (struct mmc_host *host);Don't you think we can make this transparent to mmc host drivers, instead of them having to assign their
host_ops->hw_reset()callback to this new API? Because I guess that's the though!?Quoted 4 lines
In principle the mmc core already have all the information it needs, as to understand when the eMMC pwrseq should be invoked. Or perhaps the code may become a bit too messy for that?
Quoted 6 lines
The easiest way I could think of:
Ifhost->ops->hw_resetis NULL overwrite it withpwrseq->ops->resetinmmc_add_host. Buthost->opsis defined es being const, so the compiler won't allow us to do this. Of course we could do some casting but usually I try to avoid hacks like casting away const qualifiers.
Other alternative:
typedef void (*hw_reset_t)(struct mmc_host *host);
hw_reset_t mmc_get_hw_reset(struct mmc_host *host)
{
struct mmc_pwrseq *p = host->pwrseq;
if (host->ops->hw_reset)
return host->ops->hw_reset;
else if (p && p->ops->reset)
return p->ops->reset;
else
return NULL;
}And then use what mmc_get_hw_reset returns instead of using host->ops->hw_reset directly.
How do you like this one?
Quoted 12 lines
Quoted 11 lines
Quoted 7 lines
include/linux/mmc/core.h +0
-1void mmc_set_data_timeout (struct mmc_data *data,const struct mmc_card *card);#endif /* LINUX_MMC_CORE_H */ --2.11.0
Kind regards
Uffe
PATCH 1/4 mmc: pwrseq: add op reset to struct mmc_pwrseq_ops
[...]
Quoted 17 lines
Quoted 1 line
Other alternative:
typedef void (*hw_reset_t)(struct
mmc_host*host);
hw_reset_tmmc_get_hw_reset(struct mmc_host *host){ struct mmc_pwrseq *p = host->pwrseq; if (host->ops->hw_reset) return host->ops->hw_reset; else if (p && p->ops->reset) return p->ops->reset; else return NULL; }
Quoted 4 lines
And then use what
mmc_get_hw_resetreturns instead of usinghost->ops->hw_resetdirectly.How do you like this one?
Well, I would just rather do these checks and call the correct callback in mmc_reset(). There is no need to invent a function returning a function pointer when we call it directly instead.
Additionally, I wonder whether it could make sense to allow both callbacks to co-exist and then call both. This would give the mmc host some options for doing some internal reset as well, while the pwrseq could handle the actual GPIO pin.
What do you think?
Kind regards
Uffe
Quoted 14 lines
Quoted 13 lines
Quoted 12 lines
Quoted 8 lines
void
mmc_set_data_timeout(struct mmc_data *data, const struct mmc_card *card);#endif /*
LINUX_MMC_CORE_H*/
--
2.11.0Kind regards
Uffe
PATCH 1/4 mmc: pwrseq: add op reset to struct mmc_pwrseq_ops
In reply to Heiner Kallweit[...]
Quoted 14 lines
Quoted 10 lines
include/linux/mmc/core.h int mmc_wait_for_cmd(struct mmc_host *host, struct mmc_command *cmd, · line 169
Quoted 5 lines
include/linux/mmc/core.h +1
-0@@ -166,6 +166,7 @@ int mmc_wait_for_cmd(struct mmc_host *host, struct mmc_command *cmd, int retries);int mmc_hw_reset (struct mmc_host *host); +void mmc_hw_reset_pwrseq (struct mmc_host *host);Don't you think we can make this transparent to mmc host drivers, instead of them having to assign their
host_ops->hw_reset()callback to this new API? Because I guess that's the though!?Quoted 4 lines
In principle the mmc core already have all the information it needs, as to understand when the eMMC pwrseq should be invoked. Or perhaps the code may become a bit too messy for that?
Quoted 5 lines
The easiest way I could think of:
Ifhost->ops->hw_resetis NULL overwrite it withpwrseq->ops->resetinmmc_add_host. Buthost->opsis defined es being const, so the compiler won't allow us to do this. Of course we could do some casting but usually I try to avoid hacks like casting away const qualifiers.
No thanks. :-)
[...]
Kind regards
Uffe
PATCH 2/4 mmc: pwrseq: implement reset operation in pwrseq_emmc
In reply to a message not in the archiveIn pwrseq_emmc a reset function exists already and just needs to be exposed as reset hook.
--- drivers/mmc/core/pwrseq_emmc.c | 1 + 1 file changed, 1 insertion(+)
drivers/mmc/core/pwrseq_emmc.c +1 -0
@@ -57,6 +57,7 @@ static int mmc_pwrseq_emmc_reset_nb(struct notifier_block *this,static const struct mmc_pwrseq_ops mmc_pwrseq_emmc_ops = { .post_power_on = mmc_pwrseq_emmc_reset, + .reset = mmc_pwrseq_emmc_reset, };static int mmc_pwrseq_emmc_probe (struct platform_device *pdev)
Signature · 1 line
2.11.0
PATCH 3/4 mmc: meson-gx: add pwrseq-based hw_reset
In reply to a message not in the archiveUse new function mmc_hw_reset_pwrseq as hw_reset operation.
--- drivers/mmc/host/meson-gx-mmc.c | 1 + 1 file changed, 1 insertion(+)
drivers/mmc/host/meson-gx-mmc.c +1 -0
@@ -716,6 +716,7 @@ static const struct mmc_host_ops meson_mmc_ops = { .request = meson_mmc_request, .set_ios = meson_mmc_set_ios, .get_cd = meson_mmc_get_cd, + .hw_reset = mmc_hw_reset_pwrseq, };static int meson_mmc_probe (struct platform_device *pdev)
Signature · 1 line
2.11.0
PATCH 4/4 ARM64: dts: meson-gxbb-odroidc2: add hw-reset capability flag for emmc port
In reply to a message not in the archiveAdd hw-reset capability flag for emmc port.
--- arch/arm64/boot/dts/amlogic/meson-gxbb-odroidc2.dts | 1 + 1 file changed, 1 insertion(+)
arch/arm64/boot/dts/amlogic/meson-gxbb-odroidc2.dts +1 -0
@@ -219,6 +219,7 @@ pinctrl-names = "default"; bus-width = <8>; + cap-mmc-hw-reset; cap-sd-highspeed; max-frequency = <200000000>; non-removable;
Signature · 1 line
2.11.0