377-MIPS-BCM63XX-register-lookup-for-ephy-reset-gpio.patch 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138
  1. From d13bdf92ec885105cf107183f8464c40e5f3b93b Mon Sep 17 00:00:00 2001
  2. From: Jonas Gorski <jogo@openwrt.org>
  3. Date: Sat, 21 Feb 2015 17:21:59 +0100
  4. Subject: [PATCH 4/6] MIPS: BCM63XX: register lookup for ephy-reset gpio
  5. Signed-off-by: Jonas Gorski <jogo@openwrt.org>
  6. ---
  7. arch/mips/bcm63xx/boards/board_bcm963xx.c | 2 +-
  8. arch/mips/bcm63xx/boards/board_common.c | 7 +++--
  9. arch/mips/bcm63xx/gpio.c | 32 ++++++++++++++++++++
  10. arch/mips/include/asm/mach-bcm63xx/bcm63xx_gpio.h | 2 ++
  11. .../mips/include/asm/mach-bcm63xx/board_bcm963xx.h | 5 +--
  12. 5 files changed, 42 insertions(+), 6 deletions(-)
  13. --- a/arch/mips/bcm63xx/boards/board_bcm963xx.c
  14. +++ b/arch/mips/bcm63xx/boards/board_bcm963xx.c
  15. @@ -59,7 +59,7 @@ static struct board_info __initdata boar
  16. },
  17. .ephy_reset_gpio = 36,
  18. - .ephy_reset_gpio_flags = GPIOF_INIT_HIGH,
  19. + .ephy_reset_gpio_flags = GPIO_ACTIVE_LOW,
  20. };
  21. #endif
  22. --- a/arch/mips/bcm63xx/boards/board_common.c
  23. +++ b/arch/mips/bcm63xx/boards/board_common.c
  24. @@ -278,9 +278,10 @@ int __init board_register_devices(void)
  25. platform_device_register(&bcm63xx_gpio_leds);
  26. }
  27. - if (board.ephy_reset_gpio && board.ephy_reset_gpio_flags)
  28. - gpio_request_one(board.ephy_reset_gpio,
  29. - board.ephy_reset_gpio_flags, "ephy-reset");
  30. + if (board.ephy_reset_gpio && board.ephy_reset_gpio_flags) {
  31. + bcm63xx_gpio_ephy_reset(board.ephy_reset_gpio,
  32. + board.ephy_reset_gpio_flags);
  33. + }
  34. /* count number of BUTTONs defined by this device */
  35. while (button_count < ARRAY_SIZE(board.buttons) && board.buttons[button_count].desc)
  36. --- a/arch/mips/bcm63xx/gpio.c
  37. +++ b/arch/mips/bcm63xx/gpio.c
  38. @@ -8,15 +8,24 @@
  39. * Copyright (C) Jonas Gorski <jogo@openwrt.org>
  40. */
  41. +#include <asm/addrspace.h>
  42. +
  43. #include <linux/kernel.h>
  44. #include <linux/platform_device.h>
  45. #include <linux/basic_mmio_gpio.h>
  46. #include <linux/gpio.h>
  47. +#include <linux/gpio/machine.h>
  48. #include <bcm63xx_cpu.h>
  49. #include <bcm63xx_gpio.h>
  50. #include <bcm63xx_regs.h>
  51. +/* for registering lookups; make them large enough to hold OF names */
  52. +static char *gpio_chip_labels[] = {
  53. + "xxxxxxxx.gpio-controller",
  54. + "xxxxxxxx.gpio-controller",
  55. +};
  56. +
  57. static void __init bcm63xx_gpio_init_one(int id, int dir, int data, int ngpio)
  58. {
  59. struct resource res[2];
  60. @@ -40,6 +49,7 @@ static void __init bcm63xx_gpio_init_one
  61. pdata.base = id * 32;
  62. pdata.ngpio = ngpio;
  63. + sprintf(gpio_chip_labels[id], "bcm63xx-gpio.%d", id);
  64. platform_device_register_resndata(NULL, "bcm63xx-gpio", id, res, 2,
  65. &pdata, sizeof(pdata));
  66. }
  67. @@ -64,3 +74,25 @@ int __init bcm63xx_gpio_init(void)
  68. return 0;
  69. }
  70. +
  71. +static struct gpiod_lookup_table ephy_reset = {
  72. + .dev_id = "bcm63xx_enet_shared.0",
  73. + .table = {
  74. + { /* filled at runtime */ },
  75. + { },
  76. + },
  77. +};
  78. +
  79. +
  80. +void bcm63xx_gpio_ephy_reset(int hw_gpio, enum gpio_lookup_flags flags)
  81. +{
  82. + if (ephy_reset.table[0].chip_label)
  83. + return;
  84. +
  85. + ephy_reset.table[0].chip_label = gpio_chip_labels[hw_gpio / 32];
  86. + ephy_reset.table[0].chip_hwnum = hw_gpio % 32;
  87. + ephy_reset.table[0].con_id = "ephy-reset";
  88. + ephy_reset.table[0].flags = flags;
  89. +
  90. + gpiod_add_lookup_table(&ephy_reset);
  91. +}
  92. --- a/arch/mips/include/asm/mach-bcm63xx/bcm63xx_gpio.h
  93. +++ b/arch/mips/include/asm/mach-bcm63xx/bcm63xx_gpio.h
  94. @@ -2,9 +2,11 @@
  95. #define BCM63XX_GPIO_H
  96. #include <linux/init.h>
  97. +#include <linux/gpio/machine.h>
  98. #include <bcm63xx_cpu.h>
  99. int __init bcm63xx_gpio_init(void);
  100. +void bcm63xx_gpio_ephy_reset(int hw_gpio, enum gpio_lookup_flags flags);
  101. static inline unsigned long bcm63xx_gpio_count(void)
  102. {
  103. --- a/arch/mips/include/asm/mach-bcm63xx/board_bcm963xx.h
  104. +++ b/arch/mips/include/asm/mach-bcm63xx/board_bcm963xx.h
  105. @@ -4,6 +4,7 @@
  106. #include <linux/types.h>
  107. #include <linux/gpio.h>
  108. #include <linux/gpio_keys.h>
  109. +#include <linux/gpio/machine.h>
  110. #include <linux/leds.h>
  111. #include <bcm63xx_dev_enet.h>
  112. #include <bcm63xx_dev_usb_usbd.h>
  113. @@ -58,8 +59,8 @@ struct board_info {
  114. /* External PHY reset GPIO */
  115. unsigned int ephy_reset_gpio;
  116. - /* External PHY reset GPIO flags from gpio.h */
  117. - unsigned long ephy_reset_gpio_flags;
  118. + /* External PHY reset GPIO flags from gpio/machine.h */
  119. + enum gpio_lookup_flags ephy_reset_gpio_flags;
  120. /* fallback sprom config */
  121. struct fallback_sprom_data fallback_sprom;