Skip to content
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

disk: sdhc: fix SPI clock setup #26319

Closed
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion subsys/disk/disk_access_spi_sdhc.c
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
* SPDX-License-Identifier: Apache-2.0
*/

#define DT_DRV_COMPAT zephyr_mmc_spi_slot

#include <logging/log.h>

LOG_MODULE_REGISTER(sdhc_spi, CONFIG_DISK_LOG_LEVEL);
Expand Down Expand Up @@ -784,6 +786,7 @@ static int disk_spi_sdhc_init(struct device *dev);
static int sdhc_spi_init(struct device *dev)
{
struct sdhc_spi_data *data = dev->driver_data;
uint32_t spi_max_frequency = DT_INST_PROP(0, spi_max_frequency);

data->spi = device_get_binding(DT_BUS_LABEL(DT_INST(0, zephyr_mmc_spi_slot)));

Expand All @@ -795,8 +798,12 @@ static int sdhc_spi_init(struct device *dev)
.slave = DT_REG_ADDR(DT_INST(0, zephyr_mmc_spi_slot)),
};
/* SPI config for default speed */
if (spi_max_frequency > SDHC_SPI_DEFAULT_SPEED) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this a MAX? Shouldn't the driver always take the speed from DeviceTree if it is supplied?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the commiter took the name out of the dts property (see line 789 above), but it is definitely coming from dts here.

spi_max_frequency = SDHC_SPI_DEFAULT_SPEED;
}
LOG_DBG("Maximum SPI frequency: %u", spi_max_frequency);
data->spi_cfgs[SDHC_SPI_DEFAULT_SPEED_CFG] = (struct spi_config){
.frequency = SDHC_SPI_DEFAULT_SPEED,
.frequency = spi_max_frequency,
.operation = SPI_WORD_SET(8) | SPI_HOLD_ON_CS,
.slave = DT_REG_ADDR(DT_INST(0, zephyr_mmc_spi_slot)),
};
Expand Down