pinctrl-armada-ap806.c 4.1 KB

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