0301-mt7688-detect.patch 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  1. --- a/arch/mips/include/asm/mach-ralink/mt7620.h
  2. +++ b/arch/mips/include/asm/mach-ralink/mt7620.h
  3. @@ -17,6 +17,7 @@
  4. #define SYSC_REG_CHIP_NAME0 0x00
  5. #define SYSC_REG_CHIP_NAME1 0x04
  6. +#define SYSC_REG_EFUSE_CFG 0x08
  7. #define SYSC_REG_CHIP_REV 0x0c
  8. #define SYSC_REG_SYSTEM_CONFIG0 0x10
  9. #define SYSC_REG_SYSTEM_CONFIG1 0x14
  10. --- a/arch/mips/ralink/mt7620.c
  11. +++ b/arch/mips/ralink/mt7620.c
  12. @@ -43,6 +43,9 @@
  13. #define CLKCFG_FFRAC_MASK 0x001f
  14. #define CLKCFG_FFRAC_USB_VAL 0x0003
  15. +/* EFUSE bits */
  16. +#define EFUSE_MT7688 0x100000
  17. +
  18. /* does the board have sdram or ddram */
  19. static int dram_type;
  20. @@ -391,7 +394,7 @@ void __init ralink_clk_init(void)
  21. #define RINT(x) ((x) / 1000000)
  22. #define RFRAC(x) (((x) / 1000) % 1000)
  23. - if (ralink_soc == MT762X_SOC_MT7628AN) {
  24. + if (ralink_soc == MT762X_SOC_MT7628AN || ralink_soc == MT762X_SOC_MT7688) {
  25. if (xtal_rate == MHZ(40))
  26. cpu_rate = MHZ(580);
  27. else
  28. @@ -436,7 +439,8 @@ void __init ralink_clk_init(void)
  29. ralink_clk_add("10000e00.uart2", periph_rate);
  30. ralink_clk_add("10180000.wmac", xtal_rate);
  31. - if (IS_ENABLED(CONFIG_USB) && ralink_soc != MT762X_SOC_MT7628AN) {
  32. + if (IS_ENABLED(CONFIG_USB) &&
  33. + (ralink_soc == MT762X_SOC_MT7620A || ralink_soc == MT762X_SOC_MT7620N)) {
  34. /*
  35. * When the CPU goes into sleep mode, the BUS clock will be too low for
  36. * USB to function properly
  37. @@ -536,8 +540,15 @@ void prom_soc_init(struct ralink_soc_inf
  38. #endif
  39. }
  40. } else if (n0 == MT7620_CHIP_NAME0 && n1 == MT7628_CHIP_NAME1) {
  41. - ralink_soc = MT762X_SOC_MT7628AN;
  42. - name = "MT7628AN";
  43. + u32 efuse = __raw_readl(sysc + SYSC_REG_EFUSE_CFG);
  44. +
  45. + if (efuse & EFUSE_MT7688) {
  46. + ralink_soc = MT762X_SOC_MT7688;
  47. + name = "MT7688";
  48. + } else {
  49. + ralink_soc = MT762X_SOC_MT7628AN;
  50. + name = "MT7628AN";
  51. + }
  52. soc_info->compatible = "ralink,mt7628an-soc";
  53. } else {
  54. panic("mt762x: unknown SoC, n0:%08x n1:%08x\n", n0, n1);
  55. @@ -551,13 +562,13 @@ void prom_soc_init(struct ralink_soc_inf
  56. cfg0 = __raw_readl(sysc + SYSC_REG_SYSTEM_CONFIG0);
  57. - if (ralink_soc == MT762X_SOC_MT7628AN)
  58. + if (ralink_soc == MT762X_SOC_MT7628AN || ralink_soc == MT762X_SOC_MT7688)
  59. dram_type = ((cfg0&0x00000001) == 0x00000001)?SYSCFG0_DRAM_TYPE_DDR1_MT7628:SYSCFG0_DRAM_TYPE_DDR2_MT7628;
  60. else
  61. dram_type = (cfg0 >> SYSCFG0_DRAM_TYPE_SHIFT) & SYSCFG0_DRAM_TYPE_MASK;
  62. soc_info->mem_base = MT7620_DRAM_BASE;
  63. - if (ralink_soc == MT762X_SOC_MT7628AN)
  64. + if (ralink_soc == MT762X_SOC_MT7628AN || ralink_soc == MT762X_SOC_MT7688)
  65. mt7628_dram_init(soc_info);
  66. else
  67. mt7620_dram_init(soc_info);
  68. @@ -570,7 +581,7 @@ void prom_soc_init(struct ralink_soc_inf
  69. pr_info("Digital PMU set to %s control\n",
  70. (pmu1 & DIG_SW_SEL) ? ("sw") : ("hw"));
  71. - if (ralink_soc == MT762X_SOC_MT7628AN)
  72. + if (ralink_soc == MT762X_SOC_MT7628AN || ralink_soc == MT762X_SOC_MT7688)
  73. rt2880_pinmux_data = mt7628an_pinmux_data;
  74. else
  75. rt2880_pinmux_data = mt7620a_pinmux_data;
  76. --- a/arch/mips/include/asm/mach-ralink/ralink_regs.h
  77. +++ b/arch/mips/include/asm/mach-ralink/ralink_regs.h
  78. @@ -24,6 +24,7 @@ enum ralink_soc_type {
  79. MT762X_SOC_MT7620N,
  80. MT762X_SOC_MT7621AT,
  81. MT762X_SOC_MT7628AN,
  82. + MT762X_SOC_MT7688,
  83. };
  84. extern enum ralink_soc_type ralink_soc;
  85. --- a/drivers/net/ethernet/ralink/esw_rt3052.c
  86. +++ b/drivers/net/ethernet/ralink/esw_rt3052.c
  87. @@ -618,7 +618,7 @@ static void esw_hw_init(struct rt305x_es
  88. rt305x_mii_write(esw, 0, 29, 0x598b);
  89. /* select local register */
  90. rt305x_mii_write(esw, 0, 31, 0x8000);
  91. - } else if (ralink_soc == MT762X_SOC_MT7628AN) {
  92. + } else if (ralink_soc == MT762X_SOC_MT7628AN || ralink_soc == MT762X_SOC_MT7688) {
  93. int i;
  94. // u32 phy_val;
  95. u32 val;
  96. @@ -1049,7 +1049,7 @@ esw_get_port_tr_badgood(struct switch_de
  97. int shift = attr->id == RT5350_ESW_ATTR_PORT_TR_GOOD ? 0 : 16;
  98. u32 reg;
  99. - if ((ralink_soc != RT305X_SOC_RT5350) && (ralink_soc != MT762X_SOC_MT7628AN))
  100. + if ((ralink_soc != RT305X_SOC_RT5350) && (ralink_soc != MT762X_SOC_MT7628AN) && (ralink_soc != MT762X_SOC_MT7688))
  101. return -EINVAL;
  102. if (idx < 0 || idx >= RT305X_ESW_NUM_LANWAN)