pmc.h 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  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. };
  31. static inline void pmc_lock(struct at91_pmc *pmc)
  32. {
  33. spin_lock(&pmc->lock);
  34. }
  35. static inline void pmc_unlock(struct at91_pmc *pmc)
  36. {
  37. spin_unlock(&pmc->lock);
  38. }
  39. static inline u32 pmc_read(struct at91_pmc *pmc, int offset)
  40. {
  41. return readl(pmc->regbase + offset);
  42. }
  43. static inline void pmc_write(struct at91_pmc *pmc, int offset, u32 value)
  44. {
  45. writel(value, pmc->regbase + offset);
  46. }
  47. int of_at91_get_clk_range(struct device_node *np, const char *propname,
  48. struct clk_range *range);
  49. extern void __init of_at91sam9260_clk_slow_setup(struct device_node *np,
  50. struct at91_pmc *pmc);
  51. extern void __init of_at91rm9200_clk_main_osc_setup(struct device_node *np,
  52. struct at91_pmc *pmc);
  53. extern void __init of_at91sam9x5_clk_main_rc_osc_setup(struct device_node *np,
  54. struct at91_pmc *pmc);
  55. extern void __init of_at91rm9200_clk_main_setup(struct device_node *np,
  56. struct at91_pmc *pmc);
  57. extern void __init of_at91sam9x5_clk_main_setup(struct device_node *np,
  58. struct at91_pmc *pmc);
  59. extern void __init of_at91rm9200_clk_pll_setup(struct device_node *np,
  60. struct at91_pmc *pmc);
  61. extern void __init of_at91sam9g45_clk_pll_setup(struct device_node *np,
  62. struct at91_pmc *pmc);
  63. extern void __init of_at91sam9g20_clk_pllb_setup(struct device_node *np,
  64. struct at91_pmc *pmc);
  65. extern void __init of_sama5d3_clk_pll_setup(struct device_node *np,
  66. struct at91_pmc *pmc);
  67. extern void __init of_at91sam9x5_clk_plldiv_setup(struct device_node *np,
  68. struct at91_pmc *pmc);
  69. extern void __init of_at91rm9200_clk_master_setup(struct device_node *np,
  70. struct at91_pmc *pmc);
  71. extern void __init of_at91sam9x5_clk_master_setup(struct device_node *np,
  72. struct at91_pmc *pmc);
  73. extern void __init of_at91rm9200_clk_sys_setup(struct device_node *np,
  74. struct at91_pmc *pmc);
  75. extern void __init of_at91rm9200_clk_periph_setup(struct device_node *np,
  76. struct at91_pmc *pmc);
  77. extern void __init of_at91sam9x5_clk_periph_setup(struct device_node *np,
  78. struct at91_pmc *pmc);
  79. extern void __init of_at91rm9200_clk_prog_setup(struct device_node *np,
  80. struct at91_pmc *pmc);
  81. extern void __init of_at91sam9g45_clk_prog_setup(struct device_node *np,
  82. struct at91_pmc *pmc);
  83. extern void __init of_at91sam9x5_clk_prog_setup(struct device_node *np,
  84. struct at91_pmc *pmc);
  85. #if defined(CONFIG_HAVE_AT91_UTMI)
  86. extern void __init of_at91sam9x5_clk_utmi_setup(struct device_node *np,
  87. struct at91_pmc *pmc);
  88. #endif
  89. #if defined(CONFIG_HAVE_AT91_USB_CLK)
  90. extern void __init of_at91rm9200_clk_usb_setup(struct device_node *np,
  91. struct at91_pmc *pmc);
  92. extern void __init of_at91sam9x5_clk_usb_setup(struct device_node *np,
  93. struct at91_pmc *pmc);
  94. extern void __init of_at91sam9n12_clk_usb_setup(struct device_node *np,
  95. struct at91_pmc *pmc);
  96. #endif
  97. #if defined(CONFIG_HAVE_AT91_SMD)
  98. extern void __init of_at91sam9x5_clk_smd_setup(struct device_node *np,
  99. struct at91_pmc *pmc);
  100. #endif
  101. #endif /* __PMC_H_ */