0041-arm-mediatek-enable-gpt6-on-boot-up-to-make-arch-tim.patch 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. From eec99287ace37015ed313b4fc27ba205a158b66c Mon Sep 17 00:00:00 2001
  2. From: Matthias Brugger <[email protected]>
  3. Date: Fri, 1 May 2015 15:43:26 +0800
  4. Subject: [PATCH 41/76] arm: mediatek: enable gpt6 on boot up to make arch
  5. timer working
  6. We enable GTP6 which ungates the arch timer clock.
  7. In the future this should be done in the bootloader.
  8. Signed-off-by: Matthias Brugger <[email protected]>
  9. Signed-off-by: Yingjoe Chen <[email protected]>
  10. ---
  11. arch/arm/mach-mediatek/mediatek.c | 29 +++++++++++++++++++++++++++++
  12. 1 file changed, 29 insertions(+)
  13. --- a/arch/arm/mach-mediatek/mediatek.c
  14. +++ b/arch/arm/mach-mediatek/mediatek.c
  15. @@ -16,6 +16,34 @@
  16. */
  17. #include <linux/init.h>
  18. #include <asm/mach/arch.h>
  19. +#include <linux/of.h>
  20. +#include <linux/clk-provider.h>
  21. +#include <linux/clocksource.h>
  22. +
  23. +
  24. +#define GPT6_CON_MT65xx 0x10008060
  25. +#define GPT_ENABLE 0x31
  26. +
  27. +static void __init mediatek_timer_init(void)
  28. +{
  29. + void __iomem *gpt_base = 0;
  30. +
  31. + if (of_machine_is_compatible("mediatek,mt6589") ||
  32. + of_machine_is_compatible("mediatek,mt8135") ||
  33. + of_machine_is_compatible("mediatek,mt8127")) {
  34. + /* turn on GPT6 which ungates arch timer clocks */
  35. + gpt_base = ioremap(GPT6_CON_MT65xx, 0x04);
  36. + }
  37. +
  38. + /* enabel clock and set to free-run */
  39. + if (gpt_base) {
  40. + writel(GPT_ENABLE, gpt_base);
  41. + iounmap(gpt_base);
  42. + }
  43. +
  44. + of_clk_init(NULL);
  45. + clocksource_of_init();
  46. +};
  47. static const char * const mediatek_board_dt_compat[] = {
  48. "mediatek,mt6589",
  49. @@ -27,4 +55,5 @@ static const char * const mediatek_board
  50. DT_MACHINE_START(MEDIATEK_DT, "Mediatek Cortex-A7 (Device Tree)")
  51. .dt_compat = mediatek_board_dt_compat,
  52. + .init_time = mediatek_timer_init,
  53. MACHINE_END