2
0

0520-esw-gmac.patch 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. --- a/drivers/net/ethernet/mediatek/esw_rt3050.c
  2. +++ b/drivers/net/ethernet/mediatek/esw_rt3050.c
  3. @@ -221,6 +221,8 @@ struct rt305x_esw {
  4. unsigned char port_map;
  5. unsigned char port_disable;
  6. + unsigned int reg_initval_fct2;
  7. + unsigned int reg_initval_fpa2;
  8. unsigned int reg_led_polarity;
  9. struct switch_dev swdev;
  10. @@ -452,7 +454,10 @@ static void esw_hw_init(struct rt305x_es
  11. (RT305X_ESW_PORTS_NOCPU << RT305X_ESW_POC2_UNTAG_EN_S)),
  12. RT305X_ESW_REG_POC2);
  13. - esw_w32(esw, 0x0002500c, RT305X_ESW_REG_FCT2);
  14. + if (esw->reg_initval_fct2)
  15. + esw_w32(esw, esw->reg_initval_fct2, RT305X_ESW_REG_FCT2);
  16. + else
  17. + esw_w32(esw, 0x0002500c, RT305X_ESW_REG_FCT2);
  18. /* 300s aging timer, max packet len 1536, broadcast storm prevention
  19. * disabled, disable collision abort, mac xor48 hash, 10 packet back
  20. @@ -475,7 +480,10 @@ static void esw_hw_init(struct rt305x_es
  21. * port5: disabled
  22. * port6: enabled, gige, full-duplex, rx/tx-flow-control
  23. */
  24. - esw_w32(esw, 0x3f502b28, RT305X_ESW_REG_FPA2);
  25. + if (esw->reg_initval_fpa2)
  26. + esw_w32(esw, esw->reg_initval_fpa2, RT305X_ESW_REG_FPA2);
  27. + else
  28. + esw_w32(esw, 0x3f502b28, RT305X_ESW_REG_FPA2);
  29. esw_w32(esw, 0x00000000, RT305X_ESW_REG_FPA);
  30. /* Force Link/Activity on ports */
  31. @@ -1361,6 +1369,14 @@ static int esw_probe(struct platform_dev
  32. if (port_disable)
  33. esw->port_disable = be32_to_cpu(*port_disable);
  34. + reg_init = of_get_property(np, "ralink,fct2", NULL);
  35. + if (reg_init)
  36. + esw->reg_initval_fct2 = be32_to_cpu(*reg_init);
  37. +
  38. + reg_init = of_get_property(np, "ralink,fpa2", NULL);
  39. + if (reg_init)
  40. + esw->reg_initval_fpa2 = be32_to_cpu(*reg_init);
  41. +
  42. reg_init = of_get_property(np, "mediatek,led_polarity", NULL);
  43. if (reg_init)
  44. esw->reg_led_polarity = be32_to_cpu(*reg_init);
  45. @@ -1386,6 +1402,18 @@ static int esw_probe(struct platform_dev
  46. esw_hw_init(esw);
  47. + reg_init = of_get_property(np, "ralink,rgmii", NULL);
  48. + if (reg_init && be32_to_cpu(*reg_init) == 1) {
  49. + /*
  50. + * External switch connected to RGMII interface.
  51. + * Unregister the switch device after initialization.
  52. + */
  53. + dev_err(&pdev->dev, "RGMII mode, not exporting switch device.\n");
  54. + unregister_switch(&esw->swdev);
  55. + platform_set_drvdata(pdev, NULL);
  56. + return -ENODEV;
  57. + }
  58. +
  59. ret = devm_request_irq(&pdev->dev, esw->irq, esw_interrupt, 0, "esw",
  60. esw);