pinctrl-exynos7420.c 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  1. /*
  2. * Exynos7420 pinctrl driver.
  3. * Copyright (C) 2016 Samsung Electronics
  4. * Thomas Abraham <thomas.ab@samsung.com>
  5. *
  6. * SPDX-License-Identifier: GPL-2.0+
  7. */
  8. #include <common.h>
  9. #include <dm.h>
  10. #include <errno.h>
  11. #include <asm/io.h>
  12. #include <dm/pinctrl.h>
  13. #include <dm/root.h>
  14. #include <fdtdec.h>
  15. #include <asm/arch/pinmux.h>
  16. #include "pinctrl-exynos.h"
  17. DECLARE_GLOBAL_DATA_PTR;
  18. #define GPD1_OFFSET 0xc0
  19. static struct exynos_pinctrl_config_data serial2_conf[] = {
  20. {
  21. .offset = GPD1_OFFSET + PIN_CON,
  22. .mask = 0x00ff0000,
  23. .value = 0x00220000,
  24. }, {
  25. .offset = GPD1_OFFSET + PIN_PUD,
  26. .mask = 0x00000f00,
  27. .value = 0x00000f00,
  28. },
  29. };
  30. static int exynos7420_pinctrl_request(struct udevice *dev, int peripheral,
  31. int flags)
  32. {
  33. struct exynos_pinctrl_priv *priv = dev_get_priv(dev);
  34. unsigned long base = priv->base;
  35. switch (PERIPH_ID_UART2) {
  36. case PERIPH_ID_UART2:
  37. exynos_pinctrl_setup_peri(serial2_conf,
  38. ARRAY_SIZE(serial2_conf), base);
  39. break;
  40. default:
  41. return -ENODEV;
  42. }
  43. return 0;
  44. }
  45. static struct pinctrl_ops exynos7420_pinctrl_ops = {
  46. .set_state = exynos_pinctrl_set_state,
  47. .request = exynos7420_pinctrl_request,
  48. };
  49. /* pin banks of Exynos7420 pin-controller - BUS0 */
  50. static const struct samsung_pin_bank_data exynos7420_pin_banks0[] = {
  51. EXYNOS_PIN_BANK(5, 0x000, "gpb0"),
  52. EXYNOS_PIN_BANK(8, 0x020, "gpc0"),
  53. EXYNOS_PIN_BANK(2, 0x040, "gpc1"),
  54. EXYNOS_PIN_BANK(6, 0x060, "gpc2"),
  55. EXYNOS_PIN_BANK(8, 0x080, "gpc3"),
  56. EXYNOS_PIN_BANK(4, 0x0a0, "gpd0"),
  57. EXYNOS_PIN_BANK(6, 0x0c0, "gpd1"),
  58. EXYNOS_PIN_BANK(8, 0x0e0, "gpd2"),
  59. EXYNOS_PIN_BANK(5, 0x100, "gpd4"),
  60. EXYNOS_PIN_BANK(4, 0x120, "gpd5"),
  61. EXYNOS_PIN_BANK(6, 0x140, "gpd6"),
  62. EXYNOS_PIN_BANK(3, 0x160, "gpd7"),
  63. EXYNOS_PIN_BANK(2, 0x180, "gpd8"),
  64. EXYNOS_PIN_BANK(2, 0x1a0, "gpg0"),
  65. EXYNOS_PIN_BANK(4, 0x1c0, "gpg3"),
  66. };
  67. /* pin banks of Exynos7420 pin-controller - FSYS0 */
  68. static const struct samsung_pin_bank_data exynos7420_pin_banks1[] = {
  69. EXYNOS_PIN_BANK(7, 0x000, "gpr4"),
  70. };
  71. /* pin banks of Exynos7420 pin-controller - FSYS1 */
  72. static const struct samsung_pin_bank_data exynos7420_pin_banks2[] = {
  73. EXYNOS_PIN_BANK(4, 0x000, "gpr0"),
  74. EXYNOS_PIN_BANK(8, 0x020, "gpr1"),
  75. EXYNOS_PIN_BANK(5, 0x040, "gpr2"),
  76. EXYNOS_PIN_BANK(8, 0x060, "gpr3"),
  77. };
  78. const struct samsung_pin_ctrl exynos7420_pin_ctrl[] = {
  79. {
  80. /* pin-controller instance BUS0 data */
  81. .pin_banks = exynos7420_pin_banks0,
  82. .nr_banks = ARRAY_SIZE(exynos7420_pin_banks0),
  83. }, {
  84. /* pin-controller instance FSYS0 data */
  85. .pin_banks = exynos7420_pin_banks1,
  86. .nr_banks = ARRAY_SIZE(exynos7420_pin_banks1),
  87. }, {
  88. /* pin-controller instance FSYS1 data */
  89. .pin_banks = exynos7420_pin_banks2,
  90. .nr_banks = ARRAY_SIZE(exynos7420_pin_banks2),
  91. },
  92. };
  93. static const struct udevice_id exynos7420_pinctrl_ids[] = {
  94. { .compatible = "samsung,exynos7420-pinctrl",
  95. .data = (ulong)exynos7420_pin_ctrl },
  96. { }
  97. };
  98. U_BOOT_DRIVER(pinctrl_exynos7420) = {
  99. .name = "pinctrl_exynos7420",
  100. .id = UCLASS_PINCTRL,
  101. .of_match = exynos7420_pinctrl_ids,
  102. .priv_auto_alloc_size = sizeof(struct exynos_pinctrl_priv),
  103. .ops = &exynos7420_pinctrl_ops,
  104. .probe = exynos_pinctrl_probe,
  105. .flags = DM_FLAG_PRE_RELOC
  106. };