-
Notifications
You must be signed in to change notification settings - Fork 7.8k
drivers: disk: sdmmc_stm32: power up on request #91220
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
base: main
Are you sure you want to change the base?
drivers: disk: sdmmc_stm32: power up on request #91220
Conversation
aae30df
to
6d3d7cc
Compare
if ((err != 0) && (err != -ENOENT)) { | ||
LOG_WRN("Failed to apply pin sleep states"); | ||
} | ||
gpio_pin_configure_dt(&priv->pe, GPIO_OUTPUT_INACTIVE); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I missed that: return value to be tested.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There are quite a number of calls to this function in the driver that already aren't checked.
What action would you want taken if this does fail?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Indeed.
gpio_pin_configure_dt(&priv->pe, GPIO_OUTPUT_INACTIVE); | |
if (gpio_pin_configure_dt(&priv->pe, GPIO_OUTPUT_INACTIVE) != 0) { | |
LOG_WRN("Failed to apply GPIO inactive state"); | |
} |
Provide a pointer to the first element of the clock list explicitly (as done by `stm32_sdmmc_clock_enable`), instead of a pointer to the list. Signed-off-by: Jordan Yates <[email protected]>
Move power configuration from the device init function into the `DISK_IOCTL_CTRL_INIT` and `DISK_IOCTL_CTRL_DEINIT` handlers. If `pwr-gpios` is defined, this ensures that the card is not powered up until requested, and enables power down the card when not in use. This behaviour matches the implementation for `sdhc_spi`. Signed-off-by: Jordan Yates <[email protected]>
Add support for configuring pins into an alternate mode when the device is powered off. Signed-off-by: Jordan Yates <[email protected]>
Cleanup functions that only return `0`. Signed-off-by: Jordan Yates <[email protected]>
6d3d7cc
to
e94ffad
Compare
|
if ((err != 0) && (err != -ENOENT)) { | ||
LOG_WRN("Failed to apply pin sleep states"); | ||
} | ||
gpio_pin_configure_dt(&priv->pe, GPIO_OUTPUT_INACTIVE); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Indeed.
gpio_pin_configure_dt(&priv->pe, GPIO_OUTPUT_INACTIVE); | |
if (gpio_pin_configure_dt(&priv->pe, GPIO_OUTPUT_INACTIVE) != 0) { | |
LOG_WRN("Failed to apply GPIO inactive state"); | |
} |
} | ||
|
||
gpio_pin_interrupt_configure_dt(&priv->cd, GPIO_INT_MODE_DISABLED); | ||
gpio_pin_configure_dt(&priv->cd, GPIO_DISCONNECTED); | ||
gpio_remove_callback(priv->cd.port, &priv->cd_cb); | ||
return 0; | ||
return; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could remove this instruction.
LOG_WRN("Failed to apply pin sleep states"); | ||
} | ||
gpio_pin_configure_dt(&priv->pe, GPIO_OUTPUT_INACTIVE); | ||
return; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could remove this return
instruction.
Move power configuration from the device init function into the
DISK_IOCTL_CTRL_INIT
andDISK_IOCTL_CTRL_DEINIT
handlers. Ifpwr-gpios
is defined, this ensures that the card is not powered upuntil requested, and enables powering down the card when not in use.
This behaviour matches the implementation for
sdhc_spi
.The updated implementation has been tested on a custom STM32L451RE board with the following devicetree definition:
The implementation remains working and low power after power cycling the card multiple times without an application reboot:
