pmc.h 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  1. /*
  2. * drivers/clk/at91/pmc.h
  3. *
  4. * Copyright (C) 2013 Boris BREZILLON <b.brezillon@overkiz.com>
  5. *
  6. * This program is free software; you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License as published by
  8. * the Free Software Foundation; either version 2 of the License, or
  9. * (at your option) any later version.
  10. */
  11. #ifndef __PMC_H_
  12. #define __PMC_H_
  13. #include <linux/io.h>
  14. #include <linux/irqdomain.h>
  15. #include <linux/spinlock.h>
  16. struct clk_range {
  17. unsigned long min;
  18. unsigned long max;
  19. };
  20. #define CLK_RANGE(MIN, MAX) {.min = MIN, .max = MAX,}
  21. struct at91_pmc_caps {
  22. u32 available_irqs;
  23. };
  24. struct at91_pmc {
  25. void __iomem *regbase;
  26. int virq;
  27. spinlock_t lock;
  28. const struct at91_pmc_caps *caps;
  29. struct irq_domain *irqdomain;
  30. u32 imr;
  31. };
  32. static inline void pmc_lock(struct at91_pmc *pmc)
  33. {
  34. spin_lock(&pmc->lock);
  35. }
  36. static inline void pmc_unlock(struct at91_pmc *pmc)
  37. {
  38. spin_unlock(&pmc->lock);
  39. }
  40. static inline u32 pmc_read(struct at91_pmc *pmc, int offset)
  41. {
  42. return readl(pmc->regbase + offset);
  43. }
  44. static inline void pmc_write(struct at91_pmc *pmc, int offset, u32 value)
  45. {
  46. writel(value, pmc->regbase + offset);
  47. }
  48. int of_at91_get_clk_range(struct device_node *np, const char *propname,
  49. struct clk_range *range);
  50. extern void __init of_at91sam9260_clk_slow_setup(struct device_node *np,
  51. struct at91_pmc *pmc);
  52. extern void __init of_at91rm9200_clk_main_osc_setup(struct device_node *np,
  53. struct at91_pmc *pmc);
  54. extern void __init of_at91sam9x5_clk_main_rc_osc_setup(struct device_node *np,
  55. struct at91_pmc *pmc);
  56. extern void __init of_at91rm9200_clk_main_setup(struct device_node *np,
  57. struct at91_pmc *pmc);
  58. extern void __init of_at91sam9x5_clk_main_setup(struct device_node *np,
  59. struct at91_pmc *pmc);
  60. extern void __init of_at91rm9200_clk_pll_setup(struct device_node *np,
  61. struct at91_pmc *pmc);
  62. extern void __init of_at91sam9g45_clk_pll_setup(struct device_node *np,
  63. struct at91_pmc *pmc);
  64. extern void __init of_at91sam9g20_clk_pllb_setup(struct device_node *np,
  65. struct at91_pmc *pmc);
  66. extern void __init of_sama5d3_clk_pll_setup(struct device_node *np,
  67. struct at91_pmc *pmc);
  68. extern void __init of_at91sam9x5_clk_plldiv_setup(struct device_node *np,
  69. struct at91_pmc *pmc);
  70. extern void __init of_at91rm9200_clk_master_setup(struct device_node *np,
  71. struct at91_pmc *pmc);
  72. extern void __init of_at91sam9x5_clk_master_setup(struct device_node *np,
  73. struct at91_pmc *pmc);
  74. extern void __init of_at91rm9200_clk_sys_setup(struct device_node *np,
  75. struct at91_pmc *pmc);
  76. extern void __init of_at91rm9200_clk_periph_setup(struct device_node *np,
  77. struct at91_pmc *pmc);
  78. extern void __init of_at91sam9x5_clk_periph_setup(struct device_node *np,
  79. struct at91_pmc *pmc);
  80. extern void __init of_at91rm9200_clk_prog_setup(struct device_node *np,
  81. struct at91_pmc *pmc);
  82. extern void __init of_at91sam9g45_clk_prog_setup(struct device_node *np,
  83. struct at91_pmc *pmc);
  84. extern void __init of_at91sam9x5_clk_prog_setup(struct device_node *np,
  85. struct at91_pmc *pmc);
  86. #if defined(CONFIG_HAVE_AT91_UTMI)
  87. extern void __init of_at91sam9x5_clk_utmi_setup(struct device_node *np,
  88. struct at91_pmc *pmc);
  89. #endif
  90. #if defined(CONFIG_HAVE_AT91_USB_CLK)
  91. extern void __init of_at91rm9200_clk_usb_setup(struct device_node *np,
  92. struct at91_pmc *pmc);
  93. extern void __init of_at91sam9x5_clk_usb_setup(struct device_node *np,
  94. struct at91_pmc *pmc);
  95. extern void __init of_at91sam9n12_clk_usb_setup(struct device_node *np,
  96. struct at91_pmc *pmc);
  97. #endif
  98. #if defined(CONFIG_HAVE_AT91_SMD)
  99. extern void __init of_at91sam9x5_clk_smd_setup(struct device_node *np,
  100. struct at91_pmc *pmc);
  101. #endif
  102. #if defined(CONFIG_HAVE_AT91_SMD)
  103. extern void __init of_sama5d4_clk_h32mx_setup(struct device_node *np,
  104. struct at91_pmc *pmc);
  105. #endif
  106. #endif /* __PMC_H_ */