blob: 73c66d4d10fa4d30919a24af5ed2ee9ea1f885fc [file] [log] [blame]
Ben Dooksa5030592008-10-21 14:06:43 +01001/* linux/arch/arm/plat-s3c/include/plat/clock.h
Linus Torvalds1da177e2005-04-16 15:20:36 -07002 *
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
Kukjin Kim3a0ec252011-08-19 21:12:19 +090012#ifndef __ASM_PLAT_CLOCK_H
13#define __ASM_PLAT_CLOCK_H __FILE__
14
Ben Dooksc3391e32008-10-21 14:06:37 +010015#include <linux/spinlock.h>
Thomas Abrahamf86c6662011-06-14 19:12:26 +090016#include <linux/clkdev.h>
Ben Dooksc3391e32008-10-21 14:06:37 +010017
Ben Dooksb3bf41b2009-12-01 01:24:37 +000018struct clk;
19
20/**
21 * struct clk_ops - standard clock operations
22 * @set_rate: set the clock rate, see clk_set_rate().
23 * @get_rate: get the clock rate, see clk_get_rate().
24 * @round_rate: round a given clock rate, see clk_round_rate().
25 * @set_parent: set the clock's parent, see clk_set_parent().
26 *
27 * Group the common clock implementations together so that we
Lucas De Marchi25985ed2011-03-30 22:57:33 -030028 * don't have to keep setting the same fields again. We leave
Ben Dooksb3bf41b2009-12-01 01:24:37 +000029 * enable in struct clk.
30 *
31 * Adding an extra layer of indirection into the process should
32 * not be a problem as it is unlikely these operations are going
33 * to need to be called quickly.
34 */
35struct clk_ops {
36 int (*set_rate)(struct clk *c, unsigned long rate);
37 unsigned long (*get_rate)(struct clk *c);
38 unsigned long (*round_rate)(struct clk *c, unsigned long rate);
39 int (*set_parent)(struct clk *c, struct clk *parent);
40};
41
Linus Torvalds1da177e2005-04-16 15:20:36 -070042struct clk {
43 struct list_head list;
44 struct module *owner;
45 struct clk *parent;
46 const char *name;
Thomas Abrahamf86c6662011-06-14 19:12:26 +090047 const char *devname;
Linus Torvalds1da177e2005-04-16 15:20:36 -070048 int id;
Ben Dooks2a513ce2006-02-08 21:09:05 +000049 int usage;
Linus Torvalds1da177e2005-04-16 15:20:36 -070050 unsigned long rate;
51 unsigned long ctrlbit;
Ben Dooksd3468da2006-03-20 17:10:04 +000052
Ben Dooksb3bf41b2009-12-01 01:24:37 +000053 struct clk_ops *ops;
Linus Torvalds1da177e2005-04-16 15:20:36 -070054 int (*enable)(struct clk *, int enable);
Thomas Abrahamf86c6662011-06-14 19:12:26 +090055 struct clk_lookup lookup;
Amit Daniel Kachhap436c3872011-01-12 13:40:04 +090056#if defined(CONFIG_PM_DEBUG) && defined(CONFIG_DEBUG_FS)
57 struct dentry *dent; /* For visible tree hierarchy */
58#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -070059};
60
61/* other clocks which may be registered by board support */
62
63extern struct clk s3c24xx_dclk0;
64extern struct clk s3c24xx_dclk1;
65extern struct clk s3c24xx_clkout0;
66extern struct clk s3c24xx_clkout1;
67extern struct clk s3c24xx_uclk;
68
Ben Dooks36c64af2006-03-20 21:00:48 +000069extern struct clk clk_usb_bus;
70
Ben Dooks99c13852006-06-22 22:18:20 +010071/* core clock support */
72
73extern struct clk clk_f;
74extern struct clk clk_h;
75extern struct clk clk_p;
Ben Dooks513846f2006-06-24 21:21:29 +010076extern struct clk clk_mpll;
Ben Dooks99c13852006-06-22 22:18:20 +010077extern struct clk clk_upll;
Ben Dooks4b31d8b2008-10-21 14:07:00 +010078extern struct clk clk_epll;
Ben Dooks513846f2006-06-24 21:21:29 +010079extern struct clk clk_xtal;
Ben Dooks4b31d8b2008-10-21 14:07:00 +010080extern struct clk clk_ext;
81
82/* S3C64XX specific clocks */
Werner Almesbergera03f7da2009-03-05 11:43:13 +080083extern struct clk clk_h2;
Ben Dooks4b31d8b2008-10-21 14:07:00 +010084extern struct clk clk_27m;
85extern struct clk clk_48m;
Maurus Cuelenaere05e021f2010-05-17 20:17:42 +020086extern struct clk clk_xusbxti;
Ben Dooks99c13852006-06-22 22:18:20 +010087
Kukjin Kimed276842010-01-14 12:50:23 +090088extern int clk_default_setrate(struct clk *clk, unsigned long rate);
89extern struct clk_ops clk_ops_def_setrate;
90
Linus Torvalds1da177e2005-04-16 15:20:36 -070091/* exports for arch/arm/mach-s3c2410
92 *
93 * Please DO NOT use these outside of arch/arm/mach-s3c2410
94*/
95
Ben Dooksc3391e32008-10-21 14:06:37 +010096extern spinlock_t clocks_lock;
Ben Dooks36c64af2006-03-20 21:00:48 +000097
Ben Dooks99c13852006-06-22 22:18:20 +010098extern int s3c2410_clkcon_enable(struct clk *clk, int enable);
99
Linus Torvalds1da177e2005-04-16 15:20:36 -0700100extern int s3c24xx_register_clock(struct clk *clk);
Ben Dooksce89c202007-04-20 11:15:27 +0100101extern int s3c24xx_register_clocks(struct clk **clk, int nr_clks);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700102
Ben Dooks1d9f13c2010-01-06 01:21:38 +0900103extern void s3c_register_clocks(struct clk *clk, int nr_clks);
Ben Dooks4e046912010-04-28 12:58:13 +0900104extern void s3c_disable_clocks(struct clk *clkp, int nr_clks);
Ben Dooks1d9f13c2010-01-06 01:21:38 +0900105
Ben Dookse4253822008-10-21 14:06:38 +0100106extern int s3c24xx_register_baseclocks(unsigned long xtal);
107
Kukjin Kim1a0e8a52010-01-14 08:13:37 +0900108extern void s5p_register_clocks(unsigned long xtal_freq);
Ben Dooks4b31d8b2008-10-21 14:07:00 +0100109
Ben Dookse4253822008-10-21 14:06:38 +0100110extern void s3c24xx_setup_clocks(unsigned long fclk,
111 unsigned long hclk,
112 unsigned long pclk);
113
114extern void s3c2410_setup_clocks(void);
115extern void s3c2412_setup_clocks(void);
116extern void s3c244x_setup_clocks(void);
117extern void s3c2443_setup_clocks(void);
118
Ben Dookscf18acf2008-10-21 14:07:02 +0100119/* S3C64XX specific functions and clocks */
120
121extern int s3c64xx_sclk_ctrl(struct clk *clk, int enable);
Ben Dooks9d325f22008-11-21 10:36:05 +0000122
123/* Init for pwm clock code */
124
125extern void s3c_pwmclk_init(void);
126
Marek Szyprowskicaf27302011-09-05 20:10:06 +0900127/* Global watchdog clock used by arch_wtd_reset() callback */
128
129extern struct clk *s3c2410_wdtclk;
Kukjin Kim3a0ec252011-08-19 21:12:19 +0900130
131#endif /* __ASM_PLAT_CLOCK_H */