^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1) // SPDX-License-Identifier: GPL-2.0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3) * Copyright (C) 2018 Mellanox Technologies.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6) #include <linux/bitfield.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7) #include <linux/bitops.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8) #include <linux/mmc/host.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9) #include <linux/mmc/mmc.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10) #include <linux/module.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11) #include <linux/of.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12) #include <linux/platform_device.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13) #include <linux/pm_runtime.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15) #include "dw_mmc.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16) #include "dw_mmc-pltfm.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18) #define UHS_REG_EXT_SAMPLE_MASK GENMASK(22, 16)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19) #define UHS_REG_EXT_DRIVE_MASK GENMASK(29, 23)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20) #define BLUEFIELD_UHS_REG_EXT_SAMPLE 2
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21) #define BLUEFIELD_UHS_REG_EXT_DRIVE 4
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23) static void dw_mci_bluefield_set_ios(struct dw_mci *host, struct mmc_ios *ios)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25) u32 reg;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27) /* Update the Drive and Sample fields in register UHS_REG_EXT. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28) reg = mci_readl(host, UHS_REG_EXT);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29) reg &= ~UHS_REG_EXT_SAMPLE_MASK;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30) reg |= FIELD_PREP(UHS_REG_EXT_SAMPLE_MASK,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31) BLUEFIELD_UHS_REG_EXT_SAMPLE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32) reg &= ~UHS_REG_EXT_DRIVE_MASK;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33) reg |= FIELD_PREP(UHS_REG_EXT_DRIVE_MASK, BLUEFIELD_UHS_REG_EXT_DRIVE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34) mci_writel(host, UHS_REG_EXT, reg);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37) static const struct dw_mci_drv_data bluefield_drv_data = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38) .set_ios = dw_mci_bluefield_set_ios
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41) static const struct of_device_id dw_mci_bluefield_match[] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 42) { .compatible = "mellanox,bluefield-dw-mshc",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 43) .data = &bluefield_drv_data },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 44) {},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 45) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 46) MODULE_DEVICE_TABLE(of, dw_mci_bluefield_match);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 47)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 48) static int dw_mci_bluefield_probe(struct platform_device *pdev)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 49) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 50) return dw_mci_pltfm_register(pdev, &bluefield_drv_data);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 51) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 52)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 53) static struct platform_driver dw_mci_bluefield_pltfm_driver = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 54) .probe = dw_mci_bluefield_probe,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 55) .remove = dw_mci_pltfm_remove,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 56) .driver = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 57) .name = "dwmmc_bluefield",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 58) .probe_type = PROBE_PREFER_ASYNCHRONOUS,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 59) .of_match_table = dw_mci_bluefield_match,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 60) .pm = &dw_mci_pltfm_pmops,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 61) },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 62) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 63)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 64) module_platform_driver(dw_mci_bluefield_pltfm_driver);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 65)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 66) MODULE_DESCRIPTION("BlueField DW Multimedia Card driver");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 67) MODULE_AUTHOR("Mellanox Technologies");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 68) MODULE_LICENSE("GPL v2");