Commit 6c0afb50 authored by Tero Kristo's avatar Tero Kristo

clk: ti: convert to use proper register definition for all accesses

Currently, TI clock driver uses an encapsulated struct that is cast into
a void pointer to store all register addresses. This can be considered
as rather nasty hackery, and prevents from expanding the register
address field also. Instead, replace all the code to use proper struct
in place for this, which contains all the previously used data.

This patch is rather large as it is touching multiple files, but this
can't be split up as we need to avoid any boot breakage.
Signed-off-by: default avatarTero Kristo <t-kristo@ti.com>
Acked-by: default avatarTony Lindgren <tony@atomide.com>
parent 473adbf4
...@@ -138,7 +138,8 @@ int omap2_reprogram_dpllcore(struct clk_hw *hw, unsigned long rate, ...@@ -138,7 +138,8 @@ int omap2_reprogram_dpllcore(struct clk_hw *hw, unsigned long rate,
if (!dd) if (!dd)
return -EINVAL; return -EINVAL;
tmpset.cm_clksel1_pll = readl_relaxed(dd->mult_div1_reg); tmpset.cm_clksel1_pll =
omap_clk_ll_ops.clk_readl(&dd->mult_div1_reg);
tmpset.cm_clksel1_pll &= ~(dd->mult_mask | tmpset.cm_clksel1_pll &= ~(dd->mult_mask |
dd->div1_mask); dd->div1_mask);
div = ((curr_prcm_set->xtal_speed / 1000000) - 1); div = ((curr_prcm_set->xtal_speed / 1000000) - 1);
......
...@@ -54,7 +54,7 @@ u16 cpu_mask; ...@@ -54,7 +54,7 @@ u16 cpu_mask;
#define OMAP3PLUS_DPLL_FINT_MIN 32000 #define OMAP3PLUS_DPLL_FINT_MIN 32000
#define OMAP3PLUS_DPLL_FINT_MAX 52000000 #define OMAP3PLUS_DPLL_FINT_MAX 52000000
static struct ti_clk_ll_ops omap_clk_ll_ops = { struct ti_clk_ll_ops omap_clk_ll_ops = {
.clkdm_clk_enable = clkdm_clk_enable, .clkdm_clk_enable = clkdm_clk_enable,
.clkdm_clk_disable = clkdm_clk_disable, .clkdm_clk_disable = clkdm_clk_disable,
.clkdm_lookup = clkdm_lookup, .clkdm_lookup = clkdm_lookup,
......
...@@ -64,6 +64,8 @@ ...@@ -64,6 +64,8 @@
#define OMAP4XXX_EN_DPLL_FRBYPASS 0x6 #define OMAP4XXX_EN_DPLL_FRBYPASS 0x6
#define OMAP4XXX_EN_DPLL_LOCKED 0x7 #define OMAP4XXX_EN_DPLL_LOCKED 0x7
extern struct ti_clk_ll_ops omap_clk_ll_ops;
extern u16 cpu_mask; extern u16 cpu_mask;
extern const struct clkops clkops_omap2_dflt_wait; extern const struct clkops clkops_omap2_dflt_wait;
......
...@@ -23,6 +23,7 @@ ...@@ -23,6 +23,7 @@
#define MAX_MODULE_READY_TIME 2000 #define MAX_MODULE_READY_TIME 2000
# ifndef __ASSEMBLER__ # ifndef __ASSEMBLER__
#include <linux/clk/ti.h>
extern void __iomem *cm_base; extern void __iomem *cm_base;
extern void __iomem *cm2_base; extern void __iomem *cm2_base;
extern void omap2_set_globals_cm(void __iomem *cm, void __iomem *cm2); extern void omap2_set_globals_cm(void __iomem *cm, void __iomem *cm2);
...@@ -50,7 +51,7 @@ extern void omap2_set_globals_cm(void __iomem *cm, void __iomem *cm2); ...@@ -50,7 +51,7 @@ extern void omap2_set_globals_cm(void __iomem *cm, void __iomem *cm2);
* @module_disable: ptr to the SoC CM-specific module_disable impl * @module_disable: ptr to the SoC CM-specific module_disable impl
*/ */
struct cm_ll_data { struct cm_ll_data {
int (*split_idlest_reg)(void __iomem *idlest_reg, s16 *prcm_inst, int (*split_idlest_reg)(struct clk_omap_reg *idlest_reg, s16 *prcm_inst,
u8 *idlest_reg_id); u8 *idlest_reg_id);
int (*wait_module_ready)(u8 part, s16 prcm_mod, u16 idlest_reg, int (*wait_module_ready)(u8 part, s16 prcm_mod, u16 idlest_reg,
u8 idlest_shift); u8 idlest_shift);
...@@ -60,7 +61,7 @@ struct cm_ll_data { ...@@ -60,7 +61,7 @@ struct cm_ll_data {
void (*module_disable)(u8 part, u16 inst, u16 clkctrl_offs); void (*module_disable)(u8 part, u16 inst, u16 clkctrl_offs);
}; };
extern int cm_split_idlest_reg(void __iomem *idlest_reg, s16 *prcm_inst, extern int cm_split_idlest_reg(struct clk_omap_reg *idlest_reg, s16 *prcm_inst,
u8 *idlest_reg_id); u8 *idlest_reg_id);
int omap_cm_wait_module_ready(u8 part, s16 prcm_mod, u16 idlest_reg, int omap_cm_wait_module_ready(u8 part, s16 prcm_mod, u16 idlest_reg,
u8 idlest_shift); u8 idlest_shift);
......
...@@ -204,7 +204,7 @@ void omap2xxx_cm_apll96_disable(void) ...@@ -204,7 +204,7 @@ void omap2xxx_cm_apll96_disable(void)
* XXX This function is only needed until absolute register addresses are * XXX This function is only needed until absolute register addresses are
* removed from the OMAP struct clk records. * removed from the OMAP struct clk records.
*/ */
static int omap2xxx_cm_split_idlest_reg(void __iomem *idlest_reg, static int omap2xxx_cm_split_idlest_reg(struct clk_omap_reg *idlest_reg,
s16 *prcm_inst, s16 *prcm_inst,
u8 *idlest_reg_id) u8 *idlest_reg_id)
{ {
...@@ -212,10 +212,7 @@ static int omap2xxx_cm_split_idlest_reg(void __iomem *idlest_reg, ...@@ -212,10 +212,7 @@ static int omap2xxx_cm_split_idlest_reg(void __iomem *idlest_reg,
u8 idlest_offs; u8 idlest_offs;
int i; int i;
if (idlest_reg < cm_base || idlest_reg > (cm_base + 0x0fff)) idlest_offs = idlest_reg->offset & 0xff;
return -EINVAL;
idlest_offs = (unsigned long)idlest_reg & 0xff;
for (i = 0; i < ARRAY_SIZE(omap2xxx_cm_idlest_offs); i++) { for (i = 0; i < ARRAY_SIZE(omap2xxx_cm_idlest_offs); i++) {
if (idlest_offs == omap2xxx_cm_idlest_offs[i]) { if (idlest_offs == omap2xxx_cm_idlest_offs[i]) {
*idlest_reg_id = i + 1; *idlest_reg_id = i + 1;
...@@ -226,7 +223,7 @@ static int omap2xxx_cm_split_idlest_reg(void __iomem *idlest_reg, ...@@ -226,7 +223,7 @@ static int omap2xxx_cm_split_idlest_reg(void __iomem *idlest_reg,
if (i == ARRAY_SIZE(omap2xxx_cm_idlest_offs)) if (i == ARRAY_SIZE(omap2xxx_cm_idlest_offs))
return -EINVAL; return -EINVAL;
offs = idlest_reg - cm_base; offs = idlest_reg->offset;
offs &= 0xff00; offs &= 0xff00;
*prcm_inst = offs; *prcm_inst = offs;
......
...@@ -118,7 +118,7 @@ static int omap3xxx_cm_wait_module_ready(u8 part, s16 prcm_mod, u16 idlest_id, ...@@ -118,7 +118,7 @@ static int omap3xxx_cm_wait_module_ready(u8 part, s16 prcm_mod, u16 idlest_id,
* XXX This function is only needed until absolute register addresses are * XXX This function is only needed until absolute register addresses are
* removed from the OMAP struct clk records. * removed from the OMAP struct clk records.
*/ */
static int omap3xxx_cm_split_idlest_reg(void __iomem *idlest_reg, static int omap3xxx_cm_split_idlest_reg(struct clk_omap_reg *idlest_reg,
s16 *prcm_inst, s16 *prcm_inst,
u8 *idlest_reg_id) u8 *idlest_reg_id)
{ {
...@@ -126,11 +126,7 @@ static int omap3xxx_cm_split_idlest_reg(void __iomem *idlest_reg, ...@@ -126,11 +126,7 @@ static int omap3xxx_cm_split_idlest_reg(void __iomem *idlest_reg,
u8 idlest_offs; u8 idlest_offs;
int i; int i;
if (idlest_reg < (cm_base + OMAP3430_IVA2_MOD) || idlest_offs = idlest_reg->offset & 0xff;
idlest_reg > (cm_base + 0x1ffff))
return -EINVAL;
idlest_offs = (unsigned long)idlest_reg & 0xff;
for (i = 0; i < ARRAY_SIZE(omap3xxx_cm_idlest_offs); i++) { for (i = 0; i < ARRAY_SIZE(omap3xxx_cm_idlest_offs); i++) {
if (idlest_offs == omap3xxx_cm_idlest_offs[i]) { if (idlest_offs == omap3xxx_cm_idlest_offs[i]) {
*idlest_reg_id = i + 1; *idlest_reg_id = i + 1;
...@@ -141,7 +137,7 @@ static int omap3xxx_cm_split_idlest_reg(void __iomem *idlest_reg, ...@@ -141,7 +137,7 @@ static int omap3xxx_cm_split_idlest_reg(void __iomem *idlest_reg,
if (i == ARRAY_SIZE(omap3xxx_cm_idlest_offs)) if (i == ARRAY_SIZE(omap3xxx_cm_idlest_offs))
return -EINVAL; return -EINVAL;
offs = idlest_reg - cm_base; offs = idlest_reg->offset;
offs &= 0xff00; offs &= 0xff00;
*prcm_inst = offs; *prcm_inst = offs;
......
...@@ -65,7 +65,7 @@ void __init omap2_set_globals_cm(void __iomem *cm, void __iomem *cm2) ...@@ -65,7 +65,7 @@ void __init omap2_set_globals_cm(void __iomem *cm, void __iomem *cm2)
* or 0 upon success. XXX This function is only needed until absolute * or 0 upon success. XXX This function is only needed until absolute
* register addresses are removed from the OMAP struct clk records. * register addresses are removed from the OMAP struct clk records.
*/ */
int cm_split_idlest_reg(void __iomem *idlest_reg, s16 *prcm_inst, int cm_split_idlest_reg(struct clk_omap_reg *idlest_reg, s16 *prcm_inst,
u8 *idlest_reg_id) u8 *idlest_reg_id)
{ {
if (!cm_ll_data->split_idlest_reg) { if (!cm_ll_data->split_idlest_reg) {
......
...@@ -55,20 +55,20 @@ static int dra7_apll_enable(struct clk_hw *hw) ...@@ -55,20 +55,20 @@ static int dra7_apll_enable(struct clk_hw *hw)
state <<= __ffs(ad->idlest_mask); state <<= __ffs(ad->idlest_mask);
/* Check is already locked */ /* Check is already locked */
v = ti_clk_ll_ops->clk_readl(ad->idlest_reg); v = ti_clk_ll_ops->clk_readl(&ad->idlest_reg);
if ((v & ad->idlest_mask) == state) if ((v & ad->idlest_mask) == state)
return r; return r;
v = ti_clk_ll_ops->clk_readl(ad->control_reg); v = ti_clk_ll_ops->clk_readl(&ad->control_reg);
v &= ~ad->enable_mask; v &= ~ad->enable_mask;
v |= APLL_FORCE_LOCK << __ffs(ad->enable_mask); v |= APLL_FORCE_LOCK << __ffs(ad->enable_mask);
ti_clk_ll_ops->clk_writel(v, ad->control_reg); ti_clk_ll_ops->clk_writel(v, &ad->control_reg);
state <<= __ffs(ad->idlest_mask); state <<= __ffs(ad->idlest_mask);
while (1) { while (1) {
v = ti_clk_ll_ops->clk_readl(ad->idlest_reg); v = ti_clk_ll_ops->clk_readl(&ad->idlest_reg);
if ((v & ad->idlest_mask) == state) if ((v & ad->idlest_mask) == state)
break; break;
if (i > MAX_APLL_WAIT_TRIES) if (i > MAX_APLL_WAIT_TRIES)
...@@ -99,10 +99,10 @@ static void dra7_apll_disable(struct clk_hw *hw) ...@@ -99,10 +99,10 @@ static void dra7_apll_disable(struct clk_hw *hw)
state <<= __ffs(ad->idlest_mask); state <<= __ffs(ad->idlest_mask);
v = ti_clk_ll_ops->clk_readl(ad->control_reg); v = ti_clk_ll_ops->clk_readl(&ad->control_reg);
v &= ~ad->enable_mask; v &= ~ad->enable_mask;
v |= APLL_AUTO_IDLE << __ffs(ad->enable_mask); v |= APLL_AUTO_IDLE << __ffs(ad->enable_mask);
ti_clk_ll_ops->clk_writel(v, ad->control_reg); ti_clk_ll_ops->clk_writel(v, &ad->control_reg);
} }
static int dra7_apll_is_enabled(struct clk_hw *hw) static int dra7_apll_is_enabled(struct clk_hw *hw)
...@@ -113,7 +113,7 @@ static int dra7_apll_is_enabled(struct clk_hw *hw) ...@@ -113,7 +113,7 @@ static int dra7_apll_is_enabled(struct clk_hw *hw)
ad = clk->dpll_data; ad = clk->dpll_data;
v = ti_clk_ll_ops->clk_readl(ad->control_reg); v = ti_clk_ll_ops->clk_readl(&ad->control_reg);
v &= ad->enable_mask; v &= ad->enable_mask;
v >>= __ffs(ad->enable_mask); v >>= __ffs(ad->enable_mask);
...@@ -185,6 +185,7 @@ static void __init of_dra7_apll_setup(struct device_node *node) ...@@ -185,6 +185,7 @@ static void __init of_dra7_apll_setup(struct device_node *node)
struct clk_hw_omap *clk_hw = NULL; struct clk_hw_omap *clk_hw = NULL;
struct clk_init_data *init = NULL; struct clk_init_data *init = NULL;
const char **parent_names = NULL; const char **parent_names = NULL;
int ret;
ad = kzalloc(sizeof(*ad), GFP_KERNEL); ad = kzalloc(sizeof(*ad), GFP_KERNEL);
clk_hw = kzalloc(sizeof(*clk_hw), GFP_KERNEL); clk_hw = kzalloc(sizeof(*clk_hw), GFP_KERNEL);
...@@ -212,10 +213,10 @@ static void __init of_dra7_apll_setup(struct device_node *node) ...@@ -212,10 +213,10 @@ static void __init of_dra7_apll_setup(struct device_node *node)
init->parent_names = parent_names; init->parent_names = parent_names;
ad->control_reg = ti_clk_get_reg_addr(node, 0); ret = ti_clk_get_reg_addr(node, 0, &ad->control_reg);
ad->idlest_reg = ti_clk_get_reg_addr(node, 1); ret |= ti_clk_get_reg_addr(node, 1, &ad->idlest_reg);
if (IS_ERR(ad->control_reg) || IS_ERR(ad->idlest_reg)) if (ret)
goto cleanup; goto cleanup;
ad->idlest_mask = 0x1; ad->idlest_mask = 0x1;
...@@ -241,7 +242,7 @@ static int omap2_apll_is_enabled(struct clk_hw *hw) ...@@ -241,7 +242,7 @@ static int omap2_apll_is_enabled(struct clk_hw *hw)
struct dpll_data *ad = clk->dpll_data; struct dpll_data *ad = clk->dpll_data;
u32 v; u32 v;
v = ti_clk_ll_ops->clk_readl(ad->control_reg); v = ti_clk_ll_ops->clk_readl(&ad->control_reg);
v &= ad->enable_mask; v &= ad->enable_mask;
v >>= __ffs(ad->enable_mask); v >>= __ffs(ad->enable_mask);
...@@ -267,13 +268,13 @@ static int omap2_apll_enable(struct clk_hw *hw) ...@@ -267,13 +268,13 @@ static int omap2_apll_enable(struct clk_hw *hw)
u32 v; u32 v;
int i = 0; int i = 0;
v = ti_clk_ll_ops->clk_readl(ad->control_reg); v = ti_clk_ll_ops->clk_readl(&ad->control_reg);
v &= ~ad->enable_mask; v &= ~ad->enable_mask;
v |= OMAP2_EN_APLL_LOCKED << __ffs(ad->enable_mask); v |= OMAP2_EN_APLL_LOCKED << __ffs(ad->enable_mask);
ti_clk_ll_ops->clk_writel(v, ad->control_reg); ti_clk_ll_ops->clk_writel(v, &ad->control_reg);
while (1) { while (1) {
v = ti_clk_ll_ops->clk_readl(ad->idlest_reg); v = ti_clk_ll_ops->clk_readl(&ad->idlest_reg);
if (v & ad->idlest_mask) if (v & ad->idlest_mask)
break; break;
if (i > MAX_APLL_WAIT_TRIES) if (i > MAX_APLL_WAIT_TRIES)
...@@ -297,10 +298,10 @@ static void omap2_apll_disable(struct clk_hw *hw) ...@@ -297,10 +298,10 @@ static void omap2_apll_disable(struct clk_hw *hw)
struct dpll_data *ad = clk->dpll_data; struct dpll_data *ad = clk->dpll_data;
u32 v; u32 v;
v = ti_clk_ll_ops->clk_readl(ad->control_reg); v = ti_clk_ll_ops->clk_readl(&ad->control_reg);
v &= ~ad->enable_mask; v &= ~ad->enable_mask;
v |= OMAP2_EN_APLL_STOPPED << __ffs(ad->enable_mask); v |= OMAP2_EN_APLL_STOPPED << __ffs(ad->enable_mask);
ti_clk_ll_ops->clk_writel(v, ad->control_reg); ti_clk_ll_ops->clk_writel(v, &ad->control_reg);
} }
static struct clk_ops omap2_apll_ops = { static struct clk_ops omap2_apll_ops = {
...@@ -315,10 +316,10 @@ static void omap2_apll_set_autoidle(struct clk_hw_omap *clk, u32 val) ...@@ -315,10 +316,10 @@ static void omap2_apll_set_autoidle(struct clk_hw_omap *clk, u32 val)
struct dpll_data *ad = clk->dpll_data; struct dpll_data *ad = clk->dpll_data;
u32 v; u32 v;
v = ti_clk_ll_ops->clk_readl(ad->autoidle_reg); v = ti_clk_ll_ops->clk_readl(&ad->autoidle_reg);
v &= ~ad->autoidle_mask; v &= ~ad->autoidle_mask;
v |= val << __ffs(ad->autoidle_mask); v |= val << __ffs(ad->autoidle_mask);
ti_clk_ll_ops->clk_writel(v, ad->control_reg); ti_clk_ll_ops->clk_writel(v, &ad->control_reg);
} }
#define OMAP2_APLL_AUTOIDLE_LOW_POWER_STOP 0x3 #define OMAP2_APLL_AUTOIDLE_LOW_POWER_STOP 0x3
...@@ -347,6 +348,7 @@ static void __init of_omap2_apll_setup(struct device_node *node) ...@@ -347,6 +348,7 @@ static void __init of_omap2_apll_setup(struct device_node *node)
struct clk *clk; struct clk *clk;
const char *parent_name; const char *parent_name;
u32 val; u32 val;
int ret;
ad = kzalloc(sizeof(*ad), GFP_KERNEL); ad = kzalloc(sizeof(*ad), GFP_KERNEL);
clk_hw = kzalloc(sizeof(*clk_hw), GFP_KERNEL); clk_hw = kzalloc(sizeof(*clk_hw), GFP_KERNEL);
...@@ -392,12 +394,11 @@ static void __init of_omap2_apll_setup(struct device_node *node) ...@@ -392,12 +394,11 @@ static void __init of_omap2_apll_setup(struct device_node *node)
ad->idlest_mask = 1 << val; ad->idlest_mask = 1 << val;
ad->control_reg = ti_clk_get_reg_addr(node, 0); ret = ti_clk_get_reg_addr(node, 0, &ad->control_reg);
ad->autoidle_reg = ti_clk_get_reg_addr(node, 1); ret |= ti_clk_get_reg_addr(node, 1, &ad->autoidle_reg);
ad->idlest_reg = ti_clk_get_reg_addr(node, 2); ret |= ti_clk_get_reg_addr(node, 2, &ad->idlest_reg);
if (IS_ERR(ad->control_reg) || IS_ERR(ad->autoidle_reg) || if (ret)
IS_ERR(ad->idlest_reg))
goto cleanup; goto cleanup;
clk = clk_register(NULL, &clk_hw->hw); clk = clk_register(NULL, &clk_hw->hw);
......
...@@ -25,7 +25,7 @@ ...@@ -25,7 +25,7 @@
#include "clock.h" #include "clock.h"
struct clk_ti_autoidle { struct clk_ti_autoidle {
void __iomem *reg; struct clk_omap_reg reg;
u8 shift; u8 shift;
u8 flags; u8 flags;
const char *name; const char *name;
...@@ -73,28 +73,28 @@ static void _allow_autoidle(struct clk_ti_autoidle *clk) ...@@ -73,28 +73,28 @@ static void _allow_autoidle(struct clk_ti_autoidle *clk)
{ {
u32 val; u32 val;
val = ti_clk_ll_ops->clk_readl(clk->reg); val = ti_clk_ll_ops->clk_readl(&clk->reg);
if (clk->flags & AUTOIDLE_LOW) if (clk->flags & AUTOIDLE_LOW)
val &= ~(1 << clk->shift); val &= ~(1 << clk->shift);
else else
val |= (1 << clk->shift); val |= (1 << clk->shift);
ti_clk_ll_ops->clk_writel(val, clk->reg); ti_clk_ll_ops->clk_writel(val, &clk->reg);
} }
static void _deny_autoidle(struct clk_ti_autoidle *clk) static void _deny_autoidle(struct clk_ti_autoidle *clk)
{ {
u32 val; u32 val;
val = ti_clk_ll_ops->clk_readl(clk->reg); val = ti_clk_ll_ops->clk_readl(&clk->reg);
if (clk->flags & AUTOIDLE_LOW) if (clk->flags & AUTOIDLE_LOW)
val |= (1 << clk->shift); val |= (1 << clk->shift);
else else
val &= ~(1 << clk->shift); val &= ~(1 << clk->shift);
ti_clk_ll_ops->clk_writel(val, clk->reg); ti_clk_ll_ops->clk_writel(val, &clk->reg);
} }
/** /**
...@@ -140,6 +140,7 @@ int __init of_ti_clk_autoidle_setup(struct device_node *node) ...@@ -140,6 +140,7 @@ int __init of_ti_clk_autoidle_setup(struct device_node *node)
{ {
u32 shift; u32 shift;
struct clk_ti_autoidle *clk; struct clk_ti_autoidle *clk;
int ret;
/* Check if this clock has autoidle support or not */ /* Check if this clock has autoidle support or not */
if (of_property_read_u32(node, "ti,autoidle-shift", &shift)) if (of_property_read_u32(node, "ti,autoidle-shift", &shift))
...@@ -152,11 +153,10 @@ int __init of_ti_clk_autoidle_setup(struct device_node *node) ...@@ -152,11 +153,10 @@ int __init of_ti_clk_autoidle_setup(struct device_node *node)
clk->shift = shift; clk->shift = shift;
clk->name = node->name; clk->name = node->name;
clk->reg = ti_clk_get_reg_addr(node, 0); ret = ti_clk_get_reg_addr(node, 0, &clk->reg);
if (ret) {
if (IS_ERR(clk->reg)) {
kfree(clk); kfree(clk);
return -EINVAL; return ret;
} }
if (of_property_read_bool(node, "ti,invert-autoidle-bit")) if (of_property_read_bool(node, "ti,invert-autoidle-bit"))
......
...@@ -52,14 +52,13 @@ ...@@ -52,14 +52,13 @@
* @idlest_reg and @idlest_bit. No return value. * @idlest_reg and @idlest_bit. No return value.
*/ */
static void omap3430es2_clk_ssi_find_idlest(struct clk_hw_omap *clk, static void omap3430es2_clk_ssi_find_idlest(struct clk_hw_omap *clk,
void __iomem **idlest_reg, struct clk_omap_reg *idlest_reg,
u8 *idlest_bit, u8 *idlest_bit,
u8 *idlest_val) u8 *idlest_val)
{ {
u32 r; memcpy(idlest_reg, &clk->enable_reg, sizeof(*idlest_reg));
idlest_reg->offset &= ~0xf0;
r = (((__force u32)clk->enable_reg & ~0xf0) | 0x20); idlest_reg->offset |= 0x20;
*idlest_reg = (__force void __iomem *)r;
*idlest_bit = OMAP3430ES2_ST_SSI_IDLE_SHIFT; *idlest_bit = OMAP3430ES2_ST_SSI_IDLE_SHIFT;
*idlest_val = OMAP34XX_CM_IDLEST_VAL; *idlest_val = OMAP34XX_CM_IDLEST_VAL;
} }
...@@ -85,15 +84,15 @@ const struct clk_hw_omap_ops clkhwops_omap3430es2_iclk_ssi_wait = { ...@@ -85,15 +84,15 @@ const struct clk_hw_omap_ops clkhwops_omap3430es2_iclk_ssi_wait = {
* default find_idlest code assumes that they are at the same * default find_idlest code assumes that they are at the same
* position.) No return value. * position.) No return value.
*/ */
static void omap3430es2_clk_dss_usbhost_find_idlest(struct clk_hw_omap *clk, static void
void __iomem **idlest_reg, omap3430es2_clk_dss_usbhost_find_idlest(struct clk_hw_omap *clk,
u8 *idlest_bit, struct clk_omap_reg *idlest_reg,
u8 *idlest_val) u8 *idlest_bit, u8 *idlest_val)
{ {
u32 r; memcpy(idlest_reg, &clk->enable_reg, sizeof(*idlest_reg));
r = (((__force u32)clk->enable_reg & ~0xf0) | 0x20); idlest_reg->offset &= ~0xf0;
*idlest_reg = (__force void __iomem *)r; idlest_reg->offset |= 0x20;
/* USBHOST_IDLE has same shift */ /* USBHOST_IDLE has same shift */
*idlest_bit = OMAP3430ES2_ST_DSS_IDLE_SHIFT; *idlest_bit = OMAP3430ES2_ST_DSS_IDLE_SHIFT;
*idlest_val = OMAP34XX_CM_IDLEST_VAL; *idlest_val = OMAP34XX_CM_IDLEST_VAL;
...@@ -122,15 +121,15 @@ const struct clk_hw_omap_ops clkhwops_omap3430es2_iclk_dss_usbhost_wait = { ...@@ -122,15 +121,15 @@ const struct clk_hw_omap_ops clkhwops_omap3430es2_iclk_dss_usbhost_wait = {
* shift from the CM_{I,F}CLKEN bit. Pass back the correct info via * shift from the CM_{I,F}CLKEN bit. Pass back the correct info via
* @idlest_reg and @idlest_bit. No return value. * @idlest_reg and @idlest_bit. No return value.
*/ */
static void omap3430es2_clk_hsotgusb_find_idlest(struct clk_hw_omap *clk, static void
void __iomem **idlest_reg, omap3430es2_clk_hsotgusb_find_idlest(struct clk_hw_omap *clk,
struct clk_omap_reg *idlest_reg,
u8 *idlest_bit, u8 *idlest_bit,
u8 *idlest_val) u8 *idlest_val)
{ {
u32 r; memcpy(idlest_reg, &clk->enable_reg, sizeof(*idlest_reg));
idlest_reg->offset &= ~0xf0;
r = (((__force u32)clk->enable_reg & ~0xf0) | 0x20); idlest_reg->offset |= 0x20;
*idlest_reg = (__force void __iomem *)r;
*idlest_bit = OMAP3430ES2_ST_HSOTGUSB_IDLE_SHIFT; *idlest_bit = OMAP3430ES2_ST_HSOTGUSB_IDLE_SHIFT;
*idlest_val = OMAP34XX_CM_IDLEST_VAL; *idlest_val = OMAP34XX_CM_IDLEST_VAL;
} }
...@@ -154,11 +153,11 @@ const struct clk_hw_omap_ops clkhwops_omap3430es2_iclk_hsotgusb_wait = { ...@@ -154,11 +153,11 @@ const struct clk_hw_omap_ops clkhwops_omap3430es2_iclk_hsotgusb_wait = {
* bit. A value of 1 indicates that clock is enabled. * bit. A value of 1 indicates that clock is enabled.
*/ */
static void am35xx_clk_find_idlest(struct clk_hw_omap *clk, static void am35xx_clk_find_idlest(struct clk_hw_omap *clk,
void __iomem **idlest_reg, struct clk_omap_reg *idlest_reg,
u8 *idlest_bit, u8 *idlest_bit,
u8 *idlest_val) u8 *idlest_val)
{ {
*idlest_reg = (__force void __iomem *)(clk->enable_reg); memcpy(idlest_reg, &clk->enable_reg, sizeof(*idlest_reg));
*idlest_bit = clk->enable_bit + AM35XX_IPSS_ICK_EN_ACK_OFFSET; *idlest_bit = clk->enable_bit + AM35XX_IPSS_ICK_EN_ACK_OFFSET;
*idlest_val = AM35XX_IPSS_CLK_IDLEST_VAL; *idlest_val = AM35XX_IPSS_CLK_IDLEST_VAL;
} }
...@@ -178,10 +177,10 @@ static void am35xx_clk_find_idlest(struct clk_hw_omap *clk, ...@@ -178,10 +177,10 @@ static void am35xx_clk_find_idlest(struct clk_hw_omap *clk,
* avoid this issue, and remove the casts. No return value. * avoid this issue, and remove the casts. No return value.
*/ */
static void am35xx_clk_find_companion(struct clk_hw_omap *clk, static void am35xx_clk_find_companion(struct clk_hw_omap *clk,
void __iomem **other_reg, struct clk_omap_reg *other_reg,
u8 *other_bit) u8 *other_bit)
{ {
*other_reg = (__force void __iomem *)(clk->enable_reg); memcpy(other_reg, &clk->enable_reg, sizeof(*other_reg));
if (clk->enable_bit & AM35XX_IPSS_ICK_MASK) if (clk->enable_bit & AM35XX_IPSS_ICK_MASK)
*other_bit = clk->enable_bit + AM35XX_IPSS_ICK_FCK_OFFSET; *other_bit = clk->enable_bit + AM35XX_IPSS_ICK_FCK_OFFSET;
else else
...@@ -205,14 +204,14 @@ const struct clk_hw_omap_ops clkhwops_am35xx_ipss_module_wait = { ...@@ -205,14 +204,14 @@ const struct clk_hw_omap_ops clkhwops_am35xx_ipss_module_wait = {
* and @idlest_bit. No return value. * and @idlest_bit. No return value.
*/ */
static void am35xx_clk_ipss_find_idlest(struct clk_hw_omap *clk, static void am35xx_clk_ipss_find_idlest(struct clk_hw_omap *clk,
void __iomem **idlest_reg, struct clk_omap_reg *idlest_reg,
u8 *idlest_bit, u8 *idlest_bit,
u8 *idlest_val) u8 *idlest_val)
{ {
u32 r; memcpy(idlest_reg, &clk->enable_reg, sizeof(*idlest_reg));
r = (((__force u32)clk->enable_reg & ~0xf0) | 0x20); idlest_reg->offset &= ~0xf0;
*idlest_reg = (__force void __iomem *)r; idlest_reg->offset |= 0x20;
*idlest_bit = AM35XX_ST_IPSS_SHIFT; *idlest_bit = AM35XX_ST_IPSS_SHIFT;
*idlest_val = OMAP34XX_CM_IDLEST_VAL; *idlest_val = OMAP34XX_CM_IDLEST_VAL;
} }
......
...@@ -43,27 +43,29 @@ struct clk_iomap { ...@@ -43,27 +43,29 @@ struct clk_iomap {
static struct clk_iomap *clk_memmaps[CLK_MAX_MEMMAPS]; static struct clk_iomap *clk_memmaps[CLK_MAX_MEMMAPS];
static void clk_memmap_writel(u32 val, void __iomem *reg) static void clk_memmap_writel(u32 val, const struct clk_omap_reg *reg)
{ {
struct clk_omap_reg *r = (struct clk_omap_reg *)&reg; struct clk_iomap *io = clk_memmaps[reg->index];
struct clk_iomap *io = clk_memmaps[r->index];
if (io->regmap) if (reg->ptr)
regmap_write(io->regmap, r->offset, val); writel_relaxed(val, reg->ptr);
else if (io->regmap)
regmap_write(io->regmap, reg->offset, val);
else else
writel_relaxed(val, io->mem + r->offset); writel_relaxed(val, io->mem + reg->offset);
} }
static u32 clk_memmap_readl(void __iomem *reg) static u32 clk_memmap_readl(const struct clk_omap_reg *reg)
{ {
u32 val; u32 val;
struct clk_omap_reg *r = (struct clk_omap_reg *)&reg; struct clk_iomap *io = clk_memmaps[reg->index];
struct clk_iomap *io = clk_memmaps[r->index];
if (io->regmap) if (reg->ptr)
regmap_read(io->regmap, r->offset, &val); val = readl_relaxed(reg->ptr);
else if (io->regmap)
regmap_read(io->regmap, reg->offset, &val);
else else
val = readl_relaxed(io->mem + r->offset); val = readl_relaxed(io->mem + reg->offset);
return val; return val;
} }
...@@ -162,20 +164,18 @@ int __init ti_clk_retry_init(struct device_node *node, struct clk_hw *hw, ...@@ -162,20 +164,18 @@ int __init ti_clk_retry_init(struct device_node *node, struct clk_hw *hw,
* ti_clk_get_reg_addr - get register address for a clock register * ti_clk_get_reg_addr - get register address for a clock register
* @node: device node for the clock * @node: device node for the clock
* @index: register index from the clock node * @index: register index from the clock node
* @reg: pointer to target register struct
* *
* Builds clock register address from device tree information. This * Builds clock register address from device tree information, and returns
* is a struct of type clk_omap_reg. Returns a pointer to the register * the data via the provided output pointer @reg. Returns 0 on success,
* address, or a pointer error value in failure. * negative error value on failure.
*/ */
void __iomem *ti_clk_get_reg_addr(struct device_node *node, int index) int ti_clk_get_reg_addr(struct device_node *node, int index,
struct clk_omap_reg *reg)
{ {
struct clk_omap_reg *reg;
u32 val; u32 val;
u32 tmp;
int i; int i;
reg = (struct clk_omap_reg *)&tmp;
for (i = 0; i < CLK_MAX_MEMMAPS; i++) { for (i = 0; i < CLK_MAX_MEMMAPS; i++) {
if (clocks_node_ptr[i] == node->parent) if (clocks_node_ptr[i] == node->parent)
break; break;
...@@ -183,19 +183,20 @@ void __iomem *ti_clk_get_reg_addr(struct device_node *node, int index) ...@@ -183,19 +183,20 @@ void __iomem *ti_clk_get_reg_addr(struct device_node *node, int index)
if (i == CLK_MAX_MEMMAPS) { if (i == CLK_MAX_MEMMAPS) {
pr_err("clk-provider not found for %s!\n", node->name); pr_err("clk-provider not found for %s!\n", node->name);
return IOMEM_ERR_PTR(-ENOENT); return -ENOENT;
} }
reg->index = i; reg->index = i;
if (of_property_read_u32_index(node, "reg", index, &val)) { if (of_property_read_u32_index(node, "reg", index, &val)) {
pr_err("%s must have reg[%d]!\n", node->name, index); pr_err("%s must have reg[%d]!\n", node->name, index);
return IOMEM_ERR_PTR(-EINVAL); return -EINVAL;
} }
reg->offset = val; reg->offset = val;
reg->ptr = NULL;
return (__force void __iomem *)tmp; return 0;
} }
/** /**
......
...@@ -55,7 +55,8 @@ ...@@ -55,7 +55,8 @@
* elapsed. XXX Deprecated - should be moved into drivers for the * elapsed. XXX Deprecated - should be moved into drivers for the
* individual IP block that the IDLEST register exists in. * individual IP block that the IDLEST register exists in.
*/ */
static int _wait_idlest_generic(struct clk_hw_omap *clk, void __iomem *reg, static int _wait_idlest_generic(struct clk_hw_omap *clk,
struct clk_omap_reg *reg,
u32 mask, u8 idlest, const char *name) u32 mask, u8 idlest, const char *name)
{ {
int i = 0, ena = 0; int i = 0, ena = 0;
...@@ -91,7 +92,7 @@ static int _wait_idlest_generic(struct clk_hw_omap *clk, void __iomem *reg, ...@@ -91,7 +92,7 @@ static int _wait_idlest_generic(struct clk_hw_omap *clk, void __iomem *reg,
*/ */
static void _omap2_module_wait_ready(struct clk_hw_omap *clk) static void _omap2_module_wait_ready(struct clk_hw_omap *clk)
{ {
void __iomem *companion_reg, *idlest_reg; struct clk_omap_reg companion_reg, idlest_reg;
u8 other_bit, idlest_bit, idlest_val, idlest_reg_id; u8 other_bit, idlest_bit, idlest_val, idlest_reg_id;
s16 prcm_mod; s16 prcm_mod;
int r; int r;
...@@ -99,17 +100,17 @@ static void _omap2_module_wait_ready(struct clk_hw_omap *clk) ...@@ -99,17 +100,17 @@ static void _omap2_module_wait_ready(struct clk_hw_omap *clk)
/* Not all modules have multiple clocks that their IDLEST depends on */ /* Not all modules have multiple clocks that their IDLEST depends on */
if (clk->ops->find_companion) { if (clk->ops->find_companion) {
clk->ops->find_companion(clk, &companion_reg, &other_bit); clk->ops->find_companion(clk, &companion_reg, &other_bit);
if (!(ti_clk_ll_ops->clk_readl(companion_reg) & if (!(ti_clk_ll_ops->clk_readl(&companion_reg) &
(1 << other_bit))) (1 << other_bit)))
return; return;
} }
clk->ops->find_idlest(clk, &idlest_reg, &idlest_bit, &idlest_val); clk->ops->find_idlest(clk, &idlest_reg, &idlest_bit, &idlest_val);
r = ti_clk_ll_ops->cm_split_idlest_reg(idlest_reg, &prcm_mod, r = ti_clk_ll_ops->cm_split_idlest_reg(&idlest_reg, &prcm_mod,
&idlest_reg_id); &idlest_reg_id);
if (r) { if (r) {
/* IDLEST register not in the CM module */ /* IDLEST register not in the CM module */
_wait_idlest_generic(clk, idlest_reg, (1 << idlest_bit), _wait_idlest_generic(clk, &idlest_reg, (1 << idlest_bit),
idlest_val, clk_hw_get_name(&clk->hw)); idlest_val, clk_hw_get_name(&clk->hw));
} else { } else {
ti_clk_ll_ops->cm_wait_module_ready(0, prcm_mod, idlest_reg_id, ti_clk_ll_ops->cm_wait_module_ready(0, prcm_mod, idlest_reg_id,
...@@ -139,17 +140,17 @@ static void _omap2_module_wait_ready(struct clk_hw_omap *clk) ...@@ -139,17 +140,17 @@ static void _omap2_module_wait_ready(struct clk_hw_omap *clk)
* avoid this issue, and remove the casts. No return value. * avoid this issue, and remove the casts. No return value.
*/ */
void omap2_clk_dflt_find_companion(struct clk_hw_omap *clk, void omap2_clk_dflt_find_companion(struct clk_hw_omap *clk,
void __iomem **other_reg, u8 *other_bit) struct clk_omap_reg *other_reg,
u8 *other_bit)
{ {
u32 r; memcpy(other_reg, &clk->enable_reg, sizeof(*other_reg));
/* /*
* Convert CM_ICLKEN* <-> CM_FCLKEN*. This conversion assumes * Convert CM_ICLKEN* <-> CM_FCLKEN*. This conversion assumes
* it's just a matter of XORing the bits. * it's just a matter of XORing the bits.
*/ */
r = ((__force u32)clk->enable_reg ^ (CM_FCLKEN ^ CM_ICLKEN)); other_reg->offset ^= (CM_FCLKEN ^ CM_ICLKEN);
*other_reg = (__force void __iomem *)r;
*other_bit = clk->enable_bit; *other_bit = clk->enable_bit;
} }
...@@ -168,13 +169,14 @@ void omap2_clk_dflt_find_companion(struct clk_hw_omap *clk, ...@@ -168,13 +169,14 @@ void omap2_clk_dflt_find_companion(struct clk_hw_omap *clk,
* CM_IDLEST2). This is not true for all modules. No return value. * CM_IDLEST2). This is not true for all modules. No return value.
*/ */
void omap2_clk_dflt_find_idlest(struct clk_hw_omap *clk, void omap2_clk_dflt_find_idlest(struct clk_hw_omap *clk,
void __iomem **idlest_reg, u8 *idlest_bit, struct clk_omap_reg *idlest_reg, u8 *idlest_bit,
u8 *idlest_val) u8 *idlest_val)
{ {
u32 r; memcpy(idlest_reg, &clk->enable_reg, sizeof(*idlest_reg));
idlest_reg->offset &= ~0xf0;
idlest_reg->offset |= 0x20;
r = (((__force u32)clk->enable_reg & ~0xf0) | 0x20);
*idlest_reg = (__force void __iomem *)r;
*idlest_bit = clk->enable_bit; *idlest_bit = clk->enable_bit;
/* /*
...@@ -222,31 +224,19 @@ int omap2_dflt_clk_enable(struct clk_hw *hw) ...@@ -222,31 +224,19 @@ int omap2_dflt_clk_enable(struct clk_hw *hw)
} }
} }
if (IS_ERR(clk->enable_reg)) {
pr_err("%s: %s missing enable_reg\n", __func__,
clk_hw_get_name(hw));
ret = -EINVAL;
goto err;
}
/* FIXME should not have INVERT_ENABLE bit here */ /* FIXME should not have INVERT_ENABLE bit here */
v = ti_clk_ll_ops->clk_readl(clk->enable_reg); v = ti_clk_ll_ops->clk_readl(&clk->enable_reg);
if (clk->flags & INVERT_ENABLE) if (clk->flags & INVERT_ENABLE)
v &= ~(1 << clk->enable_bit); v &= ~(1 << clk->enable_bit);
else else
v |= (1 << clk->enable_bit); v |= (1 << clk->enable_bit);
ti_clk_ll_ops->clk_writel(v, clk->enable_reg); ti_clk_ll_ops->clk_writel(v, &clk->enable_reg);
v = ti_clk_ll_ops->clk_readl(clk->enable_reg); /* OCP barrier */ v = ti_clk_ll_ops->clk_readl(&clk->enable_reg); /* OCP barrier */
if (clk->ops && clk->ops->find_idlest) if (clk->ops && clk->ops->find_idlest)
_omap2_module_wait_ready(clk); _omap2_module_wait_ready(clk);
return 0; return 0;
err:
if (clkdm_control && clk->clkdm)
ti_clk_ll_ops->clkdm_clk_disable(clk->clkdm, hw->clk);
return ret;
} }
/** /**
...@@ -264,22 +254,13 @@ void omap2_dflt_clk_disable(struct clk_hw *hw) ...@@ -264,22 +254,13 @@ void omap2_dflt_clk_disable(struct clk_hw *hw)
u32 v; u32 v;
clk = to_clk_hw_omap(hw); clk = to_clk_hw_omap(hw);
if (IS_ERR(clk->enable_reg)) {
/*
* 'independent' here refers to a clock which is not
* controlled by its parent.
*/
pr_err("%s: independent clock %s has no enable_reg\n",
__func__, clk_hw_get_name(hw));
return;
}
v = ti_clk_ll_ops->clk_readl(clk->enable_reg); v = ti_clk_ll_ops->clk_readl(&clk->enable_reg);
if (clk->flags & INVERT_ENABLE) if (clk->flags & INVERT_ENABLE)
v |= (1 << clk->enable_bit); v |= (1 << clk->enable_bit);
else else
v &= ~(1 << clk->enable_bit); v &= ~(1 << clk->enable_bit);
ti_clk_ll_ops->clk_writel(v, clk->enable_reg); ti_clk_ll_ops->clk_writel(v, &clk->enable_reg);
/* No OCP barrier needed here since it is a disable operation */ /* No OCP barrier needed here since it is a disable operation */
if (!(ti_clk_get_features()->flags & TI_CLK_DISABLE_CLKDM_CONTROL) && if (!(ti_clk_get_features()->flags & TI_CLK_DISABLE_CLKDM_CONTROL) &&
...@@ -300,7 +281,7 @@ int omap2_dflt_clk_is_enabled(struct clk_hw *hw) ...@@ -300,7 +281,7 @@ int omap2_dflt_clk_is_enabled(struct clk_hw *hw)
struct clk_hw_omap *clk = to_clk_hw_omap(hw); struct clk_hw_omap *clk = to_clk_hw_omap(hw);
u32 v; u32 v;
v = ti_clk_ll_ops->clk_readl(clk->enable_reg); v = ti_clk_ll_ops->clk_readl(&clk->enable_reg);
if (clk->flags & INVERT_ENABLE) if (clk->flags & INVERT_ENABLE)
v ^= BIT(clk->enable_bit); v ^= BIT(clk->enable_bit);
......
...@@ -213,7 +213,7 @@ u8 omap2_init_dpll_parent(struct clk_hw *hw) ...@@ -213,7 +213,7 @@ u8 omap2_init_dpll_parent(struct clk_hw *hw)
if (!dd) if (!dd)
return -EINVAL; return -EINVAL;
v = ti_clk_ll_ops->clk_readl(dd->control_reg); v = ti_clk_ll_ops->clk_readl(&dd->control_reg);
v &= dd->enable_mask; v &= dd->enable_mask;
v >>= __ffs(dd->enable_mask); v >>= __ffs(dd->enable_mask);
...@@ -249,14 +249,14 @@ unsigned long omap2_get_dpll_rate(struct clk_hw_omap *clk) ...@@ -249,14 +249,14 @@ unsigned long omap2_get_dpll_rate(struct clk_hw_omap *clk)
return 0; return 0;
/* Return bypass rate if DPLL is bypassed */ /* Return bypass rate if DPLL is bypassed */
v = ti_clk_ll_ops->clk_readl(dd->control_reg); v = ti_clk_ll_ops->clk_readl(&dd->control_reg);
v &= dd->enable_mask; v &= dd->enable_mask;
v >>= __ffs(dd->enable_mask); v >>= __ffs(dd->enable_mask);
if (_omap2_dpll_is_in_bypass(v)) if (_omap2_dpll_is_in_bypass(v))
return clk_hw_get_rate(dd->clk_bypass); return clk_hw_get_rate(dd->clk_bypass);
v = ti_clk_ll_ops->clk_readl(dd->mult_div1_reg); v = ti_clk_ll_ops->clk_readl(&dd->mult_div1_reg);
dpll_mult = v & dd->mult_mask; dpll_mult = v & dd->mult_mask;
dpll_mult >>= __ffs(dd->mult_mask); dpll_mult >>= __ffs(dd->mult_mask);
dpll_div = v & dd->div1_mask; dpll_div = v & dd->div1_mask;
......
...@@ -31,28 +31,29 @@ ...@@ -31,28 +31,29 @@
void omap2_clkt_iclk_allow_idle(struct clk_hw_omap *clk) void omap2_clkt_iclk_allow_idle(struct clk_hw_omap *clk)
{ {
u32 v; u32 v;
void __iomem *r; struct clk_omap_reg r;
r = (__force void __iomem *) memcpy(&r, &clk->enable_reg, sizeof(r));
((__force u32)clk->enable_reg ^ (CM_AUTOIDLE ^ CM_ICLKEN)); r.offset ^= (CM_AUTOIDLE ^ CM_ICLKEN);
v = ti_clk_ll_ops->clk_readl(r); v = ti_clk_ll_ops->clk_readl(&r);
v |= (1 << clk->enable_bit); v |= (1 << clk->enable_bit);
ti_clk_ll_ops->clk_writel(v, r); ti_clk_ll_ops->clk_writel(v, &r);
} }
/* XXX */ /* XXX */
void omap2_clkt_iclk_deny_idle(struct clk_hw_omap *clk) void omap2_clkt_iclk_deny_idle(struct clk_hw_omap *clk)
{ {
u32 v; u32 v;
void __iomem *r; struct clk_omap_reg r;
r = (__force void __iomem *) memcpy(&r, &clk->enable_reg, sizeof(r));
((__force u32)clk->enable_reg ^ (CM_AUTOIDLE ^ CM_ICLKEN));
v = ti_clk_ll_ops->clk_readl(r); r.offset ^= (CM_AUTOIDLE ^ CM_ICLKEN);
v = ti_clk_ll_ops->clk_readl(&r);
v &= ~(1 << clk->enable_bit); v &= ~(1 << clk->enable_bit);
ti_clk_ll_ops->clk_writel(v, r); ti_clk_ll_ops->clk_writel(v, &r);
} }
/** /**
...@@ -68,14 +69,12 @@ void omap2_clkt_iclk_deny_idle(struct clk_hw_omap *clk) ...@@ -68,14 +69,12 @@ void omap2_clkt_iclk_deny_idle(struct clk_hw_omap *clk)
* modules. No return value. * modules. No return value.
*/ */
static void omap2430_clk_i2chs_find_idlest(struct clk_hw_omap *clk, static void omap2430_clk_i2chs_find_idlest(struct clk_hw_omap *clk,
void __iomem **idlest_reg, struct clk_omap_reg *idlest_reg,
u8 *idlest_bit, u8 *idlest_bit,
u8 *idlest_val) u8 *idlest_val)
{ {
u32 r; memcpy(idlest_reg, &clk->enable_reg, sizeof(*idlest_reg));
idlest_reg->offset ^= (OMAP24XX_CM_FCLKEN2 ^ CM_IDLEST);
r = ((__force u32)clk->enable_reg ^ (OMAP24XX_CM_FCLKEN2 ^ CM_IDLEST));
*idlest_reg = (__force void __iomem *)r;
*idlest_bit = clk->enable_bit; *idlest_bit = clk->enable_bit;
*idlest_val = OMAP24XX_CM_IDLEST_VAL; *idlest_val = OMAP24XX_CM_IDLEST_VAL;
} }
......
...@@ -18,7 +18,7 @@ ...@@ -18,7 +18,7 @@
struct clk_omap_divider { struct clk_omap_divider {
struct clk_hw hw; struct clk_hw hw;
void __iomem *reg; struct clk_omap_reg reg;
u8 shift; u8 shift;
u8 width; u8 width;
u8 flags; u8 flags;
...@@ -29,7 +29,7 @@ struct clk_omap_divider { ...@@ -29,7 +29,7 @@ struct clk_omap_divider {
struct clk_omap_mux { struct clk_omap_mux {
struct clk_hw hw; struct clk_hw hw;
void __iomem *reg; struct clk_omap_reg reg;
u32 *table; u32 *table;
u32 mask; u32 mask;
u8 shift; u8 shift;
...@@ -228,7 +228,8 @@ void ti_clk_patch_legacy_clks(struct ti_clk **patch); ...@@ -228,7 +228,8 @@ void ti_clk_patch_legacy_clks(struct ti_clk **patch);
struct clk *ti_clk_register_clk(struct ti_clk *setup); struct clk *ti_clk_register_clk(struct ti_clk *setup);
int ti_clk_register_legacy_clks(struct ti_clk_alias *clks); int ti_clk_register_legacy_clks(struct ti_clk_alias *clks);
void __iomem *ti_clk_get_reg_addr(struct device_node *node, int index); int ti_clk_get_reg_addr(struct device_node *node, int index,
struct clk_omap_reg *reg);
void ti_dt_clocks_register(struct ti_dt_clk *oclks); void ti_dt_clocks_register(struct ti_dt_clk *oclks);
int ti_clk_retry_init(struct device_node *node, struct clk_hw *hw, int ti_clk_retry_init(struct device_node *node, struct clk_hw *hw,
ti_of_clk_init_cb_t func); ti_of_clk_init_cb_t func);
...@@ -263,10 +264,10 @@ int omap2_dflt_clk_enable(struct clk_hw *hw); ...@@ -263,10 +264,10 @@ int omap2_dflt_clk_enable(struct clk_hw *hw);
void omap2_dflt_clk_disable(struct clk_hw *hw); void omap2_dflt_clk_disable(struct clk_hw *hw);
int omap2_dflt_clk_is_enabled(struct clk_hw *hw); int omap2_dflt_clk_is_enabled(struct clk_hw *hw);
void omap2_clk_dflt_find_companion(struct clk_hw_omap *clk, void omap2_clk_dflt_find_companion(struct clk_hw_omap *clk,
void __iomem **other_reg, struct clk_omap_reg *other_reg,
u8 *other_bit); u8 *other_bit);
void omap2_clk_dflt_find_idlest(struct clk_hw_omap *clk, void omap2_clk_dflt_find_idlest(struct clk_hw_omap *clk,
void __iomem **idlest_reg, struct clk_omap_reg *idlest_reg,
u8 *idlest_bit, u8 *idlest_val); u8 *idlest_bit, u8 *idlest_val);
void omap2_clkt_iclk_allow_idle(struct clk_hw_omap *clk); void omap2_clkt_iclk_allow_idle(struct clk_hw_omap *clk);
......
...@@ -52,10 +52,6 @@ int omap2_clkops_enable_clkdm(struct clk_hw *hw) ...@@ -52,10 +52,6 @@ int omap2_clkops_enable_clkdm(struct clk_hw *hw)
return -EINVAL; return -EINVAL;
} }
if (unlikely(clk->enable_reg))
pr_err("%s: %s: should use dflt_clk_enable ?!\n", __func__,
clk_hw_get_name(hw));
if (ti_clk_get_features()->flags & TI_CLK_DISABLE_CLKDM_CONTROL) { if (ti_clk_get_features()->flags & TI_CLK_DISABLE_CLKDM_CONTROL) {
pr_err("%s: %s: clkfw-based clockdomain control disabled ?!\n", pr_err("%s: %s: clkfw-based clockdomain control disabled ?!\n",
__func__, clk_hw_get_name(hw)); __func__, clk_hw_get_name(hw));
...@@ -90,10 +86,6 @@ void omap2_clkops_disable_clkdm(struct clk_hw *hw) ...@@ -90,10 +86,6 @@ void omap2_clkops_disable_clkdm(struct clk_hw *hw)
return; return;
} }
if (unlikely(clk->enable_reg))
pr_err("%s: %s: should use dflt_clk_disable ?!\n", __func__,
clk_hw_get_name(hw));
if (ti_clk_get_features()->flags & TI_CLK_DISABLE_CLKDM_CONTROL) { if (ti_clk_get_features()->flags & TI_CLK_DISABLE_CLKDM_CONTROL) {
pr_err("%s: %s: clkfw-based clockdomain control disabled ?!\n", pr_err("%s: %s: clkfw-based clockdomain control disabled ?!\n",
__func__, clk_hw_get_name(hw)); __func__, clk_hw_get_name(hw));
......
...@@ -100,7 +100,7 @@ static unsigned long ti_clk_divider_recalc_rate(struct clk_hw *hw, ...@@ -100,7 +100,7 @@ static unsigned long ti_clk_divider_recalc_rate(struct clk_hw *hw,
struct clk_omap_divider *divider = to_clk_omap_divider(hw); struct clk_omap_divider *divider = to_clk_omap_divider(hw);
unsigned int div, val; unsigned int div, val;
val = ti_clk_ll_ops->clk_readl(divider->reg) >> divider->shift; val = ti_clk_ll_ops->clk_readl(&divider->reg) >> divider->shift;
val &= div_mask(divider); val &= div_mask(divider);
div = _get_div(divider, val); div = _get_div(divider, val);
...@@ -257,11 +257,11 @@ static int ti_clk_divider_set_rate(struct clk_hw *hw, unsigned long rate, ...@@ -257,11 +257,11 @@ static int ti_clk_divider_set_rate(struct clk_hw *hw, unsigned long rate,
if (divider->flags & CLK_DIVIDER_HIWORD_MASK) { if (divider->flags & CLK_DIVIDER_HIWORD_MASK) {
val = div_mask(divider) << (divider->shift + 16); val = div_mask(divider) << (divider->shift + 16);
} else { } else {
val = ti_clk_ll_ops->clk_readl(divider->reg); val = ti_clk_ll_ops->clk_readl(&divider->reg);
val &= ~(div_mask(divider) << divider->shift); val &= ~(div_mask(divider) << divider->shift);
} }
val |= value << divider->shift; val |= value << divider->shift;
ti_clk_ll_ops->clk_writel(val, divider->reg); ti_clk_ll_ops->clk_writel(val, &divider->reg);
return 0; return 0;
} }
...@@ -274,7 +274,8 @@ const struct clk_ops ti_clk_divider_ops = { ...@@ -274,7 +274,8 @@ const struct clk_ops ti_clk_divider_ops = {
static struct clk *_register_divider(struct device *dev, const char *name, static struct clk *_register_divider(struct device *dev, const char *name,
const char *parent_name, const char *parent_name,
unsigned long flags, void __iomem *reg, unsigned long flags,
struct clk_omap_reg *reg,
u8 shift, u8 width, u8 clk_divider_flags, u8 shift, u8 width, u8 clk_divider_flags,
const struct clk_div_table *table) const struct clk_div_table *table)
{ {
...@@ -303,7 +304,7 @@ static struct clk *_register_divider(struct device *dev, const char *name, ...@@ -303,7 +304,7 @@ static struct clk *_register_divider(struct device *dev, const char *name,
init.num_parents = (parent_name ? 1 : 0); init.num_parents = (parent_name ? 1 : 0);
/* struct clk_divider assignments */ /* struct clk_divider assignments */
div->reg = reg; memcpy(&div->reg, reg, sizeof(*reg));
div->shift = shift; div->shift = shift;
div->width = width; div->width = width;
div->flags = clk_divider_flags; div->flags = clk_divider_flags;
...@@ -561,14 +562,15 @@ static int _get_divider_width(struct device_node *node, ...@@ -561,14 +562,15 @@ static int _get_divider_width(struct device_node *node,
} }
static int __init ti_clk_divider_populate(struct device_node *node, static int __init ti_clk_divider_populate(struct device_node *node,
void __iomem **reg, const struct clk_div_table **table, struct clk_omap_reg *reg, const struct clk_div_table **table,
u32 *flags, u8 *div_flags, u8 *width, u8 *shift) u32 *flags, u8 *div_flags, u8 *width, u8 *shift)
{ {
u32 val; u32 val;
int ret;
*reg = ti_clk_get_reg_addr(node, 0); ret = ti_clk_get_reg_addr(node, 0, reg);
if (IS_ERR(*reg)) if (ret)
return PTR_ERR(*reg); return ret;
if (!of_property_read_u32(node, "ti,bit-shift", &val)) if (!of_property_read_u32(node, "ti,bit-shift", &val))
*shift = val; *shift = val;
...@@ -607,7 +609,7 @@ static void __init of_ti_divider_clk_setup(struct device_node *node) ...@@ -607,7 +609,7 @@ static void __init of_ti_divider_clk_setup(struct device_node *node)
{ {
struct clk *clk; struct clk *clk;
const char *parent_name; const char *parent_name;
void __iomem *reg; struct clk_omap_reg reg;
u8 clk_divider_flags = 0; u8 clk_divider_flags = 0;
u8 width = 0; u8 width = 0;
u8 shift = 0; u8 shift = 0;
...@@ -620,7 +622,7 @@ static void __init of_ti_divider_clk_setup(struct device_node *node) ...@@ -620,7 +622,7 @@ static void __init of_ti_divider_clk_setup(struct device_node *node)
&clk_divider_flags, &width, &shift)) &clk_divider_flags, &width, &shift))
goto cleanup; goto cleanup;
clk = _register_divider(NULL, node->name, parent_name, flags, reg, clk = _register_divider(NULL, node->name, parent_name, flags, &reg,
shift, width, clk_divider_flags, table); shift, width, clk_divider_flags, table);
if (!IS_ERR(clk)) { if (!IS_ERR(clk)) {
......
...@@ -203,17 +203,10 @@ static void __init _register_dpll(struct clk_hw *hw, ...@@ -203,17 +203,10 @@ static void __init _register_dpll(struct clk_hw *hw,
} }
#if defined(CONFIG_ARCH_OMAP3) && defined(CONFIG_ATAGS) #if defined(CONFIG_ARCH_OMAP3) && defined(CONFIG_ATAGS)
static void __iomem *_get_reg(u8 module, u16 offset) void _get_reg(u8 module, u16 offset, struct clk_omap_reg *reg)
{ {
u32 reg; reg->index = module;
struct clk_omap_reg *reg_setup; reg->offset = offset;
reg_setup = (struct clk_omap_reg *)&reg;
reg_setup->index = module;
reg_setup->offset = offset;
return (void __iomem *)reg;
} }
struct clk *ti_clk_register_dpll(struct ti_clk *setup) struct clk *ti_clk_register_dpll(struct ti_clk *setup)
...@@ -255,10 +248,10 @@ struct clk *ti_clk_register_dpll(struct ti_clk *setup) ...@@ -255,10 +248,10 @@ struct clk *ti_clk_register_dpll(struct ti_clk *setup)
init.num_parents = dpll->num_parents; init.num_parents = dpll->num_parents;
init.parent_names = dpll->parents; init.parent_names = dpll->parents;
dd->control_reg = _get_reg(dpll->module, dpll->control_reg); _get_reg(dpll->module, dpll->control_reg, &dd->control_reg);
dd->idlest_reg = _get_reg(dpll->module, dpll->idlest_reg); _get_reg(dpll->module, dpll->idlest_reg, &dd->idlest_reg);
dd->mult_div1_reg = _get_reg(dpll->module, dpll->mult_div1_reg); _get_reg(dpll->module, dpll->mult_div1_reg, &dd->mult_div1_reg);
dd->autoidle_reg = _get_reg(dpll->module, dpll->autoidle_reg); _get_reg(dpll->module, dpll->autoidle_reg, &dd->autoidle_reg);
dd->modes = dpll->modes; dd->modes = dpll->modes;
dd->div1_mask = dpll->div1_mask; dd->div1_mask = dpll->div1_mask;
...@@ -344,14 +337,11 @@ static void _register_dpll_x2(struct device_node *node, ...@@ -344,14 +337,11 @@ static void _register_dpll_x2(struct device_node *node,
ret = of_property_count_elems_of_size(node, "reg", 1); ret = of_property_count_elems_of_size(node, "reg", 1);
if (ret <= 0) { if (ret <= 0) {
hw_ops = NULL; hw_ops = NULL;
} else { } else if (ti_clk_get_reg_addr(node, 0, &clk_hw->clksel_reg)) {
clk_hw->clksel_reg = ti_clk_get_reg_addr(node, 0);
if (IS_ERR(clk_hw->clksel_reg)) {
kfree(clk_hw); kfree(clk_hw);
return; return;
} }
} }
}
/* register the clock */ /* register the clock */
clk = ti_clk_register(NULL, &clk_hw->hw, name); clk = ti_clk_register(NULL, &clk_hw->hw, name);
...@@ -412,7 +402,8 @@ static void __init of_ti_dpll_setup(struct device_node *node, ...@@ -412,7 +402,8 @@ static void __init of_ti_dpll_setup(struct device_node *node,
init->parent_names = parent_names; init->parent_names = parent_names;
dd->control_reg = ti_clk_get_reg_addr(node, 0); if (ti_clk_get_reg_addr(node, 0, &dd->control_reg))
goto cleanup;
/* /*
* Special case for OMAP2 DPLL, register order is different due to * Special case for OMAP2 DPLL, register order is different due to
...@@ -420,25 +411,22 @@ static void __init of_ti_dpll_setup(struct device_node *node, ...@@ -420,25 +411,22 @@ static void __init of_ti_dpll_setup(struct device_node *node,
* missing idlest_mask. * missing idlest_mask.
*/ */
if (!dd->idlest_mask) { if (!dd->idlest_mask) {
dd->mult_div1_reg = ti_clk_get_reg_addr(node, 1); if (ti_clk_get_reg_addr(node, 1, &dd->mult_div1_reg))
goto cleanup;
#ifdef CONFIG_ARCH_OMAP2 #ifdef CONFIG_ARCH_OMAP2
clk_hw->ops = &clkhwops_omap2xxx_dpll; clk_hw->ops = &clkhwops_omap2xxx_dpll;
omap2xxx_clkt_dpllcore_init(&clk_hw->hw); omap2xxx_clkt_dpllcore_init(&clk_hw->hw);
#endif #endif
} else { } else {
dd->idlest_reg = ti_clk_get_reg_addr(node, 1); if (ti_clk_get_reg_addr(node, 1, &dd->idlest_reg))
if (IS_ERR(dd->idlest_reg))
goto cleanup; goto cleanup;
dd->mult_div1_reg = ti_clk_get_reg_addr(node, 2); if (ti_clk_get_reg_addr(node, 2, &dd->mult_div1_reg))
}
if (IS_ERR(dd->control_reg) || IS_ERR(dd->mult_div1_reg))
goto cleanup; goto cleanup;
}
if (dd->autoidle_mask) { if (dd->autoidle_mask) {
dd->autoidle_reg = ti_clk_get_reg_addr(node, 3); if (ti_clk_get_reg_addr(node, 3, &dd->autoidle_reg))
if (IS_ERR(dd->autoidle_reg))
goto cleanup; goto cleanup;
} }
......
...@@ -54,10 +54,10 @@ static void _omap3_dpll_write_clken(struct clk_hw_omap *clk, u8 clken_bits) ...@@ -54,10 +54,10 @@ static void _omap3_dpll_write_clken(struct clk_hw_omap *clk, u8 clken_bits)
dd = clk->dpll_data; dd = clk->dpll_data;
v = ti_clk_ll_ops->clk_readl(dd->control_reg); v = ti_clk_ll_ops->clk_readl(&dd->control_reg);
v &= ~dd->enable_mask; v &= ~dd->enable_mask;
v |= clken_bits << __ffs(dd->enable_mask); v |= clken_bits << __ffs(dd->enable_mask);
ti_clk_ll_ops->clk_writel(v, dd->control_reg); ti_clk_ll_ops->clk_writel(v, &dd->control_reg);
} }
/* _omap3_wait_dpll_status: wait for a DPLL to enter a specific state */ /* _omap3_wait_dpll_status: wait for a DPLL to enter a specific state */
...@@ -73,7 +73,7 @@ static int _omap3_wait_dpll_status(struct clk_hw_omap *clk, u8 state) ...@@ -73,7 +73,7 @@ static int _omap3_wait_dpll_status(struct clk_hw_omap *clk, u8 state)
state <<= __ffs(dd->idlest_mask); state <<= __ffs(dd->idlest_mask);
while (((ti_clk_ll_ops->clk_readl(dd->idlest_reg) & dd->idlest_mask) while (((ti_clk_ll_ops->clk_readl(&dd->idlest_reg) & dd->idlest_mask)
!= state) && i < MAX_DPLL_WAIT_TRIES) { != state) && i < MAX_DPLL_WAIT_TRIES) {
i++; i++;
udelay(1); udelay(1);
...@@ -151,7 +151,7 @@ static int _omap3_noncore_dpll_lock(struct clk_hw_omap *clk) ...@@ -151,7 +151,7 @@ static int _omap3_noncore_dpll_lock(struct clk_hw_omap *clk)
state <<= __ffs(dd->idlest_mask); state <<= __ffs(dd->idlest_mask);
/* Check if already locked */ /* Check if already locked */
if ((ti_clk_ll_ops->clk_readl(dd->idlest_reg) & dd->idlest_mask) == if ((ti_clk_ll_ops->clk_readl(&dd->idlest_reg) & dd->idlest_mask) ==
state) state)
goto done; goto done;
...@@ -317,14 +317,14 @@ static int omap3_noncore_dpll_program(struct clk_hw_omap *clk, u16 freqsel) ...@@ -317,14 +317,14 @@ static int omap3_noncore_dpll_program(struct clk_hw_omap *clk, u16 freqsel)
* only since freqsel field is no longer present on other devices. * only since freqsel field is no longer present on other devices.
*/ */
if (ti_clk_get_features()->flags & TI_CLK_DPLL_HAS_FREQSEL) { if (ti_clk_get_features()->flags & TI_CLK_DPLL_HAS_FREQSEL) {
v = ti_clk_ll_ops->clk_readl(dd->control_reg); v = ti_clk_ll_ops->clk_readl(&dd->control_reg);
v &= ~dd->freqsel_mask; v &= ~dd->freqsel_mask;
v |= freqsel << __ffs(dd->freqsel_mask); v |= freqsel << __ffs(dd->freqsel_mask);
ti_clk_ll_ops->clk_writel(v, dd->control_reg); ti_clk_ll_ops->clk_writel(v, &dd->control_reg);
} }
/* Set DPLL multiplier, divider */ /* Set DPLL multiplier, divider */
v = ti_clk_ll_ops->clk_readl(dd->mult_div1_reg); v = ti_clk_ll_ops->clk_readl(&dd->mult_div1_reg);
/* Handle Duty Cycle Correction */ /* Handle Duty Cycle Correction */
if (dd->dcc_mask) { if (dd->dcc_mask) {
...@@ -370,11 +370,11 @@ static int omap3_noncore_dpll_program(struct clk_hw_omap *clk, u16 freqsel) ...@@ -370,11 +370,11 @@ static int omap3_noncore_dpll_program(struct clk_hw_omap *clk, u16 freqsel)
} }
} }
ti_clk_ll_ops->clk_writel(v, dd->mult_div1_reg); ti_clk_ll_ops->clk_writel(v, &dd->mult_div1_reg);
/* Set 4X multiplier and low-power mode */ /* Set 4X multiplier and low-power mode */
if (dd->m4xen_mask || dd->lpmode_mask) { if (dd->m4xen_mask || dd->lpmode_mask) {
v = ti_clk_ll_ops->clk_readl(dd->control_reg); v = ti_clk_ll_ops->clk_readl(&dd->control_reg);
if (dd->m4xen_mask) { if (dd->m4xen_mask) {
if (dd->last_rounded_m4xen) if (dd->last_rounded_m4xen)
...@@ -390,7 +390,7 @@ static int omap3_noncore_dpll_program(struct clk_hw_omap *clk, u16 freqsel) ...@@ -390,7 +390,7 @@ static int omap3_noncore_dpll_program(struct clk_hw_omap *clk, u16 freqsel)
v &= ~dd->lpmode_mask; v &= ~dd->lpmode_mask;
} }
ti_clk_ll_ops->clk_writel(v, dd->control_reg); ti_clk_ll_ops->clk_writel(v, &dd->control_reg);
} }
/* We let the clock framework set the other output dividers later */ /* We let the clock framework set the other output dividers later */
...@@ -652,10 +652,10 @@ static u32 omap3_dpll_autoidle_read(struct clk_hw_omap *clk) ...@@ -652,10 +652,10 @@ static u32 omap3_dpll_autoidle_read(struct clk_hw_omap *clk)
dd = clk->dpll_data; dd = clk->dpll_data;
if (!dd->autoidle_reg) if (!dd->autoidle_mask)
return -EINVAL; return -EINVAL;
v = ti_clk_ll_ops->clk_readl(dd->autoidle_reg); v = ti_clk_ll_ops->clk_readl(&dd->autoidle_reg);
v &= dd->autoidle_mask; v &= dd->autoidle_mask;
v >>= __ffs(dd->autoidle_mask); v >>= __ffs(dd->autoidle_mask);
...@@ -681,7 +681,7 @@ static void omap3_dpll_allow_idle(struct clk_hw_omap *clk) ...@@ -681,7 +681,7 @@ static void omap3_dpll_allow_idle(struct clk_hw_omap *clk)
dd = clk->dpll_data; dd = clk->dpll_data;
if (!dd->autoidle_reg) if (!dd->autoidle_mask)
return; return;
/* /*
...@@ -689,10 +689,10 @@ static void omap3_dpll_allow_idle(struct clk_hw_omap *clk) ...@@ -689,10 +689,10 @@ static void omap3_dpll_allow_idle(struct clk_hw_omap *clk)
* by writing 0x5 instead of 0x1. Add some mechanism to * by writing 0x5 instead of 0x1. Add some mechanism to
* optionally enter this mode. * optionally enter this mode.
*/ */
v = ti_clk_ll_ops->clk_readl(dd->autoidle_reg); v = ti_clk_ll_ops->clk_readl(&dd->autoidle_reg);
v &= ~dd->autoidle_mask; v &= ~dd->autoidle_mask;
v |= DPLL_AUTOIDLE_LOW_POWER_STOP << __ffs(dd->autoidle_mask); v |= DPLL_AUTOIDLE_LOW_POWER_STOP << __ffs(dd->autoidle_mask);
ti_clk_ll_ops->clk_writel(v, dd->autoidle_reg); ti_clk_ll_ops->clk_writel(v, &dd->autoidle_reg);
} }
/** /**
...@@ -711,13 +711,13 @@ static void omap3_dpll_deny_idle(struct clk_hw_omap *clk) ...@@ -711,13 +711,13 @@ static void omap3_dpll_deny_idle(struct clk_hw_omap *clk)
dd = clk->dpll_data; dd = clk->dpll_data;
if (!dd->autoidle_reg) if (!dd->autoidle_mask)
return; return;
v = ti_clk_ll_ops->clk_readl(dd->autoidle_reg); v = ti_clk_ll_ops->clk_readl(&dd->autoidle_reg);
v &= ~dd->autoidle_mask; v &= ~dd->autoidle_mask;
v |= DPLL_AUTOIDLE_DISABLE << __ffs(dd->autoidle_mask); v |= DPLL_AUTOIDLE_DISABLE << __ffs(dd->autoidle_mask);
ti_clk_ll_ops->clk_writel(v, dd->autoidle_reg); ti_clk_ll_ops->clk_writel(v, &dd->autoidle_reg);
} }
/* Clock control for DPLL outputs */ /* Clock control for DPLL outputs */
...@@ -773,7 +773,7 @@ unsigned long omap3_clkoutx2_recalc(struct clk_hw *hw, ...@@ -773,7 +773,7 @@ unsigned long omap3_clkoutx2_recalc(struct clk_hw *hw,
WARN_ON(!dd->enable_mask); WARN_ON(!dd->enable_mask);
v = ti_clk_ll_ops->clk_readl(dd->control_reg) & dd->enable_mask; v = ti_clk_ll_ops->clk_readl(&dd->control_reg) & dd->enable_mask;
v >>= __ffs(dd->enable_mask); v >>= __ffs(dd->enable_mask);
if ((v != OMAP3XXX_EN_DPLL_LOCKED) || (dd->flags & DPLL_J_TYPE)) if ((v != OMAP3XXX_EN_DPLL_LOCKED) || (dd->flags & DPLL_J_TYPE))
rate = parent_rate; rate = parent_rate;
......
...@@ -42,17 +42,17 @@ static void omap4_dpllmx_allow_gatectrl(struct clk_hw_omap *clk) ...@@ -42,17 +42,17 @@ static void omap4_dpllmx_allow_gatectrl(struct clk_hw_omap *clk)
u32 v; u32 v;
u32 mask; u32 mask;
if (!clk || !clk->clksel_reg) if (!clk)
return; return;
mask = clk->flags & CLOCK_CLKOUTX2 ? mask = clk->flags & CLOCK_CLKOUTX2 ?
OMAP4430_DPLL_CLKOUTX2_GATE_CTRL_MASK : OMAP4430_DPLL_CLKOUTX2_GATE_CTRL_MASK :
OMAP4430_DPLL_CLKOUT_GATE_CTRL_MASK; OMAP4430_DPLL_CLKOUT_GATE_CTRL_MASK;
v = ti_clk_ll_ops->clk_readl(clk->clksel_reg); v = ti_clk_ll_ops->clk_readl(&clk->clksel_reg);
/* Clear the bit to allow gatectrl */ /* Clear the bit to allow gatectrl */
v &= ~mask; v &= ~mask;
ti_clk_ll_ops->clk_writel(v, clk->clksel_reg); ti_clk_ll_ops->clk_writel(v, &clk->clksel_reg);
} }
static void omap4_dpllmx_deny_gatectrl(struct clk_hw_omap *clk) static void omap4_dpllmx_deny_gatectrl(struct clk_hw_omap *clk)
...@@ -60,17 +60,17 @@ static void omap4_dpllmx_deny_gatectrl(struct clk_hw_omap *clk) ...@@ -60,17 +60,17 @@ static void omap4_dpllmx_deny_gatectrl(struct clk_hw_omap *clk)
u32 v; u32 v;
u32 mask; u32 mask;
if (!clk || !clk->clksel_reg) if (!clk)
return; return;
mask = clk->flags & CLOCK_CLKOUTX2 ? mask = clk->flags & CLOCK_CLKOUTX2 ?
OMAP4430_DPLL_CLKOUTX2_GATE_CTRL_MASK : OMAP4430_DPLL_CLKOUTX2_GATE_CTRL_MASK :
OMAP4430_DPLL_CLKOUT_GATE_CTRL_MASK; OMAP4430_DPLL_CLKOUT_GATE_CTRL_MASK;
v = ti_clk_ll_ops->clk_readl(clk->clksel_reg); v = ti_clk_ll_ops->clk_readl(&clk->clksel_reg);
/* Set the bit to deny gatectrl */ /* Set the bit to deny gatectrl */
v |= mask; v |= mask;
ti_clk_ll_ops->clk_writel(v, clk->clksel_reg); ti_clk_ll_ops->clk_writel(v, &clk->clksel_reg);
} }
const struct clk_hw_omap_ops clkhwops_omap4_dpllmx = { const struct clk_hw_omap_ops clkhwops_omap4_dpllmx = {
...@@ -128,7 +128,7 @@ unsigned long omap4_dpll_regm4xen_recalc(struct clk_hw *hw, ...@@ -128,7 +128,7 @@ unsigned long omap4_dpll_regm4xen_recalc(struct clk_hw *hw,
rate = omap2_get_dpll_rate(clk); rate = omap2_get_dpll_rate(clk);
/* regm4xen adds a multiplier of 4 to DPLL calculations */ /* regm4xen adds a multiplier of 4 to DPLL calculations */
v = ti_clk_ll_ops->clk_readl(dd->control_reg); v = ti_clk_ll_ops->clk_readl(&dd->control_reg);
if (v & OMAP4430_DPLL_REGM4XEN_MASK) if (v & OMAP4430_DPLL_REGM4XEN_MASK)
rate *= OMAP4430_REGM4XEN_MULT; rate *= OMAP4430_REGM4XEN_MULT;
......
...@@ -76,15 +76,15 @@ static int omap36xx_gate_clk_enable_with_hsdiv_restore(struct clk_hw *hw) ...@@ -76,15 +76,15 @@ static int omap36xx_gate_clk_enable_with_hsdiv_restore(struct clk_hw *hw)
/* Restore the dividers */ /* Restore the dividers */
if (!ret) { if (!ret) {
orig_v = ti_clk_ll_ops->clk_readl(parent->reg); orig_v = ti_clk_ll_ops->clk_readl(&parent->reg);
dummy_v = orig_v; dummy_v = orig_v;
/* Write any other value different from the Read value */ /* Write any other value different from the Read value */
dummy_v ^= (1 << parent->shift); dummy_v ^= (1 << parent->shift);
ti_clk_ll_ops->clk_writel(dummy_v, parent->reg); ti_clk_ll_ops->clk_writel(dummy_v, &parent->reg);
/* Write the original divider */ /* Write the original divider */
ti_clk_ll_ops->clk_writel(orig_v, parent->reg); ti_clk_ll_ops->clk_writel(orig_v, &parent->reg);
} }
return ret; return ret;
...@@ -92,7 +92,7 @@ static int omap36xx_gate_clk_enable_with_hsdiv_restore(struct clk_hw *hw) ...@@ -92,7 +92,7 @@ static int omap36xx_gate_clk_enable_with_hsdiv_restore(struct clk_hw *hw)
static struct clk *_register_gate(struct device *dev, const char *name, static struct clk *_register_gate(struct device *dev, const char *name,
const char *parent_name, unsigned long flags, const char *parent_name, unsigned long flags,
void __iomem *reg, u8 bit_idx, struct clk_omap_reg *reg, u8 bit_idx,
u8 clk_gate_flags, const struct clk_ops *ops, u8 clk_gate_flags, const struct clk_ops *ops,
const struct clk_hw_omap_ops *hw_ops) const struct clk_hw_omap_ops *hw_ops)
{ {
...@@ -109,7 +109,7 @@ static struct clk *_register_gate(struct device *dev, const char *name, ...@@ -109,7 +109,7 @@ static struct clk *_register_gate(struct device *dev, const char *name,
init.name = name; init.name = name;
init.ops = ops; init.ops = ops;
clk_hw->enable_reg = reg; memcpy(&clk_hw->enable_reg, reg, sizeof(*reg));
clk_hw->enable_bit = bit_idx; clk_hw->enable_bit = bit_idx;
clk_hw->ops = hw_ops; clk_hw->ops = hw_ops;
...@@ -133,8 +133,7 @@ struct clk *ti_clk_register_gate(struct ti_clk *setup) ...@@ -133,8 +133,7 @@ struct clk *ti_clk_register_gate(struct ti_clk *setup)
{ {
const struct clk_ops *ops = &omap_gate_clk_ops; const struct clk_ops *ops = &omap_gate_clk_ops;
const struct clk_hw_omap_ops *hw_ops = NULL; const struct clk_hw_omap_ops *hw_ops = NULL;
u32 reg; struct clk_omap_reg reg;
struct clk_omap_reg *reg_setup;
u32 flags = 0; u32 flags = 0;
u8 clk_gate_flags = 0; u8 clk_gate_flags = 0;
struct ti_clk_gate *gate; struct ti_clk_gate *gate;
...@@ -144,8 +143,6 @@ struct clk *ti_clk_register_gate(struct ti_clk *setup) ...@@ -144,8 +143,6 @@ struct clk *ti_clk_register_gate(struct ti_clk *setup)
if (gate->flags & CLKF_INTERFACE) if (gate->flags & CLKF_INTERFACE)
return ti_clk_register_interface(setup); return ti_clk_register_interface(setup);
reg_setup = (struct clk_omap_reg *)&reg;
if (gate->flags & CLKF_SET_RATE_PARENT) if (gate->flags & CLKF_SET_RATE_PARENT)
flags |= CLK_SET_RATE_PARENT; flags |= CLK_SET_RATE_PARENT;
...@@ -169,11 +166,12 @@ struct clk *ti_clk_register_gate(struct ti_clk *setup) ...@@ -169,11 +166,12 @@ struct clk *ti_clk_register_gate(struct ti_clk *setup)
if (gate->flags & CLKF_AM35XX) if (gate->flags & CLKF_AM35XX)
hw_ops = &clkhwops_am35xx_ipss_module_wait; hw_ops = &clkhwops_am35xx_ipss_module_wait;
reg_setup->index = gate->module; reg.index = gate->module;
reg_setup->offset = gate->reg; reg.offset = gate->reg;
reg.ptr = NULL;
return _register_gate(NULL, setup->name, gate->parent, flags, return _register_gate(NULL, setup->name, gate->parent, flags,
(void __iomem *)reg, gate->bit_shift, &reg, gate->bit_shift,
clk_gate_flags, ops, hw_ops); clk_gate_flags, ops, hw_ops);
} }
...@@ -214,15 +212,14 @@ static void __init _of_ti_gate_clk_setup(struct device_node *node, ...@@ -214,15 +212,14 @@ static void __init _of_ti_gate_clk_setup(struct device_node *node,
{ {
struct clk *clk; struct clk *clk;
const char *parent_name; const char *parent_name;
void __iomem *reg = NULL; struct clk_omap_reg reg;
u8 enable_bit = 0; u8 enable_bit = 0;
u32 val; u32 val;
u32 flags = 0; u32 flags = 0;
u8 clk_gate_flags = 0; u8 clk_gate_flags = 0;
if (ops != &omap_gate_clkdm_clk_ops) { if (ops != &omap_gate_clkdm_clk_ops) {
reg = ti_clk_get_reg_addr(node, 0); if (ti_clk_get_reg_addr(node, 0, &reg))
if (IS_ERR(reg))
return; return;
if (!of_property_read_u32(node, "ti,bit-shift", &val)) if (!of_property_read_u32(node, "ti,bit-shift", &val))
...@@ -242,7 +239,7 @@ static void __init _of_ti_gate_clk_setup(struct device_node *node, ...@@ -242,7 +239,7 @@ static void __init _of_ti_gate_clk_setup(struct device_node *node,
if (of_property_read_bool(node, "ti,set-bit-to-disable")) if (of_property_read_bool(node, "ti,set-bit-to-disable"))
clk_gate_flags |= INVERT_ENABLE; clk_gate_flags |= INVERT_ENABLE;
clk = _register_gate(NULL, node->name, parent_name, flags, reg, clk = _register_gate(NULL, node->name, parent_name, flags, &reg,
enable_bit, clk_gate_flags, ops, hw_ops); enable_bit, clk_gate_flags, ops, hw_ops);
if (!IS_ERR(clk)) if (!IS_ERR(clk))
...@@ -260,8 +257,7 @@ _of_ti_composite_gate_clk_setup(struct device_node *node, ...@@ -260,8 +257,7 @@ _of_ti_composite_gate_clk_setup(struct device_node *node,
if (!gate) if (!gate)
return; return;
gate->enable_reg = ti_clk_get_reg_addr(node, 0); if (ti_clk_get_reg_addr(node, 0, &gate->enable_reg))
if (IS_ERR(gate->enable_reg))
goto cleanup; goto cleanup;
of_property_read_u32(node, "ti,bit-shift", &val); of_property_read_u32(node, "ti,bit-shift", &val);
......
...@@ -34,7 +34,7 @@ static const struct clk_ops ti_interface_clk_ops = { ...@@ -34,7 +34,7 @@ static const struct clk_ops ti_interface_clk_ops = {
static struct clk *_register_interface(struct device *dev, const char *name, static struct clk *_register_interface(struct device *dev, const char *name,
const char *parent_name, const char *parent_name,
void __iomem *reg, u8 bit_idx, struct clk_omap_reg *reg, u8 bit_idx,
const struct clk_hw_omap_ops *ops) const struct clk_hw_omap_ops *ops)
{ {
struct clk_init_data init = { NULL }; struct clk_init_data init = { NULL };
...@@ -47,7 +47,7 @@ static struct clk *_register_interface(struct device *dev, const char *name, ...@@ -47,7 +47,7 @@ static struct clk *_register_interface(struct device *dev, const char *name,
clk_hw->hw.init = &init; clk_hw->hw.init = &init;
clk_hw->ops = ops; clk_hw->ops = ops;
clk_hw->enable_reg = reg; memcpy(&clk_hw->enable_reg, reg, sizeof(*reg));
clk_hw->enable_bit = bit_idx; clk_hw->enable_bit = bit_idx;
init.name = name; init.name = name;
...@@ -71,14 +71,13 @@ static struct clk *_register_interface(struct device *dev, const char *name, ...@@ -71,14 +71,13 @@ static struct clk *_register_interface(struct device *dev, const char *name,
struct clk *ti_clk_register_interface(struct ti_clk *setup) struct clk *ti_clk_register_interface(struct ti_clk *setup)
{ {
const struct clk_hw_omap_ops *ops = &clkhwops_iclk_wait; const struct clk_hw_omap_ops *ops = &clkhwops_iclk_wait;
u32 reg; struct clk_omap_reg reg;
struct clk_omap_reg *reg_setup;
struct ti_clk_gate *gate; struct ti_clk_gate *gate;
gate = setup->data; gate = setup->data;
reg_setup = (struct clk_omap_reg *)&reg; reg.index = gate->module;
reg_setup->index = gate->module; reg.offset = gate->reg;
reg_setup->offset = gate->reg; reg.ptr = NULL;
if (gate->flags & CLKF_NO_WAIT) if (gate->flags & CLKF_NO_WAIT)
ops = &clkhwops_iclk; ops = &clkhwops_iclk;
...@@ -96,7 +95,7 @@ struct clk *ti_clk_register_interface(struct ti_clk *setup) ...@@ -96,7 +95,7 @@ struct clk *ti_clk_register_interface(struct ti_clk *setup)
ops = &clkhwops_am35xx_ipss_wait; ops = &clkhwops_am35xx_ipss_wait;
return _register_interface(NULL, setup->name, gate->parent, return _register_interface(NULL, setup->name, gate->parent,
(void __iomem *)reg, gate->bit_shift, ops); &reg, gate->bit_shift, ops);
} }
#endif #endif
...@@ -105,12 +104,11 @@ static void __init _of_ti_interface_clk_setup(struct device_node *node, ...@@ -105,12 +104,11 @@ static void __init _of_ti_interface_clk_setup(struct device_node *node,
{ {
struct clk *clk; struct clk *clk;
const char *parent_name; const char *parent_name;
void __iomem *reg; struct clk_omap_reg reg;
u8 enable_bit = 0; u8 enable_bit = 0;
u32 val; u32 val;
reg = ti_clk_get_reg_addr(node, 0); if (ti_clk_get_reg_addr(node, 0, &reg))
if (IS_ERR(reg))
return; return;
if (!of_property_read_u32(node, "ti,bit-shift", &val)) if (!of_property_read_u32(node, "ti,bit-shift", &val))
...@@ -122,7 +120,7 @@ static void __init _of_ti_interface_clk_setup(struct device_node *node, ...@@ -122,7 +120,7 @@ static void __init _of_ti_interface_clk_setup(struct device_node *node,
return; return;
} }
clk = _register_interface(NULL, node->name, parent_name, reg, clk = _register_interface(NULL, node->name, parent_name, &reg,
enable_bit, ops); enable_bit, ops);
if (!IS_ERR(clk)) if (!IS_ERR(clk))
......
...@@ -39,7 +39,7 @@ static u8 ti_clk_mux_get_parent(struct clk_hw *hw) ...@@ -39,7 +39,7 @@ static u8 ti_clk_mux_get_parent(struct clk_hw *hw)
* OTOH, pmd_trace_clk_mux_ck uses a separate bit for each clock, so * OTOH, pmd_trace_clk_mux_ck uses a separate bit for each clock, so
* val = 0x4 really means "bit 2, index starts at bit 0" * val = 0x4 really means "bit 2, index starts at bit 0"
*/ */
val = ti_clk_ll_ops->clk_readl(mux->reg) >> mux->shift; val = ti_clk_ll_ops->clk_readl(&mux->reg) >> mux->shift;
val &= mux->mask; val &= mux->mask;
if (mux->table) { if (mux->table) {
...@@ -81,11 +81,11 @@ static int ti_clk_mux_set_parent(struct clk_hw *hw, u8 index) ...@@ -81,11 +81,11 @@ static int ti_clk_mux_set_parent(struct clk_hw *hw, u8 index)
if (mux->flags & CLK_MUX_HIWORD_MASK) { if (mux->flags & CLK_MUX_HIWORD_MASK) {
val = mux->mask << (mux->shift + 16); val = mux->mask << (mux->shift + 16);
} else { } else {
val = ti_clk_ll_ops->clk_readl(mux->reg); val = ti_clk_ll_ops->clk_readl(&mux->reg);
val &= ~(mux->mask << mux->shift); val &= ~(mux->mask << mux->shift);
} }
val |= index << mux->shift; val |= index << mux->shift;
ti_clk_ll_ops->clk_writel(val, mux->reg); ti_clk_ll_ops->clk_writel(val, &mux->reg);
return 0; return 0;
} }
...@@ -99,7 +99,7 @@ const struct clk_ops ti_clk_mux_ops = { ...@@ -99,7 +99,7 @@ const struct clk_ops ti_clk_mux_ops = {
static struct clk *_register_mux(struct device *dev, const char *name, static struct clk *_register_mux(struct device *dev, const char *name,
const char * const *parent_names, const char * const *parent_names,
u8 num_parents, unsigned long flags, u8 num_parents, unsigned long flags,
void __iomem *reg, u8 shift, u32 mask, struct clk_omap_reg *reg, u8 shift, u32 mask,
u8 clk_mux_flags, u32 *table) u8 clk_mux_flags, u32 *table)
{ {
struct clk_omap_mux *mux; struct clk_omap_mux *mux;
...@@ -120,7 +120,7 @@ static struct clk *_register_mux(struct device *dev, const char *name, ...@@ -120,7 +120,7 @@ static struct clk *_register_mux(struct device *dev, const char *name,
init.num_parents = num_parents; init.num_parents = num_parents;
/* struct clk_mux assignments */ /* struct clk_mux assignments */
mux->reg = reg; memcpy(&mux->reg, reg, sizeof(*reg));
mux->shift = shift; mux->shift = shift;
mux->mask = mask; mux->mask = mask;
mux->flags = clk_mux_flags; mux->flags = clk_mux_flags;
...@@ -140,12 +140,9 @@ struct clk *ti_clk_register_mux(struct ti_clk *setup) ...@@ -140,12 +140,9 @@ struct clk *ti_clk_register_mux(struct ti_clk *setup)
struct ti_clk_mux *mux; struct ti_clk_mux *mux;
u32 flags; u32 flags;
u8 mux_flags = 0; u8 mux_flags = 0;
struct clk_omap_reg *reg_setup; struct clk_omap_reg reg;
u32 reg;
u32 mask; u32 mask;
reg_setup = (struct clk_omap_reg *)&reg;
mux = setup->data; mux = setup->data;
flags = CLK_SET_RATE_NO_REPARENT; flags = CLK_SET_RATE_NO_REPARENT;
...@@ -154,8 +151,9 @@ struct clk *ti_clk_register_mux(struct ti_clk *setup) ...@@ -154,8 +151,9 @@ struct clk *ti_clk_register_mux(struct ti_clk *setup)
mask--; mask--;
mask = (1 << fls(mask)) - 1; mask = (1 << fls(mask)) - 1;
reg_setup->index = mux->module; reg.index = mux->module;
reg_setup->offset = mux->reg; reg.offset = mux->reg;
reg.ptr = NULL;
if (mux->flags & CLKF_INDEX_STARTS_AT_ONE) if (mux->flags & CLKF_INDEX_STARTS_AT_ONE)
mux_flags |= CLK_MUX_INDEX_ONE; mux_flags |= CLK_MUX_INDEX_ONE;
...@@ -164,7 +162,7 @@ struct clk *ti_clk_register_mux(struct ti_clk *setup) ...@@ -164,7 +162,7 @@ struct clk *ti_clk_register_mux(struct ti_clk *setup)
flags |= CLK_SET_RATE_PARENT; flags |= CLK_SET_RATE_PARENT;
return _register_mux(NULL, setup->name, mux->parents, mux->num_parents, return _register_mux(NULL, setup->name, mux->parents, mux->num_parents,
flags, (void __iomem *)reg, mux->bit_shift, mask, flags, &reg, mux->bit_shift, mask,
mux_flags, NULL); mux_flags, NULL);
} }
...@@ -177,7 +175,7 @@ struct clk *ti_clk_register_mux(struct ti_clk *setup) ...@@ -177,7 +175,7 @@ struct clk *ti_clk_register_mux(struct ti_clk *setup)
static void of_mux_clk_setup(struct device_node *node) static void of_mux_clk_setup(struct device_node *node)
{ {
struct clk *clk; struct clk *clk;
void __iomem *reg; struct clk_omap_reg reg;
unsigned int num_parents; unsigned int num_parents;
const char **parent_names; const char **parent_names;
u8 clk_mux_flags = 0; u8 clk_mux_flags = 0;
...@@ -196,9 +194,7 @@ static void of_mux_clk_setup(struct device_node *node) ...@@ -196,9 +194,7 @@ static void of_mux_clk_setup(struct device_node *node)
of_clk_parent_fill(node, parent_names, num_parents); of_clk_parent_fill(node, parent_names, num_parents);
reg = ti_clk_get_reg_addr(node, 0); if (ti_clk_get_reg_addr(node, 0, &reg))
if (IS_ERR(reg))
goto cleanup; goto cleanup;
of_property_read_u32(node, "ti,bit-shift", &shift); of_property_read_u32(node, "ti,bit-shift", &shift);
...@@ -217,7 +213,7 @@ static void of_mux_clk_setup(struct device_node *node) ...@@ -217,7 +213,7 @@ static void of_mux_clk_setup(struct device_node *node)
mask = (1 << fls(mask)) - 1; mask = (1 << fls(mask)) - 1;
clk = _register_mux(NULL, node->name, parent_names, num_parents, clk = _register_mux(NULL, node->name, parent_names, num_parents,
flags, reg, shift, mask, clk_mux_flags, NULL); flags, &reg, shift, mask, clk_mux_flags, NULL);
if (!IS_ERR(clk)) if (!IS_ERR(clk))
of_clk_add_provider(node, of_clk_src_simple_get, clk); of_clk_add_provider(node, of_clk_src_simple_get, clk);
...@@ -230,7 +226,6 @@ CLK_OF_DECLARE(mux_clk, "ti,mux-clock", of_mux_clk_setup); ...@@ -230,7 +226,6 @@ CLK_OF_DECLARE(mux_clk, "ti,mux-clock", of_mux_clk_setup);
struct clk_hw *ti_clk_build_component_mux(struct ti_clk_mux *setup) struct clk_hw *ti_clk_build_component_mux(struct ti_clk_mux *setup)
{ {
struct clk_omap_mux *mux; struct clk_omap_mux *mux;
struct clk_omap_reg *reg;
int num_parents; int num_parents;
if (!setup) if (!setup)
...@@ -240,12 +235,10 @@ struct clk_hw *ti_clk_build_component_mux(struct ti_clk_mux *setup) ...@@ -240,12 +235,10 @@ struct clk_hw *ti_clk_build_component_mux(struct ti_clk_mux *setup)
if (!mux) if (!mux)
return ERR_PTR(-ENOMEM); return ERR_PTR(-ENOMEM);
reg = (struct clk_omap_reg *)&mux->reg;
mux->shift = setup->bit_shift; mux->shift = setup->bit_shift;
reg->index = setup->module; mux->reg.index = setup->module;
reg->offset = setup->reg; mux->reg.offset = setup->reg;
if (setup->flags & CLKF_INDEX_STARTS_AT_ONE) if (setup->flags & CLKF_INDEX_STARTS_AT_ONE)
mux->flags |= CLK_MUX_INDEX_ONE; mux->flags |= CLK_MUX_INDEX_ONE;
...@@ -268,9 +261,7 @@ static void __init of_ti_composite_mux_clk_setup(struct device_node *node) ...@@ -268,9 +261,7 @@ static void __init of_ti_composite_mux_clk_setup(struct device_node *node)
if (!mux) if (!mux)
return; return;
mux->reg = ti_clk_get_reg_addr(node, 0); if (ti_clk_get_reg_addr(node, 0, &mux->reg))
if (IS_ERR(mux->reg))
goto cleanup; goto cleanup;
if (!of_property_read_u32(node, "ti,bit-shift", &val)) if (!of_property_read_u32(node, "ti,bit-shift", &val))
......
...@@ -18,6 +18,18 @@ ...@@ -18,6 +18,18 @@
#include <linux/clk-provider.h> #include <linux/clk-provider.h>
#include <linux/clkdev.h> #include <linux/clkdev.h>
/**
* struct clk_omap_reg - OMAP register declaration
* @offset: offset from the master IP module base address
* @index: index of the master IP module
*/
struct clk_omap_reg {
void __iomem *ptr;
u16 offset;
u8 index;
u8 flags;
};
/** /**
* struct dpll_data - DPLL registers and integration data * struct dpll_data - DPLL registers and integration data
* @mult_div1_reg: register containing the DPLL M and N bitfields * @mult_div1_reg: register containing the DPLL M and N bitfields
...@@ -67,12 +79,12 @@ ...@@ -67,12 +79,12 @@
* can be placed into read-only space. * can be placed into read-only space.
*/ */
struct dpll_data { struct dpll_data {
void __iomem *mult_div1_reg; struct clk_omap_reg mult_div1_reg;
u32 mult_mask; u32 mult_mask;
u32 div1_mask; u32 div1_mask;
struct clk_hw *clk_bypass; struct clk_hw *clk_bypass;
struct clk_hw *clk_ref; struct clk_hw *clk_ref;
void __iomem *control_reg; struct clk_omap_reg control_reg;
u32 enable_mask; u32 enable_mask;
unsigned long last_rounded_rate; unsigned long last_rounded_rate;
u16 last_rounded_m; u16 last_rounded_m;
...@@ -84,8 +96,8 @@ struct dpll_data { ...@@ -84,8 +96,8 @@ struct dpll_data {
u16 max_divider; u16 max_divider;
unsigned long max_rate; unsigned long max_rate;
u8 modes; u8 modes;
void __iomem *autoidle_reg; struct clk_omap_reg autoidle_reg;
void __iomem *idlest_reg; struct clk_omap_reg idlest_reg;
u32 autoidle_mask; u32 autoidle_mask;
u32 freqsel_mask; u32 freqsel_mask;
u32 idlest_mask; u32 idlest_mask;
...@@ -113,10 +125,10 @@ struct clk_hw_omap; ...@@ -113,10 +125,10 @@ struct clk_hw_omap;
*/ */
struct clk_hw_omap_ops { struct clk_hw_omap_ops {
void (*find_idlest)(struct clk_hw_omap *oclk, void (*find_idlest)(struct clk_hw_omap *oclk,
void __iomem **idlest_reg, struct clk_omap_reg *idlest_reg,
u8 *idlest_bit, u8 *idlest_val); u8 *idlest_bit, u8 *idlest_val);
void (*find_companion)(struct clk_hw_omap *oclk, void (*find_companion)(struct clk_hw_omap *oclk,
void __iomem **other_reg, struct clk_omap_reg *other_reg,
u8 *other_bit); u8 *other_bit);
void (*allow_idle)(struct clk_hw_omap *oclk); void (*allow_idle)(struct clk_hw_omap *oclk);
void (*deny_idle)(struct clk_hw_omap *oclk); void (*deny_idle)(struct clk_hw_omap *oclk);
...@@ -139,10 +151,10 @@ struct clk_hw_omap { ...@@ -139,10 +151,10 @@ struct clk_hw_omap {
struct list_head node; struct list_head node;
unsigned long fixed_rate; unsigned long fixed_rate;
u8 fixed_div; u8 fixed_div;
void __iomem *enable_reg; struct clk_omap_reg enable_reg;
u8 enable_bit; u8 enable_bit;
u8 flags; u8 flags;
void __iomem *clksel_reg; struct clk_omap_reg clksel_reg;
struct dpll_data *dpll_data; struct dpll_data *dpll_data;
const char *clkdm_name; const char *clkdm_name;
struct clockdomain *clkdm; struct clockdomain *clkdm;
...@@ -195,16 +207,6 @@ enum { ...@@ -195,16 +207,6 @@ enum {
CLK_MAX_MEMMAPS CLK_MAX_MEMMAPS
}; };
/**
* struct clk_omap_reg - OMAP register declaration
* @offset: offset from the master IP module base address
* @index: index of the master IP module
*/
struct clk_omap_reg {
u16 offset;
u16 index;
};
/** /**
* struct ti_clk_ll_ops - low-level ops for clocks * struct ti_clk_ll_ops - low-level ops for clocks
* @clk_readl: pointer to register read function * @clk_readl: pointer to register read function
...@@ -222,16 +224,16 @@ struct clk_omap_reg { ...@@ -222,16 +224,16 @@ struct clk_omap_reg {
* operations not provided directly by clock drivers. * operations not provided directly by clock drivers.
*/ */
struct ti_clk_ll_ops { struct ti_clk_ll_ops {
u32 (*clk_readl)(void __iomem *reg); u32 (*clk_readl)(const struct clk_omap_reg *reg);
void (*clk_writel)(u32 val, void __iomem *reg); void (*clk_writel)(u32 val, const struct clk_omap_reg *reg);
int (*clkdm_clk_enable)(struct clockdomain *clkdm, struct clk *clk); int (*clkdm_clk_enable)(struct clockdomain *clkdm, struct clk *clk);
int (*clkdm_clk_disable)(struct clockdomain *clkdm, int (*clkdm_clk_disable)(struct clockdomain *clkdm,
struct clk *clk); struct clk *clk);
struct clockdomain * (*clkdm_lookup)(const char *name); struct clockdomain * (*clkdm_lookup)(const char *name);
int (*cm_wait_module_ready)(u8 part, s16 prcm_mod, u16 idlest_reg, int (*cm_wait_module_ready)(u8 part, s16 prcm_mod, u16 idlest_reg,
u8 idlest_shift); u8 idlest_shift);
int (*cm_split_idlest_reg)(void __iomem *idlest_reg, s16 *prcm_inst, int (*cm_split_idlest_reg)(struct clk_omap_reg *idlest_reg,
u8 *idlest_reg_id); s16 *prcm_inst, u8 *idlest_reg_id);
}; };
#define to_clk_hw_omap(_hw) container_of(_hw, struct clk_hw_omap, hw) #define to_clk_hw_omap(_hw) container_of(_hw, struct clk_hw_omap, hw)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment