Lines Matching refs:oh
218 int (*reset)(struct omap_hwmod *oh);
231 void (*enable_module)(struct omap_hwmod *oh);
232 int (*disable_module)(struct omap_hwmod *oh);
233 int (*wait_target_ready)(struct omap_hwmod *oh);
234 int (*assert_hardreset)(struct omap_hwmod *oh,
236 int (*deassert_hardreset)(struct omap_hwmod *oh,
238 int (*is_hardreset_asserted)(struct omap_hwmod *oh,
240 int (*init_clkdm)(struct omap_hwmod *oh);
241 void (*update_context_lost)(struct omap_hwmod *oh);
242 int (*get_context_lost)(struct omap_hwmod *oh);
243 int (*disable_direct_prcm)(struct omap_hwmod *oh);
244 u32 (*xlate_clkctrl)(struct omap_hwmod *oh);
270 static int _update_sysc_cache(struct omap_hwmod *oh) in _update_sysc_cache() argument
272 if (!oh->class->sysc) { in _update_sysc_cache()
273 WARN(1, "omap_hwmod: %s: cannot read OCP_SYSCONFIG: not defined on hwmod's class\n", oh->name); in _update_sysc_cache()
279 oh->_sysc_cache = omap_hwmod_read(oh, oh->class->sysc->sysc_offs); in _update_sysc_cache()
281 if (!(oh->class->sysc->sysc_flags & SYSC_NO_CACHE)) in _update_sysc_cache()
282 oh->_int_flags |= _HWMOD_SYSCONFIG_LOADED; in _update_sysc_cache()
295 static void _write_sysconfig(u32 v, struct omap_hwmod *oh) in _write_sysconfig() argument
297 if (!oh->class->sysc) { in _write_sysconfig()
298 WARN(1, "omap_hwmod: %s: cannot write OCP_SYSCONFIG: not defined on hwmod's class\n", oh->name); in _write_sysconfig()
305 oh->_sysc_cache = v; in _write_sysconfig()
313 if (oh->class->unlock) in _write_sysconfig()
314 oh->class->unlock(oh); in _write_sysconfig()
316 omap_hwmod_write(v, oh, oh->class->sysc->sysc_offs); in _write_sysconfig()
318 if (oh->class->lock) in _write_sysconfig()
319 oh->class->lock(oh); in _write_sysconfig()
332 static int _set_master_standbymode(struct omap_hwmod *oh, u8 standbymode, in _set_master_standbymode() argument
338 if (!oh->class->sysc || in _set_master_standbymode()
339 !(oh->class->sysc->sysc_flags & SYSC_HAS_MIDLEMODE)) in _set_master_standbymode()
342 if (!oh->class->sysc->sysc_fields) { in _set_master_standbymode()
343 WARN(1, "omap_hwmod: %s: offset struct for sysconfig not provided in class\n", oh->name); in _set_master_standbymode()
347 mstandby_shift = oh->class->sysc->sysc_fields->midle_shift; in _set_master_standbymode()
366 static int _set_slave_idlemode(struct omap_hwmod *oh, u8 idlemode, u32 *v) in _set_slave_idlemode() argument
371 if (!oh->class->sysc || in _set_slave_idlemode()
372 !(oh->class->sysc->sysc_flags & SYSC_HAS_SIDLEMODE)) in _set_slave_idlemode()
375 if (!oh->class->sysc->sysc_fields) { in _set_slave_idlemode()
376 WARN(1, "omap_hwmod: %s: offset struct for sysconfig not provided in class\n", oh->name); in _set_slave_idlemode()
380 sidle_shift = oh->class->sysc->sysc_fields->sidle_shift; in _set_slave_idlemode()
400 static int _set_clockactivity(struct omap_hwmod *oh, u8 clockact, u32 *v) in _set_clockactivity() argument
405 if (!oh->class->sysc || in _set_clockactivity()
406 !(oh->class->sysc->sysc_flags & SYSC_HAS_CLOCKACTIVITY)) in _set_clockactivity()
409 if (!oh->class->sysc->sysc_fields) { in _set_clockactivity()
410 WARN(1, "omap_hwmod: %s: offset struct for sysconfig not provided in class\n", oh->name); in _set_clockactivity()
414 clkact_shift = oh->class->sysc->sysc_fields->clkact_shift; in _set_clockactivity()
431 static int _set_softreset(struct omap_hwmod *oh, u32 *v) in _set_softreset() argument
435 if (!oh->class->sysc || in _set_softreset()
436 !(oh->class->sysc->sysc_flags & SYSC_HAS_SOFTRESET)) in _set_softreset()
439 if (!oh->class->sysc->sysc_fields) { in _set_softreset()
440 WARN(1, "omap_hwmod: %s: offset struct for sysconfig not provided in class\n", oh->name); in _set_softreset()
444 softrst_mask = (0x1 << oh->class->sysc->sysc_fields->srst_shift); in _set_softreset()
459 static int _clear_softreset(struct omap_hwmod *oh, u32 *v) in _clear_softreset() argument
463 if (!oh->class->sysc || in _clear_softreset()
464 !(oh->class->sysc->sysc_flags & SYSC_HAS_SOFTRESET)) in _clear_softreset()
467 if (!oh->class->sysc->sysc_fields) { in _clear_softreset()
470 oh->name); in _clear_softreset()
474 softrst_mask = (0x1 << oh->class->sysc->sysc_fields->srst_shift); in _clear_softreset()
491 static int _wait_softreset_complete(struct omap_hwmod *oh) in _wait_softreset_complete() argument
497 sysc = oh->class->sysc; in _wait_softreset_complete()
500 omap_test_timeout((omap_hwmod_read(oh, sysc->syss_offs) in _wait_softreset_complete()
505 omap_test_timeout(!(omap_hwmod_read(oh, sysc->sysc_offs) in _wait_softreset_complete()
525 static int _set_dmadisable(struct omap_hwmod *oh) in _set_dmadisable() argument
530 if (!oh->class->sysc || in _set_dmadisable()
531 !(oh->class->sysc->sysc_flags & SYSC_HAS_DMADISABLE)) in _set_dmadisable()
534 if (!oh->class->sysc->sysc_fields) { in _set_dmadisable()
535 WARN(1, "omap_hwmod: %s: offset struct for sysconfig not provided in class\n", oh->name); in _set_dmadisable()
540 if (oh->_state != _HWMOD_STATE_ENABLED) { in _set_dmadisable()
541 pr_warn("omap_hwmod: %s: dma can be disabled only from enabled state\n", oh->name); in _set_dmadisable()
545 pr_debug("omap_hwmod: %s: setting DMADISABLE\n", oh->name); in _set_dmadisable()
547 v = oh->_sysc_cache; in _set_dmadisable()
549 (0x1 << oh->class->sysc->sysc_fields->dmadisable_shift); in _set_dmadisable()
551 _write_sysconfig(v, oh); in _set_dmadisable()
569 static int _set_module_autoidle(struct omap_hwmod *oh, u8 autoidle, in _set_module_autoidle() argument
575 if (!oh->class->sysc || in _set_module_autoidle()
576 !(oh->class->sysc->sysc_flags & SYSC_HAS_AUTOIDLE)) in _set_module_autoidle()
579 if (!oh->class->sysc->sysc_fields) { in _set_module_autoidle()
580 WARN(1, "omap_hwmod: %s: offset struct for sysconfig not provided in class\n", oh->name); in _set_module_autoidle()
584 autoidle_shift = oh->class->sysc->sysc_fields->autoidle_shift; in _set_module_autoidle()
600 static int _enable_wakeup(struct omap_hwmod *oh, u32 *v) in _enable_wakeup() argument
602 if (!oh->class->sysc || in _enable_wakeup()
603 !((oh->class->sysc->sysc_flags & SYSC_HAS_ENAWAKEUP) || in _enable_wakeup()
604 (oh->class->sysc->idlemodes & SIDLE_SMART_WKUP) || in _enable_wakeup()
605 (oh->class->sysc->idlemodes & MSTANDBY_SMART_WKUP))) in _enable_wakeup()
608 if (!oh->class->sysc->sysc_fields) { in _enable_wakeup()
609 WARN(1, "omap_hwmod: %s: offset struct for sysconfig not provided in class\n", oh->name); in _enable_wakeup()
613 if (oh->class->sysc->sysc_flags & SYSC_HAS_ENAWAKEUP) in _enable_wakeup()
614 *v |= 0x1 << oh->class->sysc->sysc_fields->enwkup_shift; in _enable_wakeup()
616 if (oh->class->sysc->idlemodes & SIDLE_SMART_WKUP) in _enable_wakeup()
617 _set_slave_idlemode(oh, HWMOD_IDLEMODE_SMART_WKUP, v); in _enable_wakeup()
618 if (oh->class->sysc->idlemodes & MSTANDBY_SMART_WKUP) in _enable_wakeup()
619 _set_master_standbymode(oh, HWMOD_IDLEMODE_SMART_WKUP, v); in _enable_wakeup()
626 static struct clockdomain *_get_clkdm(struct omap_hwmod *oh) in _get_clkdm() argument
630 if (!oh) in _get_clkdm()
633 if (oh->clkdm) { in _get_clkdm()
634 return oh->clkdm; in _get_clkdm()
635 } else if (oh->_clk) { in _get_clkdm()
636 if (!omap2_clk_is_hw_omap(__clk_get_hw(oh->_clk))) in _get_clkdm()
638 clk = to_clk_hw_omap(__clk_get_hw(oh->_clk)); in _get_clkdm()
657 static int _add_initiator_dep(struct omap_hwmod *oh, struct omap_hwmod *init_oh) in _add_initiator_dep() argument
661 clkdm = _get_clkdm(oh); in _add_initiator_dep()
686 static int _del_initiator_dep(struct omap_hwmod *oh, struct omap_hwmod *init_oh) in _del_initiator_dep() argument
690 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()
805 __func__, oh->name, clk, in _lookup_clkctrl_clk()
824 static int _init_main_clk(struct omap_hwmod *oh) in _init_main_clk() argument
829 clk = _lookup_clkctrl_clk(oh); in _init_main_clk()
833 __clk_get_name(clk), oh->name); in _init_main_clk()
834 oh->main_clk = __clk_get_name(clk); in _init_main_clk()
835 oh->_clk = clk; in _init_main_clk()
836 soc_ops.disable_direct_prcm(oh); in _init_main_clk()
838 if (!oh->main_clk) in _init_main_clk()
841 oh->_clk = clk_get(NULL, oh->main_clk); in _init_main_clk()
844 if (IS_ERR(oh->_clk)) { in _init_main_clk()
846 oh->name, oh->main_clk); in _init_main_clk()
857 clk_prepare(oh->_clk); in _init_main_clk()
859 if (!_get_clkdm(oh)) in _init_main_clk()
861 oh->name, oh->main_clk); in _init_main_clk()
873 static int _init_interface_clks(struct omap_hwmod *oh) in _init_interface_clks() argument
879 list_for_each_entry(os, &oh->slave_ports, node) { in _init_interface_clks()
886 oh->name, os->clk); in _init_interface_clks()
912 static int _init_opt_clks(struct omap_hwmod *oh) in _init_opt_clks() argument
919 for (i = oh->opt_clks_cnt, oc = oh->opt_clks; i > 0; i--, oc++) { in _init_opt_clks()
923 oh->name, oc->clk); in _init_opt_clks()
942 static void _enable_optional_clocks(struct omap_hwmod *oh) in _enable_optional_clocks() argument
947 pr_debug("omap_hwmod: %s: enabling optional clocks\n", oh->name); in _enable_optional_clocks()
949 for (i = oh->opt_clks_cnt, oc = oh->opt_clks; i > 0; i--, oc++) in _enable_optional_clocks()
957 static void _disable_optional_clocks(struct omap_hwmod *oh) in _disable_optional_clocks() argument
962 pr_debug("omap_hwmod: %s: disabling optional clocks\n", oh->name); in _disable_optional_clocks()
964 for (i = oh->opt_clks_cnt, oc = oh->opt_clks; i > 0; i--, oc++) in _disable_optional_clocks()
979 static int _enable_clocks(struct omap_hwmod *oh) in _enable_clocks() argument
983 pr_debug("omap_hwmod: %s: enabling clocks\n", oh->name); in _enable_clocks()
985 if (oh->flags & HWMOD_OPT_CLKS_NEEDED) in _enable_clocks()
986 _enable_optional_clocks(oh); in _enable_clocks()
988 if (oh->_clk) in _enable_clocks()
989 clk_enable(oh->_clk); in _enable_clocks()
991 list_for_each_entry(os, &oh->slave_ports, node) { in _enable_clocks()
1007 static bool _omap4_clkctrl_managed_by_clkfwk(struct omap_hwmod *oh) in _omap4_clkctrl_managed_by_clkfwk() argument
1009 if (oh->prcm.omap4.flags & HWMOD_OMAP4_CLKFWK_CLKCTR_CLOCK) in _omap4_clkctrl_managed_by_clkfwk()
1019 static bool _omap4_has_clkctrl_clock(struct omap_hwmod *oh) in _omap4_has_clkctrl_clock() argument
1021 if (oh->prcm.omap4.clkctrl_offs) in _omap4_has_clkctrl_clock()
1024 if (!oh->prcm.omap4.clkctrl_offs && in _omap4_has_clkctrl_clock()
1025 oh->prcm.omap4.flags & HWMOD_OMAP4_ZERO_CLKCTRL_OFFSET) in _omap4_has_clkctrl_clock()
1037 static int _disable_clocks(struct omap_hwmod *oh) in _disable_clocks() argument
1041 pr_debug("omap_hwmod: %s: disabling clocks\n", oh->name); in _disable_clocks()
1043 if (oh->_clk) in _disable_clocks()
1044 clk_disable(oh->_clk); in _disable_clocks()
1046 list_for_each_entry(os, &oh->slave_ports, node) { in _disable_clocks()
1053 if (oh->flags & HWMOD_OPT_CLKS_NEEDED) in _disable_clocks()
1054 _disable_optional_clocks(oh); in _disable_clocks()
1068 static void _omap4_enable_module(struct omap_hwmod *oh) in _omap4_enable_module() argument
1070 if (!oh->clkdm || !oh->prcm.omap4.modulemode || in _omap4_enable_module()
1071 _omap4_clkctrl_managed_by_clkfwk(oh)) in _omap4_enable_module()
1075 oh->name, __func__, oh->prcm.omap4.modulemode); in _omap4_enable_module()
1077 omap_cm_module_enable(oh->prcm.omap4.modulemode, in _omap4_enable_module()
1078 oh->clkdm->prcm_partition, in _omap4_enable_module()
1079 oh->clkdm->cm_inst, oh->prcm.omap4.clkctrl_offs); in _omap4_enable_module()
1091 static int _omap4_wait_target_disable(struct omap_hwmod *oh) in _omap4_wait_target_disable() argument
1093 if (!oh) in _omap4_wait_target_disable()
1096 if (oh->_int_flags & _HWMOD_NO_MPU_PORT || !oh->clkdm) in _omap4_wait_target_disable()
1099 if (oh->flags & HWMOD_NO_IDLEST) in _omap4_wait_target_disable()
1102 if (_omap4_clkctrl_managed_by_clkfwk(oh)) in _omap4_wait_target_disable()
1105 if (!_omap4_has_clkctrl_clock(oh)) in _omap4_wait_target_disable()
1108 return omap_cm_wait_module_idle(oh->clkdm->prcm_partition, in _omap4_wait_target_disable()
1109 oh->clkdm->cm_inst, in _omap4_wait_target_disable()
1110 oh->prcm.omap4.clkctrl_offs, 0); in _omap4_wait_target_disable()
1122 static void __init _save_mpu_port_index(struct omap_hwmod *oh) in _save_mpu_port_index() argument
1126 if (!oh) in _save_mpu_port_index()
1129 oh->_int_flags |= _HWMOD_NO_MPU_PORT; in _save_mpu_port_index()
1131 list_for_each_entry(os, &oh->slave_ports, node) { in _save_mpu_port_index()
1133 oh->_mpu_port = os; in _save_mpu_port_index()
1134 oh->_int_flags &= ~_HWMOD_NO_MPU_PORT; in _save_mpu_port_index()
1155 static struct omap_hwmod_ocp_if *_find_mpu_rt_port(struct omap_hwmod *oh) in _find_mpu_rt_port() argument
1157 if (!oh || oh->_int_flags & _HWMOD_NO_MPU_PORT || oh->slaves_cnt == 0) in _find_mpu_rt_port()
1160 return oh->_mpu_port; in _find_mpu_rt_port()
1174 static void _enable_sysc(struct omap_hwmod *oh) in _enable_sysc() argument
1181 if (!oh->class->sysc) in _enable_sysc()
1190 if (oh->flags & HWMOD_CONTROL_OPT_CLKS_IN_RESET) in _enable_sysc()
1191 _enable_optional_clocks(oh); in _enable_sysc()
1192 _wait_softreset_complete(oh); in _enable_sysc()
1193 if (oh->flags & HWMOD_CONTROL_OPT_CLKS_IN_RESET) in _enable_sysc()
1194 _disable_optional_clocks(oh); in _enable_sysc()
1196 v = oh->_sysc_cache; in _enable_sysc()
1197 sf = oh->class->sysc->sysc_flags; in _enable_sysc()
1199 clkdm = _get_clkdm(oh); in _enable_sysc()
1201 if (oh->flags & HWMOD_SWSUP_SIDLE || in _enable_sysc()
1202 oh->flags & HWMOD_SWSUP_SIDLE_ACT) { in _enable_sysc()
1206 _enable_wakeup(oh, &v); in _enable_sysc()
1207 if (oh->class->sysc->idlemodes & SIDLE_SMART_WKUP) in _enable_sysc()
1218 if (clkdm_act && !(oh->class->sysc->idlemodes & in _enable_sysc()
1222 _set_slave_idlemode(oh, idlemode, &v); in _enable_sysc()
1226 if (oh->flags & HWMOD_FORCE_MSTANDBY) { in _enable_sysc()
1228 } else if (oh->flags & HWMOD_SWSUP_MSTANDBY) { in _enable_sysc()
1232 _enable_wakeup(oh, &v); in _enable_sysc()
1233 if (oh->class->sysc->idlemodes & MSTANDBY_SMART_WKUP) in _enable_sysc()
1238 _set_master_standbymode(oh, idlemode, &v); in _enable_sysc()
1246 if ((oh->flags & HWMOD_SET_DEFAULT_CLOCKACT) && in _enable_sysc()
1248 _set_clockactivity(oh, CLOCKACT_TEST_ICLK, &v); in _enable_sysc()
1250 _write_sysconfig(v, oh); in _enable_sysc()
1257 idlemode = (oh->flags & HWMOD_NO_OCP_AUTOIDLE) ? in _enable_sysc()
1259 _set_module_autoidle(oh, idlemode, &v); in _enable_sysc()
1260 _write_sysconfig(v, oh); in _enable_sysc()
1273 static void _idle_sysc(struct omap_hwmod *oh) in _idle_sysc() argument
1278 if (!oh->class->sysc) in _idle_sysc()
1281 v = oh->_sysc_cache; in _idle_sysc()
1282 sf = oh->class->sysc->sysc_flags; in _idle_sysc()
1285 if (oh->flags & HWMOD_SWSUP_SIDLE) { in _idle_sysc()
1289 _enable_wakeup(oh, &v); in _idle_sysc()
1290 if (oh->class->sysc->idlemodes & SIDLE_SMART_WKUP) in _idle_sysc()
1295 _set_slave_idlemode(oh, idlemode, &v); in _idle_sysc()
1299 if ((oh->flags & HWMOD_SWSUP_MSTANDBY) || in _idle_sysc()
1300 (oh->flags & HWMOD_FORCE_MSTANDBY)) { in _idle_sysc()
1304 _enable_wakeup(oh, &v); in _idle_sysc()
1305 if (oh->class->sysc->idlemodes & MSTANDBY_SMART_WKUP) in _idle_sysc()
1310 _set_master_standbymode(oh, idlemode, &v); in _idle_sysc()
1314 if (oh->_sysc_cache != v) in _idle_sysc()
1315 _write_sysconfig(v, oh); in _idle_sysc()
1325 static void _shutdown_sysc(struct omap_hwmod *oh) in _shutdown_sysc() argument
1330 if (!oh->class->sysc) in _shutdown_sysc()
1333 v = oh->_sysc_cache; in _shutdown_sysc()
1334 sf = oh->class->sysc->sysc_flags; in _shutdown_sysc()
1337 _set_slave_idlemode(oh, HWMOD_IDLEMODE_FORCE, &v); in _shutdown_sysc()
1340 _set_master_standbymode(oh, HWMOD_IDLEMODE_FORCE, &v); in _shutdown_sysc()
1343 _set_module_autoidle(oh, 1, &v); in _shutdown_sysc()
1345 _write_sysconfig(v, oh); in _shutdown_sysc()
1356 struct omap_hwmod *oh, *temp_oh; in _lookup() local
1358 oh = NULL; in _lookup()
1362 oh = temp_oh; in _lookup()
1367 return oh; in _lookup()
1378 static int _init_clkdm(struct omap_hwmod *oh) in _init_clkdm() argument
1380 if (!oh->clkdm_name) { in _init_clkdm()
1381 pr_debug("omap_hwmod: %s: missing clockdomain\n", oh->name); in _init_clkdm()
1385 oh->clkdm = clkdm_lookup(oh->clkdm_name); in _init_clkdm()
1386 if (!oh->clkdm) { in _init_clkdm()
1388 oh->name, oh->clkdm_name); in _init_clkdm()
1393 oh->name, oh->clkdm_name); in _init_clkdm()
1408 static int _init_clocks(struct omap_hwmod *oh, struct device_node *np) in _init_clocks() argument
1412 if (oh->_state != _HWMOD_STATE_REGISTERED) in _init_clocks()
1415 pr_debug("omap_hwmod: %s: looking up clocks\n", oh->name); in _init_clocks()
1418 ret |= soc_ops.init_clkdm(oh); in _init_clocks()
1420 ret |= _init_main_clk(oh); in _init_clocks()
1421 ret |= _init_interface_clks(oh); in _init_clocks()
1422 ret |= _init_opt_clks(oh); in _init_clocks()
1425 oh->_state = _HWMOD_STATE_CLKS_INITED; in _init_clocks()
1427 pr_warn("omap_hwmod: %s: cannot _init_clocks\n", oh->name); in _init_clocks()
1441 static int _lookup_hardreset(struct omap_hwmod *oh, const char *name, in _lookup_hardreset() argument
1446 for (i = 0; i < oh->rst_lines_cnt; i++) { in _lookup_hardreset()
1447 const char *rst_line = oh->rst_lines[i].name; in _lookup_hardreset()
1449 ohri->rst_shift = oh->rst_lines[i].rst_shift; in _lookup_hardreset()
1450 ohri->st_shift = oh->rst_lines[i].st_shift; in _lookup_hardreset()
1452 oh->name, __func__, rst_line, ohri->rst_shift, in _lookup_hardreset()
1475 static int _assert_hardreset(struct omap_hwmod *oh, const char *name) in _assert_hardreset() argument
1480 if (!oh) in _assert_hardreset()
1486 ret = _lookup_hardreset(oh, name, &ohri); in _assert_hardreset()
1490 ret = soc_ops.assert_hardreset(oh, &ohri); in _assert_hardreset()
1508 static int _deassert_hardreset(struct omap_hwmod *oh, const char *name) in _deassert_hardreset() argument
1513 if (!oh) in _deassert_hardreset()
1519 ret = _lookup_hardreset(oh, name, &ohri); in _deassert_hardreset()
1523 if (oh->clkdm) { in _deassert_hardreset()
1529 clkdm_deny_idle(oh->clkdm); in _deassert_hardreset()
1530 ret = clkdm_hwmod_enable(oh->clkdm, oh); in _deassert_hardreset()
1533 oh->name, oh->clkdm->name, ret); in _deassert_hardreset()
1538 _enable_clocks(oh); in _deassert_hardreset()
1540 soc_ops.enable_module(oh); in _deassert_hardreset()
1542 ret = soc_ops.deassert_hardreset(oh, &ohri); in _deassert_hardreset()
1545 soc_ops.disable_module(oh); in _deassert_hardreset()
1546 _disable_clocks(oh); in _deassert_hardreset()
1549 pr_warn("omap_hwmod: %s: failed to hardreset\n", oh->name); in _deassert_hardreset()
1551 if (oh->clkdm) { in _deassert_hardreset()
1556 clkdm_allow_idle(oh->clkdm); in _deassert_hardreset()
1558 clkdm_hwmod_disable(oh->clkdm, oh); in _deassert_hardreset()
1576 static int _read_hardreset(struct omap_hwmod *oh, const char *name) in _read_hardreset() argument
1581 if (!oh) in _read_hardreset()
1587 ret = _lookup_hardreset(oh, name, &ohri); in _read_hardreset()
1591 return soc_ops.is_hardreset_asserted(oh, &ohri); in _read_hardreset()
1604 static bool _are_all_hardreset_lines_asserted(struct omap_hwmod *oh) in _are_all_hardreset_lines_asserted() argument
1608 if (oh->rst_lines_cnt == 0) in _are_all_hardreset_lines_asserted()
1611 for (i = 0; i < oh->rst_lines_cnt; i++) in _are_all_hardreset_lines_asserted()
1612 if (_read_hardreset(oh, oh->rst_lines[i].name) > 0) in _are_all_hardreset_lines_asserted()
1615 if (oh->rst_lines_cnt == rst_cnt) in _are_all_hardreset_lines_asserted()
1632 static bool _are_any_hardreset_lines_asserted(struct omap_hwmod *oh) in _are_any_hardreset_lines_asserted() argument
1637 for (i = 0; i < oh->rst_lines_cnt && rst_cnt == 0; i++) in _are_any_hardreset_lines_asserted()
1638 if (_read_hardreset(oh, oh->rst_lines[i].name) > 0) in _are_any_hardreset_lines_asserted()
1651 static int _omap4_disable_module(struct omap_hwmod *oh) in _omap4_disable_module() argument
1655 if (!oh->clkdm || !oh->prcm.omap4.modulemode || in _omap4_disable_module()
1656 _omap4_clkctrl_managed_by_clkfwk(oh)) in _omap4_disable_module()
1663 if (_are_any_hardreset_lines_asserted(oh)) in _omap4_disable_module()
1666 pr_debug("omap_hwmod: %s: %s\n", oh->name, __func__); in _omap4_disable_module()
1668 omap_cm_module_disable(oh->clkdm->prcm_partition, oh->clkdm->cm_inst, in _omap4_disable_module()
1669 oh->prcm.omap4.clkctrl_offs); in _omap4_disable_module()
1671 v = _omap4_wait_target_disable(oh); in _omap4_disable_module()
1674 oh->name); in _omap4_disable_module()
1695 static int _ocp_softreset(struct omap_hwmod *oh) in _ocp_softreset() argument
1701 if (!oh->class->sysc || in _ocp_softreset()
1702 !(oh->class->sysc->sysc_flags & SYSC_HAS_SOFTRESET)) in _ocp_softreset()
1706 if (oh->_state != _HWMOD_STATE_ENABLED) { in _ocp_softreset()
1708 oh->name); in _ocp_softreset()
1713 if (oh->flags & HWMOD_CONTROL_OPT_CLKS_IN_RESET) in _ocp_softreset()
1714 _enable_optional_clocks(oh); in _ocp_softreset()
1716 pr_debug("omap_hwmod: %s: resetting via OCP SOFTRESET\n", oh->name); in _ocp_softreset()
1718 v = oh->_sysc_cache; in _ocp_softreset()
1719 ret = _set_softreset(oh, &v); in _ocp_softreset()
1723 _write_sysconfig(v, oh); in _ocp_softreset()
1725 if (oh->class->sysc->srst_udelay) in _ocp_softreset()
1726 udelay(oh->class->sysc->srst_udelay); in _ocp_softreset()
1728 c = _wait_softreset_complete(oh); in _ocp_softreset()
1731 oh->name, MAX_MODULE_SOFTRESET_WAIT); in _ocp_softreset()
1735 pr_debug("omap_hwmod: %s: softreset in %d usec\n", oh->name, c); in _ocp_softreset()
1738 ret = _clear_softreset(oh, &v); in _ocp_softreset()
1742 _write_sysconfig(v, oh); in _ocp_softreset()
1750 if (oh->flags & HWMOD_CONTROL_OPT_CLKS_IN_RESET) in _ocp_softreset()
1751 _disable_optional_clocks(oh); in _ocp_softreset()
1789 static int _reset(struct omap_hwmod *oh) in _reset() argument
1793 pr_debug("omap_hwmod: %s: resetting\n", oh->name); in _reset()
1795 if (oh->class->reset) { in _reset()
1796 r = oh->class->reset(oh); in _reset()
1798 if (oh->rst_lines_cnt > 0) { in _reset()
1799 for (i = 0; i < oh->rst_lines_cnt; i++) in _reset()
1800 _assert_hardreset(oh, oh->rst_lines[i].name); in _reset()
1803 r = _ocp_softreset(oh); in _reset()
1809 _set_dmadisable(oh); in _reset()
1816 if (oh->class->sysc) { in _reset()
1817 _update_sysc_cache(oh); in _reset()
1818 _enable_sysc(oh); in _reset()
1833 static void _omap4_update_context_lost(struct omap_hwmod *oh) in _omap4_update_context_lost() argument
1835 if (oh->prcm.omap4.flags & HWMOD_OMAP4_NO_CONTEXT_LOSS_BIT) in _omap4_update_context_lost()
1838 if (!prm_was_any_context_lost_old(oh->clkdm->pwrdm.ptr->prcm_partition, in _omap4_update_context_lost()
1839 oh->clkdm->pwrdm.ptr->prcm_offs, in _omap4_update_context_lost()
1840 oh->prcm.omap4.context_offs)) in _omap4_update_context_lost()
1843 oh->prcm.omap4.context_lost_counter++; in _omap4_update_context_lost()
1844 prm_clear_context_loss_flags_old(oh->clkdm->pwrdm.ptr->prcm_partition, in _omap4_update_context_lost()
1845 oh->clkdm->pwrdm.ptr->prcm_offs, in _omap4_update_context_lost()
1846 oh->prcm.omap4.context_offs); in _omap4_update_context_lost()
1855 static int _omap4_get_context_lost(struct omap_hwmod *oh) in _omap4_get_context_lost() argument
1857 return oh->prcm.omap4.context_lost_counter; in _omap4_get_context_lost()
1868 static int _enable(struct omap_hwmod *oh) in _enable() argument
1872 pr_debug("omap_hwmod: %s: enabling\n", oh->name); in _enable()
1878 if (oh->_int_flags & _HWMOD_SKIP_ENABLE) { in _enable()
1879 oh->_int_flags &= ~_HWMOD_SKIP_ENABLE; in _enable()
1883 if (oh->_state != _HWMOD_STATE_INITIALIZED && in _enable()
1884 oh->_state != _HWMOD_STATE_IDLE && in _enable()
1885 oh->_state != _HWMOD_STATE_DISABLED) { in _enable()
1887 oh->name); in _enable()
1900 if (_are_all_hardreset_lines_asserted(oh)) in _enable()
1903 _add_initiator_dep(oh, mpu_oh); in _enable()
1905 if (oh->clkdm) { in _enable()
1911 clkdm_deny_idle(oh->clkdm); in _enable()
1912 r = clkdm_hwmod_enable(oh->clkdm, oh); in _enable()
1915 oh->name, oh->clkdm->name, r); in _enable()
1920 _enable_clocks(oh); in _enable()
1922 soc_ops.enable_module(oh); in _enable()
1923 if (oh->flags & HWMOD_BLOCK_WFI) in _enable()
1927 soc_ops.update_context_lost(oh); in _enable()
1929 r = (soc_ops.wait_target_ready) ? soc_ops.wait_target_ready(oh) : in _enable()
1931 if (oh->clkdm && !(oh->flags & HWMOD_CLKDM_NOAUTO)) in _enable()
1932 clkdm_allow_idle(oh->clkdm); in _enable()
1935 oh->_state = _HWMOD_STATE_ENABLED; in _enable()
1938 if (oh->class->sysc) { in _enable()
1939 if (!(oh->_int_flags & _HWMOD_SYSCONFIG_LOADED)) in _enable()
1940 _update_sysc_cache(oh); in _enable()
1941 _enable_sysc(oh); in _enable()
1945 soc_ops.disable_module(oh); in _enable()
1946 _disable_clocks(oh); in _enable()
1948 oh->name, r); in _enable()
1950 if (oh->clkdm) in _enable()
1951 clkdm_hwmod_disable(oh->clkdm, oh); in _enable()
1965 static int _idle(struct omap_hwmod *oh) in _idle() argument
1967 if (oh->flags & HWMOD_NO_IDLE) { in _idle()
1968 oh->_int_flags |= _HWMOD_SKIP_ENABLE; in _idle()
1972 pr_debug("omap_hwmod: %s: idling\n", oh->name); in _idle()
1974 if (_are_all_hardreset_lines_asserted(oh)) in _idle()
1977 if (oh->_state != _HWMOD_STATE_ENABLED) { in _idle()
1979 oh->name); in _idle()
1983 if (oh->class->sysc) in _idle()
1984 _idle_sysc(oh); in _idle()
1985 _del_initiator_dep(oh, mpu_oh); in _idle()
1992 if (oh->clkdm && !(oh->flags & HWMOD_CLKDM_NOAUTO)) in _idle()
1993 clkdm_deny_idle(oh->clkdm); in _idle()
1995 if (oh->flags & HWMOD_BLOCK_WFI) in _idle()
1998 soc_ops.disable_module(oh); in _idle()
2006 _disable_clocks(oh); in _idle()
2007 if (oh->clkdm) { in _idle()
2008 clkdm_allow_idle(oh->clkdm); in _idle()
2009 clkdm_hwmod_disable(oh->clkdm, oh); in _idle()
2012 oh->_state = _HWMOD_STATE_IDLE; in _idle()
2026 static int _shutdown(struct omap_hwmod *oh) in _shutdown() argument
2031 if (_are_all_hardreset_lines_asserted(oh)) in _shutdown()
2034 if (oh->_state != _HWMOD_STATE_IDLE && in _shutdown()
2035 oh->_state != _HWMOD_STATE_ENABLED) { in _shutdown()
2037 oh->name); in _shutdown()
2041 pr_debug("omap_hwmod: %s: disabling\n", oh->name); in _shutdown()
2043 if (oh->class->pre_shutdown) { in _shutdown()
2044 prev_state = oh->_state; in _shutdown()
2045 if (oh->_state == _HWMOD_STATE_IDLE) in _shutdown()
2046 _enable(oh); in _shutdown()
2047 ret = oh->class->pre_shutdown(oh); in _shutdown()
2050 _idle(oh); in _shutdown()
2055 if (oh->class->sysc) { in _shutdown()
2056 if (oh->_state == _HWMOD_STATE_IDLE) in _shutdown()
2057 _enable(oh); in _shutdown()
2058 _shutdown_sysc(oh); in _shutdown()
2062 if (oh->_state == _HWMOD_STATE_ENABLED) { in _shutdown()
2063 _del_initiator_dep(oh, mpu_oh); in _shutdown()
2065 if (oh->flags & HWMOD_BLOCK_WFI) in _shutdown()
2068 soc_ops.disable_module(oh); in _shutdown()
2069 _disable_clocks(oh); in _shutdown()
2070 if (oh->clkdm) in _shutdown()
2071 clkdm_hwmod_disable(oh->clkdm, oh); in _shutdown()
2075 for (i = 0; i < oh->rst_lines_cnt; i++) in _shutdown()
2076 _assert_hardreset(oh, oh->rst_lines[i].name); in _shutdown()
2078 oh->_state = _HWMOD_STATE_DISABLED; in _shutdown()
2084 struct omap_hwmod *oh) in of_dev_find_hwmod() argument
2098 if (!strcmp(p, oh->name)) { in of_dev_find_hwmod()
2100 np, i, oh->name); in of_dev_find_hwmod()
2120 struct omap_hwmod *oh, in of_dev_hwmod_lookup() argument
2127 res = of_dev_find_hwmod(np, oh); in of_dev_hwmod_lookup()
2138 res = of_dev_hwmod_lookup(np0, oh, &i, &fc); in of_dev_hwmod_lookup()
2167 static void omap_hwmod_fix_mpu_rt_idx(struct omap_hwmod *oh, in omap_hwmod_fix_mpu_rt_idx() argument
2178 error = of_address_to_resource(child, oh->mpu_rt_idx, res); in omap_hwmod_fix_mpu_rt_idx()
2195 int omap_hwmod_parse_module_range(struct omap_hwmod *oh, in omap_hwmod_parse_module_range() argument
2235 oh->name, np); in omap_hwmod_parse_module_range()
2244 oh->name, np, base, size); in omap_hwmod_parse_module_range()
2246 if (oh && oh->mpu_rt_idx) { in omap_hwmod_parse_module_range()
2247 omap_hwmod_fix_mpu_rt_idx(oh, np, res); in omap_hwmod_parse_module_range()
2276 static int __init _init_mpu_rt_base(struct omap_hwmod *oh, void *data, in _init_mpu_rt_base() argument
2283 if (!oh) in _init_mpu_rt_base()
2286 _save_mpu_port_index(oh); in _init_mpu_rt_base()
2289 if (!oh->class->sysc) in _init_mpu_rt_base()
2293 if (oh->_int_flags & _HWMOD_NO_MPU_PORT) in _init_mpu_rt_base()
2297 pr_err("omap_hwmod: %s: no dt node\n", oh->name); in _init_mpu_rt_base()
2302 error = omap_hwmod_parse_module_range(oh, np, &res); in _init_mpu_rt_base()
2308 va_start = of_iomap(np, index + oh->mpu_rt_idx); in _init_mpu_rt_base()
2311 oh->name, index, np); in _init_mpu_rt_base()
2316 oh->name, va_start); in _init_mpu_rt_base()
2318 oh->_mpu_rt_va = va_start; in _init_mpu_rt_base()
2322 static void __init parse_module_flags(struct omap_hwmod *oh, in parse_module_flags() argument
2326 oh->flags |= HWMOD_INIT_NO_RESET; in parse_module_flags()
2328 oh->flags |= HWMOD_INIT_NO_IDLE; in parse_module_flags()
2330 oh->flags |= HWMOD_NO_IDLE; in parse_module_flags()
2346 static int __init _init(struct omap_hwmod *oh, void *data) in _init() argument
2352 if (oh->_state != _HWMOD_STATE_REGISTERED) in _init()
2359 r = of_dev_hwmod_lookup(bus, oh, &index, &np); in _init()
2361 pr_debug("omap_hwmod: %s missing dt data\n", oh->name); in _init()
2364 oh->name, np); in _init()
2366 r = _init_mpu_rt_base(oh, NULL, index, np); in _init()
2369 oh->name); in _init()
2373 r = _init_clocks(oh, np); in _init()
2375 WARN(1, "omap_hwmod: %s: couldn't init clocks\n", oh->name); in _init()
2382 parse_module_flags(oh, np); in _init()
2385 parse_module_flags(oh, child); in _init()
2388 oh->_state = _HWMOD_STATE_INITIALIZED; in _init()
2401 static void _setup_iclk_autoidle(struct omap_hwmod *oh) in _setup_iclk_autoidle() argument
2405 if (oh->_state != _HWMOD_STATE_INITIALIZED) in _setup_iclk_autoidle()
2408 list_for_each_entry(os, &oh->slave_ports, node) { in _setup_iclk_autoidle()
2436 static int _setup_reset(struct omap_hwmod *oh) in _setup_reset() argument
2440 if (oh->_state != _HWMOD_STATE_INITIALIZED) in _setup_reset()
2443 if (oh->flags & HWMOD_EXT_OPT_MAIN_CLK) in _setup_reset()
2446 if (oh->rst_lines_cnt == 0) { in _setup_reset()
2447 r = _enable(oh); in _setup_reset()
2450 oh->name, oh->_state); in _setup_reset()
2455 if (!(oh->flags & HWMOD_INIT_NO_RESET)) in _setup_reset()
2456 r = _reset(oh); in _setup_reset()
2497 static void _setup_postsetup(struct omap_hwmod *oh) in _setup_postsetup() argument
2501 if (oh->rst_lines_cnt > 0) in _setup_postsetup()
2504 postsetup_state = oh->_postsetup_state; in _setup_postsetup()
2512 if ((oh->flags & (HWMOD_INIT_NO_IDLE | HWMOD_NO_IDLE)) && in _setup_postsetup()
2514 oh->_int_flags |= _HWMOD_SKIP_ENABLE; in _setup_postsetup()
2519 _idle(oh); in _setup_postsetup()
2521 _shutdown(oh); in _setup_postsetup()
2524 oh->name, postsetup_state); in _setup_postsetup()
2545 static int _setup(struct omap_hwmod *oh, void *data) in _setup() argument
2547 if (oh->_state != _HWMOD_STATE_INITIALIZED) in _setup()
2550 if (oh->parent_hwmod) { in _setup()
2553 r = _enable(oh->parent_hwmod); in _setup()
2555 oh->name, oh->parent_hwmod->name); in _setup()
2558 _setup_iclk_autoidle(oh); in _setup()
2560 if (!_setup_reset(oh)) in _setup()
2561 _setup_postsetup(oh); in _setup()
2563 if (oh->parent_hwmod) { in _setup()
2566 postsetup_state = oh->parent_hwmod->_postsetup_state; in _setup()
2569 _idle(oh->parent_hwmod); in _setup()
2571 _shutdown(oh->parent_hwmod); in _setup()
2574 oh->parent_hwmod->name, postsetup_state); in _setup()
2597 static int _register(struct omap_hwmod *oh) in _register() argument
2599 if (!oh || !oh->name || !oh->class || !oh->class->name || in _register()
2600 (oh->_state != _HWMOD_STATE_UNKNOWN)) in _register()
2603 pr_debug("omap_hwmod: %s: registering\n", oh->name); in _register()
2605 if (_lookup(oh->name)) in _register()
2608 list_add_tail(&oh->node, &omap_hwmod_list); in _register()
2610 INIT_LIST_HEAD(&oh->slave_ports); in _register()
2611 spin_lock_init(&oh->_lock); in _register()
2612 lockdep_set_class(&oh->_lock, &oh->hwmod_key); in _register()
2614 oh->_state = _HWMOD_STATE_REGISTERED; in _register()
2620 if (!strcmp(oh->name, MPU_INITIATOR_NAME)) in _register()
2621 mpu_oh = oh; in _register()
2699 static int _omap2xxx_3xxx_wait_target_ready(struct omap_hwmod *oh) in _omap2xxx_3xxx_wait_target_ready() argument
2701 if (!oh) in _omap2xxx_3xxx_wait_target_ready()
2704 if (oh->flags & HWMOD_NO_IDLEST) in _omap2xxx_3xxx_wait_target_ready()
2707 if (!_find_mpu_rt_port(oh)) in _omap2xxx_3xxx_wait_target_ready()
2712 return omap_cm_wait_module_ready(0, oh->prcm.omap2.module_offs, in _omap2xxx_3xxx_wait_target_ready()
2713 oh->prcm.omap2.idlest_reg_id, in _omap2xxx_3xxx_wait_target_ready()
2714 oh->prcm.omap2.idlest_idle_bit); in _omap2xxx_3xxx_wait_target_ready()
2726 static int _omap4_wait_target_ready(struct omap_hwmod *oh) in _omap4_wait_target_ready() argument
2728 if (!oh) in _omap4_wait_target_ready()
2731 if (oh->flags & HWMOD_NO_IDLEST || !oh->clkdm) in _omap4_wait_target_ready()
2734 if (!_find_mpu_rt_port(oh)) in _omap4_wait_target_ready()
2737 if (_omap4_clkctrl_managed_by_clkfwk(oh)) in _omap4_wait_target_ready()
2740 if (!_omap4_has_clkctrl_clock(oh)) in _omap4_wait_target_ready()
2745 return omap_cm_wait_module_ready(oh->clkdm->prcm_partition, in _omap4_wait_target_ready()
2746 oh->clkdm->cm_inst, in _omap4_wait_target_ready()
2747 oh->prcm.omap4.clkctrl_offs, 0); in _omap4_wait_target_ready()
2761 static int _omap2_assert_hardreset(struct omap_hwmod *oh, in _omap2_assert_hardreset() argument
2765 oh->prcm.omap2.module_offs, 0); in _omap2_assert_hardreset()
2779 static int _omap2_deassert_hardreset(struct omap_hwmod *oh, in _omap2_deassert_hardreset() argument
2783 oh->prcm.omap2.module_offs, 0, 0); in _omap2_deassert_hardreset()
2798 static int _omap2_is_hardreset_asserted(struct omap_hwmod *oh, in _omap2_is_hardreset_asserted() argument
2802 oh->prcm.omap2.module_offs, 0); in _omap2_is_hardreset_asserted()
2817 static int _omap4_assert_hardreset(struct omap_hwmod *oh, in _omap4_assert_hardreset() argument
2820 if (!oh->clkdm) in _omap4_assert_hardreset()
2824 oh->clkdm->pwrdm.ptr->prcm_partition, in _omap4_assert_hardreset()
2825 oh->clkdm->pwrdm.ptr->prcm_offs, in _omap4_assert_hardreset()
2826 oh->prcm.omap4.rstctrl_offs); in _omap4_assert_hardreset()
2841 static int _omap4_deassert_hardreset(struct omap_hwmod *oh, in _omap4_deassert_hardreset() argument
2844 if (!oh->clkdm) in _omap4_deassert_hardreset()
2849 oh->name, ohri->name); in _omap4_deassert_hardreset()
2851 oh->clkdm->pwrdm.ptr->prcm_partition, in _omap4_deassert_hardreset()
2852 oh->clkdm->pwrdm.ptr->prcm_offs, in _omap4_deassert_hardreset()
2853 oh->prcm.omap4.rstctrl_offs, in _omap4_deassert_hardreset()
2854 oh->prcm.omap4.rstctrl_offs + in _omap4_deassert_hardreset()
2870 static int _omap4_is_hardreset_asserted(struct omap_hwmod *oh, in _omap4_is_hardreset_asserted() argument
2873 if (!oh->clkdm) in _omap4_is_hardreset_asserted()
2877 oh->clkdm->pwrdm.ptr-> in _omap4_is_hardreset_asserted()
2879 oh->clkdm->pwrdm.ptr->prcm_offs, in _omap4_is_hardreset_asserted()
2880 oh->prcm.omap4.rstctrl_offs); in _omap4_is_hardreset_asserted()
2891 static int _omap4_disable_direct_prcm(struct omap_hwmod *oh) in _omap4_disable_direct_prcm() argument
2893 if (!oh) in _omap4_disable_direct_prcm()
2896 oh->prcm.omap4.flags |= HWMOD_OMAP4_CLKFWK_CLKCTR_CLOCK; in _omap4_disable_direct_prcm()
2913 static int _am33xx_deassert_hardreset(struct omap_hwmod *oh, in _am33xx_deassert_hardreset() argument
2917 oh->clkdm->pwrdm.ptr->prcm_partition, in _am33xx_deassert_hardreset()
2918 oh->clkdm->pwrdm.ptr->prcm_offs, in _am33xx_deassert_hardreset()
2919 oh->prcm.omap4.rstctrl_offs, in _am33xx_deassert_hardreset()
2920 oh->prcm.omap4.rstst_offs); in _am33xx_deassert_hardreset()
2925 u32 omap_hwmod_read(struct omap_hwmod *oh, u16 reg_offs) in omap_hwmod_read() argument
2927 if (oh->flags & HWMOD_16BIT_REG) in omap_hwmod_read()
2928 return readw_relaxed(oh->_mpu_rt_va + reg_offs); in omap_hwmod_read()
2930 return readl_relaxed(oh->_mpu_rt_va + reg_offs); in omap_hwmod_read()
2933 void omap_hwmod_write(u32 v, struct omap_hwmod *oh, u16 reg_offs) in omap_hwmod_write() argument
2935 if (oh->flags & HWMOD_16BIT_REG) in omap_hwmod_write()
2936 writew_relaxed(v, oh->_mpu_rt_va + reg_offs); in omap_hwmod_write()
2938 writel_relaxed(v, oh->_mpu_rt_va + reg_offs); in omap_hwmod_write()
2950 int omap_hwmod_softreset(struct omap_hwmod *oh) in omap_hwmod_softreset() argument
2955 if (!oh || !(oh->_sysc_cache)) in omap_hwmod_softreset()
2958 v = oh->_sysc_cache; in omap_hwmod_softreset()
2959 ret = _set_softreset(oh, &v); in omap_hwmod_softreset()
2962 _write_sysconfig(v, oh); in omap_hwmod_softreset()
2964 ret = _clear_softreset(oh, &v); in omap_hwmod_softreset()
2967 _write_sysconfig(v, oh); in omap_hwmod_softreset()
2982 struct omap_hwmod *oh; in omap_hwmod_lookup() local
2987 oh = _lookup(name); in omap_hwmod_lookup()
2989 return oh; in omap_hwmod_lookup()
3004 int omap_hwmod_for_each(int (*fn)(struct omap_hwmod *oh, void *data), in omap_hwmod_for_each() argument
3069 static void __init _ensure_mpu_hwmod_is_setup(struct omap_hwmod *oh) in _ensure_mpu_hwmod_is_setup() argument
3074 else if (mpu_oh->_state == _HWMOD_STATE_REGISTERED && oh != mpu_oh) in _ensure_mpu_hwmod_is_setup()
3091 struct omap_hwmod *oh; in omap_hwmod_setup_one() local
3095 oh = _lookup(oh_name); in omap_hwmod_setup_one()
3096 if (!oh) { in omap_hwmod_setup_one()
3101 _ensure_mpu_hwmod_is_setup(oh); in omap_hwmod_setup_one()
3103 _init(oh, NULL); in omap_hwmod_setup_one()
3104 _setup(oh, NULL); in omap_hwmod_setup_one()
3163 static int omap_hwmod_init_regbits(struct device *dev, struct omap_hwmod *oh, in omap_hwmod_init_regbits() argument
3202 if (!oh->class->sysc->sysc_fields) in omap_hwmod_init_regbits()
3362 struct omap_hwmod *oh, in omap_hwmod_check_module() argument
3369 if (!oh->class->sysc) in omap_hwmod_check_module()
3372 if (oh->class->sysc->sysc_fields && in omap_hwmod_check_module()
3373 sysc_fields != oh->class->sysc->sysc_fields) in omap_hwmod_check_module()
3376 if (rev_offs != oh->class->sysc->rev_offs) in omap_hwmod_check_module()
3378 oh->class->sysc->rev_offs); in omap_hwmod_check_module()
3379 if (sysc_offs != oh->class->sysc->sysc_offs) in omap_hwmod_check_module()
3381 oh->class->sysc->sysc_offs); in omap_hwmod_check_module()
3382 if (syss_offs != oh->class->sysc->syss_offs) in omap_hwmod_check_module()
3384 oh->class->sysc->syss_offs); in omap_hwmod_check_module()
3386 if (sysc_flags != oh->class->sysc->sysc_flags) in omap_hwmod_check_module()
3388 oh->class->sysc->sysc_flags); in omap_hwmod_check_module()
3390 if (idlemodes != oh->class->sysc->idlemodes) in omap_hwmod_check_module()
3392 oh->class->sysc->idlemodes); in omap_hwmod_check_module()
3394 if (data->cfg->srst_udelay != oh->class->sysc->srst_udelay) in omap_hwmod_check_module()
3397 oh->class->sysc->srst_udelay); in omap_hwmod_check_module()
3416 static int omap_hwmod_allocate_module(struct device *dev, struct omap_hwmod *oh, in omap_hwmod_allocate_module() argument
3442 if (!oh->_mpu_rt_va) { in omap_hwmod_allocate_module()
3453 if (oh->class->name && strcmp(oh->class->name, data->name)) { in omap_hwmod_allocate_module()
3454 class = kmemdup(oh->class, sizeof(*oh->class), GFP_KERNEL); in omap_hwmod_allocate_module()
3459 if (list_empty(&oh->slave_ports)) { in omap_hwmod_allocate_module()
3469 oi->slave = oh; in omap_hwmod_allocate_module()
3473 spin_lock_irqsave(&oh->_lock, flags); in omap_hwmod_allocate_module()
3475 oh->_mpu_rt_va = regs; in omap_hwmod_allocate_module()
3477 oh->class = class; in omap_hwmod_allocate_module()
3478 oh->class->sysc = sysc; in omap_hwmod_allocate_module()
3482 oh->clkdm = clkdm; in omap_hwmod_allocate_module()
3483 oh->_state = _HWMOD_STATE_INITIALIZED; in omap_hwmod_allocate_module()
3484 oh->_postsetup_state = _HWMOD_STATE_DEFAULT; in omap_hwmod_allocate_module()
3485 _setup(oh, NULL); in omap_hwmod_allocate_module()
3486 spin_unlock_irqrestore(&oh->_lock, flags); in omap_hwmod_allocate_module()
3511 omap_hwmod_init_reset_quirk(struct device *dev, struct omap_hwmod *oh, in omap_hwmod_init_reset_quirk() argument
3522 oh->class->reset = quirk->reset; in omap_hwmod_init_reset_quirk()
3530 omap_hwmod_init_reset_quirks(struct device *dev, struct omap_hwmod *oh, in omap_hwmod_init_reset_quirks() argument
3534 omap_hwmod_init_reset_quirk(dev, oh, data, in omap_hwmod_init_reset_quirks()
3538 omap_hwmod_init_reset_quirk(dev, oh, data, omap_reset_quirks, in omap_hwmod_init_reset_quirks()
3552 struct omap_hwmod *oh; in omap_hwmod_init_module() local
3561 oh = _lookup(data->name); in omap_hwmod_init_module()
3562 if (!oh) { in omap_hwmod_init_module()
3563 oh = kzalloc(sizeof(*oh), GFP_KERNEL); in omap_hwmod_init_module()
3564 if (!oh) in omap_hwmod_init_module()
3567 oh->name = data->name; in omap_hwmod_init_module()
3568 oh->_state = _HWMOD_STATE_UNKNOWN; in omap_hwmod_init_module()
3569 lockdep_register_key(&oh->hwmod_key); in omap_hwmod_init_module()
3572 oh->prcm.omap4.flags = HWMOD_OMAP4_NO_CONTEXT_LOSS_BIT; in omap_hwmod_init_module()
3574 oh->class = kzalloc(sizeof(*oh->class), GFP_KERNEL); in omap_hwmod_init_module()
3575 if (!oh->class) { in omap_hwmod_init_module()
3576 kfree(oh); in omap_hwmod_init_module()
3580 omap_hwmod_init_reset_quirks(dev, oh, data); in omap_hwmod_init_module()
3582 oh->class->name = data->name; in omap_hwmod_init_module()
3584 error = _register(oh); in omap_hwmod_init_module()
3588 cookie->data = oh; in omap_hwmod_init_module()
3590 error = omap_hwmod_init_regbits(dev, oh, data, &sysc_fields); in omap_hwmod_init_module()
3608 oh->flags |= HWMOD_NO_IDLE; in omap_hwmod_init_module()
3610 oh->flags |= HWMOD_INIT_NO_IDLE; in omap_hwmod_init_module()
3612 oh->flags |= HWMOD_INIT_NO_RESET; in omap_hwmod_init_module()
3614 oh->flags |= HWMOD_SET_DEFAULT_CLOCKACT; in omap_hwmod_init_module()
3616 oh->flags |= HWMOD_SWSUP_SIDLE; in omap_hwmod_init_module()
3618 oh->flags |= HWMOD_SWSUP_SIDLE_ACT; in omap_hwmod_init_module()
3620 oh->flags |= HWMOD_SWSUP_MSTANDBY; in omap_hwmod_init_module()
3622 oh->flags |= HWMOD_CLKDM_NOAUTO; in omap_hwmod_init_module()
3624 error = omap_hwmod_check_module(dev, oh, data, sysc_fields, in omap_hwmod_init_module()
3630 return omap_hwmod_allocate_module(dev, oh, data, sysc_fields, in omap_hwmod_init_module()
3647 struct omap_hwmod *oh; in omap_hwmod_setup_earlycon_flags() local
3657 oh = omap_hwmod_lookup(uart); in omap_hwmod_setup_earlycon_flags()
3658 if (!oh) { in omap_hwmod_setup_earlycon_flags()
3662 oh = omap_hwmod_lookup(uart); in omap_hwmod_setup_earlycon_flags()
3664 if (oh) in omap_hwmod_setup_earlycon_flags()
3665 oh->flags |= DEBUG_OMAPUART_FLAGS; in omap_hwmod_setup_earlycon_flags()
3704 int omap_hwmod_enable(struct omap_hwmod *oh) in omap_hwmod_enable() argument
3709 if (!oh) in omap_hwmod_enable()
3712 spin_lock_irqsave(&oh->_lock, flags); in omap_hwmod_enable()
3713 r = _enable(oh); in omap_hwmod_enable()
3714 spin_unlock_irqrestore(&oh->_lock, flags); in omap_hwmod_enable()
3726 int omap_hwmod_idle(struct omap_hwmod *oh) in omap_hwmod_idle() argument
3731 if (!oh) in omap_hwmod_idle()
3734 spin_lock_irqsave(&oh->_lock, flags); in omap_hwmod_idle()
3735 r = _idle(oh); in omap_hwmod_idle()
3736 spin_unlock_irqrestore(&oh->_lock, flags); in omap_hwmod_idle()
3749 int omap_hwmod_shutdown(struct omap_hwmod *oh) in omap_hwmod_shutdown() argument
3754 if (!oh) in omap_hwmod_shutdown()
3757 spin_lock_irqsave(&oh->_lock, flags); in omap_hwmod_shutdown()
3758 r = _shutdown(oh); in omap_hwmod_shutdown()
3759 spin_unlock_irqrestore(&oh->_lock, flags); in omap_hwmod_shutdown()
3777 void __iomem *omap_hwmod_get_mpu_rt_va(struct omap_hwmod *oh) in omap_hwmod_get_mpu_rt_va() argument
3779 if (!oh) in omap_hwmod_get_mpu_rt_va()
3782 if (oh->_int_flags & _HWMOD_NO_MPU_PORT) in omap_hwmod_get_mpu_rt_va()
3785 if (oh->_state == _HWMOD_STATE_UNKNOWN) in omap_hwmod_get_mpu_rt_va()
3788 return oh->_mpu_rt_va; in omap_hwmod_get_mpu_rt_va()
3808 int omap_hwmod_assert_hardreset(struct omap_hwmod *oh, const char *name) in omap_hwmod_assert_hardreset() argument
3813 if (!oh) in omap_hwmod_assert_hardreset()
3816 spin_lock_irqsave(&oh->_lock, flags); in omap_hwmod_assert_hardreset()
3817 ret = _assert_hardreset(oh, name); in omap_hwmod_assert_hardreset()
3818 spin_unlock_irqrestore(&oh->_lock, flags); in omap_hwmod_assert_hardreset()
3835 int omap_hwmod_deassert_hardreset(struct omap_hwmod *oh, const char *name) in omap_hwmod_deassert_hardreset() argument
3840 if (!oh) in omap_hwmod_deassert_hardreset()
3843 spin_lock_irqsave(&oh->_lock, flags); in omap_hwmod_deassert_hardreset()
3844 ret = _deassert_hardreset(oh, name); in omap_hwmod_deassert_hardreset()
3845 spin_unlock_irqrestore(&oh->_lock, flags); in omap_hwmod_deassert_hardreset()
3863 int (*fn)(struct omap_hwmod *oh, in omap_hwmod_for_each_by_class() argument
3904 int omap_hwmod_set_postsetup_state(struct omap_hwmod *oh, u8 state) in omap_hwmod_set_postsetup_state() argument
3909 if (!oh) in omap_hwmod_set_postsetup_state()
3917 spin_lock_irqsave(&oh->_lock, flags); in omap_hwmod_set_postsetup_state()
3919 if (oh->_state != _HWMOD_STATE_REGISTERED) { in omap_hwmod_set_postsetup_state()
3924 oh->_postsetup_state = state; in omap_hwmod_set_postsetup_state()
3928 spin_unlock_irqrestore(&oh->_lock, flags); in omap_hwmod_set_postsetup_state()