Brian Swetland | 600f7cf | 2008-09-09 11:04:14 -0700 | [diff] [blame] | 1 | /* arch/arm/mach-msm/clock.h |
| 2 | * |
| 3 | * Copyright (C) 2007 Google, Inc. |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 4 | * Copyright (c) 2007-2011, Code Aurora Forum. All rights reserved. |
Brian Swetland | 600f7cf | 2008-09-09 11:04:14 -0700 | [diff] [blame] | 5 | * |
| 6 | * This software is licensed under the terms of the GNU General Public |
| 7 | * License version 2, as published by the Free Software Foundation, and |
| 8 | * may be copied, distributed, and modified under those terms. |
| 9 | * |
| 10 | * This program is distributed in the hope that it will be useful, |
| 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 13 | * GNU General Public License for more details. |
| 14 | * |
| 15 | */ |
| 16 | |
| 17 | #ifndef __ARCH_ARM_MACH_MSM_CLOCK_H |
| 18 | #define __ARCH_ARM_MACH_MSM_CLOCK_H |
| 19 | |
Matt Wagantall | d64560fe | 2011-01-26 16:20:54 -0800 | [diff] [blame] | 20 | #include <linux/init.h> |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 21 | #include <linux/types.h> |
Brian Swetland | 600f7cf | 2008-09-09 11:04:14 -0700 | [diff] [blame] | 22 | #include <linux/list.h> |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 23 | #include <linux/clkdev.h> |
| 24 | #include <linux/spinlock.h> |
| 25 | |
Daniel Walker | 5e96da5 | 2010-05-12 13:43:28 -0700 | [diff] [blame] | 26 | #include <mach/clk.h> |
| 27 | |
Brian Swetland | 600f7cf | 2008-09-09 11:04:14 -0700 | [diff] [blame] | 28 | #define CLKFLAG_INVERT 0x00000001 |
| 29 | #define CLKFLAG_NOINVERT 0x00000002 |
| 30 | #define CLKFLAG_NONEST 0x00000004 |
| 31 | #define CLKFLAG_NORESET 0x00000008 |
| 32 | |
Matt Wagantall | 22b0a79 | 2011-08-01 16:39:48 -0700 | [diff] [blame^] | 33 | #define CLKFLAG_SKIP_AUTO_OFF 0x00000200 |
Daniel Walker | 5e96da5 | 2010-05-12 13:43:28 -0700 | [diff] [blame] | 34 | #define CLKFLAG_MIN 0x00000400 |
| 35 | #define CLKFLAG_MAX 0x00000800 |
| 36 | |
| 37 | struct clk_ops { |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 38 | int (*enable)(struct clk *clk); |
| 39 | void (*disable)(struct clk *clk); |
| 40 | void (*auto_off)(struct clk *clk); |
| 41 | int (*reset)(struct clk *clk, enum clk_reset_action action); |
| 42 | int (*set_rate)(struct clk *clk, unsigned rate); |
| 43 | int (*set_min_rate)(struct clk *clk, unsigned rate); |
| 44 | int (*set_max_rate)(struct clk *clk, unsigned rate); |
| 45 | int (*set_flags)(struct clk *clk, unsigned flags); |
| 46 | unsigned (*get_rate)(struct clk *clk); |
| 47 | int (*list_rate)(struct clk *clk, unsigned n); |
| 48 | int (*is_enabled)(struct clk *clk); |
| 49 | long (*round_rate)(struct clk *clk, unsigned rate); |
| 50 | int (*set_parent)(struct clk *clk, struct clk *parent); |
| 51 | struct clk *(*get_parent)(struct clk *clk); |
| 52 | bool (*is_local)(struct clk *clk); |
Daniel Walker | 5e96da5 | 2010-05-12 13:43:28 -0700 | [diff] [blame] | 53 | }; |
Brian Swetland | 600f7cf | 2008-09-09 11:04:14 -0700 | [diff] [blame] | 54 | |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 55 | /** |
| 56 | * struct clk |
| 57 | * @count: enable refcount |
| 58 | * @lock: protects clk_enable()/clk_disable() path and @count |
| 59 | */ |
Brian Swetland | 600f7cf | 2008-09-09 11:04:14 -0700 | [diff] [blame] | 60 | struct clk { |
Brian Swetland | 600f7cf | 2008-09-09 11:04:14 -0700 | [diff] [blame] | 61 | uint32_t flags; |
Daniel Walker | 5e96da5 | 2010-05-12 13:43:28 -0700 | [diff] [blame] | 62 | struct clk_ops *ops; |
| 63 | const char *dbg_name; |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 64 | |
| 65 | struct list_head children; |
| 66 | struct list_head siblings; |
| 67 | |
| 68 | unsigned count; |
| 69 | spinlock_t lock; |
Brian Swetland | 600f7cf | 2008-09-09 11:04:14 -0700 | [diff] [blame] | 70 | }; |
| 71 | |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 72 | #define CLK_INIT(name) \ |
| 73 | .lock = __SPIN_LOCK_UNLOCKED((name).lock), \ |
| 74 | .children = LIST_HEAD_INIT((name).children), \ |
| 75 | .siblings = LIST_HEAD_INIT((name).siblings) |
| 76 | |
| 77 | void msm_clock_init(struct clk_lookup *clock_tbl, size_t num_clocks); |
| 78 | void msm7x30_clock_init(void); |
| 79 | void msm8660_clock_init(void); |
| 80 | void msm8960_clock_init(void); |
| 81 | void msm8960_clock_init_dummy(void); |
Brian Swetland | 600f7cf | 2008-09-09 11:04:14 -0700 | [diff] [blame] | 82 | |
Matt Wagantall | d64560fe | 2011-01-26 16:20:54 -0800 | [diff] [blame] | 83 | #ifdef CONFIG_DEBUG_FS |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 84 | int __init clock_debug_init(struct clk_lookup *clocks, unsigned num_clocks); |
Matt Wagantall | d64560fe | 2011-01-26 16:20:54 -0800 | [diff] [blame] | 85 | int __init clock_debug_add(struct clk *clock); |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 86 | void clock_debug_print_enabled(void); |
Matt Wagantall | d64560fe | 2011-01-26 16:20:54 -0800 | [diff] [blame] | 87 | #else |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 88 | static inline int __init clock_debug_init(struct clk_lookup *clocks, |
| 89 | unsigned num_clocks) { return 0; } |
Matt Wagantall | d64560fe | 2011-01-26 16:20:54 -0800 | [diff] [blame] | 90 | static inline int __init clock_debug_add(struct clk *clock) { return 0; } |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 91 | static inline void clock_debug_print_enabled(void) { return; } |
Matt Wagantall | d64560fe | 2011-01-26 16:20:54 -0800 | [diff] [blame] | 92 | #endif |
| 93 | |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 94 | extern struct clk dummy_clk; |
| 95 | |
| 96 | #define CLK_DUMMY(clk_name, clk_id, clk_dev, flags) { \ |
| 97 | .con_id = clk_name, \ |
| 98 | .dev_id = clk_dev, \ |
| 99 | .clk = &dummy_clk, \ |
| 100 | } |
| 101 | |
| 102 | #define CLK_LOOKUP(con, c, dev) { .con_id = con, .clk = &c, .dev_id = dev } |
| 103 | |
Brian Swetland | 600f7cf | 2008-09-09 11:04:14 -0700 | [diff] [blame] | 104 | #endif |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 105 | |