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

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  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. @@ -55,7 +55,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. @@ -258,9 +258,10 @@ int __init board_register_devices(void)
  25. platform_device_register(&bcm63xx_gpio_leds);
  26. - if (board.ephy_reset_gpio && board.ephy_reset_gpio_flags)
  27. - gpio_request_one(board.ephy_reset_gpio,
  28. - board.ephy_reset_gpio_flags, "ephy-reset");
  29. + if (board.ephy_reset_gpio && board.ephy_reset_gpio_flags) {
  30. + bcm63xx_gpio_ephy_reset(board.ephy_reset_gpio,
  31. + board.ephy_reset_gpio_flags);
  32. + }
  33. return 0;
  34. }
  35. --- a/arch/mips/bcm63xx/gpio.c
  36. +++ b/arch/mips/bcm63xx/gpio.c
  37. @@ -8,15 +8,23 @@
  38. * Copyright (C) Jonas Gorski <jogo@openwrt.org>
  39. */
  40. +#include <asm/addrspace.h>
  41. +
  42. #include <linux/kernel.h>
  43. #include <linux/platform_device.h>
  44. #include <linux/basic_mmio_gpio.h>
  45. #include <linux/gpio.h>
  46. +#include <linux/gpio/machine.h>
  47. #include <bcm63xx_cpu.h>
  48. #include <bcm63xx_gpio.h>
  49. #include <bcm63xx_regs.h>
  50. +static const char * const gpio_chip_labels[] = {
  51. + "bcm63xx-gpio.0",
  52. + "bcm63xx-gpio.1",
  53. +};
  54. +
  55. static void __init bcm63xx_gpio_init_one(int id, int dir, int data, int ngpio)
  56. {
  57. struct resource res[2];
  58. @@ -64,3 +72,25 @@ int __init bcm63xx_gpio_init(void)
  59. return 0;
  60. }
  61. +
  62. +static struct gpiod_lookup_table ephy_reset = {
  63. + .dev_id = "bcm63xx_enet_shared.0",
  64. + .table = {
  65. + { /* filled at runtime */ },
  66. + { },
  67. + },
  68. +};
  69. +
  70. +
  71. +void bcm63xx_gpio_ephy_reset(int hw_gpio, enum gpio_lookup_flags flags)
  72. +{
  73. + if (ephy_reset.table[0].chip_label)
  74. + return;
  75. +
  76. + ephy_reset.table[0].chip_label = gpio_chip_labels[hw_gpio / 32];
  77. + ephy_reset.table[0].chip_hwnum = hw_gpio % 32;
  78. + ephy_reset.table[0].con_id = "ephy-reset";
  79. + ephy_reset.table[0].flags = flags;
  80. +
  81. + gpiod_add_lookup_table(&ephy_reset);
  82. +}
  83. --- a/arch/mips/include/asm/mach-bcm63xx/bcm63xx_gpio.h
  84. +++ b/arch/mips/include/asm/mach-bcm63xx/bcm63xx_gpio.h
  85. @@ -2,9 +2,11 @@
  86. #define BCM63XX_GPIO_H
  87. #include <linux/init.h>
  88. +#include <linux/gpio/machine.h>
  89. #include <bcm63xx_cpu.h>
  90. int __init bcm63xx_gpio_init(void);
  91. +void bcm63xx_gpio_ephy_reset(int hw_gpio, enum gpio_lookup_flags flags);
  92. static inline unsigned long bcm63xx_gpio_count(void)
  93. {
  94. --- a/arch/mips/include/asm/mach-bcm63xx/board_bcm963xx.h
  95. +++ b/arch/mips/include/asm/mach-bcm63xx/board_bcm963xx.h
  96. @@ -3,6 +3,7 @@
  97. #include <linux/types.h>
  98. #include <linux/gpio.h>
  99. +#include <linux/gpio/machine.h>
  100. #include <linux/leds.h>
  101. #include <bcm63xx_dev_enet.h>
  102. #include <bcm63xx_dev_usb_usbd.h>
  103. @@ -54,8 +55,8 @@ struct board_info {
  104. /* External PHY reset GPIO */
  105. unsigned int ephy_reset_gpio;
  106. - /* External PHY reset GPIO flags from gpio.h */
  107. - unsigned long ephy_reset_gpio_flags;
  108. + /* External PHY reset GPIO flags from gpio/machine.h */
  109. + enum gpio_lookup_flags ephy_reset_gpio_flags;
  110. /* fallback sprom config */
  111. struct fallback_sprom_data fallback_sprom;