pinctrl-armada-ap806.c 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136
  1. // SPDX-License-Identifier: GPL-2.0-or-later
  2. /*
  3. * Marvell Armada ap806 pinctrl driver based on mvebu pinctrl core
  4. *
  5. * Copyright (C) 2017 Marvell
  6. *
  7. * Thomas Petazzoni <[email protected]>
  8. * Hanna Hawa <[email protected]>
  9. */
  10. #include <linux/err.h>
  11. #include <linux/init.h>
  12. #include <linux/io.h>
  13. #include <linux/platform_device.h>
  14. #include <linux/of.h>
  15. #include <linux/of_device.h>
  16. #include <linux/pinctrl/pinctrl.h>
  17. #include "pinctrl-mvebu.h"
  18. static struct mvebu_mpp_mode armada_ap806_mpp_modes[] = {
  19. MPP_MODE(0,
  20. MPP_FUNCTION(0, "gpio", NULL),
  21. MPP_FUNCTION(1, "sdio", "clk"),
  22. MPP_FUNCTION(3, "spi0", "clk")),
  23. MPP_MODE(1,
  24. MPP_FUNCTION(0, "gpio", NULL),
  25. MPP_FUNCTION(1, "sdio", "cmd"),
  26. MPP_FUNCTION(3, "spi0", "miso")),
  27. MPP_MODE(2,
  28. MPP_FUNCTION(0, "gpio", NULL),
  29. MPP_FUNCTION(1, "sdio", "d0"),
  30. MPP_FUNCTION(3, "spi0", "mosi")),
  31. MPP_MODE(3,
  32. MPP_FUNCTION(0, "gpio", NULL),
  33. MPP_FUNCTION(1, "sdio", "d1"),
  34. MPP_FUNCTION(3, "spi0", "cs0n")),
  35. MPP_MODE(4,
  36. MPP_FUNCTION(0, "gpio", NULL),
  37. MPP_FUNCTION(1, "sdio", "d2"),
  38. MPP_FUNCTION(3, "i2c0", "sda")),
  39. MPP_MODE(5,
  40. MPP_FUNCTION(0, "gpio", NULL),
  41. MPP_FUNCTION(1, "sdio", "d3"),
  42. MPP_FUNCTION(3, "i2c0", "sdk")),
  43. MPP_MODE(6,
  44. MPP_FUNCTION(0, "gpio", NULL),
  45. MPP_FUNCTION(1, "sdio", "ds")),
  46. MPP_MODE(7,
  47. MPP_FUNCTION(0, "gpio", NULL),
  48. MPP_FUNCTION(1, "sdio", "d4"),
  49. MPP_FUNCTION(3, "uart1", "rxd")),
  50. MPP_MODE(8,
  51. MPP_FUNCTION(0, "gpio", NULL),
  52. MPP_FUNCTION(1, "sdio", "d5"),
  53. MPP_FUNCTION(3, "uart1", "txd")),
  54. MPP_MODE(9,
  55. MPP_FUNCTION(0, "gpio", NULL),
  56. MPP_FUNCTION(1, "sdio", "d6"),
  57. MPP_FUNCTION(3, "spi0", "cs1n")),
  58. MPP_MODE(10,
  59. MPP_FUNCTION(0, "gpio", NULL),
  60. MPP_FUNCTION(1, "sdio", "d7")),
  61. MPP_MODE(11,
  62. MPP_FUNCTION(0, "gpio", NULL),
  63. MPP_FUNCTION(3, "uart0", "txd")),
  64. MPP_MODE(12,
  65. MPP_FUNCTION(0, "gpio", NULL),
  66. MPP_FUNCTION(1, "sdio", "pw_off"),
  67. MPP_FUNCTION(2, "sdio", "hw_rst")),
  68. MPP_MODE(13,
  69. MPP_FUNCTION(0, "gpio", NULL)),
  70. MPP_MODE(14,
  71. MPP_FUNCTION(0, "gpio", NULL)),
  72. MPP_MODE(15,
  73. MPP_FUNCTION(0, "gpio", NULL)),
  74. MPP_MODE(16,
  75. MPP_FUNCTION(0, "gpio", NULL)),
  76. MPP_MODE(17,
  77. MPP_FUNCTION(0, "gpio", NULL)),
  78. MPP_MODE(18,
  79. MPP_FUNCTION(0, "gpio", NULL)),
  80. MPP_MODE(19,
  81. MPP_FUNCTION(0, "gpio", NULL),
  82. MPP_FUNCTION(3, "uart0", "rxd"),
  83. MPP_FUNCTION(4, "sdio", "pw_off")),
  84. };
  85. static struct mvebu_pinctrl_soc_info armada_ap806_pinctrl_info;
  86. static const struct of_device_id armada_ap806_pinctrl_of_match[] = {
  87. {
  88. .compatible = "marvell,ap806-pinctrl",
  89. },
  90. { },
  91. };
  92. static const struct mvebu_mpp_ctrl armada_ap806_mpp_controls[] = {
  93. MPP_FUNC_CTRL(0, 19, NULL, mvebu_regmap_mpp_ctrl),
  94. };
  95. static struct pinctrl_gpio_range armada_ap806_mpp_gpio_ranges[] = {
  96. MPP_GPIO_RANGE(0, 0, 0, 20),
  97. };
  98. static int armada_ap806_pinctrl_probe(struct platform_device *pdev)
  99. {
  100. struct mvebu_pinctrl_soc_info *soc = &armada_ap806_pinctrl_info;
  101. const struct of_device_id *match =
  102. of_match_device(armada_ap806_pinctrl_of_match, &pdev->dev);
  103. if (!match || !pdev->dev.parent)
  104. return -ENODEV;
  105. soc->variant = 0; /* no variants for Armada AP806 */
  106. soc->controls = armada_ap806_mpp_controls;
  107. soc->ncontrols = ARRAY_SIZE(armada_ap806_mpp_controls);
  108. soc->gpioranges = armada_ap806_mpp_gpio_ranges;
  109. soc->ngpioranges = ARRAY_SIZE(armada_ap806_mpp_gpio_ranges);
  110. soc->modes = armada_ap806_mpp_modes;
  111. soc->nmodes = armada_ap806_mpp_controls[0].npins;
  112. pdev->dev.platform_data = soc;
  113. return mvebu_pinctrl_simple_regmap_probe(pdev, pdev->dev.parent, 0);
  114. }
  115. static struct platform_driver armada_ap806_pinctrl_driver = {
  116. .driver = {
  117. .name = "armada-ap806-pinctrl",
  118. .of_match_table = of_match_ptr(armada_ap806_pinctrl_of_match),
  119. },
  120. .probe = armada_ap806_pinctrl_probe,
  121. };
  122. builtin_platform_driver(armada_ap806_pinctrl_driver);