pinctrl-exynos7420.c 3.1 KB

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