OMAP hwmod: convert header files with static allocations into C files
[deliverable/linux.git] / arch / arm / mach-omap2 / omap_hwmod.c
index d8c8545875b18b84aa89449ffa87911d687d129e..501660aae962bed05c2da10e5ec6708cfaa40891 100644 (file)
@@ -94,7 +94,8 @@ static int _update_sysc_cache(struct omap_hwmod *oh)
 
        oh->_sysc_cache = omap_hwmod_readl(oh, oh->sysconfig->sysc_offs);
 
-       oh->_int_flags |= _HWMOD_SYSCONFIG_LOADED;
+       if (!(oh->sysconfig->sysc_flags & SYSC_NO_CACHE))
+               oh->_int_flags |= _HWMOD_SYSCONFIG_LOADED;
 
        return 0;
 }
@@ -136,12 +137,24 @@ static void _write_sysconfig(u32 v, struct omap_hwmod *oh)
 static int _set_master_standbymode(struct omap_hwmod *oh, u8 standbymode,
                                   u32 *v)
 {
+       u32 mstandby_mask;
+       u8 mstandby_shift;
+
        if (!oh->sysconfig ||
            !(oh->sysconfig->sysc_flags & SYSC_HAS_MIDLEMODE))
                return -EINVAL;
 
-       *v &= ~SYSC_MIDLEMODE_MASK;
-       *v |= __ffs(standbymode) << SYSC_MIDLEMODE_SHIFT;
+       if (!oh->sysconfig->sysc_fields) {
+               WARN(!oh->sysconfig->sysc_fields, "offset struct for "
+                       "sysconfig not provided!\n");
+               return -EINVAL;
+       }
+
+       mstandby_shift = oh->sysconfig->sysc_fields->midle_shift;
+       mstandby_mask = (0x3 << mstandby_shift);
+
+       *v &= ~mstandby_mask;
+       *v |= __ffs(standbymode) << mstandby_shift;
 
        return 0;
 }
@@ -158,12 +171,24 @@ static int _set_master_standbymode(struct omap_hwmod *oh, u8 standbymode,
  */
 static int _set_slave_idlemode(struct omap_hwmod *oh, u8 idlemode, u32 *v)
 {
+       u32 sidle_mask;
+       u8 sidle_shift;
+
        if (!oh->sysconfig ||
            !(oh->sysconfig->sysc_flags & SYSC_HAS_SIDLEMODE))
                return -EINVAL;
 
-       *v &= ~SYSC_SIDLEMODE_MASK;
-       *v |= __ffs(idlemode) << SYSC_SIDLEMODE_SHIFT;
+       if (!oh->sysconfig->sysc_fields) {
+               WARN(!oh->sysconfig->sysc_fields, "offset struct for "
+                       "sysconfig not provided!\n");
+               return -EINVAL;
+       }
+
+       sidle_shift = oh->sysconfig->sysc_fields->sidle_shift;
+       sidle_mask = (0x3 << sidle_shift);
+
+       *v &= ~sidle_mask;
+       *v |= __ffs(idlemode) << sidle_shift;
 
        return 0;
 }
@@ -181,12 +206,24 @@ static int _set_slave_idlemode(struct omap_hwmod *oh, u8 idlemode, u32 *v)
  */
 static int _set_clockactivity(struct omap_hwmod *oh, u8 clockact, u32 *v)
 {
+       u32 clkact_mask;
+       u8  clkact_shift;
+
        if (!oh->sysconfig ||
            !(oh->sysconfig->sysc_flags & SYSC_HAS_CLOCKACTIVITY))
                return -EINVAL;
 
-       *v &= ~SYSC_CLOCKACTIVITY_MASK;
-       *v |= clockact << SYSC_CLOCKACTIVITY_SHIFT;
+       if (!oh->sysconfig->sysc_fields) {
+               WARN(!oh->sysconfig->sysc_fields, "offset struct for "
+                       "sysconfig not provided!\n");
+               return -EINVAL;
+       }
+
+       clkact_shift = oh->sysconfig->sysc_fields->clkact_shift;
+       clkact_mask = (0x3 << clkact_shift);
+
+       *v &= ~clkact_mask;
+       *v |= clockact << clkact_shift;
 
        return 0;
 }
@@ -201,11 +238,21 @@ static int _set_clockactivity(struct omap_hwmod *oh, u8 clockact, u32 *v)
  */
 static int _set_softreset(struct omap_hwmod *oh, u32 *v)
 {
+       u32 softrst_mask;
+
        if (!oh->sysconfig ||
            !(oh->sysconfig->sysc_flags & SYSC_HAS_SOFTRESET))
                return -EINVAL;
 
-       *v |= SYSC_SOFTRESET_MASK;
+       if (!oh->sysconfig->sysc_fields) {
+               WARN(!oh->sysconfig->sysc_fields, "offset struct for "
+                       "sysconfig not provided!\n");
+               return -EINVAL;
+       }
+
+       softrst_mask = (0x1 << oh->sysconfig->sysc_fields->srst_shift);
+
+       *v |= softrst_mask;
 
        return 0;
 }
@@ -226,12 +273,24 @@ static int _set_softreset(struct omap_hwmod *oh, u32 *v)
 static int _set_module_autoidle(struct omap_hwmod *oh, u8 autoidle,
                                u32 *v)
 {
+       u32 autoidle_mask;
+       u8 autoidle_shift;
+
        if (!oh->sysconfig ||
            !(oh->sysconfig->sysc_flags & SYSC_HAS_AUTOIDLE))
                return -EINVAL;
 
-       *v &= ~SYSC_AUTOIDLE_MASK;
-       *v |= autoidle << SYSC_AUTOIDLE_SHIFT;
+       if (!oh->sysconfig->sysc_fields) {
+               WARN(oh->sysconfig->sysc_fields, "offset struct for "
+                       "sysconfig not provided!\n");
+               return -EINVAL;
+       }
+
+       autoidle_shift = oh->sysconfig->sysc_fields->autoidle_shift;
+       autoidle_mask = (0x3 << autoidle_shift);
+
+       *v &= ~autoidle_mask;
+       *v |= autoidle << autoidle_shift;
 
        return 0;
 }
@@ -245,14 +304,22 @@ static int _set_module_autoidle(struct omap_hwmod *oh, u8 autoidle,
  */
 static int _enable_wakeup(struct omap_hwmod *oh)
 {
-       u32 v;
+       u32 v, wakeup_mask;
 
        if (!oh->sysconfig ||
            !(oh->sysconfig->sysc_flags & SYSC_HAS_ENAWAKEUP))
                return -EINVAL;
 
+       if (!oh->sysconfig->sysc_fields) {
+               WARN(!oh->sysconfig->sysc_fields, "offset struct for "
+                       "sysconfig not provided!\n");
+               return -EINVAL;
+       }
+
+       wakeup_mask = (0x1 << oh->sysconfig->sysc_fields->enwkup_shift);
+
        v = oh->_sysc_cache;
-       v |= SYSC_ENAWAKEUP_MASK;
+       v |= wakeup_mask;
        _write_sysconfig(v, oh);
 
        /* XXX test pwrdm_get_wken for this hwmod's subsystem */
@@ -271,14 +338,22 @@ static int _enable_wakeup(struct omap_hwmod *oh)
  */
 static int _disable_wakeup(struct omap_hwmod *oh)
 {
-       u32 v;
+       u32 v, wakeup_mask;
 
        if (!oh->sysconfig ||
            !(oh->sysconfig->sysc_flags & SYSC_HAS_ENAWAKEUP))
                return -EINVAL;
 
+       if (!oh->sysconfig->sysc_fields) {
+               WARN(!oh->sysconfig->sysc_fields, "offset struct for "
+                       "sysconfig not provided!\n");
+               return -EINVAL;
+       }
+
+       wakeup_mask = (0x1 << oh->sysconfig->sysc_fields->enwkup_shift);
+
        v = oh->_sysc_cache;
-       v &= ~SYSC_ENAWAKEUP_MASK;
+       v &= ~wakeup_mask;
        _write_sysconfig(v, oh);
 
        /* XXX test pwrdm_get_wken for this hwmod's subsystem */
@@ -298,15 +373,14 @@ static int _disable_wakeup(struct omap_hwmod *oh)
  * be accessed by the IVA, there should be a sleepdep between the IVA
  * initiator and the module).  Only applies to modules in smart-idle
  * mode.  Returns -EINVAL upon error or passes along
- * pwrdm_add_sleepdep() value upon success.
+ * clkdm_add_sleepdep() value upon success.
  */
 static int _add_initiator_dep(struct omap_hwmod *oh, struct omap_hwmod *init_oh)
 {
        if (!oh->_clk)
                return -EINVAL;
 
-       return pwrdm_add_sleepdep(oh->_clk->clkdm->pwrdm.ptr,
-                                 init_oh->_clk->clkdm->pwrdm.ptr);
+       return clkdm_add_sleepdep(oh->_clk->clkdm, init_oh->_clk->clkdm);
 }
 
 /**
@@ -319,15 +393,14 @@ static int _add_initiator_dep(struct omap_hwmod *oh, struct omap_hwmod *init_oh)
  * be accessed by the IVA, there should be no sleepdep between the IVA
  * initiator and the module).  Only applies to modules in smart-idle
  * mode.  Returns -EINVAL upon error or passes along
- * pwrdm_add_sleepdep() value upon success.
+ * clkdm_del_sleepdep() value upon success.
  */
 static int _del_initiator_dep(struct omap_hwmod *oh, struct omap_hwmod *init_oh)
 {
        if (!oh->_clk)
                return -EINVAL;
 
-       return pwrdm_del_sleepdep(oh->_clk->clkdm->pwrdm.ptr,
-                                 init_oh->_clk->clkdm->pwrdm.ptr);
+       return clkdm_del_sleepdep(oh->_clk->clkdm, init_oh->_clk->clkdm);
 }
 
 /**
@@ -343,18 +416,18 @@ static int _init_main_clk(struct omap_hwmod *oh)
        struct clk *c;
        int ret = 0;
 
-       if (!oh->clkdev_con_id)
+       if (!oh->main_clk)
                return 0;
 
-       c = clk_get_sys(oh->clkdev_dev_id, oh->clkdev_con_id);
-       WARN(IS_ERR(c), "omap_hwmod: %s: cannot clk_get main_clk %s.%s\n",
-            oh->name, oh->clkdev_dev_id, oh->clkdev_con_id);
+       c = omap_clk_get_by_name(oh->main_clk);
+       WARN(IS_ERR(c), "omap_hwmod: %s: cannot clk_get main_clk %s\n",
+            oh->name, oh->main_clk);
        if (IS_ERR(c))
                ret = -EINVAL;
        oh->_clk = c;
 
        WARN(!c->clkdm, "omap_hwmod: %s: missing clockdomain for %s.\n",
-            oh->clkdev_con_id, c->name);
+            oh->main_clk, c->name);
 
        return ret;
 }
@@ -377,13 +450,12 @@ static int _init_interface_clks(struct omap_hwmod *oh)
                return 0;
 
        for (i = 0, os = *oh->slaves; i < oh->slaves_cnt; i++, os++) {
-               if (!os->clkdev_con_id)
+               if (!os->clk)
                        continue;
 
-               c = clk_get_sys(os->clkdev_dev_id, os->clkdev_con_id);
+               c = omap_clk_get_by_name(os->clk);
                WARN(IS_ERR(c), "omap_hwmod: %s: cannot clk_get "
-                    "interface_clk %s.%s\n", oh->name,
-                    os->clkdev_dev_id, os->clkdev_con_id);
+                    "interface_clk %s\n", oh->name, os->clk);
                if (IS_ERR(c))
                        ret = -EINVAL;
                os->_clk = c;
@@ -407,10 +479,9 @@ static int _init_opt_clks(struct omap_hwmod *oh)
        int ret = 0;
 
        for (i = oh->opt_clks_cnt, oc = oh->opt_clks; i > 0; i--, oc++) {
-               c = clk_get_sys(oc->clkdev_dev_id, oc->clkdev_con_id);
+               c = omap_clk_get_by_name(oc->clk);
                WARN(IS_ERR(c), "omap_hwmod: %s: cannot clk_get opt_clk "
-                    "%s.%s\n", oh->name, oc->clkdev_dev_id,
-                    oc->clkdev_con_id);
+                    "%s\n", oh->name, oc->clk);
                if (IS_ERR(c))
                        ret = -EINVAL;
                oc->_clk = c;
@@ -993,6 +1064,23 @@ void omap_hwmod_writel(u32 v, struct omap_hwmod *oh, u16 reg_offs)
        __raw_writel(v, oh->_rt_va + reg_offs);
 }
 
+int omap_hwmod_set_slave_idlemode(struct omap_hwmod *oh, u8 idlemode)
+{
+       u32 v;
+       int retval = 0;
+
+       if (!oh)
+               return -EINVAL;
+
+       v = oh->_sysc_cache;
+
+       retval = _set_slave_idlemode(oh, idlemode, &v);
+       if (!retval)
+               _write_sysconfig(v, oh);
+
+       return retval;
+}
+
 /**
  * omap_hwmod_register - register a struct omap_hwmod
  * @oh: struct omap_hwmod *
This page took 0.125333 seconds and 5 git commands to generate.