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 | |
| 33 | #define CLK_FIRST_AVAILABLE_FLAG 0x00000100 |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame^] | 34 | #define CLKFLAG_SKIP_AUTO_OFF 0x00000200 |
Daniel Walker | 5e96da5 | 2010-05-12 13:43:28 -0700 | [diff] [blame] | 35 | #define CLKFLAG_MIN 0x00000400 |
| 36 | #define CLKFLAG_MAX 0x00000800 |
| 37 | |
| 38 | struct clk_ops { |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame^] | 39 | int (*enable)(struct clk *clk); |
| 40 | void (*disable)(struct clk *clk); |
| 41 | void (*auto_off)(struct clk *clk); |
| 42 | int (*reset)(struct clk *clk, enum clk_reset_action action); |
| 43 | int (*set_rate)(struct clk *clk, unsigned rate); |
| 44 | int (*set_min_rate)(struct clk *clk, unsigned rate); |
| 45 | int (*set_max_rate)(struct clk *clk, unsigned rate); |
| 46 | int (*set_flags)(struct clk *clk, unsigned flags); |
| 47 | unsigned (*get_rate)(struct clk *clk); |
| 48 | int (*list_rate)(struct clk *clk, unsigned n); |
| 49 | int (*is_enabled)(struct clk *clk); |
| 50 | long (*round_rate)(struct clk *clk, unsigned rate); |
| 51 | int (*set_parent)(struct clk *clk, struct clk *parent); |
| 52 | struct clk *(*get_parent)(struct clk *clk); |
| 53 | bool (*is_local)(struct clk *clk); |
Daniel Walker | 5e96da5 | 2010-05-12 13:43:28 -0700 | [diff] [blame] | 54 | }; |
Brian Swetland | 600f7cf | 2008-09-09 11:04:14 -0700 | [diff] [blame] | 55 | |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame^] | 56 | /** |
| 57 | * struct clk |
| 58 | * @count: enable refcount |
| 59 | * @lock: protects clk_enable()/clk_disable() path and @count |
| 60 | */ |
Brian Swetland | 600f7cf | 2008-09-09 11:04:14 -0700 | [diff] [blame] | 61 | struct clk { |
Brian Swetland | 600f7cf | 2008-09-09 11:04:14 -0700 | [diff] [blame] | 62 | uint32_t flags; |
Daniel Walker | 5e96da5 | 2010-05-12 13:43:28 -0700 | [diff] [blame] | 63 | struct clk_ops *ops; |
| 64 | const char *dbg_name; |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame^] | 65 | |
| 66 | struct list_head children; |
| 67 | struct list_head siblings; |
| 68 | |
| 69 | unsigned count; |
| 70 | spinlock_t lock; |
Brian Swetland | 600f7cf | 2008-09-09 11:04:14 -0700 | [diff] [blame] | 71 | }; |
| 72 | |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame^] | 73 | #define CLK_INIT(name) \ |
| 74 | .lock = __SPIN_LOCK_UNLOCKED((name).lock), \ |
| 75 | .children = LIST_HEAD_INIT((name).children), \ |
| 76 | .siblings = LIST_HEAD_INIT((name).siblings) |
| 77 | |
| 78 | void msm_clock_init(struct clk_lookup *clock_tbl, size_t num_clocks); |
| 79 | void msm7x30_clock_init(void); |
| 80 | void msm8660_clock_init(void); |
| 81 | void msm8960_clock_init(void); |
| 82 | void msm8960_clock_init_dummy(void); |
Brian Swetland | 600f7cf | 2008-09-09 11:04:14 -0700 | [diff] [blame] | 83 | |
Matt Wagantall | d64560fe | 2011-01-26 16:20:54 -0800 | [diff] [blame] | 84 | #ifdef CONFIG_DEBUG_FS |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame^] | 85 | int __init clock_debug_init(struct clk_lookup *clocks, unsigned num_clocks); |
Matt Wagantall | d64560fe | 2011-01-26 16:20:54 -0800 | [diff] [blame] | 86 | int __init clock_debug_add(struct clk *clock); |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame^] | 87 | void clock_debug_print_enabled(void); |
Matt Wagantall | d64560fe | 2011-01-26 16:20:54 -0800 | [diff] [blame] | 88 | #else |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame^] | 89 | static inline int __init clock_debug_init(struct clk_lookup *clocks, |
| 90 | unsigned num_clocks) { return 0; } |
Matt Wagantall | d64560fe | 2011-01-26 16:20:54 -0800 | [diff] [blame] | 91 | static inline int __init clock_debug_add(struct clk *clock) { return 0; } |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame^] | 92 | static inline void clock_debug_print_enabled(void) { return; } |
Matt Wagantall | d64560fe | 2011-01-26 16:20:54 -0800 | [diff] [blame] | 93 | #endif |
| 94 | |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame^] | 95 | extern struct clk dummy_clk; |
| 96 | |
| 97 | #define CLK_DUMMY(clk_name, clk_id, clk_dev, flags) { \ |
| 98 | .con_id = clk_name, \ |
| 99 | .dev_id = clk_dev, \ |
| 100 | .clk = &dummy_clk, \ |
| 101 | } |
| 102 | |
| 103 | #define CLK_LOOKUP(con, c, dev) { .con_id = con, .clk = &c, .dev_id = dev } |
| 104 | |
Brian Swetland | 600f7cf | 2008-09-09 11:04:14 -0700 | [diff] [blame] | 105 | #endif |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame^] | 106 | |