Merge tag 'iwlwifi-next-for-kalle-2016-07-01' of git://git.kernel.org/pub/scm/linux...
[deliverable/linux.git] / drivers / mmc / host / sdhci-dove.c
CommitLineData
985b1aa0
MR
1/*
2 * sdhci-dove.c Support for SDHCI on Marvell's Dove SoC
3 *
4 * Author: Saeed Bishara <saeed@marvell.com>
5 * Mike Rapoport <mike@compulab.co.il>
6 * Based on sdhci-cns3xxx.c
7 *
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.
11 *
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.
16 *
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.
20 */
21
30b87c60
SH
22#include <linux/clk.h>
23#include <linux/err.h>
f8ec589b 24#include <linux/io.h>
985b1aa0 25#include <linux/mmc/host.h>
f8ec589b 26#include <linux/module.h>
4ee7ed0d 27#include <linux/of.h>
985b1aa0 28
985b1aa0
MR
29#include "sdhci-pltfm.h"
30
31static u16 sdhci_dove_readw(struct sdhci_host *host, int reg)
32{
33 u16 ret;
34
35 switch (reg) {
36 case SDHCI_HOST_VERSION:
37 case SDHCI_SLOT_INT_STATUS:
38 /* those registers don't exist */
39 return 0;
40 default:
41 ret = readw(host->ioaddr + reg);
42 }
43 return ret;
44}
45
46static u32 sdhci_dove_readl(struct sdhci_host *host, int reg)
47{
48 u32 ret;
49
f8ec589b
RK
50 ret = readl(host->ioaddr + reg);
51
985b1aa0
MR
52 switch (reg) {
53 case SDHCI_CAPABILITIES:
985b1aa0
MR
54 /* Mask the support for 3.0V */
55 ret &= ~SDHCI_CAN_VDD_300;
56 break;
985b1aa0
MR
57 }
58 return ret;
59}
60
c915568d 61static const struct sdhci_ops sdhci_dove_ops = {
985b1aa0
MR
62 .read_w = sdhci_dove_readw,
63 .read_l = sdhci_dove_readl,
1771059c 64 .set_clock = sdhci_set_clock,
2317f56c 65 .set_bus_width = sdhci_set_bus_width,
03231f9b 66 .reset = sdhci_reset,
96d7b78c 67 .set_uhs_signaling = sdhci_set_uhs_signaling,
985b1aa0
MR
68};
69
1db5eebf 70static const struct sdhci_pltfm_data sdhci_dove_pdata = {
985b1aa0
MR
71 .ops = &sdhci_dove_ops,
72 .quirks = SDHCI_QUIRK_NO_SIMULT_VDD_AND_POWER |
73 SDHCI_QUIRK_NO_BUSY_IRQ |
74 SDHCI_QUIRK_BROKEN_TIMEOUT_VAL |
a9ca1d54
SH
75 SDHCI_QUIRK_FORCE_DMA |
76 SDHCI_QUIRK_NO_HISPD_BIT,
985b1aa0 77};
85d6509d 78
c3be1efd 79static int sdhci_dove_probe(struct platform_device *pdev)
85d6509d 80{
30b87c60
SH
81 struct sdhci_host *host;
82 struct sdhci_pltfm_host *pltfm_host;
30b87c60
SH
83 int ret;
84
0e748234 85 host = sdhci_pltfm_init(pdev, &sdhci_dove_pdata, 0);
c5ee2490
SH
86 if (IS_ERR(host))
87 return PTR_ERR(host);
ee3298a2 88
30b87c60 89 pltfm_host = sdhci_priv(host);
35daeede 90 pltfm_host->clk = devm_clk_get(&pdev->dev, NULL);
30b87c60 91
35daeede
KH
92 if (!IS_ERR(pltfm_host->clk))
93 clk_prepare_enable(pltfm_host->clk);
c430689f 94
c5ee2490
SH
95 ret = mmc_of_parse(host->mmc);
96 if (ret)
97 goto err_sdhci_add;
c430689f
RK
98
99 ret = sdhci_add_host(host);
100 if (ret)
101 goto err_sdhci_add;
102
30b87c60
SH
103 return 0;
104
c430689f 105err_sdhci_add:
35daeede 106 clk_disable_unprepare(pltfm_host->clk);
c430689f 107 sdhci_pltfm_free(pdev);
30b87c60 108 return ret;
85d6509d
SG
109}
110
498d83e7 111static const struct of_device_id sdhci_dove_of_match_table[] = {
4ee7ed0d
SH
112 { .compatible = "marvell,dove-sdhci", },
113 {}
114};
115MODULE_DEVICE_TABLE(of, sdhci_dove_of_match_table);
116
85d6509d
SG
117static struct platform_driver sdhci_dove_driver = {
118 .driver = {
119 .name = "sdhci-dove",
29495aa0 120 .pm = SDHCI_PLTFM_PMOPS,
5941fd07 121 .of_match_table = sdhci_dove_of_match_table,
85d6509d
SG
122 },
123 .probe = sdhci_dove_probe,
caebcae9 124 .remove = sdhci_pltfm_unregister,
85d6509d
SG
125};
126
d1f81a64 127module_platform_driver(sdhci_dove_driver);
85d6509d
SG
128
129MODULE_DESCRIPTION("SDHCI driver for Dove");
130MODULE_AUTHOR("Saeed Bishara <saeed@marvell.com>, "
131 "Mike Rapoport <mike@compulab.co.il>");
132MODULE_LICENSE("GPL v2");
This page took 0.318458 seconds and 5 git commands to generate.