1 // SPDX-License-Identifier: GPL-2.0
3 * SDHCI driver for Synopsys DWC_MSHC controller
5 * Copyright (C) 2018 Synopsys, Inc. (www.synopsys.com)
8 * Prabu Thangamuthu <prabu.t@synopsys.com>
9 * Manjunath M B <manjumb@synopsys.com>
13 #include "sdhci-pci.h"
15 #define SDHCI_VENDOR_PTR_R 0xE8
17 /* Synopsys vendor specific registers */
18 #define SDHC_GPIO_OUT 0x34
19 #define SDHC_AT_CTRL_R 0x40
20 #define SDHC_SW_TUNE_EN 0x00000010
23 #define SDHC_MMCM_DIV_REG 0x1020
24 #define DIV_REG_100_MHZ 0x1145
25 #define DIV_REG_200_MHZ 0x1083
26 #define SDHC_MMCM_CLKFBOUT 0x1024
27 #define CLKFBOUT_100_MHZ 0x0000
28 #define CLKFBOUT_200_MHZ 0x0080
29 #define SDHC_CCLK_MMCM_RST 0x00000001
31 static void sdhci_snps_set_clock(struct sdhci_host
*host
, unsigned int clock
)
36 vendor_ptr
= sdhci_readw(host
, SDHCI_VENDOR_PTR_R
);
38 /* Disable software managed rx tuning */
39 reg
= sdhci_readl(host
, (SDHC_AT_CTRL_R
+ vendor_ptr
));
40 reg
&= ~SDHC_SW_TUNE_EN
;
41 sdhci_writel(host
, reg
, (SDHC_AT_CTRL_R
+ vendor_ptr
));
43 if (clock
<= 52000000) {
44 sdhci_set_clock(host
, clock
);
46 /* Assert reset to MMCM */
47 reg
= sdhci_readl(host
, (SDHC_GPIO_OUT
+ vendor_ptr
));
48 reg
|= SDHC_CCLK_MMCM_RST
;
49 sdhci_writel(host
, reg
, (SDHC_GPIO_OUT
+ vendor_ptr
));
52 if (clock
== 100000000) {
53 sdhci_writel(host
, DIV_REG_100_MHZ
, SDHC_MMCM_DIV_REG
);
54 sdhci_writel(host
, CLKFBOUT_100_MHZ
,
57 sdhci_writel(host
, DIV_REG_200_MHZ
, SDHC_MMCM_DIV_REG
);
58 sdhci_writel(host
, CLKFBOUT_200_MHZ
,
62 /* De-assert reset to MMCM */
63 reg
= sdhci_readl(host
, (SDHC_GPIO_OUT
+ vendor_ptr
));
64 reg
&= ~SDHC_CCLK_MMCM_RST
;
65 sdhci_writel(host
, reg
, (SDHC_GPIO_OUT
+ vendor_ptr
));
68 clk
= SDHCI_PROG_CLOCK_MODE
| SDHCI_CLOCK_INT_EN
|
70 sdhci_writew(host
, clk
, SDHCI_CLOCK_CONTROL
);
74 static const struct sdhci_ops sdhci_snps_ops
= {
75 .set_clock
= sdhci_snps_set_clock
,
76 .enable_dma
= sdhci_pci_enable_dma
,
77 .set_bus_width
= sdhci_set_bus_width
,
79 .set_uhs_signaling
= sdhci_set_uhs_signaling
,
82 const struct sdhci_pci_fixes sdhci_snps
= {
83 .ops
= &sdhci_snps_ops
,