sdhci_misc.h 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. /*
  2. * Copyright (c) 2006-2024 RT-Thread Development Team
  3. *
  4. * SPDX-License-Identifier: Apache-2.0
  5. *
  6. * Change Logs:
  7. * Date Author Notes
  8. * 2024-08-16 zhujiale first version
  9. */
  10. #ifndef __RT_SDHCI_MISC_H__
  11. #define __RT_SDHCI_MISC_H__
  12. #define __BF_FIELD_CHECK(...)
  13. #define __bf_shf(x) (__builtin_ffsll(x) - 1)
  14. #define FIELD_GET(_mask, _reg) \
  15. ({ \
  16. __BF_FIELD_CHECK(_mask, _reg, 0U, "FIELD_GET: "); \
  17. (typeof(_mask))(((_reg) & (_mask)) >> __bf_shf(_mask)); \
  18. })
  19. #define FIELD_PREP(_mask, _val) \
  20. ({ \
  21. __BF_FIELD_CHECK(_mask, 0ULL, _val, "FIELD_PREP: "); \
  22. ((typeof(_mask))(_val) << __bf_shf(_mask)) & (_mask); \
  23. })
  24. #define DIV_ROUND_UP(n, d) (((n) + (d) - 1) / (d))
  25. #define min_t(type, x, y) (((type)x < (type)y) ? x : y)
  26. #define max_t(type, x, y) (((type)x > (type)y) ? x : y)
  27. #define min(x, y) ((x) < (y) ? (x) : (y))
  28. #define from_timer(var, callback_timer, timer_fieldname) \
  29. container_of(callback_timer, typeof(*var), timer_fieldname)
  30. #define le32_to_cpu(x) (x)
  31. #define le16_to_cpu(x) (x)
  32. #define cpu_to_le16(x) (x)
  33. #define cpu_to_le32(x) (x)
  34. #define lower_32_bits(n) ((rt_uint32_t)((n) & 0xffffffff))
  35. #define upper_32_bits(n) ((rt_uint32_t)(((n) >> 16) >> 16))
  36. #define DIV_ROUND_UP(n, d) (((n) + (d) - 1) / (d))
  37. #define do_div(n, base) ({ \
  38. uint32_t __base = (base); \
  39. uint32_t __rem; \
  40. __rem = ((uint64_t)(n)) % __base; \
  41. (n) = ((uint64_t)(n)) / __base; \
  42. __rem; \
  43. })
  44. #define fallthrough \
  45. do { \
  46. } while (0)
  47. int regulator_is_supported_voltage(struct regulator *regulator,
  48. int min_uV, int max_uV);
  49. rt_bool_t rt_mmc_can_gpio_cd(struct rt_mmc_host *host);
  50. struct regulator
  51. {
  52. const char *supply_name;
  53. };
  54. int regulator_get_current_limit(struct regulator *regulator);
  55. #endif