Hello Yann, On 29.02.24 16:57, Yann Sionneau wrote: > Kalray Coolidge v2 SoC eMMC controller needs static tx delay tuning even > for basic standard or high speed modes. > > This patch also adds possibility to do some vendor specific tuning > in set_ios(). > This will be needed for Coolidge v2 for >50 MHz speeds and HS200/HS400 > modes. > > Signed-off-by: Yann Sionneau <ysionneau@xxxxxxxxxxxxx> > --- > drivers/mci/dwcmshc-sdhci.c | 40 +++++++++++++++++++++++++++++++++++++ > 1 file changed, 40 insertions(+) > > diff --git a/drivers/mci/dwcmshc-sdhci.c b/drivers/mci/dwcmshc-sdhci.c > index d9c51752db..5017a1f56e 100644 > --- a/drivers/mci/dwcmshc-sdhci.c > +++ b/drivers/mci/dwcmshc-sdhci.c > @@ -9,11 +9,16 @@ > #include <dma.h> > #include <malloc.h> > #include <mci.h> > +#include <of_device.h> > #include <linux/err.h> > #include <linux/clk.h> > > #include "sdhci.h" > > +#define tx_delay_static_cfg(delay) (delay << 5) > +#define tx_tuning_clk_sel(delay) (delay) > + > +#define DWCMSHC_GPIO_OUT 0x34 /* offset from vendor specific area */ > #define CARD_STATUS_MASK (0x1e00) > #define CARD_STATUS_TRAN (4 << 9) > > @@ -22,6 +27,13 @@ static int do_send_cmd(struct mci_host *mci, struct mci_cmd *cmd, struct mci_dat > struct dwcmshc_host { > struct mci_host mci; > struct sdhci sdhci; > + int vendor_specific_area; > + const struct dwcmshc_callbacks *cb; > +}; > + > +struct dwcmshc_callbacks { > + void (*init)(struct mci_host *mci, struct device *dev); Why is dev needed? There's already mci->hw_dev and mci->mci->dev > + void (*set_ios)(struct mci_host *mci, struct mci_ios *ios); You don't actually use set_ios. But I assume you intend to add in future? Maybe add it when it's actually needed? > +static void dwcmshc_coolidgev2_init(struct mci_host *mci, struct device *dev) > +{ > + struct dwcmshc_host *host = priv_from_mci_host(mci); > + > + // configure TX delay to set correct setup/hold for Coolidge V2 Nite: If you are going to send v2, please change into /* */ comments for uniformity. Cheers, Ahmad > + sdhci_write32(&host->sdhci, > + host->vendor_specific_area + DWCMSHC_GPIO_OUT, > + tx_delay_static_cfg(0xf) | tx_tuning_clk_sel(4)); > +} > + > +struct dwcmshc_callbacks kalray_coolidgev2_callbacks = { > + .init = dwcmshc_coolidgev2_init, > +}; > + > static struct of_device_id dwcmshc_dt_ids[] = { > { .compatible = "snps,dwcmshc-sdhci", }, > + { .compatible = "kalray,coolidge-v2-dwcmshc-sdhci", .data = &kalray_coolidgev2_callbacks }, > { } > }; > -- Pengutronix e.K. | | Steuerwalder Str. 21 | http://www.pengutronix.de/ | 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 | Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |