1 // SPDX-License-Identifier: GPL-2.0
3 * Copyright (C) 2018 Mellanox Technologies.
6 #include <linux/bitfield.h>
7 #include <linux/bitops.h>
8 #include <linux/mmc/host.h>
9 #include <linux/mmc/mmc.h>
10 #include <linux/module.h>
12 #include <linux/platform_device.h>
13 #include <linux/pm_runtime.h>
16 #include "dw_mmc-pltfm.h"
18 #define UHS_REG_EXT_SAMPLE_MASK GENMASK(22, 16)
19 #define UHS_REG_EXT_DRIVE_MASK GENMASK(29, 23)
20 #define BLUEFIELD_UHS_REG_EXT_SAMPLE 2
21 #define BLUEFIELD_UHS_REG_EXT_DRIVE 4
23 static void dw_mci_bluefield_set_ios(struct dw_mci
*host
, struct mmc_ios
*ios
)
27 /* Update the Drive and Sample fields in register UHS_REG_EXT. */
28 reg
= mci_readl(host
, UHS_REG_EXT
);
29 reg
&= ~UHS_REG_EXT_SAMPLE_MASK
;
30 reg
|= FIELD_PREP(UHS_REG_EXT_SAMPLE_MASK
,
31 BLUEFIELD_UHS_REG_EXT_SAMPLE
);
32 reg
&= ~UHS_REG_EXT_DRIVE_MASK
;
33 reg
|= FIELD_PREP(UHS_REG_EXT_DRIVE_MASK
, BLUEFIELD_UHS_REG_EXT_DRIVE
);
34 mci_writel(host
, UHS_REG_EXT
, reg
);
37 static const struct dw_mci_drv_data bluefield_drv_data
= {
38 .set_ios
= dw_mci_bluefield_set_ios
41 static const struct of_device_id dw_mci_bluefield_match
[] = {
42 { .compatible
= "mellanox,bluefield-dw-mshc",
43 .data
= &bluefield_drv_data
},
46 MODULE_DEVICE_TABLE(of
, dw_mci_bluefield_match
);
48 static int dw_mci_bluefield_probe(struct platform_device
*pdev
)
50 const struct dw_mci_drv_data
*drv_data
= NULL
;
51 const struct of_device_id
*match
;
53 if (pdev
->dev
.of_node
) {
54 match
= of_match_node(dw_mci_bluefield_match
,
56 drv_data
= match
->data
;
59 return dw_mci_pltfm_register(pdev
, drv_data
);
62 static struct platform_driver dw_mci_bluefield_pltfm_driver
= {
63 .probe
= dw_mci_bluefield_probe
,
64 .remove
= dw_mci_pltfm_remove
,
66 .name
= "dwmmc_bluefield",
67 .of_match_table
= dw_mci_bluefield_match
,
68 .pm
= &dw_mci_pltfm_pmops
,
72 module_platform_driver(dw_mci_bluefield_pltfm_driver
);
74 MODULE_DESCRIPTION("BlueField DW Multimedia Card driver");
75 MODULE_AUTHOR("Mellanox Technologies");
76 MODULE_LICENSE("GPL v2");