struct clk_ti_divider_priv {
struct clk parent;
- fdt_addr_t reg;
+ struct clk_ti_reg reg;
const struct clk_div_table *table;
u8 shift;
u8 flags;
val = _get_val(priv->table, priv->div_flags, div);
- v = readl(priv->reg);
+ v = clk_ti_readl(&priv->reg);
v &= ~(priv->mask << priv->shift);
v |= val << priv->shift;
- writel(v, priv->reg);
- clk_ti_latch(priv->reg, priv->latch);
+ clk_ti_writel(v, &priv->reg);
+ clk_ti_latch(&priv->reg, priv->latch);
return clk_get_rate(clk);
}
if (IS_ERR_VALUE(parent_rate))
return parent_rate;
- v = readl(priv->reg) >> priv->shift;
+ v = clk_ti_readl(&priv->reg) >> priv->shift;
v &= priv->mask;
div = _get_div(priv->table, priv->div_flags, v);
u32 min_div = 0;
u32 max_val, max_div = 0;
u16 mask;
- int i, div_num;
+ int i, div_num, err;
+
+ err = clk_ti_get_reg_addr(dev, 0, &priv->reg);
+ if (err) {
+ dev_err(dev, "failed to get register address\n");
+ return err;
+ }
- priv->reg = dev_read_addr(dev);
- dev_dbg(dev, "reg=0x%08lx\n", priv->reg);
priv->shift = dev_read_u32_default(dev, "ti,bit-shift", 0);
priv->latch = dev_read_s32_default(dev, "ti,latch-bit", -EINVAL);
if (dev_read_bool(dev, "ti,index-starts-at-one"))
struct clk_ti_mux_priv {
struct clk_bulk parents;
- fdt_addr_t reg;
+ struct clk_ti_reg reg;
u32 flags;
u32 mux_flags;
u32 mask;
struct clk_ti_mux_priv *priv = dev_get_priv(clk->dev);
u32 val;
- val = readl(priv->reg);
+ val = clk_ti_readl(&priv->reg);
val >>= priv->shift;
val &= priv->mask;
if (priv->flags & CLK_MUX_HIWORD_MASK) {
val = priv->mask << (priv->shift + 16);
} else {
- val = readl(priv->reg);
+ val = clk_ti_readl(&priv->reg);
val &= ~(priv->mask << priv->shift);
}
val |= index << priv->shift;
- writel(val, priv->reg);
- clk_ti_latch(priv->reg, priv->latch);
+ clk_ti_writel(val, &priv->reg);
+ clk_ti_latch(&priv->reg, priv->latch);
return 0;
}
static int clk_ti_mux_of_to_plat(struct udevice *dev)
{
struct clk_ti_mux_priv *priv = dev_get_priv(dev);
+ int err;
- priv->reg = dev_read_addr(dev);
- if (priv->reg == FDT_ADDR_T_NONE) {
- dev_err(dev, "failed to get register\n");
- return -EINVAL;
+ err = clk_ti_get_reg_addr(dev, 0, &priv->reg);
+ if (err) {
+ dev_err(dev, "failed to get register address\n");
+ return err;
}
- dev_dbg(dev, "reg=0x%08lx\n", priv->reg);
priv->shift = dev_read_u32_default(dev, "ti,bit-shift", 0);
priv->latch = dev_read_s32_default(dev, "ti,latch-bit", -EINVAL);
static unsigned int clk_memmaps_num;
static struct clk_iomap clk_memmaps[CLK_MAX_MEMMAPS];
-static void clk_ti_rmw(u32 val, u32 mask, fdt_addr_t reg)
+static void clk_ti_rmw(u32 val, u32 mask, struct clk_ti_reg *reg)
{
u32 v;
- v = readl(reg);
+ v = clk_ti_readl(reg);
v &= ~mask;
v |= val;
- writel(v, reg);
+ clk_ti_writel(v, reg);
}
-void clk_ti_latch(fdt_addr_t reg, s8 shift)
+void clk_ti_latch(struct clk_ti_reg *reg, s8 shift)
{
u32 latch;
clk_ti_rmw(latch, latch, reg);
clk_ti_rmw(0, latch, reg);
- readl(reg); /* OCP barrier */
+ clk_ti_readl(reg); /* OCP barrier */
}
void clk_ti_writel(u32 val, struct clk_ti_reg *reg)
#ifndef _CLK_TI_H
#define _CLK_TI_H
-void clk_ti_latch(fdt_addr_t reg, s8 shift);
/**
* struct clk_ti_reg - TI register declaration
* @offset: offset from the master IP module base address
u8 index;
};
+void clk_ti_latch(struct clk_ti_reg *reg, s8 shift);
void clk_ti_writel(u32 val, struct clk_ti_reg *reg);
u32 clk_ti_readl(struct clk_ti_reg *reg);
int clk_ti_get_reg_addr(struct udevice *dev, int index, struct clk_ti_reg *reg);