clk-efm32gg.c 3.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. /*
  2. * Copyright (C) 2013 Pengutronix
  3. * Uwe Kleine-Koenig <u.kleine-koenig@pengutronix.de>
  4. *
  5. * This program is free software; you can redistribute it and/or modify it under
  6. * the terms of the GNU General Public License version 2 as published by the
  7. * Free Software Foundation.
  8. */
  9. #include <linux/io.h>
  10. #include <linux/clk-provider.h>
  11. #include <linux/of.h>
  12. #include <linux/of_address.h>
  13. #include <dt-bindings/clock/efm32-cmu.h>
  14. #define CMU_HFPERCLKEN0 0x44
  15. static struct clk *clk[37];
  16. static struct clk_onecell_data clk_data = {
  17. .clks = clk,
  18. .clk_num = ARRAY_SIZE(clk),
  19. };
  20. static void __init efm32gg_cmu_init(struct device_node *np)
  21. {
  22. int i;
  23. void __iomem *base;
  24. for (i = 0; i < ARRAY_SIZE(clk); ++i)
  25. clk[i] = ERR_PTR(-ENOENT);
  26. base = of_iomap(np, 0);
  27. if (!base) {
  28. pr_warn("Failed to map address range for efm32gg,cmu node\n");
  29. return;
  30. }
  31. clk[clk_HFXO] = clk_register_fixed_rate(NULL, "HFXO", NULL,
  32. CLK_IS_ROOT, 48000000);
  33. clk[clk_HFPERCLKUSART0] = clk_register_gate(NULL, "HFPERCLK.USART0",
  34. "HFXO", 0, base + CMU_HFPERCLKEN0, 0, 0, NULL);
  35. clk[clk_HFPERCLKUSART1] = clk_register_gate(NULL, "HFPERCLK.USART1",
  36. "HFXO", 0, base + CMU_HFPERCLKEN0, 1, 0, NULL);
  37. clk[clk_HFPERCLKUSART2] = clk_register_gate(NULL, "HFPERCLK.USART2",
  38. "HFXO", 0, base + CMU_HFPERCLKEN0, 2, 0, NULL);
  39. clk[clk_HFPERCLKUART0] = clk_register_gate(NULL, "HFPERCLK.UART0",
  40. "HFXO", 0, base + CMU_HFPERCLKEN0, 3, 0, NULL);
  41. clk[clk_HFPERCLKUART1] = clk_register_gate(NULL, "HFPERCLK.UART1",
  42. "HFXO", 0, base + CMU_HFPERCLKEN0, 4, 0, NULL);
  43. clk[clk_HFPERCLKTIMER0] = clk_register_gate(NULL, "HFPERCLK.TIMER0",
  44. "HFXO", 0, base + CMU_HFPERCLKEN0, 5, 0, NULL);
  45. clk[clk_HFPERCLKTIMER1] = clk_register_gate(NULL, "HFPERCLK.TIMER1",
  46. "HFXO", 0, base + CMU_HFPERCLKEN0, 6, 0, NULL);
  47. clk[clk_HFPERCLKTIMER2] = clk_register_gate(NULL, "HFPERCLK.TIMER2",
  48. "HFXO", 0, base + CMU_HFPERCLKEN0, 7, 0, NULL);
  49. clk[clk_HFPERCLKTIMER3] = clk_register_gate(NULL, "HFPERCLK.TIMER3",
  50. "HFXO", 0, base + CMU_HFPERCLKEN0, 8, 0, NULL);
  51. clk[clk_HFPERCLKACMP0] = clk_register_gate(NULL, "HFPERCLK.ACMP0",
  52. "HFXO", 0, base + CMU_HFPERCLKEN0, 9, 0, NULL);
  53. clk[clk_HFPERCLKACMP1] = clk_register_gate(NULL, "HFPERCLK.ACMP1",
  54. "HFXO", 0, base + CMU_HFPERCLKEN0, 10, 0, NULL);
  55. clk[clk_HFPERCLKI2C0] = clk_register_gate(NULL, "HFPERCLK.I2C0",
  56. "HFXO", 0, base + CMU_HFPERCLKEN0, 11, 0, NULL);
  57. clk[clk_HFPERCLKI2C1] = clk_register_gate(NULL, "HFPERCLK.I2C1",
  58. "HFXO", 0, base + CMU_HFPERCLKEN0, 12, 0, NULL);
  59. clk[clk_HFPERCLKGPIO] = clk_register_gate(NULL, "HFPERCLK.GPIO",
  60. "HFXO", 0, base + CMU_HFPERCLKEN0, 13, 0, NULL);
  61. clk[clk_HFPERCLKVCMP] = clk_register_gate(NULL, "HFPERCLK.VCMP",
  62. "HFXO", 0, base + CMU_HFPERCLKEN0, 14, 0, NULL);
  63. clk[clk_HFPERCLKPRS] = clk_register_gate(NULL, "HFPERCLK.PRS",
  64. "HFXO", 0, base + CMU_HFPERCLKEN0, 15, 0, NULL);
  65. clk[clk_HFPERCLKADC0] = clk_register_gate(NULL, "HFPERCLK.ADC0",
  66. "HFXO", 0, base + CMU_HFPERCLKEN0, 16, 0, NULL);
  67. clk[clk_HFPERCLKDAC0] = clk_register_gate(NULL, "HFPERCLK.DAC0",
  68. "HFXO", 0, base + CMU_HFPERCLKEN0, 17, 0, NULL);
  69. of_clk_add_provider(np, of_clk_src_onecell_get, &clk_data);
  70. }
  71. CLK_OF_DECLARE(efm32ggcmu, "efm32gg,cmu", efm32gg_cmu_init);