sdhci-xenon.h 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. /* SPDX-License-Identifier: GPL-2.0-only */
  2. /*
  3. * Copyright (C) 2016 Marvell, All Rights Reserved.
  4. *
  5. * Author: Hu Ziji <[email protected]>
  6. * Date: 2016-8-24
  7. */
  8. #ifndef SDHCI_XENON_H_
  9. #define SDHCI_XENON_H_
  10. /* Register Offset of Xenon SDHC self-defined register */
  11. #define XENON_SYS_CFG_INFO 0x0104
  12. #define XENON_SLOT_TYPE_SDIO_SHIFT 24
  13. #define XENON_NR_SUPPORTED_SLOT_MASK 0x7
  14. #define XENON_SYS_OP_CTRL 0x0108
  15. #define XENON_AUTO_CLKGATE_DISABLE_MASK BIT(20)
  16. #define XENON_SDCLK_IDLEOFF_ENABLE_SHIFT 8
  17. #define XENON_SLOT_ENABLE_SHIFT 0
  18. #define XENON_SYS_EXT_OP_CTRL 0x010C
  19. #define XENON_MASK_CMD_CONFLICT_ERR BIT(8)
  20. #define XENON_SLOT_OP_STATUS_CTRL 0x0128
  21. #define XENON_TUN_CONSECUTIVE_TIMES_SHIFT 16
  22. #define XENON_TUN_CONSECUTIVE_TIMES_MASK 0x7
  23. #define XENON_TUN_CONSECUTIVE_TIMES 0x4
  24. #define XENON_TUNING_STEP_SHIFT 12
  25. #define XENON_TUNING_STEP_MASK 0xF
  26. #define XENON_TUNING_STEP_DIVIDER BIT(6)
  27. #define XENON_SLOT_EMMC_CTRL 0x0130
  28. #define XENON_ENABLE_RESP_STROBE BIT(25)
  29. #define XENON_ENABLE_DATA_STROBE BIT(24)
  30. #define XENON_SLOT_RETUNING_REQ_CTRL 0x0144
  31. /* retuning compatible */
  32. #define XENON_RETUNING_COMPATIBLE 0x1
  33. #define XENON_SLOT_EXT_PRESENT_STATE 0x014C
  34. #define XENON_DLL_LOCK_STATE 0x1
  35. #define XENON_SLOT_DLL_CUR_DLY_VAL 0x0150
  36. /* Tuning Parameter */
  37. #define XENON_TMR_RETUN_NO_PRESENT 0xF
  38. #define XENON_DEF_TUNING_COUNT 0x9
  39. #define XENON_DEFAULT_SDCLK_FREQ 400000
  40. #define XENON_LOWEST_SDCLK_FREQ 100000
  41. /* Xenon specific Mode Select value */
  42. #define XENON_CTRL_HS200 0x5
  43. #define XENON_CTRL_HS400 0x6
  44. enum xenon_variant {
  45. XENON_A3700,
  46. XENON_AP806,
  47. XENON_AP807,
  48. XENON_CP110
  49. };
  50. struct xenon_priv {
  51. unsigned char tuning_count;
  52. /* idx of SDHC */
  53. u8 sdhc_id;
  54. /*
  55. * eMMC/SD/SDIO require different register settings.
  56. * Xenon driver has to recognize card type
  57. * before mmc_host->card is not available.
  58. * This field records the card type during init.
  59. * It is updated in xenon_init_card().
  60. *
  61. * It is only valid during initialization after it is updated.
  62. * Do not access this variable in normal transfers after
  63. * initialization completes.
  64. */
  65. unsigned int init_card_type;
  66. /*
  67. * The bus_width, timing, and clock fields in below
  68. * record the current ios setting of Xenon SDHC.
  69. * Driver will adjust PHY setting if any change to
  70. * ios affects PHY timing.
  71. */
  72. unsigned char bus_width;
  73. unsigned char timing;
  74. unsigned int clock;
  75. struct clk *axi_clk;
  76. int phy_type;
  77. /*
  78. * Contains board-specific PHY parameters
  79. * passed from device tree.
  80. */
  81. void *phy_params;
  82. struct xenon_emmc_phy_regs *emmc_phy_regs;
  83. bool restore_needed;
  84. enum xenon_variant hw_version;
  85. };
  86. int xenon_phy_adj(struct sdhci_host *host, struct mmc_ios *ios);
  87. int xenon_phy_parse_params(struct device *dev,
  88. struct sdhci_host *host);
  89. void xenon_soc_pad_ctrl(struct sdhci_host *host,
  90. unsigned char signal_voltage);
  91. #endif