dw_mmc-bluefield.c 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. // SPDX-License-Identifier: GPL-2.0
  2. /*
  3. * Copyright (C) 2018 Mellanox Technologies.
  4. *
  5. * This program is free software; you can redistribute it and/or modify
  6. * it under the terms of the GNU General Public License as published by
  7. * the Free Software Foundation; either version 2 of the License, or
  8. * (at your option) any later version.
  9. */
  10. #include <linux/bitfield.h>
  11. #include <linux/bitops.h>
  12. #include <linux/mmc/host.h>
  13. #include <linux/mmc/mmc.h>
  14. #include <linux/module.h>
  15. #include <linux/of.h>
  16. #include <linux/platform_device.h>
  17. #include <linux/pm_runtime.h>
  18. #include "dw_mmc.h"
  19. #include "dw_mmc-pltfm.h"
  20. #define UHS_REG_EXT_SAMPLE_MASK GENMASK(22, 16)
  21. #define UHS_REG_EXT_DRIVE_MASK GENMASK(29, 23)
  22. #define BLUEFIELD_UHS_REG_EXT_SAMPLE 2
  23. #define BLUEFIELD_UHS_REG_EXT_DRIVE 4
  24. static void dw_mci_bluefield_set_ios(struct dw_mci *host, struct mmc_ios *ios)
  25. {
  26. u32 reg;
  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);
  35. }
  36. static const struct dw_mci_drv_data bluefield_drv_data = {
  37. .set_ios = dw_mci_bluefield_set_ios
  38. };
  39. static const struct of_device_id dw_mci_bluefield_match[] = {
  40. { .compatible = "mellanox,bluefield-dw-mshc",
  41. .data = &bluefield_drv_data },
  42. {},
  43. };
  44. MODULE_DEVICE_TABLE(of, dw_mci_bluefield_match);
  45. static int dw_mci_bluefield_probe(struct platform_device *pdev)
  46. {
  47. const struct dw_mci_drv_data *drv_data = NULL;
  48. const struct of_device_id *match;
  49. if (pdev->dev.of_node) {
  50. match = of_match_node(dw_mci_bluefield_match,
  51. pdev->dev.of_node);
  52. drv_data = match->data;
  53. }
  54. return dw_mci_pltfm_register(pdev, drv_data);
  55. }
  56. static struct platform_driver dw_mci_bluefield_pltfm_driver = {
  57. .probe = dw_mci_bluefield_probe,
  58. .remove = dw_mci_pltfm_remove,
  59. .driver = {
  60. .name = "dwmmc_bluefield",
  61. .of_match_table = dw_mci_bluefield_match,
  62. .pm = &dw_mci_pltfm_pmops,
  63. },
  64. };
  65. module_platform_driver(dw_mci_bluefield_pltfm_driver);
  66. MODULE_DESCRIPTION("BlueField DW Multimedia Card driver");
  67. MODULE_AUTHOR("Mellanox Technologies");
  68. MODULE_LICENSE("GPL v2");