0321-pinctrl-bcm2835-Return-pins-to-inputs-when-freed.patch 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. From 2e4f06a9b7276db1e2dafe33564ad5115f63a210 Mon Sep 17 00:00:00 2001
  2. From: Phil Elwell <phil@raspberrypi.org>
  3. Date: Fri, 6 May 2016 12:32:47 +0100
  4. Subject: [PATCH 321/381] pinctrl-bcm2835: Return pins to inputs when freed
  5. When dynamically unloading overlays, it is important that freed pins are
  6. restored to being inputs to prevent functions from being enabled in
  7. multiple places at once.
  8. Signed-off-by: Phil Elwell <phil@raspberrypi.org>
  9. ---
  10. drivers/pinctrl/bcm/pinctrl-bcm2835.c | 10 ++++++++++
  11. 1 file changed, 10 insertions(+)
  12. --- a/drivers/pinctrl/bcm/pinctrl-bcm2835.c
  13. +++ b/drivers/pinctrl/bcm/pinctrl-bcm2835.c
  14. @@ -831,6 +831,15 @@ static const struct pinctrl_ops bcm2835_
  15. .dt_free_map = bcm2835_pctl_dt_free_map,
  16. };
  17. +static void bcm2835_pmx_free(struct pinctrl_dev *pctldev,
  18. + unsigned offset)
  19. +{
  20. + struct bcm2835_pinctrl *pc = pinctrl_dev_get_drvdata(pctldev);
  21. +
  22. + /* disable by setting to GPIO_IN */
  23. + bcm2835_pinctrl_fsel_set(pc, offset, BCM2835_FSEL_GPIO_IN);
  24. +}
  25. +
  26. static int bcm2835_pmx_get_functions_count(struct pinctrl_dev *pctldev)
  27. {
  28. return BCM2835_FSEL_COUNT;
  29. @@ -890,6 +899,7 @@ static int bcm2835_pmx_gpio_set_directio
  30. }
  31. static const struct pinmux_ops bcm2835_pmx_ops = {
  32. + .free = bcm2835_pmx_free,
  33. .get_functions_count = bcm2835_pmx_get_functions_count,
  34. .get_function_name = bcm2835_pmx_get_function_name,
  35. .get_function_groups = bcm2835_pmx_get_function_groups,