drivers: sdhc: allow bandwidth selection

The current implementation uses both, host and card capabilites to derive
the maximum bus width to be used. However, in cases where a MMC device is
not connected to the host via shdc using the full bus width of 8 lines,
device initialization fails. Introducing the `bus-width` property
circumvents this by reducing the host bus capabilites and forcing
communication with the MMC device using 1, 4 or 8 lines.

Signed-off-by: Mourad Kharrazi <mourad.kharrazi@ithinx.io>
This commit is contained in:
Mourad Kharrazi 2023-06-30 13:12:21 +02:00 committed by Carles Cufí
commit a85ffa8130
4 changed files with 19 additions and 2 deletions

View file

@ -21,6 +21,7 @@ enum sd_status {
struct mmc_config {
const struct device *host_controller;
uint8_t bus_width;
};
struct mmc_data {
@ -104,8 +105,10 @@ static struct disk_info mmc_disk = {
static int disk_mmc_init(const struct device *dev)
{
struct mmc_data *data = dev->data;
const struct mmc_config *config = dev->config;
data->status = SD_UNINIT;
data->card.bus_width = config->bus_width;
mmc_disk.dev = dev;
mmc_disk.name = data->name;
@ -115,6 +118,7 @@ static int disk_mmc_init(const struct device *dev)
#define DISK_ACCESS_MMC_INIT(n) \
static const struct mmc_config mmc_config_##n = { \
.host_controller = DEVICE_DT_GET(DT_INST_PARENT(n)), \
.bus_width = DT_INST_PROP(n, bus_width), \
}; \
\
static struct mmc_data mmc_data_##n = { \