002-net-usb-r8152-add-LED-configuration-from-OF.patch 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. From 82985725e071f2a5735052f18e109a32aeac3a0b Mon Sep 17 00:00:00 2001
  2. From: David Bauer <mail@david-bauer.net>
  3. Date: Sun, 26 Jul 2020 02:38:31 +0200
  4. Subject: [PATCH] net: usb: r8152: add LED configuration from OF
  5. This adds the ability to configure the LED configuration register using
  6. OF. This way, the correct value for board specific LED configuration can
  7. be determined.
  8. Signed-off-by: David Bauer <mail@david-bauer.net>
  9. ---
  10. drivers/net/usb/r8152.c | 23 +++++++++++++++++++++++
  11. 1 file changed, 23 insertions(+)
  12. --- a/drivers/net/usb/r8152.c
  13. +++ b/drivers/net/usb/r8152.c
  14. @@ -15,6 +15,7 @@
  15. #include <linux/mii.h>
  16. #include <linux/ethtool.h>
  17. #include <linux/usb.h>
  18. +#include <linux/of.h>
  19. #include <linux/crc32.h>
  20. #include <linux/if_vlan.h>
  21. #include <linux/uaccess.h>
  22. @@ -3974,6 +3975,22 @@ static void rtl_tally_reset(struct r8152
  23. ocp_write_word(tp, MCU_TYPE_PLA, PLA_RSTTALLY, ocp_data);
  24. }
  25. +static int r8152_led_configuration(struct r8152 *tp)
  26. +{
  27. + u32 led_data;
  28. + int ret;
  29. +
  30. + ret = of_property_read_u32(tp->udev->dev.of_node, "realtek,led-data",
  31. + &led_data);
  32. +
  33. + if (ret)
  34. + return ret;
  35. +
  36. + ocp_write_word(tp, MCU_TYPE_PLA, PLA_LEDSEL, led_data);
  37. +
  38. + return 0;
  39. +}
  40. +
  41. static void r8152b_init(struct r8152 *tp)
  42. {
  43. u32 ocp_data;
  44. @@ -4015,6 +4032,8 @@ static void r8152b_init(struct r8152 *tp
  45. ocp_data = ocp_read_word(tp, MCU_TYPE_USB, USB_USB_CTRL);
  46. ocp_data &= ~(RX_AGG_DISABLE | RX_ZERO_EN);
  47. ocp_write_word(tp, MCU_TYPE_USB, USB_USB_CTRL, ocp_data);
  48. +
  49. + r8152_led_configuration(tp);
  50. }
  51. static void r8153_init(struct r8152 *tp)
  52. @@ -4138,6 +4157,8 @@ static void r8153_init(struct r8152 *tp)
  53. tp->coalesce = COALESCE_SLOW;
  54. break;
  55. }
  56. +
  57. + r8152_led_configuration(tp);
  58. }
  59. static void r8153b_init(struct r8152 *tp)
  60. @@ -4201,6 +4222,8 @@ static void r8153b_init(struct r8152 *tp
  61. rtl_tally_reset(tp);
  62. tp->coalesce = 15000; /* 15 us */
  63. +
  64. + r8152_led_configuration(tp);
  65. }
  66. static int rtl8152_pre_reset(struct usb_interface *intf)