blob: 4596468e50ab13cba0f3890a7ce1c2b02c063a8b [file] [log] [blame]
Paul Walmsley02e19a92008-03-18 15:09:51 +02001/*
2 * OMAP3-specific clock framework functions
3 *
Paul Walmsley542313c2008-07-03 12:24:45 +03004 * Copyright (C) 2007-2008 Texas Instruments, Inc.
Paul Walmsleyec538e32011-02-25 15:39:30 -07005 * Copyright (C) 2007-2011 Nokia Corporation
Paul Walmsley02e19a92008-03-18 15:09:51 +02006 *
Paul Walmsleyda4d2902010-01-26 20:13:10 -07007 * Paul Walmsley
8 * Jouni Högander
Paul Walmsley02e19a92008-03-18 15:09:51 +02009 *
10 * Parts of this code are based on code written by
Paul Walmsley657ebfa2010-02-22 22:09:20 -070011 * Richard Woodruff, Tony Lindgren, Tuukka Tikkanen, Karthik Dasu,
12 * Russell King
Paul Walmsley02e19a92008-03-18 15:09:51 +020013 *
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 Walmsley02e19a92008-03-18 15:09:51 +020020#include <linux/kernel.h>
Paul Walmsley02e19a92008-03-18 15:09:51 +020021#include <linux/clk.h>
22#include <linux/io.h>
23
Paul Walmsley02e19a92008-03-18 15:09:51 +020024#include "clock.h"
Paul Walmsley82e9bd52009-12-08 16:18:47 -070025#include "clock34xx.h"
Paul Walmsleyff4ae5d2012-10-21 01:01:11 -060026#include "cm3xxx.h"
Paul Walmsley02e19a92008-03-18 15:09:51 +020027#include "cm-regbits-34xx.h"
28
Paul Walmsley02e19a92008-03-18 15:09:51 +020029/**
Paul Walmsley3c82e222009-07-24 19:44:06 -060030 * omap3430es2_clk_ssi_find_idlest - return CM_IDLEST info for SSI
31 * @clk: struct clk * being enabled
32 * @idlest_reg: void __iomem ** to store CM_IDLEST reg address into
33 * @idlest_bit: pointer to a u8 to store the CM_IDLEST bit shift into
Ranjith Lohithakshan419cc972010-02-24 12:05:54 -070034 * @idlest_val: pointer to a u8 to store the CM_IDLEST indicator
Paul Walmsley3c82e222009-07-24 19:44:06 -060035 *
36 * The OMAP3430ES2 SSI target CM_IDLEST bit is at a different shift
37 * from the CM_{I,F}CLKEN bit. Pass back the correct info via
38 * @idlest_reg and @idlest_bit. No return value.
39 */
Rajendra Nayakb4777a22012-04-27 15:53:48 +053040static void omap3430es2_clk_ssi_find_idlest(struct clk_hw_omap *clk,
Paul Walmsley3c82e222009-07-24 19:44:06 -060041 void __iomem **idlest_reg,
Ranjith Lohithakshan419cc972010-02-24 12:05:54 -070042 u8 *idlest_bit,
43 u8 *idlest_val)
Paul Walmsley3c82e222009-07-24 19:44:06 -060044{
45 u32 r;
46
47 r = (((__force u32)clk->enable_reg & ~0xf0) | 0x20);
48 *idlest_reg = (__force void __iomem *)r;
49 *idlest_bit = OMAP3430ES2_ST_SSI_IDLE_SHIFT;
Ranjith Lohithakshan419cc972010-02-24 12:05:54 -070050 *idlest_val = OMAP34XX_CM_IDLEST_VAL;
Paul Walmsley3c82e222009-07-24 19:44:06 -060051}
Rajendra Nayakb4777a22012-04-27 15:53:48 +053052const struct clk_hw_omap_ops clkhwops_omap3430es2_ssi_wait = {
53 .find_idlest = omap3430es2_clk_ssi_find_idlest,
54 .find_companion = omap2_clk_dflt_find_companion,
55};
Paul Walmsley3c82e222009-07-24 19:44:06 -060056
Rajendra Nayakb4777a22012-04-27 15:53:48 +053057const struct clk_hw_omap_ops clkhwops_omap3430es2_iclk_ssi_wait = {
58 .allow_idle = omap2_clkt_iclk_allow_idle,
59 .deny_idle = omap2_clkt_iclk_deny_idle,
60 .find_idlest = omap3430es2_clk_ssi_find_idlest,
61 .find_companion = omap2_clk_dflt_find_companion,
62};
Paul Walmsleyec538e32011-02-25 15:39:30 -070063
Paul Walmsley3c82e222009-07-24 19:44:06 -060064/**
65 * omap3430es2_clk_dss_usbhost_find_idlest - CM_IDLEST info for DSS, USBHOST
66 * @clk: struct clk * being enabled
67 * @idlest_reg: void __iomem ** to store CM_IDLEST reg address into
68 * @idlest_bit: pointer to a u8 to store the CM_IDLEST bit shift into
Ranjith Lohithakshan419cc972010-02-24 12:05:54 -070069 * @idlest_val: pointer to a u8 to store the CM_IDLEST indicator
Paul Walmsley3c82e222009-07-24 19:44:06 -060070 *
71 * Some OMAP modules on OMAP3 ES2+ chips have both initiator and
72 * target IDLEST bits. For our purposes, we are concerned with the
73 * target IDLEST bits, which exist at a different bit position than
74 * the *CLKEN bit position for these modules (DSS and USBHOST) (The
75 * default find_idlest code assumes that they are at the same
76 * position.) No return value.
77 */
Rajendra Nayakb4777a22012-04-27 15:53:48 +053078static void omap3430es2_clk_dss_usbhost_find_idlest(struct clk_hw_omap *clk,
Paul Walmsley3c82e222009-07-24 19:44:06 -060079 void __iomem **idlest_reg,
Ranjith Lohithakshan419cc972010-02-24 12:05:54 -070080 u8 *idlest_bit,
81 u8 *idlest_val)
Paul Walmsley3c82e222009-07-24 19:44:06 -060082{
83 u32 r;
84
85 r = (((__force u32)clk->enable_reg & ~0xf0) | 0x20);
86 *idlest_reg = (__force void __iomem *)r;
87 /* USBHOST_IDLE has same shift */
88 *idlest_bit = OMAP3430ES2_ST_DSS_IDLE_SHIFT;
Ranjith Lohithakshan419cc972010-02-24 12:05:54 -070089 *idlest_val = OMAP34XX_CM_IDLEST_VAL;
Paul Walmsley3c82e222009-07-24 19:44:06 -060090}
Rajendra Nayak25f42142012-04-27 16:35:52 +053091
Rajendra Nayakb4777a22012-04-27 15:53:48 +053092const struct clk_hw_omap_ops clkhwops_omap3430es2_dss_usbhost_wait = {
93 .find_idlest = omap3430es2_clk_dss_usbhost_find_idlest,
94 .find_companion = omap2_clk_dflt_find_companion,
95};
Paul Walmsley3c82e222009-07-24 19:44:06 -060096
Rajendra Nayakb4777a22012-04-27 15:53:48 +053097const struct clk_hw_omap_ops clkhwops_omap3430es2_iclk_dss_usbhost_wait = {
98 .allow_idle = omap2_clkt_iclk_allow_idle,
99 .deny_idle = omap2_clkt_iclk_deny_idle,
100 .find_idlest = omap3430es2_clk_dss_usbhost_find_idlest,
101 .find_companion = omap2_clk_dflt_find_companion,
102};
Paul Walmsleyec538e32011-02-25 15:39:30 -0700103
Paul Walmsley3c82e222009-07-24 19:44:06 -0600104/**
105 * omap3430es2_clk_hsotgusb_find_idlest - return CM_IDLEST info for HSOTGUSB
106 * @clk: struct clk * being enabled
107 * @idlest_reg: void __iomem ** to store CM_IDLEST reg address into
108 * @idlest_bit: pointer to a u8 to store the CM_IDLEST bit shift into
Ranjith Lohithakshan419cc972010-02-24 12:05:54 -0700109 * @idlest_val: pointer to a u8 to store the CM_IDLEST indicator
Paul Walmsley3c82e222009-07-24 19:44:06 -0600110 *
111 * The OMAP3430ES2 HSOTGUSB target CM_IDLEST bit is at a different
112 * shift from the CM_{I,F}CLKEN bit. Pass back the correct info via
113 * @idlest_reg and @idlest_bit. No return value.
114 */
Rajendra Nayakb4777a22012-04-27 15:53:48 +0530115static void omap3430es2_clk_hsotgusb_find_idlest(struct clk_hw_omap *clk,
Paul Walmsley3c82e222009-07-24 19:44:06 -0600116 void __iomem **idlest_reg,
Ranjith Lohithakshan419cc972010-02-24 12:05:54 -0700117 u8 *idlest_bit,
118 u8 *idlest_val)
Paul Walmsley3c82e222009-07-24 19:44:06 -0600119{
120 u32 r;
121
122 r = (((__force u32)clk->enable_reg & ~0xf0) | 0x20);
123 *idlest_reg = (__force void __iomem *)r;
124 *idlest_bit = OMAP3430ES2_ST_HSOTGUSB_IDLE_SHIFT;
Ranjith Lohithakshan419cc972010-02-24 12:05:54 -0700125 *idlest_val = OMAP34XX_CM_IDLEST_VAL;
Paul Walmsley3c82e222009-07-24 19:44:06 -0600126}
Rajendra Nayak25f42142012-04-27 16:35:52 +0530127
Rajendra Nayakb4777a22012-04-27 15:53:48 +0530128const struct clk_hw_omap_ops clkhwops_omap3430es2_iclk_hsotgusb_wait = {
129 .allow_idle = omap2_clkt_iclk_allow_idle,
130 .deny_idle = omap2_clkt_iclk_deny_idle,
131 .find_idlest = omap3430es2_clk_hsotgusb_find_idlest,
132 .find_companion = omap2_clk_dflt_find_companion,
133};
Paul Walmsley3c82e222009-07-24 19:44:06 -0600134
Rajendra Nayakb4777a22012-04-27 15:53:48 +0530135const struct clk_hw_omap_ops clkhwops_omap3430es2_hsotgusb_wait = {
136 .find_idlest = omap3430es2_clk_hsotgusb_find_idlest,
137 .find_companion = omap2_clk_dflt_find_companion,
138};