0001
0002
0003
0004
0005
0006
0007
0008 #undef DEBUG
0009
0010 #include <linux/kernel.h>
0011 #include <linux/clk-provider.h>
0012 #include <linux/io.h>
0013 #include <linux/clk/ti.h>
0014
0015 #include "clock.h"
0016
0017
0018 #define OMAP24XX_CM_FCLKEN2 0x04
0019 #define CM_AUTOIDLE 0x30
0020 #define CM_ICLKEN 0x10
0021 #define CM_IDLEST 0x20
0022
0023 #define OMAP24XX_CM_IDLEST_VAL 0
0024
0025
0026
0027
0028 void omap2_clkt_iclk_allow_idle(struct clk_hw_omap *clk)
0029 {
0030 u32 v;
0031 struct clk_omap_reg r;
0032
0033 memcpy(&r, &clk->enable_reg, sizeof(r));
0034 r.offset ^= (CM_AUTOIDLE ^ CM_ICLKEN);
0035
0036 v = ti_clk_ll_ops->clk_readl(&r);
0037 v |= (1 << clk->enable_bit);
0038 ti_clk_ll_ops->clk_writel(v, &r);
0039 }
0040
0041
0042 void omap2_clkt_iclk_deny_idle(struct clk_hw_omap *clk)
0043 {
0044 u32 v;
0045 struct clk_omap_reg r;
0046
0047 memcpy(&r, &clk->enable_reg, sizeof(r));
0048
0049 r.offset ^= (CM_AUTOIDLE ^ CM_ICLKEN);
0050
0051 v = ti_clk_ll_ops->clk_readl(&r);
0052 v &= ~(1 << clk->enable_bit);
0053 ti_clk_ll_ops->clk_writel(v, &r);
0054 }
0055
0056
0057
0058
0059
0060
0061
0062
0063
0064
0065
0066
0067
0068 static void omap2430_clk_i2chs_find_idlest(struct clk_hw_omap *clk,
0069 struct clk_omap_reg *idlest_reg,
0070 u8 *idlest_bit,
0071 u8 *idlest_val)
0072 {
0073 memcpy(idlest_reg, &clk->enable_reg, sizeof(*idlest_reg));
0074 idlest_reg->offset ^= (OMAP24XX_CM_FCLKEN2 ^ CM_IDLEST);
0075 *idlest_bit = clk->enable_bit;
0076 *idlest_val = OMAP24XX_CM_IDLEST_VAL;
0077 }
0078
0079
0080
0081 const struct clk_hw_omap_ops clkhwops_iclk = {
0082 .allow_idle = omap2_clkt_iclk_allow_idle,
0083 .deny_idle = omap2_clkt_iclk_deny_idle,
0084 };
0085
0086 const struct clk_hw_omap_ops clkhwops_iclk_wait = {
0087 .allow_idle = omap2_clkt_iclk_allow_idle,
0088 .deny_idle = omap2_clkt_iclk_deny_idle,
0089 .find_idlest = omap2_clk_dflt_find_idlest,
0090 .find_companion = omap2_clk_dflt_find_companion,
0091 };
0092
0093
0094 const struct clk_hw_omap_ops clkhwops_omap2430_i2chs_wait = {
0095 .find_idlest = omap2430_clk_i2chs_find_idlest,
0096 .find_companion = omap2_clk_dflt_find_companion,
0097 };