Back to home page

OSCL-LXR

 
 

    


0001 // SPDX-License-Identifier: GPL-2.0-only
0002 /*
0003  * OMAP2/3 interface clock control
0004  *
0005  * Copyright (C) 2011 Nokia Corporation
0006  * Paul Walmsley
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 /* Register offsets */
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 /* Private functions */
0026 
0027 /* XXX */
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 /* XXX */
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  * omap2430_clk_i2chs_find_idlest - return CM_IDLEST info for 2430 I2CHS
0058  * @clk: struct clk * being enabled
0059  * @idlest_reg: void __iomem ** to store CM_IDLEST reg address into
0060  * @idlest_bit: pointer to a u8 to store the CM_IDLEST bit shift into
0061  * @idlest_val: pointer to a u8 to store the CM_IDLEST indicator
0062  *
0063  * OMAP2430 I2CHS CM_IDLEST bits are in CM_IDLEST1_CORE, but the
0064  * CM_*CLKEN bits are in CM_{I,F}CLKEN2_CORE.  This custom function
0065  * passes back the correct CM_IDLEST register address for I2CHS
0066  * modules.  No return value.
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 /* Public data */
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 /* 2430 I2CHS has non-standard IDLEST register */
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 };