Back to home page

OSCL-LXR

 
 

    


0001 // SPDX-License-Identifier: GPL-2.0-only
0002 /*
0003  * sdhci-dove.c Support for SDHCI on Marvell's Dove SoC
0004  *
0005  * Author: Saeed Bishara <saeed@marvell.com>
0006  *     Mike Rapoport <mike@compulab.co.il>
0007  * Based on sdhci-cns3xxx.c
0008  */
0009 
0010 #include <linux/clk.h>
0011 #include <linux/err.h>
0012 #include <linux/io.h>
0013 #include <linux/mmc/host.h>
0014 #include <linux/module.h>
0015 #include <linux/of.h>
0016 
0017 #include "sdhci-pltfm.h"
0018 
0019 static u16 sdhci_dove_readw(struct sdhci_host *host, int reg)
0020 {
0021     u16 ret;
0022 
0023     switch (reg) {
0024     case SDHCI_HOST_VERSION:
0025     case SDHCI_SLOT_INT_STATUS:
0026         /* those registers don't exist */
0027         return 0;
0028     default:
0029         ret = readw(host->ioaddr + reg);
0030     }
0031     return ret;
0032 }
0033 
0034 static u32 sdhci_dove_readl(struct sdhci_host *host, int reg)
0035 {
0036     u32 ret;
0037 
0038     ret = readl(host->ioaddr + reg);
0039 
0040     switch (reg) {
0041     case SDHCI_CAPABILITIES:
0042         /* Mask the support for 3.0V */
0043         ret &= ~SDHCI_CAN_VDD_300;
0044         break;
0045     }
0046     return ret;
0047 }
0048 
0049 static const struct sdhci_ops sdhci_dove_ops = {
0050     .read_w = sdhci_dove_readw,
0051     .read_l = sdhci_dove_readl,
0052     .set_clock = sdhci_set_clock,
0053     .set_bus_width = sdhci_set_bus_width,
0054     .reset = sdhci_reset,
0055     .set_uhs_signaling = sdhci_set_uhs_signaling,
0056 };
0057 
0058 static const struct sdhci_pltfm_data sdhci_dove_pdata = {
0059     .ops    = &sdhci_dove_ops,
0060     .quirks = SDHCI_QUIRK_NO_SIMULT_VDD_AND_POWER |
0061           SDHCI_QUIRK_NO_BUSY_IRQ |
0062           SDHCI_QUIRK_BROKEN_TIMEOUT_VAL |
0063           SDHCI_QUIRK_FORCE_DMA |
0064           SDHCI_QUIRK_NO_HISPD_BIT,
0065 };
0066 
0067 static int sdhci_dove_probe(struct platform_device *pdev)
0068 {
0069     struct sdhci_host *host;
0070     struct sdhci_pltfm_host *pltfm_host;
0071     int ret;
0072 
0073     host = sdhci_pltfm_init(pdev, &sdhci_dove_pdata, 0);
0074     if (IS_ERR(host))
0075         return PTR_ERR(host);
0076 
0077     pltfm_host = sdhci_priv(host);
0078     pltfm_host->clk = devm_clk_get(&pdev->dev, NULL);
0079 
0080     if (!IS_ERR(pltfm_host->clk))
0081         clk_prepare_enable(pltfm_host->clk);
0082 
0083     ret = mmc_of_parse(host->mmc);
0084     if (ret)
0085         goto err_sdhci_add;
0086 
0087     ret = sdhci_add_host(host);
0088     if (ret)
0089         goto err_sdhci_add;
0090 
0091     return 0;
0092 
0093 err_sdhci_add:
0094     clk_disable_unprepare(pltfm_host->clk);
0095     sdhci_pltfm_free(pdev);
0096     return ret;
0097 }
0098 
0099 static const struct of_device_id sdhci_dove_of_match_table[] = {
0100     { .compatible = "marvell,dove-sdhci", },
0101     {}
0102 };
0103 MODULE_DEVICE_TABLE(of, sdhci_dove_of_match_table);
0104 
0105 static struct platform_driver sdhci_dove_driver = {
0106     .driver     = {
0107         .name   = "sdhci-dove",
0108         .probe_type = PROBE_PREFER_ASYNCHRONOUS,
0109         .pm = &sdhci_pltfm_pmops,
0110         .of_match_table = sdhci_dove_of_match_table,
0111     },
0112     .probe      = sdhci_dove_probe,
0113     .remove     = sdhci_pltfm_unregister,
0114 };
0115 
0116 module_platform_driver(sdhci_dove_driver);
0117 
0118 MODULE_DESCRIPTION("SDHCI driver for Dove");
0119 MODULE_AUTHOR("Saeed Bishara <saeed@marvell.com>, "
0120           "Mike Rapoport <mike@compulab.co.il>");
0121 MODULE_LICENSE("GPL v2");