| Paul Walmsley | 02e19a9 | 2008-03-18 15:09:51 +0200 | [diff] [blame] | 1 | /* | 
 | 2 |  * OMAP3-specific clock framework functions | 
 | 3 |  * | 
| Paul Walmsley | 542313c | 2008-07-03 12:24:45 +0300 | [diff] [blame] | 4 |  * Copyright (C) 2007-2008 Texas Instruments, Inc. | 
| Paul Walmsley | ec538e3 | 2011-02-25 15:39:30 -0700 | [diff] [blame] | 5 |  * Copyright (C) 2007-2011 Nokia Corporation | 
| Paul Walmsley | 02e19a9 | 2008-03-18 15:09:51 +0200 | [diff] [blame] | 6 |  * | 
| Paul Walmsley | da4d290 | 2010-01-26 20:13:10 -0700 | [diff] [blame] | 7 |  * Paul Walmsley | 
 | 8 |  * Jouni Högander | 
| Paul Walmsley | 02e19a9 | 2008-03-18 15:09:51 +0200 | [diff] [blame] | 9 |  * | 
 | 10 |  * Parts of this code are based on code written by | 
| Paul Walmsley | 657ebfa | 2010-02-22 22:09:20 -0700 | [diff] [blame] | 11 |  * Richard Woodruff, Tony Lindgren, Tuukka Tikkanen, Karthik Dasu, | 
 | 12 |  * Russell King | 
| Paul Walmsley | 02e19a9 | 2008-03-18 15:09:51 +0200 | [diff] [blame] | 13 |  * | 
 | 14 |  * This program is free software; you can redistribute it and/or modify | 
 | 15 |  * it under the terms of the GNU General Public License version 2 as | 
 | 16 |  * published by the Free Software Foundation. | 
 | 17 |  */ | 
 | 18 | #undef DEBUG | 
 | 19 |  | 
| Paul Walmsley | 02e19a9 | 2008-03-18 15:09:51 +0200 | [diff] [blame] | 20 | #include <linux/kernel.h> | 
| Paul Walmsley | 02e19a9 | 2008-03-18 15:09:51 +0200 | [diff] [blame] | 21 | #include <linux/clk.h> | 
 | 22 | #include <linux/io.h> | 
 | 23 |  | 
| Tony Lindgren | ce491cf | 2009-10-20 09:40:47 -0700 | [diff] [blame] | 24 | #include <plat/clock.h> | 
| Paul Walmsley | 02e19a9 | 2008-03-18 15:09:51 +0200 | [diff] [blame] | 25 |  | 
| Paul Walmsley | 02e19a9 | 2008-03-18 15:09:51 +0200 | [diff] [blame] | 26 | #include "clock.h" | 
| Paul Walmsley | 82e9bd5 | 2009-12-08 16:18:47 -0700 | [diff] [blame] | 27 | #include "clock34xx.h" | 
| Paul Walmsley | 59fb659 | 2010-12-21 15:30:55 -0700 | [diff] [blame] | 28 | #include "cm2xxx_3xxx.h" | 
| Paul Walmsley | 02e19a9 | 2008-03-18 15:09:51 +0200 | [diff] [blame] | 29 | #include "cm-regbits-34xx.h" | 
 | 30 |  | 
| Paul Walmsley | 02e19a9 | 2008-03-18 15:09:51 +0200 | [diff] [blame] | 31 | /** | 
| Paul Walmsley | 3c82e22 | 2009-07-24 19:44:06 -0600 | [diff] [blame] | 32 |  * omap3430es2_clk_ssi_find_idlest - return CM_IDLEST info for SSI | 
 | 33 |  * @clk: struct clk * being enabled | 
 | 34 |  * @idlest_reg: void __iomem ** to store CM_IDLEST reg address into | 
 | 35 |  * @idlest_bit: pointer to a u8 to store the CM_IDLEST bit shift into | 
| Ranjith Lohithakshan | 419cc97 | 2010-02-24 12:05:54 -0700 | [diff] [blame] | 36 |  * @idlest_val: pointer to a u8 to store the CM_IDLEST indicator | 
| Paul Walmsley | 3c82e22 | 2009-07-24 19:44:06 -0600 | [diff] [blame] | 37 |  * | 
 | 38 |  * The OMAP3430ES2 SSI target CM_IDLEST bit is at a different shift | 
 | 39 |  * from the CM_{I,F}CLKEN bit.  Pass back the correct info via | 
 | 40 |  * @idlest_reg and @idlest_bit.  No return value. | 
 | 41 |  */ | 
 | 42 | static void omap3430es2_clk_ssi_find_idlest(struct clk *clk, | 
 | 43 | 					    void __iomem **idlest_reg, | 
| Ranjith Lohithakshan | 419cc97 | 2010-02-24 12:05:54 -0700 | [diff] [blame] | 44 | 					    u8 *idlest_bit, | 
 | 45 | 					    u8 *idlest_val) | 
| Paul Walmsley | 3c82e22 | 2009-07-24 19:44:06 -0600 | [diff] [blame] | 46 | { | 
 | 47 | 	u32 r; | 
 | 48 |  | 
 | 49 | 	r = (((__force u32)clk->enable_reg & ~0xf0) | 0x20); | 
 | 50 | 	*idlest_reg = (__force void __iomem *)r; | 
 | 51 | 	*idlest_bit = OMAP3430ES2_ST_SSI_IDLE_SHIFT; | 
| Ranjith Lohithakshan | 419cc97 | 2010-02-24 12:05:54 -0700 | [diff] [blame] | 52 | 	*idlest_val = OMAP34XX_CM_IDLEST_VAL; | 
| Paul Walmsley | 3c82e22 | 2009-07-24 19:44:06 -0600 | [diff] [blame] | 53 | } | 
 | 54 |  | 
| Paul Walmsley | 82e9bd5 | 2009-12-08 16:18:47 -0700 | [diff] [blame] | 55 | const struct clkops clkops_omap3430es2_ssi_wait = { | 
 | 56 | 	.enable		= omap2_dflt_clk_enable, | 
 | 57 | 	.disable	= omap2_dflt_clk_disable, | 
 | 58 | 	.find_idlest	= omap3430es2_clk_ssi_find_idlest, | 
 | 59 | 	.find_companion = omap2_clk_dflt_find_companion, | 
 | 60 | }; | 
 | 61 |  | 
| Paul Walmsley | ec538e3 | 2011-02-25 15:39:30 -0700 | [diff] [blame] | 62 | const struct clkops clkops_omap3430es2_iclk_ssi_wait = { | 
 | 63 | 	.enable		= omap2_dflt_clk_enable, | 
 | 64 | 	.disable	= omap2_dflt_clk_disable, | 
 | 65 | 	.find_idlest	= omap3430es2_clk_ssi_find_idlest, | 
 | 66 | 	.find_companion = omap2_clk_dflt_find_companion, | 
 | 67 | 	.allow_idle	= omap2_clkt_iclk_allow_idle, | 
 | 68 | 	.deny_idle	= omap2_clkt_iclk_deny_idle, | 
 | 69 | }; | 
 | 70 |  | 
| Paul Walmsley | 3c82e22 | 2009-07-24 19:44:06 -0600 | [diff] [blame] | 71 | /** | 
 | 72 |  * omap3430es2_clk_dss_usbhost_find_idlest - CM_IDLEST info for DSS, USBHOST | 
 | 73 |  * @clk: struct clk * being enabled | 
 | 74 |  * @idlest_reg: void __iomem ** to store CM_IDLEST reg address into | 
 | 75 |  * @idlest_bit: pointer to a u8 to store the CM_IDLEST bit shift into | 
| Ranjith Lohithakshan | 419cc97 | 2010-02-24 12:05:54 -0700 | [diff] [blame] | 76 |  * @idlest_val: pointer to a u8 to store the CM_IDLEST indicator | 
| Paul Walmsley | 3c82e22 | 2009-07-24 19:44:06 -0600 | [diff] [blame] | 77 |  * | 
 | 78 |  * Some OMAP modules on OMAP3 ES2+ chips have both initiator and | 
 | 79 |  * target IDLEST bits.  For our purposes, we are concerned with the | 
 | 80 |  * target IDLEST bits, which exist at a different bit position than | 
 | 81 |  * the *CLKEN bit position for these modules (DSS and USBHOST) (The | 
 | 82 |  * default find_idlest code assumes that they are at the same | 
 | 83 |  * position.)  No return value. | 
 | 84 |  */ | 
 | 85 | static void omap3430es2_clk_dss_usbhost_find_idlest(struct clk *clk, | 
 | 86 | 						    void __iomem **idlest_reg, | 
| Ranjith Lohithakshan | 419cc97 | 2010-02-24 12:05:54 -0700 | [diff] [blame] | 87 | 						    u8 *idlest_bit, | 
 | 88 | 						    u8 *idlest_val) | 
| Paul Walmsley | 3c82e22 | 2009-07-24 19:44:06 -0600 | [diff] [blame] | 89 | { | 
 | 90 | 	u32 r; | 
 | 91 |  | 
 | 92 | 	r = (((__force u32)clk->enable_reg & ~0xf0) | 0x20); | 
 | 93 | 	*idlest_reg = (__force void __iomem *)r; | 
 | 94 | 	/* USBHOST_IDLE has same shift */ | 
 | 95 | 	*idlest_bit = OMAP3430ES2_ST_DSS_IDLE_SHIFT; | 
| Ranjith Lohithakshan | 419cc97 | 2010-02-24 12:05:54 -0700 | [diff] [blame] | 96 | 	*idlest_val = OMAP34XX_CM_IDLEST_VAL; | 
| Paul Walmsley | 3c82e22 | 2009-07-24 19:44:06 -0600 | [diff] [blame] | 97 | } | 
 | 98 |  | 
| Paul Walmsley | 82e9bd5 | 2009-12-08 16:18:47 -0700 | [diff] [blame] | 99 | const struct clkops clkops_omap3430es2_dss_usbhost_wait = { | 
 | 100 | 	.enable		= omap2_dflt_clk_enable, | 
 | 101 | 	.disable	= omap2_dflt_clk_disable, | 
 | 102 | 	.find_idlest	= omap3430es2_clk_dss_usbhost_find_idlest, | 
 | 103 | 	.find_companion = omap2_clk_dflt_find_companion, | 
 | 104 | }; | 
 | 105 |  | 
| Paul Walmsley | ec538e3 | 2011-02-25 15:39:30 -0700 | [diff] [blame] | 106 | const struct clkops clkops_omap3430es2_iclk_dss_usbhost_wait = { | 
 | 107 | 	.enable		= omap2_dflt_clk_enable, | 
 | 108 | 	.disable	= omap2_dflt_clk_disable, | 
 | 109 | 	.find_idlest	= omap3430es2_clk_dss_usbhost_find_idlest, | 
 | 110 | 	.find_companion = omap2_clk_dflt_find_companion, | 
 | 111 | 	.allow_idle	= omap2_clkt_iclk_allow_idle, | 
 | 112 | 	.deny_idle	= omap2_clkt_iclk_deny_idle, | 
 | 113 | }; | 
 | 114 |  | 
| Paul Walmsley | 3c82e22 | 2009-07-24 19:44:06 -0600 | [diff] [blame] | 115 | /** | 
 | 116 |  * omap3430es2_clk_hsotgusb_find_idlest - return CM_IDLEST info for HSOTGUSB | 
 | 117 |  * @clk: struct clk * being enabled | 
 | 118 |  * @idlest_reg: void __iomem ** to store CM_IDLEST reg address into | 
 | 119 |  * @idlest_bit: pointer to a u8 to store the CM_IDLEST bit shift into | 
| Ranjith Lohithakshan | 419cc97 | 2010-02-24 12:05:54 -0700 | [diff] [blame] | 120 |  * @idlest_val: pointer to a u8 to store the CM_IDLEST indicator | 
| Paul Walmsley | 3c82e22 | 2009-07-24 19:44:06 -0600 | [diff] [blame] | 121 |  * | 
 | 122 |  * The OMAP3430ES2 HSOTGUSB target CM_IDLEST bit is at a different | 
 | 123 |  * shift from the CM_{I,F}CLKEN bit.  Pass back the correct info via | 
 | 124 |  * @idlest_reg and @idlest_bit.  No return value. | 
 | 125 |  */ | 
 | 126 | static void omap3430es2_clk_hsotgusb_find_idlest(struct clk *clk, | 
 | 127 | 						 void __iomem **idlest_reg, | 
| Ranjith Lohithakshan | 419cc97 | 2010-02-24 12:05:54 -0700 | [diff] [blame] | 128 | 						 u8 *idlest_bit, | 
 | 129 | 						 u8 *idlest_val) | 
| Paul Walmsley | 3c82e22 | 2009-07-24 19:44:06 -0600 | [diff] [blame] | 130 | { | 
 | 131 | 	u32 r; | 
 | 132 |  | 
 | 133 | 	r = (((__force u32)clk->enable_reg & ~0xf0) | 0x20); | 
 | 134 | 	*idlest_reg = (__force void __iomem *)r; | 
 | 135 | 	*idlest_bit = OMAP3430ES2_ST_HSOTGUSB_IDLE_SHIFT; | 
| Ranjith Lohithakshan | 419cc97 | 2010-02-24 12:05:54 -0700 | [diff] [blame] | 136 | 	*idlest_val = OMAP34XX_CM_IDLEST_VAL; | 
| Paul Walmsley | 3c82e22 | 2009-07-24 19:44:06 -0600 | [diff] [blame] | 137 | } | 
 | 138 |  | 
| Paul Walmsley | 82e9bd5 | 2009-12-08 16:18:47 -0700 | [diff] [blame] | 139 | const struct clkops clkops_omap3430es2_hsotgusb_wait = { | 
 | 140 | 	.enable		= omap2_dflt_clk_enable, | 
 | 141 | 	.disable	= omap2_dflt_clk_disable, | 
 | 142 | 	.find_idlest	= omap3430es2_clk_hsotgusb_find_idlest, | 
 | 143 | 	.find_companion = omap2_clk_dflt_find_companion, | 
 | 144 | }; | 
| Paul Walmsley | ec538e3 | 2011-02-25 15:39:30 -0700 | [diff] [blame] | 145 |  | 
 | 146 | const struct clkops clkops_omap3430es2_iclk_hsotgusb_wait = { | 
 | 147 | 	.enable		= omap2_dflt_clk_enable, | 
 | 148 | 	.disable	= omap2_dflt_clk_disable, | 
 | 149 | 	.find_idlest	= omap3430es2_clk_hsotgusb_find_idlest, | 
 | 150 | 	.find_companion = omap2_clk_dflt_find_companion, | 
 | 151 | 	.allow_idle	= omap2_clkt_iclk_allow_idle, | 
 | 152 | 	.deny_idle	= omap2_clkt_iclk_deny_idle, | 
 | 153 | }; |