blob: a03919df00ef9b573c402b7342efaccad720a465 [file] [log] [blame]
Paul Walmsley530e5442011-02-25 15:39:28 -07001/*
2 * OMAP2/3 interface clock control
3 *
4 * Copyright (C) 2011 Nokia Corporation
5 * Paul Walmsley
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License version 2 as
9 * published by the Free Software Foundation.
10 */
11#undef DEBUG
12
13#include <linux/kernel.h>
Mike Turquette32cc0022012-11-10 16:58:41 -070014#include <linux/clk-provider.h>
Paul Walmsley530e5442011-02-25 15:39:28 -070015#include <linux/io.h>
Tero Kristoef14db02015-03-02 14:33:54 +020016#include <linux/clk/ti.h>
Paul Walmsley530e5442011-02-25 15:39:28 -070017
Paul Walmsley530e5442011-02-25 15:39:28 -070018#include "clock.h"
Tero Kristoacd052b2014-07-02 11:47:47 +030019
20/* Register offsets */
21#define CM_AUTOIDLE 0x30
22#define CM_ICLKEN 0x10
Paul Walmsley530e5442011-02-25 15:39:28 -070023
24/* Private functions */
25
26/* XXX */
Rajendra Nayakb4777a22012-04-27 15:53:48 +053027void omap2_clkt_iclk_allow_idle(struct clk_hw_omap *clk)
Paul Walmsley530e5442011-02-25 15:39:28 -070028{
Tero Kristo519ab8b2013-10-22 11:49:58 +030029 u32 v;
30 void __iomem *r;
Paul Walmsley530e5442011-02-25 15:39:28 -070031
Tero Kristo519ab8b2013-10-22 11:49:58 +030032 r = (__force void __iomem *)
33 ((__force u32)clk->enable_reg ^ (CM_AUTOIDLE ^ CM_ICLKEN));
Paul Walmsley530e5442011-02-25 15:39:28 -070034
Tero Kristoef14db02015-03-02 14:33:54 +020035 v = ti_clk_ll_ops->clk_readl(r);
Paul Walmsley530e5442011-02-25 15:39:28 -070036 v |= (1 << clk->enable_bit);
Tero Kristoef14db02015-03-02 14:33:54 +020037 ti_clk_ll_ops->clk_writel(v, r);
Paul Walmsley530e5442011-02-25 15:39:28 -070038}
39
40/* XXX */
Rajendra Nayakb4777a22012-04-27 15:53:48 +053041void omap2_clkt_iclk_deny_idle(struct clk_hw_omap *clk)
Paul Walmsley530e5442011-02-25 15:39:28 -070042{
Tero Kristo519ab8b2013-10-22 11:49:58 +030043 u32 v;
44 void __iomem *r;
Paul Walmsley530e5442011-02-25 15:39:28 -070045
Tero Kristo519ab8b2013-10-22 11:49:58 +030046 r = (__force void __iomem *)
47 ((__force u32)clk->enable_reg ^ (CM_AUTOIDLE ^ CM_ICLKEN));
Paul Walmsley530e5442011-02-25 15:39:28 -070048
Tero Kristoef14db02015-03-02 14:33:54 +020049 v = ti_clk_ll_ops->clk_readl(r);
Paul Walmsley530e5442011-02-25 15:39:28 -070050 v &= ~(1 << clk->enable_bit);
Tero Kristoef14db02015-03-02 14:33:54 +020051 ti_clk_ll_ops->clk_writel(v, r);
Paul Walmsley530e5442011-02-25 15:39:28 -070052}
53
54/* Public data */
55
Rajendra Nayakb4777a22012-04-27 15:53:48 +053056const struct clk_hw_omap_ops clkhwops_iclk = {
57 .allow_idle = omap2_clkt_iclk_allow_idle,
58 .deny_idle = omap2_clkt_iclk_deny_idle,
59};
60
Mike Turquette32cc0022012-11-10 16:58:41 -070061const struct clk_hw_omap_ops clkhwops_iclk_wait = {
62 .allow_idle = omap2_clkt_iclk_allow_idle,
63 .deny_idle = omap2_clkt_iclk_deny_idle,
64 .find_idlest = omap2_clk_dflt_find_idlest,
65 .find_companion = omap2_clk_dflt_find_companion,
66};