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 | |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 20 | #include <linux/types.h> |
Brian Swetland | 600f7cf | 2008-09-09 11:04:14 -0700 | [diff] [blame] | 21 | #include <linux/list.h> |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 22 | #include <linux/clkdev.h> |
| 23 | #include <linux/spinlock.h> |
| 24 | |
Daniel Walker | 5e96da5 | 2010-05-12 13:43:28 -0700 | [diff] [blame] | 25 | #include <mach/clk.h> |
| 26 | |
Brian Swetland | 600f7cf | 2008-09-09 11:04:14 -0700 | [diff] [blame] | 27 | #define CLKFLAG_INVERT 0x00000001 |
| 28 | #define CLKFLAG_NOINVERT 0x00000002 |
| 29 | #define CLKFLAG_NONEST 0x00000004 |
| 30 | #define CLKFLAG_NORESET 0x00000008 |
Matt Wagantall | 14dc2af | 2011-08-12 13:16:06 -0700 | [diff] [blame] | 31 | #define CLKFLAG_HANDOFF_RATE 0x00000010 |
Matt Wagantall | 22b0a79 | 2011-08-01 16:39:48 -0700 | [diff] [blame] | 32 | #define CLKFLAG_SKIP_AUTO_OFF 0x00000200 |
Daniel Walker | 5e96da5 | 2010-05-12 13:43:28 -0700 | [diff] [blame] | 33 | #define CLKFLAG_MIN 0x00000400 |
| 34 | #define CLKFLAG_MAX 0x00000800 |
| 35 | |
| 36 | struct clk_ops { |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 37 | int (*enable)(struct clk *clk); |
| 38 | void (*disable)(struct clk *clk); |
| 39 | void (*auto_off)(struct clk *clk); |
Matt Wagantall | 271a6cd | 2011-09-20 16:06:31 -0700 | [diff] [blame] | 40 | int (*handoff)(struct clk *clk); |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 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 |
Stephen Boyd | 7fa2674 | 2011-08-11 23:22:29 -0700 | [diff] [blame] | 59 | * @depends: non-direct parent of clock to enable when this clock is enabled |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 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; |
Stephen Boyd | 7fa2674 | 2011-08-11 23:22:29 -0700 | [diff] [blame] | 65 | struct clk *depends; |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 66 | |
| 67 | struct list_head children; |
| 68 | struct list_head siblings; |
| 69 | |
| 70 | unsigned count; |
| 71 | spinlock_t lock; |
Brian Swetland | 600f7cf | 2008-09-09 11:04:14 -0700 | [diff] [blame] | 72 | }; |
| 73 | |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 74 | #define CLK_INIT(name) \ |
| 75 | .lock = __SPIN_LOCK_UNLOCKED((name).lock), \ |
| 76 | .children = LIST_HEAD_INIT((name).children), \ |
| 77 | .siblings = LIST_HEAD_INIT((name).siblings) |
| 78 | |
Stephen Boyd | bb600ae | 2011-08-02 20:11:40 -0700 | [diff] [blame] | 79 | /** |
| 80 | * struct clock_init_data - SoC specific clock initialization data |
| 81 | * @table: table of lookups to add |
| 82 | * @size: size of @table |
| 83 | * @init: called before registering @table |
| 84 | * @late_init: called during late init |
| 85 | */ |
| 86 | struct clock_init_data { |
| 87 | struct clk_lookup *table; |
| 88 | size_t size; |
| 89 | void (*init)(void); |
| 90 | int (*late_init)(void); |
| 91 | }; |
| 92 | |
Vikram Mulukutla | 489e39e | 2011-08-31 18:04:05 -0700 | [diff] [blame] | 93 | extern struct clock_init_data msm9615_clock_init_data; |
Tianyi Gou | 41515e2 | 2011-09-01 19:37:43 -0700 | [diff] [blame] | 94 | extern struct clock_init_data apq8064_clock_init_data; |
Stephen Boyd | bb600ae | 2011-08-02 20:11:40 -0700 | [diff] [blame] | 95 | extern struct clock_init_data apq8064_dummy_clock_init_data; |
| 96 | extern struct clock_init_data fsm9xxx_clock_init_data; |
| 97 | extern struct clock_init_data msm7x01a_clock_init_data; |
| 98 | extern struct clock_init_data msm7x27_clock_init_data; |
| 99 | extern struct clock_init_data msm7x27a_clock_init_data; |
| 100 | extern struct clock_init_data msm7x30_clock_init_data; |
| 101 | extern struct clock_init_data msm8960_clock_init_data; |
| 102 | extern struct clock_init_data msm8960_dummy_clock_init_data; |
| 103 | extern struct clock_init_data msm8x60_clock_init_data; |
| 104 | extern struct clock_init_data qds8x50_clock_init_data; |
| 105 | |
| 106 | void msm_clock_init(struct clock_init_data *data); |
Brian Swetland | 600f7cf | 2008-09-09 11:04:14 -0700 | [diff] [blame] | 107 | |
Matt Wagantall | d64560fe | 2011-01-26 16:20:54 -0800 | [diff] [blame] | 108 | #ifdef CONFIG_DEBUG_FS |
Stephen Boyd | bb600ae | 2011-08-02 20:11:40 -0700 | [diff] [blame] | 109 | int clock_debug_init(struct clock_init_data *data); |
| 110 | int clock_debug_add(struct clk *clock); |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 111 | void clock_debug_print_enabled(void); |
Matt Wagantall | d64560fe | 2011-01-26 16:20:54 -0800 | [diff] [blame] | 112 | #else |
Stephen Boyd | bb600ae | 2011-08-02 20:11:40 -0700 | [diff] [blame] | 113 | static inline int clock_debug_init(struct clk_init_data *data) { return 0; } |
| 114 | static inline int clock_debug_add(struct clk *clock) { return 0; } |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 115 | static inline void clock_debug_print_enabled(void) { return; } |
Matt Wagantall | d64560fe | 2011-01-26 16:20:54 -0800 | [diff] [blame] | 116 | #endif |
| 117 | |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 118 | extern struct clk dummy_clk; |
| 119 | |
| 120 | #define CLK_DUMMY(clk_name, clk_id, clk_dev, flags) { \ |
| 121 | .con_id = clk_name, \ |
| 122 | .dev_id = clk_dev, \ |
| 123 | .clk = &dummy_clk, \ |
| 124 | } |
| 125 | |
| 126 | #define CLK_LOOKUP(con, c, dev) { .con_id = con, .clk = &c, .dev_id = dev } |
| 127 | |
Brian Swetland | 600f7cf | 2008-09-09 11:04:14 -0700 | [diff] [blame] | 128 | #endif |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 129 | |