20 #include <linux/module.h>
27 #include <linux/slab.h>
39 static struct sdhci_ops sdhci_pltfm_ops = {
49 unsigned long gpio_irq_type;
59 if (sdhci->
data->card_power_gpio >= 0) {
60 if (!sdhci->
data->power_always_enb) {
62 val = sdhci->
data->power_active_high ? !val :
val ;
81 cd_gpio = of_get_named_gpio(np,
"cd-gpios", 0);
82 if (!gpio_is_valid(cd_gpio))
117 dev_dbg(&pdev->
dev,
"memory resource not defined\n");
122 resource_size(iomem),
"spear-sdhci")) {
124 dev_dbg(&pdev->
dev,
"cannot request region\n");
131 dev_dbg(&pdev->
dev,
"cannot allocate memory for sdhci\n");
137 if (IS_ERR(sdhci->
clk)) {
138 ret = PTR_ERR(sdhci->
clk);
143 ret = clk_prepare_enable(sdhci->
clk);
145 dev_dbg(&pdev->
dev,
"Error enabling clock\n");
150 sdhci->
data = sdhci_probe_config_dt(pdev);
151 if (IS_ERR(sdhci->
data)) {
152 dev_err(&pdev->
dev,
"DT: Failed to get pdata\n");
156 sdhci->
data = dev_get_platdata(&pdev->
dev);
159 pdev->
dev.platform_data = sdhci;
161 if (pdev->
dev.parent)
168 dev_dbg(&pdev->
dev,
"error allocating host\n");
173 host->
ops = &sdhci_pltfm_ops;
178 resource_size(iomem));
181 dev_dbg(&pdev->
dev,
"failed to remap registers\n");
191 platform_set_drvdata(pdev, host);
204 if (sdhci->
data->card_power_gpio >= 0) {
208 sdhci->
data->card_power_gpio,
"sdhci");
210 dev_dbg(&pdev->
dev,
"gpio request fail: %d\n",
211 sdhci->
data->card_power_gpio);
215 if (sdhci->
data->power_always_enb)
216 val = sdhci->
data->power_active_high;
218 val = !sdhci->
data->power_active_high;
222 dev_dbg(&pdev->
dev,
"gpio set direction fail: %d\n",
223 sdhci->
data->card_power_gpio);
228 if (sdhci->
data->card_int_gpio >= 0) {
232 dev_dbg(&pdev->
dev,
"gpio request fail: %d\n",
233 sdhci->
data->card_int_gpio);
239 dev_dbg(&pdev->
dev,
"gpio set direction fail: %d\n",
240 sdhci->
data->card_int_gpio);
243 ret = devm_request_irq(&pdev->
dev,
248 dev_dbg(&pdev->
dev,
"gpio request irq fail: %d\n",
249 sdhci->
data->card_int_gpio);
258 platform_set_drvdata(pdev,
NULL);
263 clk_disable_unprepare(sdhci->
clk);
267 dev_err(&pdev->
dev,
"spear-sdhci probe failed: %d\n", ret);
273 struct sdhci_host *host = platform_get_drvdata(pdev);
278 platform_set_drvdata(pdev,
NULL);
280 if (scratch == (
u32)-1)
285 clk_disable_unprepare(sdhci->
clk);
292 static int sdhci_suspend(
struct device *
dev)
298 ret = sdhci_suspend_host(host);
300 clk_disable_unprepare(sdhci->
clk);
305 static int sdhci_resume(
struct device *dev)
311 ret = clk_prepare_enable(sdhci->
clk);
313 dev_dbg(dev,
"Resume: Error enabling clock\n");
317 return sdhci_resume_host(host);
324 static const struct of_device_id sdhci_spear_id_table[] = {
338 .probe = sdhci_probe,