blob: 9b3c85b3c28836629832f65c30242366a421a9e3 [file] [log] [blame]
Robin Getzf16295e2007-08-03 18:07:17 +08001/*
Robin Getz96f10502009-09-24 14:11:24 +00002 * Common Clock definitions for various kernel files
Robin Getzf16295e2007-08-03 18:07:17 +08003 *
Robin Getz96f10502009-09-24 14:11:24 +00004 * Copyright 2007-2008 Analog Devices Inc.
Robin Getzf16295e2007-08-03 18:07:17 +08005 *
Robin Getz96f10502009-09-24 14:11:24 +00006 * Licensed under the GPL-2 or later.
Robin Getzf16295e2007-08-03 18:07:17 +08007 */
8
Robin Getz3bebca22007-10-10 23:55:26 +08009#ifndef _BFIN_CLOCKS_H
10#define _BFIN_CLOCKS_H
Robin Getzf16295e2007-08-03 18:07:17 +080011
Mike Frysinger761ec442009-10-15 17:12:05 +000012#include <asm/dpmc.h>
13
Robin Getzf16295e2007-08-03 18:07:17 +080014#ifdef CONFIG_CCLK_DIV_1
15# define CONFIG_CCLK_ACT_DIV CCLK_DIV1
16# define CONFIG_CCLK_DIV 1
17#endif
18
19#ifdef CONFIG_CCLK_DIV_2
20# define CONFIG_CCLK_ACT_DIV CCLK_DIV2
21# define CONFIG_CCLK_DIV 2
22#endif
23
24#ifdef CONFIG_CCLK_DIV_4
25# define CONFIG_CCLK_ACT_DIV CCLK_DIV4
26# define CONFIG_CCLK_DIV 4
27#endif
28
29#ifdef CONFIG_CCLK_DIV_8
30# define CONFIG_CCLK_ACT_DIV CCLK_DIV8
31# define CONFIG_CCLK_DIV 8
32#endif
33
34#ifndef CONFIG_PLL_BYPASS
35# ifndef CONFIG_CLKIN_HALF
36# define CONFIG_VCO_HZ (CONFIG_CLKIN_HZ * CONFIG_VCO_MULT)
37# else
38# define CONFIG_VCO_HZ ((CONFIG_CLKIN_HZ * CONFIG_VCO_MULT)/2)
39# endif
40
41# define CONFIG_CCLK_HZ (CONFIG_VCO_HZ/CONFIG_CCLK_DIV)
42# define CONFIG_SCLK_HZ (CONFIG_VCO_HZ/CONFIG_SCLK_DIV)
43
44#else
45# define CONFIG_VCO_HZ (CONFIG_CLKIN_HZ)
46# define CONFIG_CCLK_HZ (CONFIG_CLKIN_HZ)
47# define CONFIG_SCLK_HZ (CONFIG_CLKIN_HZ)
48# define CONFIG_VCO_MULT 0
49#endif
50
Steven Miao96900312012-05-16 17:49:52 +080051#include <linux/clk.h>
52
53struct clk_ops {
54 unsigned long (*get_rate)(struct clk *clk);
55 unsigned long (*round_rate)(struct clk *clk, unsigned long rate);
56 int (*set_rate)(struct clk *clk, unsigned long rate);
57 int (*enable)(struct clk *clk);
58 int (*disable)(struct clk *clk);
59};
60
61struct clk {
62 struct clk *parent;
63 const char *name;
64 unsigned long rate;
65 spinlock_t lock;
66 u32 flags;
67 const struct clk_ops *ops;
68 void __iomem *reg;
69 u32 mask;
70 u32 shift;
71};
72
73int clk_init(void);
Robin Getz3bebca22007-10-10 23:55:26 +080074#endif