Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

mips: pci-mt7620: add more register init values

These missing register init values are ported from the vendor SDK.
It should have some stability enhancements. Tested on both MT7620
and MT7628.

Signed-off-by: Shiji Yang <yangshiji66@outlook.com>
Signed-off-by: Thomas Bogendoerfer <tsbogend@alpha.franken.de>

authored by

Shiji Yang and committed by
Thomas Bogendoerfer
c2631cc4 3dbb0827

+45 -12
+45 -12
arch/mips/pci/pci-mt7620.c
··· 26 26 27 27 #define RALINK_INT_PCIE0 4 28 28 29 + #define RALINK_SYSCFG0 0x10 30 + #define RALINK_SYSCFG0_XTAL40 BIT(6) 29 31 #define RALINK_CLKCFG1 0x30 30 32 #define RALINK_GPIOMODE 0x60 31 33 ··· 64 62 65 63 #define PCIEPHY0_CFG 0x90 66 64 67 - #define RALINK_PCIEPHY_P0_CTL_OFFSET 0x7498 65 + #define RALINK_PCIEPHY_P0_CTL_OFFSET 0x7000 68 66 #define RALINK_PCIE0_CLK_EN BIT(26) 69 67 70 68 #define BUSY 0x80000000 ··· 115 113 val &= ~clr; 116 114 val |= set; 117 115 pcie_w32(val, reg); 116 + } 117 + 118 + static inline void 119 + pcie_phyctrl_set(unsigned offset, u32 b_start, u32 bits, u32 val) 120 + { 121 + pcie_m32(GENMASK(b_start + bits - 1, b_start), 122 + val << b_start, 123 + RALINK_PCIEPHY_P0_CTL_OFFSET + offset); 118 124 } 119 125 120 126 static int wait_pciephy_busy(void) ··· 273 263 return 0; 274 264 } 275 265 276 - static int mt7628_pci_hw_init(struct platform_device *pdev) 266 + static void mt7628_pci_hw_init(struct platform_device *pdev) 277 267 { 278 - u32 val = 0; 279 - 280 268 /* bring the core out of reset */ 281 269 rt_sysc_m32(BIT(16), 0, RALINK_GPIOMODE); 282 270 reset_control_deassert(rstpcie0); ··· 284 276 mdelay(100); 285 277 286 278 /* voodoo from the SDK driver */ 287 - pcie_m32(~0xff, 0x5, RALINK_PCIEPHY_P0_CTL_OFFSET); 279 + pcie_phyctrl_set(0x400, 8, 1, 0x1); 280 + pcie_phyctrl_set(0x400, 9, 2, 0x0); 281 + pcie_phyctrl_set(0x000, 4, 1, 0x1); 282 + pcie_phyctrl_set(0x000, 5, 1, 0x0); 283 + pcie_phyctrl_set(0x4ac, 16, 3, 0x3); 288 284 289 - pci_config_read(NULL, 0, 0x70c, 4, &val); 290 - val &= ~(0xff) << 8; 291 - val |= 0x50 << 8; 292 - pci_config_write(NULL, 0, 0x70c, 4, val); 285 + if (rt_sysc_r32(RALINK_SYSCFG0) & RALINK_SYSCFG0_XTAL40) { 286 + pcie_phyctrl_set(0x4bc, 24, 8, 0x7d); 287 + pcie_phyctrl_set(0x490, 12, 4, 0x08); 288 + pcie_phyctrl_set(0x490, 6, 2, 0x01); 289 + pcie_phyctrl_set(0x4c0, 0, 32, 0x1f400000); 290 + pcie_phyctrl_set(0x4a4, 0, 16, 0x013d); 291 + pcie_phyctrl_set(0x4a8, 16, 16, 0x74); 292 + pcie_phyctrl_set(0x4a8, 0, 16, 0x74); 293 + } else { 294 + pcie_phyctrl_set(0x4bc, 24, 8, 0x64); 295 + pcie_phyctrl_set(0x490, 12, 4, 0x0a); 296 + pcie_phyctrl_set(0x490, 6, 2, 0x00); 297 + pcie_phyctrl_set(0x4c0, 0, 32, 0x19000000); 298 + pcie_phyctrl_set(0x4a4, 0, 16, 0x018d); 299 + pcie_phyctrl_set(0x4a8, 16, 16, 0x4a); 300 + pcie_phyctrl_set(0x4a8, 0, 16, 0x4a); 301 + } 293 302 294 - return 0; 303 + pcie_phyctrl_set(0x498, 0, 8, 0x5); 304 + pcie_phyctrl_set(0x000, 5, 1, 0x1); 305 + pcie_phyctrl_set(0x000, 4, 1, 0x0); 295 306 } 296 307 297 308 static int mt7620_pci_probe(struct platform_device *pdev) ··· 343 316 344 317 case MT762X_SOC_MT7628AN: 345 318 case MT762X_SOC_MT7688: 346 - if (mt7628_pci_hw_init(pdev)) 347 - return -1; 319 + mt7628_pci_hw_init(pdev); 348 320 break; 349 321 350 322 default: ··· 362 336 rt_sysc_m32(RALINK_PCIE0_CLK_EN, 0, RALINK_CLKCFG1); 363 337 if (ralink_soc == MT762X_SOC_MT7620A) 364 338 rt_sysc_m32(LC_CKDRVPD, PDRV_SW_SET, PPLL_DRV); 339 + else 340 + pcie_phyctrl_set(0x000, 0, 32, 0x10); 365 341 dev_info(&pdev->dev, "PCIE0 no card, disable it(RST&CLK)\n"); 366 342 return -1; 367 343 } ··· 382 354 /* voodoo from the SDK driver */ 383 355 pci_config_read(NULL, 0, 4, 4, &val); 384 356 pci_config_write(NULL, 0, 4, 4, val | 0x7); 357 + 358 + pci_config_read(NULL, 0, 0x70c, 4, &val); 359 + val &= ~(0xff) << 8; 360 + val |= 0x50 << 8; 361 + pci_config_write(NULL, 0, 0x70c, 4, val); 385 362 386 363 pci_load_of_ranges(&mt7620_controller, pdev->dev.of_node); 387 364 register_pci_controller(&mt7620_controller);