clock.h 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152
  1. /* linux/arch/arm/plat-s3c/include/plat/clock.h
  2. *
  3. * Copyright (c) 2004-2005 Simtec Electronics
  4. * http://www.simtec.co.uk/products/SWLINUX/
  5. * Written by Ben Dooks, <ben@simtec.co.uk>
  6. *
  7. * This program is free software; you can redistribute it and/or modify
  8. * it under the terms of the GNU General Public License version 2 as
  9. * published by the Free Software Foundation.
  10. */
  11. #ifndef __ASM_PLAT_CLOCK_H
  12. #define __ASM_PLAT_CLOCK_H __FILE__
  13. #include <linux/spinlock.h>
  14. #include <linux/clkdev.h>
  15. struct clk;
  16. /**
  17. * struct clk_ops - standard clock operations
  18. * @set_rate: set the clock rate, see clk_set_rate().
  19. * @get_rate: get the clock rate, see clk_get_rate().
  20. * @round_rate: round a given clock rate, see clk_round_rate().
  21. * @set_parent: set the clock's parent, see clk_set_parent().
  22. *
  23. * Group the common clock implementations together so that we
  24. * don't have to keep setting the same fields again. We leave
  25. * enable in struct clk.
  26. *
  27. * Adding an extra layer of indirection into the process should
  28. * not be a problem as it is unlikely these operations are going
  29. * to need to be called quickly.
  30. */
  31. struct clk_ops {
  32. int (*set_rate)(struct clk *c, unsigned long rate);
  33. unsigned long (*get_rate)(struct clk *c);
  34. unsigned long (*round_rate)(struct clk *c, unsigned long rate);
  35. int (*set_parent)(struct clk *c, struct clk *parent);
  36. };
  37. struct clk {
  38. struct list_head list;
  39. struct module *owner;
  40. struct clk *parent;
  41. const char *name;
  42. const char *devname;
  43. int id;
  44. int usage;
  45. unsigned long rate;
  46. unsigned long ctrlbit;
  47. struct clk_ops *ops;
  48. int (*enable)(struct clk *, int enable);
  49. struct clk_lookup lookup;
  50. #if defined(CONFIG_PM_DEBUG) && defined(CONFIG_DEBUG_FS)
  51. struct dentry *dent; /* For visible tree hierarchy */
  52. #endif
  53. };
  54. /* other clocks which may be registered by board support */
  55. extern struct clk s3c24xx_dclk0;
  56. extern struct clk s3c24xx_dclk1;
  57. extern struct clk s3c24xx_clkout0;
  58. extern struct clk s3c24xx_clkout1;
  59. extern struct clk s3c24xx_uclk;
  60. extern struct clk clk_usb_bus;
  61. /* core clock support */
  62. extern struct clk clk_f;
  63. extern struct clk clk_h;
  64. extern struct clk clk_p;
  65. extern struct clk clk_mpll;
  66. extern struct clk clk_upll;
  67. extern struct clk clk_epll;
  68. extern struct clk clk_xtal;
  69. extern struct clk clk_ext;
  70. /* S3C2443/S3C2416 specific clocks */
  71. extern struct clksrc_clk clk_epllref;
  72. extern struct clksrc_clk clk_esysclk;
  73. /* S3C64XX specific clocks */
  74. extern struct clk clk_h2;
  75. extern struct clk clk_27m;
  76. extern struct clk clk_48m;
  77. extern struct clk clk_xusbxti;
  78. extern int clk_default_setrate(struct clk *clk, unsigned long rate);
  79. extern struct clk_ops clk_ops_def_setrate;
  80. /* exports for arch/arm/mach-s3c2410
  81. *
  82. * Please DO NOT use these outside of arch/arm/mach-s3c2410
  83. */
  84. extern spinlock_t clocks_lock;
  85. extern int s3c2410_clkcon_enable(struct clk *clk, int enable);
  86. extern int s3c24xx_register_clock(struct clk *clk);
  87. extern int s3c24xx_register_clocks(struct clk **clk, int nr_clks);
  88. extern void s3c_register_clocks(struct clk *clk, int nr_clks);
  89. extern void s3c_disable_clocks(struct clk *clkp, int nr_clks);
  90. extern int s3c24xx_register_baseclocks(unsigned long xtal);
  91. extern void s5p_register_clocks(unsigned long xtal_freq);
  92. extern void s3c24xx_setup_clocks(unsigned long fclk,
  93. unsigned long hclk,
  94. unsigned long pclk);
  95. extern void s3c2410_setup_clocks(void);
  96. extern void s3c2412_setup_clocks(void);
  97. extern void s3c244x_setup_clocks(void);
  98. /* S3C2410 specific clock functions */
  99. extern int s3c2410_baseclk_add(void);
  100. /* S3C2443/S3C2416 specific clock functions */
  101. typedef unsigned int (*pll_fn)(unsigned int reg, unsigned int base);
  102. extern void s3c2443_common_setup_clocks(pll_fn get_mpll);
  103. extern void s3c2443_common_init_clocks(int xtal, pll_fn get_mpll,
  104. unsigned int *divs, int nr_divs,
  105. int divmask);
  106. extern int s3c2443_clkcon_enable_h(struct clk *clk, int enable);
  107. extern int s3c2443_clkcon_enable_p(struct clk *clk, int enable);
  108. extern int s3c2443_clkcon_enable_s(struct clk *clk, int enable);
  109. /* S3C64XX specific functions and clocks */
  110. extern int s3c64xx_sclk_ctrl(struct clk *clk, int enable);
  111. /* Init for pwm clock code */
  112. extern void s3c_pwmclk_init(void);
  113. /* Global watchdog clock used by arch_wtd_reset() callback */
  114. extern struct clk *s3c2410_wdtclk;
  115. #endif /* __ASM_PLAT_CLOCK_H */