Lines Matching refs:oh
217 void (*enable_module)(struct omap_hwmod *oh);
218 int (*disable_module)(struct omap_hwmod *oh);
219 int (*wait_target_ready)(struct omap_hwmod *oh);
220 int (*assert_hardreset)(struct omap_hwmod *oh,
222 int (*deassert_hardreset)(struct omap_hwmod *oh,
224 int (*is_hardreset_asserted)(struct omap_hwmod *oh,
226 int (*init_clkdm)(struct omap_hwmod *oh);
227 void (*update_context_lost)(struct omap_hwmod *oh);
228 int (*get_context_lost)(struct omap_hwmod *oh);
229 int (*disable_direct_prcm)(struct omap_hwmod *oh);
230 u32 (*xlate_clkctrl)(struct omap_hwmod *oh);
255 static int _update_sysc_cache(struct omap_hwmod *oh) in _update_sysc_cache() argument
257 if (!oh->class->sysc) { in _update_sysc_cache()
258 WARN(1, "omap_hwmod: %s: cannot read OCP_SYSCONFIG: not defined on hwmod's class\n", oh->name); in _update_sysc_cache()
264 oh->_sysc_cache = omap_hwmod_read(oh, oh->class->sysc->sysc_offs); in _update_sysc_cache()
266 if (!(oh->class->sysc->sysc_flags & SYSC_NO_CACHE)) in _update_sysc_cache()
267 oh->_int_flags |= _HWMOD_SYSCONFIG_LOADED; in _update_sysc_cache()
280 static void _write_sysconfig(u32 v, struct omap_hwmod *oh) in _write_sysconfig() argument
282 if (!oh->class->sysc) { in _write_sysconfig()
283 WARN(1, "omap_hwmod: %s: cannot write OCP_SYSCONFIG: not defined on hwmod's class\n", oh->name); in _write_sysconfig()
290 oh->_sysc_cache = v; in _write_sysconfig()
298 if (oh->class->unlock) in _write_sysconfig()
299 oh->class->unlock(oh); in _write_sysconfig()
301 omap_hwmod_write(v, oh, oh->class->sysc->sysc_offs); in _write_sysconfig()
303 if (oh->class->lock) in _write_sysconfig()
304 oh->class->lock(oh); in _write_sysconfig()
317 static int _set_master_standbymode(struct omap_hwmod *oh, u8 standbymode, in _set_master_standbymode() argument
323 if (!oh->class->sysc || in _set_master_standbymode()
324 !(oh->class->sysc->sysc_flags & SYSC_HAS_MIDLEMODE)) in _set_master_standbymode()
327 if (!oh->class->sysc->sysc_fields) { in _set_master_standbymode()
328 WARN(1, "omap_hwmod: %s: offset struct for sysconfig not provided in class\n", oh->name); in _set_master_standbymode()
332 mstandby_shift = oh->class->sysc->sysc_fields->midle_shift; in _set_master_standbymode()
351 static int _set_slave_idlemode(struct omap_hwmod *oh, u8 idlemode, u32 *v) in _set_slave_idlemode() argument
356 if (!oh->class->sysc || in _set_slave_idlemode()
357 !(oh->class->sysc->sysc_flags & SYSC_HAS_SIDLEMODE)) in _set_slave_idlemode()
360 if (!oh->class->sysc->sysc_fields) { in _set_slave_idlemode()
361 WARN(1, "omap_hwmod: %s: offset struct for sysconfig not provided in class\n", oh->name); in _set_slave_idlemode()
365 sidle_shift = oh->class->sysc->sysc_fields->sidle_shift; in _set_slave_idlemode()
385 static int _set_clockactivity(struct omap_hwmod *oh, u8 clockact, u32 *v) in _set_clockactivity() argument
390 if (!oh->class->sysc || in _set_clockactivity()
391 !(oh->class->sysc->sysc_flags & SYSC_HAS_CLOCKACTIVITY)) in _set_clockactivity()
394 if (!oh->class->sysc->sysc_fields) { in _set_clockactivity()
395 WARN(1, "omap_hwmod: %s: offset struct for sysconfig not provided in class\n", oh->name); in _set_clockactivity()
399 clkact_shift = oh->class->sysc->sysc_fields->clkact_shift; in _set_clockactivity()
416 static int _set_softreset(struct omap_hwmod *oh, u32 *v) in _set_softreset() argument
420 if (!oh->class->sysc || in _set_softreset()
421 !(oh->class->sysc->sysc_flags & SYSC_HAS_SOFTRESET)) in _set_softreset()
424 if (!oh->class->sysc->sysc_fields) { in _set_softreset()
425 WARN(1, "omap_hwmod: %s: offset struct for sysconfig not provided in class\n", oh->name); in _set_softreset()
429 softrst_mask = (0x1 << oh->class->sysc->sysc_fields->srst_shift); in _set_softreset()
444 static int _clear_softreset(struct omap_hwmod *oh, u32 *v) in _clear_softreset() argument
448 if (!oh->class->sysc || in _clear_softreset()
449 !(oh->class->sysc->sysc_flags & SYSC_HAS_SOFTRESET)) in _clear_softreset()
452 if (!oh->class->sysc->sysc_fields) { in _clear_softreset()
455 oh->name); in _clear_softreset()
459 softrst_mask = (0x1 << oh->class->sysc->sysc_fields->srst_shift); in _clear_softreset()
476 static int _wait_softreset_complete(struct omap_hwmod *oh) in _wait_softreset_complete() argument
482 sysc = oh->class->sysc; in _wait_softreset_complete()
485 omap_test_timeout((omap_hwmod_read(oh, sysc->syss_offs) in _wait_softreset_complete()
490 omap_test_timeout(!(omap_hwmod_read(oh, sysc->sysc_offs) in _wait_softreset_complete()
510 static int _set_dmadisable(struct omap_hwmod *oh) in _set_dmadisable() argument
515 if (!oh->class->sysc || in _set_dmadisable()
516 !(oh->class->sysc->sysc_flags & SYSC_HAS_DMADISABLE)) in _set_dmadisable()
519 if (!oh->class->sysc->sysc_fields) { in _set_dmadisable()
520 WARN(1, "omap_hwmod: %s: offset struct for sysconfig not provided in class\n", oh->name); in _set_dmadisable()
525 if (oh->_state != _HWMOD_STATE_ENABLED) { in _set_dmadisable()
526 pr_warn("omap_hwmod: %s: dma can be disabled only from enabled state\n", oh->name); in _set_dmadisable()
530 pr_debug("omap_hwmod: %s: setting DMADISABLE\n", oh->name); in _set_dmadisable()
532 v = oh->_sysc_cache; in _set_dmadisable()
534 (0x1 << oh->class->sysc->sysc_fields->dmadisable_shift); in _set_dmadisable()
536 _write_sysconfig(v, oh); in _set_dmadisable()
554 static int _set_module_autoidle(struct omap_hwmod *oh, u8 autoidle, in _set_module_autoidle() argument
560 if (!oh->class->sysc || in _set_module_autoidle()
561 !(oh->class->sysc->sysc_flags & SYSC_HAS_AUTOIDLE)) in _set_module_autoidle()
564 if (!oh->class->sysc->sysc_fields) { in _set_module_autoidle()
565 WARN(1, "omap_hwmod: %s: offset struct for sysconfig not provided in class\n", oh->name); in _set_module_autoidle()
569 autoidle_shift = oh->class->sysc->sysc_fields->autoidle_shift; in _set_module_autoidle()
585 static int _enable_wakeup(struct omap_hwmod *oh, u32 *v) in _enable_wakeup() argument
587 if (!oh->class->sysc || in _enable_wakeup()
588 !((oh->class->sysc->sysc_flags & SYSC_HAS_ENAWAKEUP) || in _enable_wakeup()
589 (oh->class->sysc->idlemodes & SIDLE_SMART_WKUP) || in _enable_wakeup()
590 (oh->class->sysc->idlemodes & MSTANDBY_SMART_WKUP))) in _enable_wakeup()
593 if (!oh->class->sysc->sysc_fields) { in _enable_wakeup()
594 WARN(1, "omap_hwmod: %s: offset struct for sysconfig not provided in class\n", oh->name); in _enable_wakeup()
598 if (oh->class->sysc->sysc_flags & SYSC_HAS_ENAWAKEUP) in _enable_wakeup()
599 *v |= 0x1 << oh->class->sysc->sysc_fields->enwkup_shift; in _enable_wakeup()
601 if (oh->class->sysc->idlemodes & SIDLE_SMART_WKUP) in _enable_wakeup()
602 _set_slave_idlemode(oh, HWMOD_IDLEMODE_SMART_WKUP, v); in _enable_wakeup()
603 if (oh->class->sysc->idlemodes & MSTANDBY_SMART_WKUP) in _enable_wakeup()
604 _set_master_standbymode(oh, HWMOD_IDLEMODE_SMART_WKUP, v); in _enable_wakeup()
618 static int _disable_wakeup(struct omap_hwmod *oh, u32 *v) in _disable_wakeup() argument
620 if (!oh->class->sysc || in _disable_wakeup()
621 !((oh->class->sysc->sysc_flags & SYSC_HAS_ENAWAKEUP) || in _disable_wakeup()
622 (oh->class->sysc->idlemodes & SIDLE_SMART_WKUP) || in _disable_wakeup()
623 (oh->class->sysc->idlemodes & MSTANDBY_SMART_WKUP))) in _disable_wakeup()
626 if (!oh->class->sysc->sysc_fields) { in _disable_wakeup()
627 WARN(1, "omap_hwmod: %s: offset struct for sysconfig not provided in class\n", oh->name); in _disable_wakeup()
631 if (oh->class->sysc->sysc_flags & SYSC_HAS_ENAWAKEUP) in _disable_wakeup()
632 *v &= ~(0x1 << oh->class->sysc->sysc_fields->enwkup_shift); in _disable_wakeup()
634 if (oh->class->sysc->idlemodes & SIDLE_SMART_WKUP) in _disable_wakeup()
635 _set_slave_idlemode(oh, HWMOD_IDLEMODE_SMART, v); in _disable_wakeup()
636 if (oh->class->sysc->idlemodes & MSTANDBY_SMART_WKUP) in _disable_wakeup()
637 _set_master_standbymode(oh, HWMOD_IDLEMODE_SMART, v); in _disable_wakeup()
644 static struct clockdomain *_get_clkdm(struct omap_hwmod *oh) in _get_clkdm() argument
648 if (oh->clkdm) { in _get_clkdm()
649 return oh->clkdm; in _get_clkdm()
650 } else if (oh->_clk) { in _get_clkdm()
651 if (__clk_get_flags(oh->_clk) & CLK_IS_BASIC) in _get_clkdm()
653 clk = to_clk_hw_omap(__clk_get_hw(oh->_clk)); in _get_clkdm()
672 static int _add_initiator_dep(struct omap_hwmod *oh, struct omap_hwmod *init_oh) in _add_initiator_dep() argument
676 clkdm = _get_clkdm(oh); in _add_initiator_dep()
701 static int _del_initiator_dep(struct omap_hwmod *oh, struct omap_hwmod *init_oh) in _del_initiator_dep() argument
705 clkdm = _get_clkdm(oh); in _del_initiator_dep()
764 static u32 _omap4_xlate_clkctrl(struct omap_hwmod *oh) in _omap4_xlate_clkctrl() argument
766 if (!oh->prcm.omap4.modulemode) in _omap4_xlate_clkctrl()
769 return omap_cm_xlate_clkctrl(oh->clkdm->prcm_partition, in _omap4_xlate_clkctrl()
770 oh->clkdm->cm_inst, in _omap4_xlate_clkctrl()
771 oh->prcm.omap4.clkctrl_offs); in _omap4_xlate_clkctrl()
774 static struct clk *_lookup_clkctrl_clk(struct omap_hwmod *oh) in _lookup_clkctrl_clk() argument
783 addr = soc_ops.xlate_clkctrl(oh); in _lookup_clkctrl_clk()
787 pr_debug("%s: %s: addr=%x\n", __func__, oh->name, addr); in _lookup_clkctrl_clk()
803 __func__, oh->name, clk, clkspec.args[0], in _lookup_clkctrl_clk()
821 static int _init_main_clk(struct omap_hwmod *oh) in _init_main_clk() argument
826 clk = _lookup_clkctrl_clk(oh); in _init_main_clk()
830 __clk_get_name(clk), oh->name); in _init_main_clk()
831 oh->main_clk = __clk_get_name(clk); in _init_main_clk()
832 oh->_clk = clk; in _init_main_clk()
833 soc_ops.disable_direct_prcm(oh); in _init_main_clk()
835 if (!oh->main_clk) in _init_main_clk()
838 oh->_clk = clk_get(NULL, oh->main_clk); in _init_main_clk()
841 if (IS_ERR(oh->_clk)) { in _init_main_clk()
843 oh->name, oh->main_clk); in _init_main_clk()
854 clk_prepare(oh->_clk); in _init_main_clk()
856 if (!_get_clkdm(oh)) in _init_main_clk()
858 oh->name, oh->main_clk); in _init_main_clk()
870 static int _init_interface_clks(struct omap_hwmod *oh) in _init_interface_clks() argument
876 list_for_each_entry(os, &oh->slave_ports, node) { in _init_interface_clks()
883 oh->name, os->clk); in _init_interface_clks()
909 static int _init_opt_clks(struct omap_hwmod *oh) in _init_opt_clks() argument
916 for (i = oh->opt_clks_cnt, oc = oh->opt_clks; i > 0; i--, oc++) { in _init_opt_clks()
920 oh->name, oc->clk); in _init_opt_clks()
939 static void _enable_optional_clocks(struct omap_hwmod *oh) in _enable_optional_clocks() argument
944 pr_debug("omap_hwmod: %s: enabling optional clocks\n", oh->name); in _enable_optional_clocks()
946 for (i = oh->opt_clks_cnt, oc = oh->opt_clks; i > 0; i--, oc++) in _enable_optional_clocks()
954 static void _disable_optional_clocks(struct omap_hwmod *oh) in _disable_optional_clocks() argument
959 pr_debug("omap_hwmod: %s: disabling optional clocks\n", oh->name); in _disable_optional_clocks()
961 for (i = oh->opt_clks_cnt, oc = oh->opt_clks; i > 0; i--, oc++) in _disable_optional_clocks()
976 static int _enable_clocks(struct omap_hwmod *oh) in _enable_clocks() argument
980 pr_debug("omap_hwmod: %s: enabling clocks\n", oh->name); in _enable_clocks()
982 if (oh->flags & HWMOD_OPT_CLKS_NEEDED) in _enable_clocks()
983 _enable_optional_clocks(oh); in _enable_clocks()
985 if (oh->_clk) in _enable_clocks()
986 clk_enable(oh->_clk); in _enable_clocks()
988 list_for_each_entry(os, &oh->slave_ports, node) { in _enable_clocks()
1002 static bool _omap4_clkctrl_managed_by_clkfwk(struct omap_hwmod *oh) in _omap4_clkctrl_managed_by_clkfwk() argument
1004 if (oh->prcm.omap4.flags & HWMOD_OMAP4_CLKFWK_CLKCTR_CLOCK) in _omap4_clkctrl_managed_by_clkfwk()
1014 static bool _omap4_has_clkctrl_clock(struct omap_hwmod *oh) in _omap4_has_clkctrl_clock() argument
1016 if (oh->prcm.omap4.clkctrl_offs) in _omap4_has_clkctrl_clock()
1019 if (!oh->prcm.omap4.clkctrl_offs && in _omap4_has_clkctrl_clock()
1020 oh->prcm.omap4.flags & HWMOD_OMAP4_ZERO_CLKCTRL_OFFSET) in _omap4_has_clkctrl_clock()
1032 static int _disable_clocks(struct omap_hwmod *oh) in _disable_clocks() argument
1036 pr_debug("omap_hwmod: %s: disabling clocks\n", oh->name); in _disable_clocks()
1038 if (oh->_clk) in _disable_clocks()
1039 clk_disable(oh->_clk); in _disable_clocks()
1041 list_for_each_entry(os, &oh->slave_ports, node) { in _disable_clocks()
1046 if (oh->flags & HWMOD_OPT_CLKS_NEEDED) in _disable_clocks()
1047 _disable_optional_clocks(oh); in _disable_clocks()
1061 static void _omap4_enable_module(struct omap_hwmod *oh) in _omap4_enable_module() argument
1063 if (!oh->clkdm || !oh->prcm.omap4.modulemode || in _omap4_enable_module()
1064 _omap4_clkctrl_managed_by_clkfwk(oh)) in _omap4_enable_module()
1068 oh->name, __func__, oh->prcm.omap4.modulemode); in _omap4_enable_module()
1070 omap_cm_module_enable(oh->prcm.omap4.modulemode, in _omap4_enable_module()
1071 oh->clkdm->prcm_partition, in _omap4_enable_module()
1072 oh->clkdm->cm_inst, oh->prcm.omap4.clkctrl_offs); in _omap4_enable_module()
1084 static int _omap4_wait_target_disable(struct omap_hwmod *oh) in _omap4_wait_target_disable() argument
1086 if (!oh) in _omap4_wait_target_disable()
1089 if (oh->_int_flags & _HWMOD_NO_MPU_PORT || !oh->clkdm) in _omap4_wait_target_disable()
1092 if (oh->flags & HWMOD_NO_IDLEST) in _omap4_wait_target_disable()
1095 if (_omap4_clkctrl_managed_by_clkfwk(oh)) in _omap4_wait_target_disable()
1098 if (!_omap4_has_clkctrl_clock(oh)) in _omap4_wait_target_disable()
1101 return omap_cm_wait_module_idle(oh->clkdm->prcm_partition, in _omap4_wait_target_disable()
1102 oh->clkdm->cm_inst, in _omap4_wait_target_disable()
1103 oh->prcm.omap4.clkctrl_offs, 0); in _omap4_wait_target_disable()
1115 static void __init _save_mpu_port_index(struct omap_hwmod *oh) in _save_mpu_port_index() argument
1119 if (!oh) in _save_mpu_port_index()
1122 oh->_int_flags |= _HWMOD_NO_MPU_PORT; in _save_mpu_port_index()
1124 list_for_each_entry(os, &oh->slave_ports, node) { in _save_mpu_port_index()
1126 oh->_mpu_port = os; in _save_mpu_port_index()
1127 oh->_int_flags &= ~_HWMOD_NO_MPU_PORT; in _save_mpu_port_index()
1148 static struct omap_hwmod_ocp_if *_find_mpu_rt_port(struct omap_hwmod *oh) in _find_mpu_rt_port() argument
1150 if (!oh || oh->_int_flags & _HWMOD_NO_MPU_PORT || oh->slaves_cnt == 0) in _find_mpu_rt_port()
1153 return oh->_mpu_port; in _find_mpu_rt_port()
1167 static void _enable_sysc(struct omap_hwmod *oh) in _enable_sysc() argument
1174 if (!oh->class->sysc) in _enable_sysc()
1183 if (oh->flags & HWMOD_CONTROL_OPT_CLKS_IN_RESET) in _enable_sysc()
1184 _enable_optional_clocks(oh); in _enable_sysc()
1185 _wait_softreset_complete(oh); in _enable_sysc()
1186 if (oh->flags & HWMOD_CONTROL_OPT_CLKS_IN_RESET) in _enable_sysc()
1187 _disable_optional_clocks(oh); in _enable_sysc()
1189 v = oh->_sysc_cache; in _enable_sysc()
1190 sf = oh->class->sysc->sysc_flags; in _enable_sysc()
1192 clkdm = _get_clkdm(oh); in _enable_sysc()
1194 if (oh->flags & HWMOD_SWSUP_SIDLE || in _enable_sysc()
1195 oh->flags & HWMOD_SWSUP_SIDLE_ACT) { in _enable_sysc()
1199 _enable_wakeup(oh, &v); in _enable_sysc()
1200 if (oh->class->sysc->idlemodes & SIDLE_SMART_WKUP) in _enable_sysc()
1211 if (clkdm_act && !(oh->class->sysc->idlemodes & in _enable_sysc()
1215 _set_slave_idlemode(oh, idlemode, &v); in _enable_sysc()
1219 if (oh->flags & HWMOD_FORCE_MSTANDBY) { in _enable_sysc()
1221 } else if (oh->flags & HWMOD_SWSUP_MSTANDBY) { in _enable_sysc()
1225 _enable_wakeup(oh, &v); in _enable_sysc()
1226 if (oh->class->sysc->idlemodes & MSTANDBY_SMART_WKUP) in _enable_sysc()
1231 _set_master_standbymode(oh, idlemode, &v); in _enable_sysc()
1239 if ((oh->flags & HWMOD_SET_DEFAULT_CLOCKACT) && in _enable_sysc()
1241 _set_clockactivity(oh, CLOCKACT_TEST_ICLK, &v); in _enable_sysc()
1243 _write_sysconfig(v, oh); in _enable_sysc()
1250 idlemode = (oh->flags & HWMOD_NO_OCP_AUTOIDLE) ? in _enable_sysc()
1252 _set_module_autoidle(oh, idlemode, &v); in _enable_sysc()
1253 _write_sysconfig(v, oh); in _enable_sysc()
1266 static void _idle_sysc(struct omap_hwmod *oh) in _idle_sysc() argument
1271 if (!oh->class->sysc) in _idle_sysc()
1274 v = oh->_sysc_cache; in _idle_sysc()
1275 sf = oh->class->sysc->sysc_flags; in _idle_sysc()
1278 if (oh->flags & HWMOD_SWSUP_SIDLE) { in _idle_sysc()
1282 _enable_wakeup(oh, &v); in _idle_sysc()
1283 if (oh->class->sysc->idlemodes & SIDLE_SMART_WKUP) in _idle_sysc()
1288 _set_slave_idlemode(oh, idlemode, &v); in _idle_sysc()
1292 if ((oh->flags & HWMOD_SWSUP_MSTANDBY) || in _idle_sysc()
1293 (oh->flags & HWMOD_FORCE_MSTANDBY)) { in _idle_sysc()
1297 _enable_wakeup(oh, &v); in _idle_sysc()
1298 if (oh->class->sysc->idlemodes & MSTANDBY_SMART_WKUP) in _idle_sysc()
1303 _set_master_standbymode(oh, idlemode, &v); in _idle_sysc()
1307 if (oh->_sysc_cache != v) in _idle_sysc()
1308 _write_sysconfig(v, oh); in _idle_sysc()
1318 static void _shutdown_sysc(struct omap_hwmod *oh) in _shutdown_sysc() argument
1323 if (!oh->class->sysc) in _shutdown_sysc()
1326 v = oh->_sysc_cache; in _shutdown_sysc()
1327 sf = oh->class->sysc->sysc_flags; in _shutdown_sysc()
1330 _set_slave_idlemode(oh, HWMOD_IDLEMODE_FORCE, &v); in _shutdown_sysc()
1333 _set_master_standbymode(oh, HWMOD_IDLEMODE_FORCE, &v); in _shutdown_sysc()
1336 _set_module_autoidle(oh, 1, &v); in _shutdown_sysc()
1338 _write_sysconfig(v, oh); in _shutdown_sysc()
1349 struct omap_hwmod *oh, *temp_oh; in _lookup() local
1351 oh = NULL; in _lookup()
1355 oh = temp_oh; in _lookup()
1360 return oh; in _lookup()
1371 static int _init_clkdm(struct omap_hwmod *oh) in _init_clkdm() argument
1373 if (!oh->clkdm_name) { in _init_clkdm()
1374 pr_debug("omap_hwmod: %s: missing clockdomain\n", oh->name); in _init_clkdm()
1378 oh->clkdm = clkdm_lookup(oh->clkdm_name); in _init_clkdm()
1379 if (!oh->clkdm) { in _init_clkdm()
1381 oh->name, oh->clkdm_name); in _init_clkdm()
1386 oh->name, oh->clkdm_name); in _init_clkdm()
1401 static int _init_clocks(struct omap_hwmod *oh, struct device_node *np) in _init_clocks() argument
1405 if (oh->_state != _HWMOD_STATE_REGISTERED) in _init_clocks()
1408 pr_debug("omap_hwmod: %s: looking up clocks\n", oh->name); in _init_clocks()
1411 ret |= soc_ops.init_clkdm(oh); in _init_clocks()
1413 ret |= _init_main_clk(oh); in _init_clocks()
1414 ret |= _init_interface_clks(oh); in _init_clocks()
1415 ret |= _init_opt_clks(oh); in _init_clocks()
1418 oh->_state = _HWMOD_STATE_CLKS_INITED; in _init_clocks()
1420 pr_warn("omap_hwmod: %s: cannot _init_clocks\n", oh->name); in _init_clocks()
1434 static int _lookup_hardreset(struct omap_hwmod *oh, const char *name, in _lookup_hardreset() argument
1439 for (i = 0; i < oh->rst_lines_cnt; i++) { in _lookup_hardreset()
1440 const char *rst_line = oh->rst_lines[i].name; in _lookup_hardreset()
1442 ohri->rst_shift = oh->rst_lines[i].rst_shift; in _lookup_hardreset()
1443 ohri->st_shift = oh->rst_lines[i].st_shift; in _lookup_hardreset()
1445 oh->name, __func__, rst_line, ohri->rst_shift, in _lookup_hardreset()
1468 static int _assert_hardreset(struct omap_hwmod *oh, const char *name) in _assert_hardreset() argument
1473 if (!oh) in _assert_hardreset()
1479 ret = _lookup_hardreset(oh, name, &ohri); in _assert_hardreset()
1483 ret = soc_ops.assert_hardreset(oh, &ohri); in _assert_hardreset()
1501 static int _deassert_hardreset(struct omap_hwmod *oh, const char *name) in _deassert_hardreset() argument
1506 if (!oh) in _deassert_hardreset()
1512 ret = _lookup_hardreset(oh, name, &ohri); in _deassert_hardreset()
1516 if (oh->clkdm) { in _deassert_hardreset()
1522 clkdm_deny_idle(oh->clkdm); in _deassert_hardreset()
1523 ret = clkdm_hwmod_enable(oh->clkdm, oh); in _deassert_hardreset()
1526 oh->name, oh->clkdm->name, ret); in _deassert_hardreset()
1531 _enable_clocks(oh); in _deassert_hardreset()
1533 soc_ops.enable_module(oh); in _deassert_hardreset()
1535 ret = soc_ops.deassert_hardreset(oh, &ohri); in _deassert_hardreset()
1538 soc_ops.disable_module(oh); in _deassert_hardreset()
1539 _disable_clocks(oh); in _deassert_hardreset()
1542 pr_warn("omap_hwmod: %s: failed to hardreset\n", oh->name); in _deassert_hardreset()
1544 if (oh->clkdm) { in _deassert_hardreset()
1549 clkdm_allow_idle(oh->clkdm); in _deassert_hardreset()
1551 clkdm_hwmod_disable(oh->clkdm, oh); in _deassert_hardreset()
1569 static int _read_hardreset(struct omap_hwmod *oh, const char *name) in _read_hardreset() argument
1574 if (!oh) in _read_hardreset()
1580 ret = _lookup_hardreset(oh, name, &ohri); in _read_hardreset()
1584 return soc_ops.is_hardreset_asserted(oh, &ohri); in _read_hardreset()
1597 static bool _are_all_hardreset_lines_asserted(struct omap_hwmod *oh) in _are_all_hardreset_lines_asserted() argument
1601 if (oh->rst_lines_cnt == 0) in _are_all_hardreset_lines_asserted()
1604 for (i = 0; i < oh->rst_lines_cnt; i++) in _are_all_hardreset_lines_asserted()
1605 if (_read_hardreset(oh, oh->rst_lines[i].name) > 0) in _are_all_hardreset_lines_asserted()
1608 if (oh->rst_lines_cnt == rst_cnt) in _are_all_hardreset_lines_asserted()
1625 static bool _are_any_hardreset_lines_asserted(struct omap_hwmod *oh) in _are_any_hardreset_lines_asserted() argument
1630 for (i = 0; i < oh->rst_lines_cnt && rst_cnt == 0; i++) in _are_any_hardreset_lines_asserted()
1631 if (_read_hardreset(oh, oh->rst_lines[i].name) > 0) in _are_any_hardreset_lines_asserted()
1644 static int _omap4_disable_module(struct omap_hwmod *oh) in _omap4_disable_module() argument
1648 if (!oh->clkdm || !oh->prcm.omap4.modulemode || in _omap4_disable_module()
1649 _omap4_clkctrl_managed_by_clkfwk(oh)) in _omap4_disable_module()
1656 if (_are_any_hardreset_lines_asserted(oh)) in _omap4_disable_module()
1659 pr_debug("omap_hwmod: %s: %s\n", oh->name, __func__); in _omap4_disable_module()
1661 omap_cm_module_disable(oh->clkdm->prcm_partition, oh->clkdm->cm_inst, in _omap4_disable_module()
1662 oh->prcm.omap4.clkctrl_offs); in _omap4_disable_module()
1664 v = _omap4_wait_target_disable(oh); in _omap4_disable_module()
1667 oh->name); in _omap4_disable_module()
1688 static int _ocp_softreset(struct omap_hwmod *oh) in _ocp_softreset() argument
1694 if (!oh->class->sysc || in _ocp_softreset()
1695 !(oh->class->sysc->sysc_flags & SYSC_HAS_SOFTRESET)) in _ocp_softreset()
1699 if (oh->_state != _HWMOD_STATE_ENABLED) { in _ocp_softreset()
1701 oh->name); in _ocp_softreset()
1706 if (oh->flags & HWMOD_CONTROL_OPT_CLKS_IN_RESET) in _ocp_softreset()
1707 _enable_optional_clocks(oh); in _ocp_softreset()
1709 pr_debug("omap_hwmod: %s: resetting via OCP SOFTRESET\n", oh->name); in _ocp_softreset()
1711 v = oh->_sysc_cache; in _ocp_softreset()
1712 ret = _set_softreset(oh, &v); in _ocp_softreset()
1716 _write_sysconfig(v, oh); in _ocp_softreset()
1718 if (oh->class->sysc->srst_udelay) in _ocp_softreset()
1719 udelay(oh->class->sysc->srst_udelay); in _ocp_softreset()
1721 c = _wait_softreset_complete(oh); in _ocp_softreset()
1724 oh->name, MAX_MODULE_SOFTRESET_WAIT); in _ocp_softreset()
1728 pr_debug("omap_hwmod: %s: softreset in %d usec\n", oh->name, c); in _ocp_softreset()
1731 ret = _clear_softreset(oh, &v); in _ocp_softreset()
1735 _write_sysconfig(v, oh); in _ocp_softreset()
1743 if (oh->flags & HWMOD_CONTROL_OPT_CLKS_IN_RESET) in _ocp_softreset()
1744 _disable_optional_clocks(oh); in _ocp_softreset()
1782 static int _reset(struct omap_hwmod *oh) in _reset() argument
1786 pr_debug("omap_hwmod: %s: resetting\n", oh->name); in _reset()
1788 if (oh->class->reset) { in _reset()
1789 r = oh->class->reset(oh); in _reset()
1791 if (oh->rst_lines_cnt > 0) { in _reset()
1792 for (i = 0; i < oh->rst_lines_cnt; i++) in _reset()
1793 _assert_hardreset(oh, oh->rst_lines[i].name); in _reset()
1796 r = _ocp_softreset(oh); in _reset()
1802 _set_dmadisable(oh); in _reset()
1809 if (oh->class->sysc) { in _reset()
1810 _update_sysc_cache(oh); in _reset()
1811 _enable_sysc(oh); in _reset()
1826 static void _omap4_update_context_lost(struct omap_hwmod *oh) in _omap4_update_context_lost() argument
1828 if (oh->prcm.omap4.flags & HWMOD_OMAP4_NO_CONTEXT_LOSS_BIT) in _omap4_update_context_lost()
1831 if (!prm_was_any_context_lost_old(oh->clkdm->pwrdm.ptr->prcm_partition, in _omap4_update_context_lost()
1832 oh->clkdm->pwrdm.ptr->prcm_offs, in _omap4_update_context_lost()
1833 oh->prcm.omap4.context_offs)) in _omap4_update_context_lost()
1836 oh->prcm.omap4.context_lost_counter++; in _omap4_update_context_lost()
1837 prm_clear_context_loss_flags_old(oh->clkdm->pwrdm.ptr->prcm_partition, in _omap4_update_context_lost()
1838 oh->clkdm->pwrdm.ptr->prcm_offs, in _omap4_update_context_lost()
1839 oh->prcm.omap4.context_offs); in _omap4_update_context_lost()
1848 static int _omap4_get_context_lost(struct omap_hwmod *oh) in _omap4_get_context_lost() argument
1850 return oh->prcm.omap4.context_lost_counter; in _omap4_get_context_lost()
1862 static int _enable_preprogram(struct omap_hwmod *oh) in _enable_preprogram() argument
1864 if (!oh->class->enable_preprogram) in _enable_preprogram()
1867 return oh->class->enable_preprogram(oh); in _enable_preprogram()
1878 static int _enable(struct omap_hwmod *oh) in _enable() argument
1882 pr_debug("omap_hwmod: %s: enabling\n", oh->name); in _enable()
1888 if (oh->_int_flags & _HWMOD_SKIP_ENABLE) { in _enable()
1889 oh->_int_flags &= ~_HWMOD_SKIP_ENABLE; in _enable()
1893 if (oh->_state != _HWMOD_STATE_INITIALIZED && in _enable()
1894 oh->_state != _HWMOD_STATE_IDLE && in _enable()
1895 oh->_state != _HWMOD_STATE_DISABLED) { in _enable()
1897 oh->name); in _enable()
1910 if (_are_all_hardreset_lines_asserted(oh)) in _enable()
1913 _add_initiator_dep(oh, mpu_oh); in _enable()
1915 if (oh->clkdm) { in _enable()
1921 clkdm_deny_idle(oh->clkdm); in _enable()
1922 r = clkdm_hwmod_enable(oh->clkdm, oh); in _enable()
1925 oh->name, oh->clkdm->name, r); in _enable()
1930 _enable_clocks(oh); in _enable()
1932 soc_ops.enable_module(oh); in _enable()
1933 if (oh->flags & HWMOD_BLOCK_WFI) in _enable()
1937 soc_ops.update_context_lost(oh); in _enable()
1939 r = (soc_ops.wait_target_ready) ? soc_ops.wait_target_ready(oh) : in _enable()
1941 if (oh->clkdm && !(oh->flags & HWMOD_CLKDM_NOAUTO)) in _enable()
1942 clkdm_allow_idle(oh->clkdm); in _enable()
1945 oh->_state = _HWMOD_STATE_ENABLED; in _enable()
1948 if (oh->class->sysc) { in _enable()
1949 if (!(oh->_int_flags & _HWMOD_SYSCONFIG_LOADED)) in _enable()
1950 _update_sysc_cache(oh); in _enable()
1951 _enable_sysc(oh); in _enable()
1953 r = _enable_preprogram(oh); in _enable()
1956 soc_ops.disable_module(oh); in _enable()
1957 _disable_clocks(oh); in _enable()
1959 oh->name, r); in _enable()
1961 if (oh->clkdm) in _enable()
1962 clkdm_hwmod_disable(oh->clkdm, oh); in _enable()
1976 static int _idle(struct omap_hwmod *oh) in _idle() argument
1978 if (oh->flags & HWMOD_NO_IDLE) { in _idle()
1979 oh->_int_flags |= _HWMOD_SKIP_ENABLE; in _idle()
1983 pr_debug("omap_hwmod: %s: idling\n", oh->name); in _idle()
1985 if (_are_all_hardreset_lines_asserted(oh)) in _idle()
1988 if (oh->_state != _HWMOD_STATE_ENABLED) { in _idle()
1990 oh->name); in _idle()
1994 if (oh->class->sysc) in _idle()
1995 _idle_sysc(oh); in _idle()
1996 _del_initiator_dep(oh, mpu_oh); in _idle()
2003 if (oh->clkdm && !(oh->flags & HWMOD_CLKDM_NOAUTO)) in _idle()
2004 clkdm_deny_idle(oh->clkdm); in _idle()
2006 if (oh->flags & HWMOD_BLOCK_WFI) in _idle()
2009 soc_ops.disable_module(oh); in _idle()
2017 _disable_clocks(oh); in _idle()
2018 if (oh->clkdm) { in _idle()
2019 clkdm_allow_idle(oh->clkdm); in _idle()
2020 clkdm_hwmod_disable(oh->clkdm, oh); in _idle()
2023 oh->_state = _HWMOD_STATE_IDLE; in _idle()
2037 static int _shutdown(struct omap_hwmod *oh) in _shutdown() argument
2042 if (_are_all_hardreset_lines_asserted(oh)) in _shutdown()
2045 if (oh->_state != _HWMOD_STATE_IDLE && in _shutdown()
2046 oh->_state != _HWMOD_STATE_ENABLED) { in _shutdown()
2048 oh->name); in _shutdown()
2052 pr_debug("omap_hwmod: %s: disabling\n", oh->name); in _shutdown()
2054 if (oh->class->pre_shutdown) { in _shutdown()
2055 prev_state = oh->_state; in _shutdown()
2056 if (oh->_state == _HWMOD_STATE_IDLE) in _shutdown()
2057 _enable(oh); in _shutdown()
2058 ret = oh->class->pre_shutdown(oh); in _shutdown()
2061 _idle(oh); in _shutdown()
2066 if (oh->class->sysc) { in _shutdown()
2067 if (oh->_state == _HWMOD_STATE_IDLE) in _shutdown()
2068 _enable(oh); in _shutdown()
2069 _shutdown_sysc(oh); in _shutdown()
2073 if (oh->_state == _HWMOD_STATE_ENABLED) { in _shutdown()
2074 _del_initiator_dep(oh, mpu_oh); in _shutdown()
2076 if (oh->flags & HWMOD_BLOCK_WFI) in _shutdown()
2079 soc_ops.disable_module(oh); in _shutdown()
2080 _disable_clocks(oh); in _shutdown()
2081 if (oh->clkdm) in _shutdown()
2082 clkdm_hwmod_disable(oh->clkdm, oh); in _shutdown()
2086 for (i = 0; i < oh->rst_lines_cnt; i++) in _shutdown()
2087 _assert_hardreset(oh, oh->rst_lines[i].name); in _shutdown()
2089 oh->_state = _HWMOD_STATE_DISABLED; in _shutdown()
2095 struct omap_hwmod *oh) in of_dev_find_hwmod() argument
2109 if (!strcmp(p, oh->name)) { in of_dev_find_hwmod()
2111 np->name, i, oh->name); in of_dev_find_hwmod()
2131 struct omap_hwmod *oh, in of_dev_hwmod_lookup() argument
2138 res = of_dev_find_hwmod(np, oh); in of_dev_hwmod_lookup()
2149 res = of_dev_hwmod_lookup(np0, oh, &i, &fc); in of_dev_hwmod_lookup()
2177 static void omap_hwmod_fix_mpu_rt_idx(struct omap_hwmod *oh, in omap_hwmod_fix_mpu_rt_idx() argument
2188 error = of_address_to_resource(child, oh->mpu_rt_idx, res); in omap_hwmod_fix_mpu_rt_idx()
2205 int omap_hwmod_parse_module_range(struct omap_hwmod *oh, in omap_hwmod_parse_module_range() argument
2245 oh->name, np->name); in omap_hwmod_parse_module_range()
2254 oh ? oh->name : "", np->name, base, size); in omap_hwmod_parse_module_range()
2256 if (oh && oh->mpu_rt_idx) { in omap_hwmod_parse_module_range()
2257 omap_hwmod_fix_mpu_rt_idx(oh, np, res); in omap_hwmod_parse_module_range()
2286 static int __init _init_mpu_rt_base(struct omap_hwmod *oh, void *data, in _init_mpu_rt_base() argument
2293 if (!oh) in _init_mpu_rt_base()
2296 _save_mpu_port_index(oh); in _init_mpu_rt_base()
2299 if (!oh->class->sysc) in _init_mpu_rt_base()
2303 if (oh->_int_flags & _HWMOD_NO_MPU_PORT) in _init_mpu_rt_base()
2307 pr_err("omap_hwmod: %s: no dt node\n", oh->name); in _init_mpu_rt_base()
2312 error = omap_hwmod_parse_module_range(oh, np, &res); in _init_mpu_rt_base()
2318 va_start = of_iomap(np, index + oh->mpu_rt_idx); in _init_mpu_rt_base()
2321 oh->name, index, np); in _init_mpu_rt_base()
2326 oh->name, va_start); in _init_mpu_rt_base()
2328 oh->_mpu_rt_va = va_start; in _init_mpu_rt_base()
2345 static int __init _init(struct omap_hwmod *oh, void *data) in _init() argument
2351 if (oh->_state != _HWMOD_STATE_REGISTERED) in _init()
2358 r = of_dev_hwmod_lookup(bus, oh, &index, &np); in _init()
2360 pr_debug("omap_hwmod: %s missing dt data\n", oh->name); in _init()
2363 oh->name, np->name); in _init()
2365 r = _init_mpu_rt_base(oh, NULL, index, np); in _init()
2368 oh->name); in _init()
2372 r = _init_clocks(oh, np); in _init()
2374 WARN(1, "omap_hwmod: %s: couldn't init clocks\n", oh->name); in _init()
2380 oh->flags |= HWMOD_INIT_NO_RESET; in _init()
2382 oh->flags |= HWMOD_INIT_NO_IDLE; in _init()
2384 oh->flags |= HWMOD_NO_IDLE; in _init()
2387 oh->_state = _HWMOD_STATE_INITIALIZED; in _init()
2400 static void __init _setup_iclk_autoidle(struct omap_hwmod *oh) in _setup_iclk_autoidle() argument
2404 if (oh->_state != _HWMOD_STATE_INITIALIZED) in _setup_iclk_autoidle()
2407 list_for_each_entry(os, &oh->slave_ports, node) { in _setup_iclk_autoidle()
2431 static int __init _setup_reset(struct omap_hwmod *oh) in _setup_reset() argument
2435 if (oh->_state != _HWMOD_STATE_INITIALIZED) in _setup_reset()
2438 if (oh->flags & HWMOD_EXT_OPT_MAIN_CLK) in _setup_reset()
2441 if (oh->rst_lines_cnt == 0) { in _setup_reset()
2442 r = _enable(oh); in _setup_reset()
2445 oh->name, oh->_state); in _setup_reset()
2450 if (!(oh->flags & HWMOD_INIT_NO_RESET)) in _setup_reset()
2451 r = _reset(oh); in _setup_reset()
2492 static void __init _setup_postsetup(struct omap_hwmod *oh) in _setup_postsetup() argument
2496 if (oh->rst_lines_cnt > 0) in _setup_postsetup()
2499 postsetup_state = oh->_postsetup_state; in _setup_postsetup()
2507 if ((oh->flags & (HWMOD_INIT_NO_IDLE | HWMOD_NO_IDLE)) && in _setup_postsetup()
2509 oh->_int_flags |= _HWMOD_SKIP_ENABLE; in _setup_postsetup()
2514 _idle(oh); in _setup_postsetup()
2516 _shutdown(oh); in _setup_postsetup()
2519 oh->name, postsetup_state); in _setup_postsetup()
2540 static int _setup(struct omap_hwmod *oh, void *data) in _setup() argument
2542 if (oh->_state != _HWMOD_STATE_INITIALIZED) in _setup()
2545 if (oh->parent_hwmod) { in _setup()
2548 r = _enable(oh->parent_hwmod); in _setup()
2550 oh->name, oh->parent_hwmod->name); in _setup()
2553 _setup_iclk_autoidle(oh); in _setup()
2555 if (!_setup_reset(oh)) in _setup()
2556 _setup_postsetup(oh); in _setup()
2558 if (oh->parent_hwmod) { in _setup()
2561 postsetup_state = oh->parent_hwmod->_postsetup_state; in _setup()
2564 _idle(oh->parent_hwmod); in _setup()
2566 _shutdown(oh->parent_hwmod); in _setup()
2569 oh->parent_hwmod->name, postsetup_state); in _setup()
2592 static int __init _register(struct omap_hwmod *oh) in _register() argument
2594 if (!oh || !oh->name || !oh->class || !oh->class->name || in _register()
2595 (oh->_state != _HWMOD_STATE_UNKNOWN)) in _register()
2598 pr_debug("omap_hwmod: %s: registering\n", oh->name); in _register()
2600 if (_lookup(oh->name)) in _register()
2603 list_add_tail(&oh->node, &omap_hwmod_list); in _register()
2605 INIT_LIST_HEAD(&oh->slave_ports); in _register()
2606 spin_lock_init(&oh->_lock); in _register()
2607 lockdep_set_class(&oh->_lock, &oh->hwmod_key); in _register()
2609 oh->_state = _HWMOD_STATE_REGISTERED; in _register()
2615 if (!strcmp(oh->name, MPU_INITIATOR_NAME)) in _register()
2616 mpu_oh = oh; in _register()
2694 static int _omap2xxx_3xxx_wait_target_ready(struct omap_hwmod *oh) in _omap2xxx_3xxx_wait_target_ready() argument
2696 if (!oh) in _omap2xxx_3xxx_wait_target_ready()
2699 if (oh->flags & HWMOD_NO_IDLEST) in _omap2xxx_3xxx_wait_target_ready()
2702 if (!_find_mpu_rt_port(oh)) in _omap2xxx_3xxx_wait_target_ready()
2707 return omap_cm_wait_module_ready(0, oh->prcm.omap2.module_offs, in _omap2xxx_3xxx_wait_target_ready()
2708 oh->prcm.omap2.idlest_reg_id, in _omap2xxx_3xxx_wait_target_ready()
2709 oh->prcm.omap2.idlest_idle_bit); in _omap2xxx_3xxx_wait_target_ready()
2721 static int _omap4_wait_target_ready(struct omap_hwmod *oh) in _omap4_wait_target_ready() argument
2723 if (!oh) in _omap4_wait_target_ready()
2726 if (oh->flags & HWMOD_NO_IDLEST || !oh->clkdm) in _omap4_wait_target_ready()
2729 if (!_find_mpu_rt_port(oh)) in _omap4_wait_target_ready()
2732 if (_omap4_clkctrl_managed_by_clkfwk(oh)) in _omap4_wait_target_ready()
2735 if (!_omap4_has_clkctrl_clock(oh)) in _omap4_wait_target_ready()
2740 return omap_cm_wait_module_ready(oh->clkdm->prcm_partition, in _omap4_wait_target_ready()
2741 oh->clkdm->cm_inst, in _omap4_wait_target_ready()
2742 oh->prcm.omap4.clkctrl_offs, 0); in _omap4_wait_target_ready()
2756 static int _omap2_assert_hardreset(struct omap_hwmod *oh, in _omap2_assert_hardreset() argument
2760 oh->prcm.omap2.module_offs, 0); in _omap2_assert_hardreset()
2774 static int _omap2_deassert_hardreset(struct omap_hwmod *oh, in _omap2_deassert_hardreset() argument
2778 oh->prcm.omap2.module_offs, 0, 0); in _omap2_deassert_hardreset()
2793 static int _omap2_is_hardreset_asserted(struct omap_hwmod *oh, in _omap2_is_hardreset_asserted() argument
2797 oh->prcm.omap2.module_offs, 0); in _omap2_is_hardreset_asserted()
2812 static int _omap4_assert_hardreset(struct omap_hwmod *oh, in _omap4_assert_hardreset() argument
2815 if (!oh->clkdm) in _omap4_assert_hardreset()
2819 oh->clkdm->pwrdm.ptr->prcm_partition, in _omap4_assert_hardreset()
2820 oh->clkdm->pwrdm.ptr->prcm_offs, in _omap4_assert_hardreset()
2821 oh->prcm.omap4.rstctrl_offs); in _omap4_assert_hardreset()
2836 static int _omap4_deassert_hardreset(struct omap_hwmod *oh, in _omap4_deassert_hardreset() argument
2839 if (!oh->clkdm) in _omap4_deassert_hardreset()
2844 oh->name, ohri->name); in _omap4_deassert_hardreset()
2846 oh->clkdm->pwrdm.ptr->prcm_partition, in _omap4_deassert_hardreset()
2847 oh->clkdm->pwrdm.ptr->prcm_offs, in _omap4_deassert_hardreset()
2848 oh->prcm.omap4.rstctrl_offs, in _omap4_deassert_hardreset()
2849 oh->prcm.omap4.rstctrl_offs + in _omap4_deassert_hardreset()
2865 static int _omap4_is_hardreset_asserted(struct omap_hwmod *oh, in _omap4_is_hardreset_asserted() argument
2868 if (!oh->clkdm) in _omap4_is_hardreset_asserted()
2872 oh->clkdm->pwrdm.ptr-> in _omap4_is_hardreset_asserted()
2874 oh->clkdm->pwrdm.ptr->prcm_offs, in _omap4_is_hardreset_asserted()
2875 oh->prcm.omap4.rstctrl_offs); in _omap4_is_hardreset_asserted()
2886 static int _omap4_disable_direct_prcm(struct omap_hwmod *oh) in _omap4_disable_direct_prcm() argument
2888 if (!oh) in _omap4_disable_direct_prcm()
2891 oh->prcm.omap4.flags |= HWMOD_OMAP4_CLKFWK_CLKCTR_CLOCK; in _omap4_disable_direct_prcm()
2908 static int _am33xx_deassert_hardreset(struct omap_hwmod *oh, in _am33xx_deassert_hardreset() argument
2912 oh->clkdm->pwrdm.ptr->prcm_partition, in _am33xx_deassert_hardreset()
2913 oh->clkdm->pwrdm.ptr->prcm_offs, in _am33xx_deassert_hardreset()
2914 oh->prcm.omap4.rstctrl_offs, in _am33xx_deassert_hardreset()
2915 oh->prcm.omap4.rstst_offs); in _am33xx_deassert_hardreset()
2920 u32 omap_hwmod_read(struct omap_hwmod *oh, u16 reg_offs) in omap_hwmod_read() argument
2922 if (oh->flags & HWMOD_16BIT_REG) in omap_hwmod_read()
2923 return readw_relaxed(oh->_mpu_rt_va + reg_offs); in omap_hwmod_read()
2925 return readl_relaxed(oh->_mpu_rt_va + reg_offs); in omap_hwmod_read()
2928 void omap_hwmod_write(u32 v, struct omap_hwmod *oh, u16 reg_offs) in omap_hwmod_write() argument
2930 if (oh->flags & HWMOD_16BIT_REG) in omap_hwmod_write()
2931 writew_relaxed(v, oh->_mpu_rt_va + reg_offs); in omap_hwmod_write()
2933 writel_relaxed(v, oh->_mpu_rt_va + reg_offs); in omap_hwmod_write()
2945 int omap_hwmod_softreset(struct omap_hwmod *oh) in omap_hwmod_softreset() argument
2950 if (!oh || !(oh->_sysc_cache)) in omap_hwmod_softreset()
2953 v = oh->_sysc_cache; in omap_hwmod_softreset()
2954 ret = _set_softreset(oh, &v); in omap_hwmod_softreset()
2957 _write_sysconfig(v, oh); in omap_hwmod_softreset()
2959 ret = _clear_softreset(oh, &v); in omap_hwmod_softreset()
2962 _write_sysconfig(v, oh); in omap_hwmod_softreset()
2977 struct omap_hwmod *oh; in omap_hwmod_lookup() local
2982 oh = _lookup(name); in omap_hwmod_lookup()
2984 return oh; in omap_hwmod_lookup()
2999 int omap_hwmod_for_each(int (*fn)(struct omap_hwmod *oh, void *data), in omap_hwmod_for_each() argument
3062 static void __init _ensure_mpu_hwmod_is_setup(struct omap_hwmod *oh) in _ensure_mpu_hwmod_is_setup() argument
3067 else if (mpu_oh->_state == _HWMOD_STATE_REGISTERED && oh != mpu_oh) in _ensure_mpu_hwmod_is_setup()
3084 struct omap_hwmod *oh; in omap_hwmod_setup_one() local
3088 oh = _lookup(oh_name); in omap_hwmod_setup_one()
3089 if (!oh) { in omap_hwmod_setup_one()
3094 _ensure_mpu_hwmod_is_setup(oh); in omap_hwmod_setup_one()
3096 _init(oh, NULL); in omap_hwmod_setup_one()
3097 _setup(oh, NULL); in omap_hwmod_setup_one()
3349 struct omap_hwmod *oh, in omap_hwmod_check_module() argument
3356 if (!oh->class->sysc) in omap_hwmod_check_module()
3359 if (sysc_fields != oh->class->sysc->sysc_fields) in omap_hwmod_check_module()
3361 oh->class->sysc->sysc_fields); in omap_hwmod_check_module()
3363 if (rev_offs != oh->class->sysc->rev_offs) in omap_hwmod_check_module()
3365 oh->class->sysc->rev_offs); in omap_hwmod_check_module()
3366 if (sysc_offs != oh->class->sysc->sysc_offs) in omap_hwmod_check_module()
3368 oh->class->sysc->sysc_offs); in omap_hwmod_check_module()
3369 if (syss_offs != oh->class->sysc->syss_offs) in omap_hwmod_check_module()
3371 oh->class->sysc->syss_offs); in omap_hwmod_check_module()
3373 if (sysc_flags != oh->class->sysc->sysc_flags) in omap_hwmod_check_module()
3375 oh->class->sysc->sysc_flags); in omap_hwmod_check_module()
3377 if (idlemodes != oh->class->sysc->idlemodes) in omap_hwmod_check_module()
3379 oh->class->sysc->idlemodes); in omap_hwmod_check_module()
3381 if (data->cfg->srst_udelay != oh->class->sysc->srst_udelay) in omap_hwmod_check_module()
3384 oh->class->sysc->srst_udelay); in omap_hwmod_check_module()
3402 int omap_hwmod_allocate_module(struct device *dev, struct omap_hwmod *oh, in omap_hwmod_allocate_module() argument
3425 if (!oh->_mpu_rt_va) { in omap_hwmod_allocate_module()
3436 class = kmemdup(oh->class, sizeof(*oh->class), GFP_KERNEL); in omap_hwmod_allocate_module()
3442 spin_lock_irqsave(&oh->_lock, flags); in omap_hwmod_allocate_module()
3444 oh->_mpu_rt_va = regs; in omap_hwmod_allocate_module()
3445 oh->class = class; in omap_hwmod_allocate_module()
3446 oh->_state = _HWMOD_STATE_INITIALIZED; in omap_hwmod_allocate_module()
3447 _setup(oh, NULL); in omap_hwmod_allocate_module()
3448 spin_unlock_irqrestore(&oh->_lock, flags); in omap_hwmod_allocate_module()
3463 struct omap_hwmod *oh; in omap_hwmod_init_module() local
3472 oh = _lookup(data->name); in omap_hwmod_init_module()
3473 if (!oh) in omap_hwmod_init_module()
3476 cookie->data = oh; in omap_hwmod_init_module()
3496 oh->flags |= HWMOD_INIT_NO_IDLE; in omap_hwmod_init_module()
3498 oh->flags |= HWMOD_INIT_NO_RESET; in omap_hwmod_init_module()
3500 error = omap_hwmod_check_module(dev, oh, data, sysc_fields, in omap_hwmod_init_module()
3506 return omap_hwmod_allocate_module(dev, oh, data, sysc_fields, in omap_hwmod_init_module()
3522 struct omap_hwmod *oh; in omap_hwmod_setup_earlycon_flags() local
3532 oh = omap_hwmod_lookup(uart); in omap_hwmod_setup_earlycon_flags()
3533 if (!oh) { in omap_hwmod_setup_earlycon_flags()
3537 oh = omap_hwmod_lookup(uart); in omap_hwmod_setup_earlycon_flags()
3539 if (oh) in omap_hwmod_setup_earlycon_flags()
3540 oh->flags |= DEBUG_OMAPUART_FLAGS; in omap_hwmod_setup_earlycon_flags()
3576 int omap_hwmod_enable(struct omap_hwmod *oh) in omap_hwmod_enable() argument
3581 if (!oh) in omap_hwmod_enable()
3584 spin_lock_irqsave(&oh->_lock, flags); in omap_hwmod_enable()
3585 r = _enable(oh); in omap_hwmod_enable()
3586 spin_unlock_irqrestore(&oh->_lock, flags); in omap_hwmod_enable()
3598 int omap_hwmod_idle(struct omap_hwmod *oh) in omap_hwmod_idle() argument
3603 if (!oh) in omap_hwmod_idle()
3606 spin_lock_irqsave(&oh->_lock, flags); in omap_hwmod_idle()
3607 r = _idle(oh); in omap_hwmod_idle()
3608 spin_unlock_irqrestore(&oh->_lock, flags); in omap_hwmod_idle()
3621 int omap_hwmod_shutdown(struct omap_hwmod *oh) in omap_hwmod_shutdown() argument
3626 if (!oh) in omap_hwmod_shutdown()
3629 spin_lock_irqsave(&oh->_lock, flags); in omap_hwmod_shutdown()
3630 r = _shutdown(oh); in omap_hwmod_shutdown()
3631 spin_unlock_irqrestore(&oh->_lock, flags); in omap_hwmod_shutdown()
3651 struct powerdomain *omap_hwmod_get_pwrdm(struct omap_hwmod *oh) in omap_hwmod_get_pwrdm() argument
3658 if (!oh) in omap_hwmod_get_pwrdm()
3661 if (oh->clkdm) in omap_hwmod_get_pwrdm()
3662 return oh->clkdm->pwrdm.ptr; in omap_hwmod_get_pwrdm()
3664 if (oh->_clk) { in omap_hwmod_get_pwrdm()
3665 c = oh->_clk; in omap_hwmod_get_pwrdm()
3667 oi = _find_mpu_rt_port(oh); in omap_hwmod_get_pwrdm()
3690 void __iomem *omap_hwmod_get_mpu_rt_va(struct omap_hwmod *oh) in omap_hwmod_get_mpu_rt_va() argument
3692 if (!oh) in omap_hwmod_get_mpu_rt_va()
3695 if (oh->_int_flags & _HWMOD_NO_MPU_PORT) in omap_hwmod_get_mpu_rt_va()
3698 if (oh->_state == _HWMOD_STATE_UNKNOWN) in omap_hwmod_get_mpu_rt_va()
3701 return oh->_mpu_rt_va; in omap_hwmod_get_mpu_rt_va()
3722 int omap_hwmod_enable_wakeup(struct omap_hwmod *oh) in omap_hwmod_enable_wakeup() argument
3727 spin_lock_irqsave(&oh->_lock, flags); in omap_hwmod_enable_wakeup()
3729 if (oh->class->sysc && in omap_hwmod_enable_wakeup()
3730 (oh->class->sysc->sysc_flags & SYSC_HAS_ENAWAKEUP)) { in omap_hwmod_enable_wakeup()
3731 v = oh->_sysc_cache; in omap_hwmod_enable_wakeup()
3732 _enable_wakeup(oh, &v); in omap_hwmod_enable_wakeup()
3733 _write_sysconfig(v, oh); in omap_hwmod_enable_wakeup()
3736 spin_unlock_irqrestore(&oh->_lock, flags); in omap_hwmod_enable_wakeup()
3754 int omap_hwmod_disable_wakeup(struct omap_hwmod *oh) in omap_hwmod_disable_wakeup() argument
3759 spin_lock_irqsave(&oh->_lock, flags); in omap_hwmod_disable_wakeup()
3761 if (oh->class->sysc && in omap_hwmod_disable_wakeup()
3762 (oh->class->sysc->sysc_flags & SYSC_HAS_ENAWAKEUP)) { in omap_hwmod_disable_wakeup()
3763 v = oh->_sysc_cache; in omap_hwmod_disable_wakeup()
3764 _disable_wakeup(oh, &v); in omap_hwmod_disable_wakeup()
3765 _write_sysconfig(v, oh); in omap_hwmod_disable_wakeup()
3768 spin_unlock_irqrestore(&oh->_lock, flags); in omap_hwmod_disable_wakeup()
3785 int omap_hwmod_assert_hardreset(struct omap_hwmod *oh, const char *name) in omap_hwmod_assert_hardreset() argument
3790 if (!oh) in omap_hwmod_assert_hardreset()
3793 spin_lock_irqsave(&oh->_lock, flags); in omap_hwmod_assert_hardreset()
3794 ret = _assert_hardreset(oh, name); in omap_hwmod_assert_hardreset()
3795 spin_unlock_irqrestore(&oh->_lock, flags); in omap_hwmod_assert_hardreset()
3812 int omap_hwmod_deassert_hardreset(struct omap_hwmod *oh, const char *name) in omap_hwmod_deassert_hardreset() argument
3817 if (!oh) in omap_hwmod_deassert_hardreset()
3820 spin_lock_irqsave(&oh->_lock, flags); in omap_hwmod_deassert_hardreset()
3821 ret = _deassert_hardreset(oh, name); in omap_hwmod_deassert_hardreset()
3822 spin_unlock_irqrestore(&oh->_lock, flags); in omap_hwmod_deassert_hardreset()
3840 int (*fn)(struct omap_hwmod *oh, in omap_hwmod_for_each_by_class() argument
3881 int omap_hwmod_set_postsetup_state(struct omap_hwmod *oh, u8 state) in omap_hwmod_set_postsetup_state() argument
3886 if (!oh) in omap_hwmod_set_postsetup_state()
3894 spin_lock_irqsave(&oh->_lock, flags); in omap_hwmod_set_postsetup_state()
3896 if (oh->_state != _HWMOD_STATE_REGISTERED) { in omap_hwmod_set_postsetup_state()
3901 oh->_postsetup_state = state; in omap_hwmod_set_postsetup_state()
3905 spin_unlock_irqrestore(&oh->_lock, flags); in omap_hwmod_set_postsetup_state()
3921 int omap_hwmod_get_context_loss_count(struct omap_hwmod *oh) in omap_hwmod_get_context_loss_count() argument
3927 return soc_ops.get_context_lost(oh); in omap_hwmod_get_context_loss_count()
3929 pwrdm = omap_hwmod_get_pwrdm(oh); in omap_hwmod_get_context_loss_count()
3995 const char *omap_hwmod_get_main_clk(struct omap_hwmod *oh) in omap_hwmod_get_main_clk() argument
3997 if (!oh) in omap_hwmod_get_main_clk()
4000 return oh->main_clk; in omap_hwmod_get_main_clk()