0023-MIPS-ralink-mt7620-fix-usb-issue-during-frequency-sc.patch 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. From 1f1c12e85defba9459b41ec95b86f23b4791f1ab Mon Sep 17 00:00:00 2001
  2. From: John Crispin <blogic@openwrt.org>
  3. Date: Mon, 4 Aug 2014 20:43:25 +0200
  4. Subject: [PATCH 23/57] MIPS: ralink: mt7620: fix usb issue during frequency
  5. scaling
  6. If the USB HCD is running and the cpu is scaled too low, then the USB stops
  7. working. Increase the idle speed of the core to fix this if the kernel is
  8. built with USB support.
  9. The values are taken from the Ralink SDK Kernel.
  10. Signed-off-by: John Crispin <blogic@openwrt.org>
  11. ---
  12. arch/mips/ralink/mt7620.c | 19 +++++++++++++++++++
  13. 1 file changed, 19 insertions(+)
  14. --- a/arch/mips/ralink/mt7620.c
  15. +++ b/arch/mips/ralink/mt7620.c
  16. @@ -36,6 +36,12 @@
  17. #define PMU1_CFG 0x8C
  18. #define DIG_SW_SEL BIT(25)
  19. +/* clock scaling */
  20. +#define CLKCFG_FDIV_MASK 0x1f00
  21. +#define CLKCFG_FDIV_USB_VAL 0x0300
  22. +#define CLKCFG_FFRAC_MASK 0x001f
  23. +#define CLKCFG_FFRAC_USB_VAL 0x0003
  24. +
  25. /* does the board have sdram or ddram */
  26. static int dram_type;
  27. @@ -337,6 +343,19 @@ void __init ralink_clk_init(void)
  28. ralink_clk_add("10000b00.spi", sys_rate);
  29. ralink_clk_add("10000c00.uartlite", periph_rate);
  30. ralink_clk_add("10180000.wmac", xtal_rate);
  31. +
  32. + if (IS_ENABLED(CONFIG_USB)) {
  33. + /*
  34. + * When the CPU goes into sleep mode, the BUS clock will be too low for
  35. + * USB to function properly
  36. + */
  37. + u32 val = rt_sysc_r32(SYSC_REG_CPU_SYS_CLKCFG);
  38. +
  39. + val &= ~(CLKCFG_FDIV_MASK | CLKCFG_FFRAC_MASK);
  40. + val |= CLKCFG_FDIV_USB_VAL | CLKCFG_FFRAC_USB_VAL;
  41. +
  42. + rt_sysc_w32(val, SYSC_REG_CPU_SYS_CLKCFG);
  43. + }
  44. }
  45. void __init ralink_of_remap(void)