Skip to content

Commit e095b78

Browse files
blarson866Ulf Hansson
authored andcommitted
mmc: sdhci-cadence: Support device specific init during probe
Move struct sdhci_pltfm_data under new struct sdhci_cdns_drv_data. Add an init() into sdhci_cdns_drv_data for platform specific device initialization in the device probe which is not used for existing devices. Signed-off-by: Brad Larson <blarson@amd.com> Acked-by: Adrian Hunter <adrian.hunter@intel.com> Link: https://lore.kernel.org/r/20230410184526.15990-13-blarson@amd.com Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
1 parent d3e32f8 commit e095b78

1 file changed

Lines changed: 23 additions & 9 deletions

File tree

drivers/mmc/host/sdhci-cadence.c

Lines changed: 23 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,11 @@ struct sdhci_cdns_phy_cfg {
7777
u8 addr;
7878
};
7979

80+
struct sdhci_cdns_drv_data {
81+
int (*init)(struct platform_device *pdev);
82+
const struct sdhci_pltfm_data pltfm_data;
83+
};
84+
8085
static const struct sdhci_cdns_phy_cfg sdhci_cdns_phy_cfgs[] = {
8186
{ "cdns,phy-input-delay-sd-highspeed", SDHCI_CDNS_PHY_DLY_SD_HS, },
8287
{ "cdns,phy-input-delay-legacy", SDHCI_CDNS_PHY_DLY_SD_DEFAULT, },
@@ -325,13 +330,17 @@ static const struct sdhci_ops sdhci_cdns_ops = {
325330
.set_uhs_signaling = sdhci_cdns_set_uhs_signaling,
326331
};
327332

328-
static const struct sdhci_pltfm_data sdhci_cdns_uniphier_pltfm_data = {
329-
.ops = &sdhci_cdns_ops,
330-
.quirks2 = SDHCI_QUIRK2_PRESET_VALUE_BROKEN,
333+
static const struct sdhci_cdns_drv_data sdhci_cdns_uniphier_drv_data = {
334+
.pltfm_data = {
335+
.ops = &sdhci_cdns_ops,
336+
.quirks2 = SDHCI_QUIRK2_PRESET_VALUE_BROKEN,
337+
},
331338
};
332339

333-
static const struct sdhci_pltfm_data sdhci_cdns_pltfm_data = {
334-
.ops = &sdhci_cdns_ops,
340+
static const struct sdhci_cdns_drv_data sdhci_cdns_drv_data = {
341+
.pltfm_data = {
342+
.ops = &sdhci_cdns_ops,
343+
},
335344
};
336345

337346
static void sdhci_cdns_hs400_enhanced_strobe(struct mmc_host *mmc,
@@ -357,7 +366,7 @@ static void sdhci_cdns_hs400_enhanced_strobe(struct mmc_host *mmc,
357366
static int sdhci_cdns_probe(struct platform_device *pdev)
358367
{
359368
struct sdhci_host *host;
360-
const struct sdhci_pltfm_data *data;
369+
const struct sdhci_cdns_drv_data *data;
361370
struct sdhci_pltfm_host *pltfm_host;
362371
struct sdhci_cdns_priv *priv;
363372
struct clk *clk;
@@ -376,10 +385,10 @@ static int sdhci_cdns_probe(struct platform_device *pdev)
376385

377386
data = of_device_get_match_data(dev);
378387
if (!data)
379-
data = &sdhci_cdns_pltfm_data;
388+
data = &sdhci_cdns_drv_data;
380389

381390
nr_phy_params = sdhci_cdns_phy_param_count(dev->of_node);
382-
host = sdhci_pltfm_init(pdev, data,
391+
host = sdhci_pltfm_init(pdev, &data->pltfm_data,
383392
struct_size(priv, phy_params, nr_phy_params));
384393
if (IS_ERR(host)) {
385394
ret = PTR_ERR(host);
@@ -397,6 +406,11 @@ static int sdhci_cdns_probe(struct platform_device *pdev)
397406
host->ioaddr += SDHCI_CDNS_SRS_BASE;
398407
host->mmc_host_ops.hs400_enhanced_strobe =
399408
sdhci_cdns_hs400_enhanced_strobe;
409+
if (data->init) {
410+
ret = data->init(pdev);
411+
if (ret)
412+
goto free;
413+
}
400414
sdhci_enable_v4_mode(host);
401415
__sdhci_read_caps(host, &version, NULL, NULL);
402416

@@ -461,7 +475,7 @@ static const struct dev_pm_ops sdhci_cdns_pm_ops = {
461475
static const struct of_device_id sdhci_cdns_match[] = {
462476
{
463477
.compatible = "socionext,uniphier-sd4hc",
464-
.data = &sdhci_cdns_uniphier_pltfm_data,
478+
.data = &sdhci_cdns_uniphier_drv_data,
465479
},
466480
{ .compatible = "cdns,sd4hc" },
467481
{ /* sentinel */ }

0 commit comments

Comments
 (0)