Lines Matching +full:host +full:- +full:only
1 // SPDX-License-Identifier: GPL-2.0-only
3 * sdhci-pltfm.c Support for SDHCI platform devices
16 * Inspired by sdhci-pci.c, by Pierre Ossman
26 #include "sdhci-pltfm.h"
28 unsigned int sdhci_pltfm_clk_get_max_clock(struct sdhci_host *host) in sdhci_pltfm_clk_get_max_clock() argument
30 struct sdhci_pltfm_host *pltfm_host = sdhci_priv(host); in sdhci_pltfm_clk_get_max_clock()
32 return clk_get_rate(pltfm_host->clk); in sdhci_pltfm_clk_get_max_clock()
45 if (device_property_present(dev, "sdhci,wp-inverted") || in sdhci_wp_inverted()
46 device_property_present(dev, "wp-inverted")) in sdhci_wp_inverted()
49 /* Old device trees don't have the wp-inverted property. */ in sdhci_wp_inverted()
60 struct sdhci_host *host = platform_get_drvdata(pdev); in sdhci_get_compatibility() local
61 struct device_node *np = pdev->dev.of_node; in sdhci_get_compatibility()
66 if (of_device_is_compatible(np, "fsl,p2020-rev1-esdhc")) in sdhci_get_compatibility()
67 host->quirks |= SDHCI_QUIRK_BROKEN_DMA; in sdhci_get_compatibility()
69 if (of_device_is_compatible(np, "fsl,p2020-esdhc") || in sdhci_get_compatibility()
70 of_device_is_compatible(np, "fsl,p1010-esdhc") || in sdhci_get_compatibility()
71 of_device_is_compatible(np, "fsl,t4240-esdhc") || in sdhci_get_compatibility()
72 of_device_is_compatible(np, "fsl,mpc8536-esdhc")) in sdhci_get_compatibility()
73 host->quirks |= SDHCI_QUIRK_BROKEN_TIMEOUT_VAL; in sdhci_get_compatibility()
81 struct device *dev = &pdev->dev; in sdhci_get_property()
82 struct sdhci_host *host = platform_get_drvdata(pdev); in sdhci_get_property() local
83 struct sdhci_pltfm_host *pltfm_host = sdhci_priv(host); in sdhci_get_property()
86 if (device_property_present(dev, "sdhci,auto-cmd12")) in sdhci_get_property()
87 host->quirks |= SDHCI_QUIRK_MULTIBLOCK_READ_ACMD12; in sdhci_get_property()
89 if (device_property_present(dev, "sdhci,1-bit-only") || in sdhci_get_property()
90 (device_property_read_u32(dev, "bus-width", &bus_width) == 0 && in sdhci_get_property()
92 host->quirks |= SDHCI_QUIRK_FORCE_1_BIT_DATA; in sdhci_get_property()
95 host->quirks |= SDHCI_QUIRK_INVERTED_WRITE_PROTECT; in sdhci_get_property()
97 if (device_property_present(dev, "broken-cd")) in sdhci_get_property()
98 host->quirks |= SDHCI_QUIRK_BROKEN_CARD_DETECTION; in sdhci_get_property()
100 if (device_property_present(dev, "no-1-8-v")) in sdhci_get_property()
101 host->quirks2 |= SDHCI_QUIRK2_NO_1_8_V; in sdhci_get_property()
105 device_property_read_u32(dev, "clock-frequency", &pltfm_host->clock); in sdhci_get_property()
107 if (device_property_present(dev, "keep-power-in-suspend")) in sdhci_get_property()
108 host->mmc->pm_caps |= MMC_PM_KEEP_POWER; in sdhci_get_property()
110 if (device_property_read_bool(dev, "wakeup-source") || in sdhci_get_property()
111 device_property_read_bool(dev, "enable-sdio-wakeup")) /* legacy */ in sdhci_get_property()
112 host->mmc->pm_caps |= MMC_PM_WAKE_SDIO_IRQ; in sdhci_get_property()
120 struct sdhci_host *host; in sdhci_pltfm_init() local
136 host = sdhci_alloc_host(&pdev->dev, in sdhci_pltfm_init()
139 if (IS_ERR(host)) { in sdhci_pltfm_init()
140 ret = PTR_ERR(host); in sdhci_pltfm_init()
144 host->ioaddr = ioaddr; in sdhci_pltfm_init()
145 host->irq = irq; in sdhci_pltfm_init()
146 host->hw_name = dev_name(&pdev->dev); in sdhci_pltfm_init()
147 if (pdata && pdata->ops) in sdhci_pltfm_init()
148 host->ops = pdata->ops; in sdhci_pltfm_init()
150 host->ops = &sdhci_pltfm_ops; in sdhci_pltfm_init()
152 host->quirks = pdata->quirks; in sdhci_pltfm_init()
153 host->quirks2 = pdata->quirks2; in sdhci_pltfm_init()
156 platform_set_drvdata(pdev, host); in sdhci_pltfm_init()
158 return host; in sdhci_pltfm_init()
160 dev_err(&pdev->dev, "%s failed %d\n", __func__, ret); in sdhci_pltfm_init()
167 struct sdhci_host *host = platform_get_drvdata(pdev); in sdhci_pltfm_free() local
169 sdhci_free_host(host); in sdhci_pltfm_free()
177 struct sdhci_host *host; in sdhci_pltfm_register() local
180 host = sdhci_pltfm_init(pdev, pdata, priv_size); in sdhci_pltfm_register()
181 if (IS_ERR(host)) in sdhci_pltfm_register()
182 return PTR_ERR(host); in sdhci_pltfm_register()
186 ret = sdhci_add_host(host); in sdhci_pltfm_register()
196 struct sdhci_host *host = platform_get_drvdata(pdev); in sdhci_pltfm_unregister() local
197 struct sdhci_pltfm_host *pltfm_host = sdhci_priv(host); in sdhci_pltfm_unregister()
198 int dead = (readl(host->ioaddr + SDHCI_INT_STATUS) == 0xffffffff); in sdhci_pltfm_unregister()
200 sdhci_remove_host(host, dead); in sdhci_pltfm_unregister()
201 clk_disable_unprepare(pltfm_host->clk); in sdhci_pltfm_unregister()
211 struct sdhci_host *host = dev_get_drvdata(dev); in sdhci_pltfm_suspend() local
212 struct sdhci_pltfm_host *pltfm_host = sdhci_priv(host); in sdhci_pltfm_suspend()
215 if (host->tuning_mode != SDHCI_TUNING_MODE_3) in sdhci_pltfm_suspend()
216 mmc_retune_needed(host->mmc); in sdhci_pltfm_suspend()
218 ret = sdhci_suspend_host(host); in sdhci_pltfm_suspend()
222 clk_disable_unprepare(pltfm_host->clk); in sdhci_pltfm_suspend()
230 struct sdhci_host *host = dev_get_drvdata(dev); in sdhci_pltfm_resume() local
231 struct sdhci_pltfm_host *pltfm_host = sdhci_priv(host); in sdhci_pltfm_resume()
234 ret = clk_prepare_enable(pltfm_host->clk); in sdhci_pltfm_resume()
238 ret = sdhci_resume_host(host); in sdhci_pltfm_resume()
240 clk_disable_unprepare(pltfm_host->clk); in sdhci_pltfm_resume()
254 pr_info("sdhci-pltfm: SDHCI platform and OF driver helper\n"); in sdhci_pltfm_drv_init()