2 * sdhci-dove.c Support for SDHCI on Marvell's Dove SoC
4 * Author: Saeed Bishara <saeed@marvell.com>
5 * Mike Rapoport <mike@compulab.co.il>
6 * Based on sdhci-cns3xxx.c
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License version 2 as
10 * published by the Free Software Foundation.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
22 #include <linux/clk.h>
23 #include <linux/err.h>
25 #include <linux/mmc/host.h>
26 #include <linux/module.h>
29 #include "sdhci-pltfm.h"
31 struct sdhci_dove_priv
{
35 static u16
sdhci_dove_readw(struct sdhci_host
*host
, int reg
)
40 case SDHCI_HOST_VERSION
:
41 case SDHCI_SLOT_INT_STATUS
:
42 /* those registers don't exist */
45 ret
= readw(host
->ioaddr
+ reg
);
50 static u32
sdhci_dove_readl(struct sdhci_host
*host
, int reg
)
54 ret
= readl(host
->ioaddr
+ reg
);
57 case SDHCI_CAPABILITIES
:
58 /* Mask the support for 3.0V */
59 ret
&= ~SDHCI_CAN_VDD_300
;
65 static const struct sdhci_ops sdhci_dove_ops
= {
66 .read_w
= sdhci_dove_readw
,
67 .read_l
= sdhci_dove_readl
,
68 .set_clock
= sdhci_set_clock
,
69 .set_bus_width
= sdhci_set_bus_width
,
71 .set_uhs_signaling
= sdhci_set_uhs_signaling
,
74 static const struct sdhci_pltfm_data sdhci_dove_pdata
= {
75 .ops
= &sdhci_dove_ops
,
76 .quirks
= SDHCI_QUIRK_NO_SIMULT_VDD_AND_POWER
|
77 SDHCI_QUIRK_NO_BUSY_IRQ
|
78 SDHCI_QUIRK_BROKEN_TIMEOUT_VAL
|
79 SDHCI_QUIRK_FORCE_DMA
|
80 SDHCI_QUIRK_NO_HISPD_BIT
,
83 static int sdhci_dove_probe(struct platform_device
*pdev
)
85 struct sdhci_host
*host
;
86 struct sdhci_pltfm_host
*pltfm_host
;
87 struct sdhci_dove_priv
*priv
;
90 priv
= devm_kzalloc(&pdev
->dev
, sizeof(struct sdhci_dove_priv
),
93 dev_err(&pdev
->dev
, "unable to allocate private data");
97 priv
->clk
= devm_clk_get(&pdev
->dev
, NULL
);
99 host
= sdhci_pltfm_init(pdev
, &sdhci_dove_pdata
, 0);
101 return PTR_ERR(host
);
103 pltfm_host
= sdhci_priv(host
);
104 pltfm_host
->priv
= priv
;
106 if (!IS_ERR(priv
->clk
))
107 clk_prepare_enable(priv
->clk
);
109 ret
= mmc_of_parse(host
->mmc
);
113 ret
= sdhci_add_host(host
);
120 if (!IS_ERR(priv
->clk
))
121 clk_disable_unprepare(priv
->clk
);
122 sdhci_pltfm_free(pdev
);
126 static int sdhci_dove_remove(struct platform_device
*pdev
)
128 struct sdhci_host
*host
= platform_get_drvdata(pdev
);
129 struct sdhci_pltfm_host
*pltfm_host
= sdhci_priv(host
);
130 struct sdhci_dove_priv
*priv
= pltfm_host
->priv
;
132 sdhci_pltfm_unregister(pdev
);
134 if (!IS_ERR(priv
->clk
))
135 clk_disable_unprepare(priv
->clk
);
140 static const struct of_device_id sdhci_dove_of_match_table
[] = {
141 { .compatible
= "marvell,dove-sdhci", },
144 MODULE_DEVICE_TABLE(of
, sdhci_dove_of_match_table
);
146 static struct platform_driver sdhci_dove_driver
= {
148 .name
= "sdhci-dove",
149 .pm
= SDHCI_PLTFM_PMOPS
,
150 .of_match_table
= sdhci_dove_of_match_table
,
152 .probe
= sdhci_dove_probe
,
153 .remove
= sdhci_dove_remove
,
156 module_platform_driver(sdhci_dove_driver
);
158 MODULE_DESCRIPTION("SDHCI driver for Dove");
159 MODULE_AUTHOR("Saeed Bishara <saeed@marvell.com>, "
160 "Mike Rapoport <mike@compulab.co.il>");
161 MODULE_LICENSE("GPL v2");