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 return dw_mci_pltfm_register(pdev
, &bluefield_drv_data
);
53 static struct platform_driver dw_mci_bluefield_pltfm_driver
= {
54 .probe
= dw_mci_bluefield_probe
,
55 .remove
= dw_mci_pltfm_remove
,
57 .name
= "dwmmc_bluefield",
58 .of_match_table
= dw_mci_bluefield_match
,
59 .pm
= &dw_mci_pltfm_pmops
,
63 module_platform_driver(dw_mci_bluefield_pltfm_driver
);
65 MODULE_DESCRIPTION("BlueField DW Multimedia Card driver");
66 MODULE_AUTHOR("Mellanox Technologies");
67 MODULE_LICENSE("GPL v2");