Lines Matching refs:oh
190 void (*enable_module)(struct omap_hwmod *oh);
191 int (*disable_module)(struct omap_hwmod *oh);
192 int (*wait_target_ready)(struct omap_hwmod *oh);
193 int (*assert_hardreset)(struct omap_hwmod *oh,
195 int (*deassert_hardreset)(struct omap_hwmod *oh,
197 int (*is_hardreset_asserted)(struct omap_hwmod *oh,
199 int (*init_clkdm)(struct omap_hwmod *oh);
200 void (*update_context_lost)(struct omap_hwmod *oh);
201 int (*get_context_lost)(struct omap_hwmod *oh);
266 static int _update_sysc_cache(struct omap_hwmod *oh) in _update_sysc_cache() argument
268 if (!oh->class->sysc) { in _update_sysc_cache()
269 WARN(1, "omap_hwmod: %s: cannot read OCP_SYSCONFIG: not defined on hwmod's class\n", oh->name); in _update_sysc_cache()
275 oh->_sysc_cache = omap_hwmod_read(oh, oh->class->sysc->sysc_offs); in _update_sysc_cache()
277 if (!(oh->class->sysc->sysc_flags & SYSC_NO_CACHE)) in _update_sysc_cache()
278 oh->_int_flags |= _HWMOD_SYSCONFIG_LOADED; in _update_sysc_cache()
291 static void _write_sysconfig(u32 v, struct omap_hwmod *oh) in _write_sysconfig() argument
293 if (!oh->class->sysc) { in _write_sysconfig()
294 WARN(1, "omap_hwmod: %s: cannot write OCP_SYSCONFIG: not defined on hwmod's class\n", oh->name); in _write_sysconfig()
301 oh->_sysc_cache = v; in _write_sysconfig()
302 omap_hwmod_write(v, oh, oh->class->sysc->sysc_offs); in _write_sysconfig()
315 static int _set_master_standbymode(struct omap_hwmod *oh, u8 standbymode, in _set_master_standbymode() argument
321 if (!oh->class->sysc || in _set_master_standbymode()
322 !(oh->class->sysc->sysc_flags & SYSC_HAS_MIDLEMODE)) in _set_master_standbymode()
325 if (!oh->class->sysc->sysc_fields) { in _set_master_standbymode()
326 WARN(1, "omap_hwmod: %s: offset struct for sysconfig not provided in class\n", oh->name); in _set_master_standbymode()
330 mstandby_shift = oh->class->sysc->sysc_fields->midle_shift; in _set_master_standbymode()
349 static int _set_slave_idlemode(struct omap_hwmod *oh, u8 idlemode, u32 *v) in _set_slave_idlemode() argument
354 if (!oh->class->sysc || in _set_slave_idlemode()
355 !(oh->class->sysc->sysc_flags & SYSC_HAS_SIDLEMODE)) in _set_slave_idlemode()
358 if (!oh->class->sysc->sysc_fields) { in _set_slave_idlemode()
359 WARN(1, "omap_hwmod: %s: offset struct for sysconfig not provided in class\n", oh->name); in _set_slave_idlemode()
363 sidle_shift = oh->class->sysc->sysc_fields->sidle_shift; in _set_slave_idlemode()
383 static int _set_clockactivity(struct omap_hwmod *oh, u8 clockact, u32 *v) in _set_clockactivity() argument
388 if (!oh->class->sysc || in _set_clockactivity()
389 !(oh->class->sysc->sysc_flags & SYSC_HAS_CLOCKACTIVITY)) in _set_clockactivity()
392 if (!oh->class->sysc->sysc_fields) { in _set_clockactivity()
393 WARN(1, "omap_hwmod: %s: offset struct for sysconfig not provided in class\n", oh->name); in _set_clockactivity()
397 clkact_shift = oh->class->sysc->sysc_fields->clkact_shift; in _set_clockactivity()
414 static int _set_softreset(struct omap_hwmod *oh, u32 *v) in _set_softreset() argument
418 if (!oh->class->sysc || in _set_softreset()
419 !(oh->class->sysc->sysc_flags & SYSC_HAS_SOFTRESET)) in _set_softreset()
422 if (!oh->class->sysc->sysc_fields) { in _set_softreset()
423 WARN(1, "omap_hwmod: %s: offset struct for sysconfig not provided in class\n", oh->name); in _set_softreset()
427 softrst_mask = (0x1 << oh->class->sysc->sysc_fields->srst_shift); in _set_softreset()
442 static int _clear_softreset(struct omap_hwmod *oh, u32 *v) in _clear_softreset() argument
446 if (!oh->class->sysc || in _clear_softreset()
447 !(oh->class->sysc->sysc_flags & SYSC_HAS_SOFTRESET)) in _clear_softreset()
450 if (!oh->class->sysc->sysc_fields) { in _clear_softreset()
453 oh->name); in _clear_softreset()
457 softrst_mask = (0x1 << oh->class->sysc->sysc_fields->srst_shift); in _clear_softreset()
474 static int _wait_softreset_complete(struct omap_hwmod *oh) in _wait_softreset_complete() argument
480 sysc = oh->class->sysc; in _wait_softreset_complete()
483 omap_test_timeout((omap_hwmod_read(oh, sysc->syss_offs) in _wait_softreset_complete()
488 omap_test_timeout(!(omap_hwmod_read(oh, sysc->sysc_offs) in _wait_softreset_complete()
508 static int _set_dmadisable(struct omap_hwmod *oh) in _set_dmadisable() argument
513 if (!oh->class->sysc || in _set_dmadisable()
514 !(oh->class->sysc->sysc_flags & SYSC_HAS_DMADISABLE)) in _set_dmadisable()
517 if (!oh->class->sysc->sysc_fields) { in _set_dmadisable()
518 WARN(1, "omap_hwmod: %s: offset struct for sysconfig not provided in class\n", oh->name); in _set_dmadisable()
523 if (oh->_state != _HWMOD_STATE_ENABLED) { in _set_dmadisable()
524 pr_warn("omap_hwmod: %s: dma can be disabled only from enabled state\n", oh->name); in _set_dmadisable()
528 pr_debug("omap_hwmod: %s: setting DMADISABLE\n", oh->name); in _set_dmadisable()
530 v = oh->_sysc_cache; in _set_dmadisable()
532 (0x1 << oh->class->sysc->sysc_fields->dmadisable_shift); in _set_dmadisable()
534 _write_sysconfig(v, oh); in _set_dmadisable()
552 static int _set_module_autoidle(struct omap_hwmod *oh, u8 autoidle, in _set_module_autoidle() argument
558 if (!oh->class->sysc || in _set_module_autoidle()
559 !(oh->class->sysc->sysc_flags & SYSC_HAS_AUTOIDLE)) in _set_module_autoidle()
562 if (!oh->class->sysc->sysc_fields) { in _set_module_autoidle()
563 WARN(1, "omap_hwmod: %s: offset struct for sysconfig not provided in class\n", oh->name); in _set_module_autoidle()
567 autoidle_shift = oh->class->sysc->sysc_fields->autoidle_shift; in _set_module_autoidle()
590 static void _set_idle_ioring_wakeup(struct omap_hwmod *oh, bool set_wake) in _set_idle_ioring_wakeup() argument
597 if (!oh->mux || !oh->mux->enabled) in _set_idle_ioring_wakeup()
600 for (j = 0; j < oh->mux->nr_pads_dynamic; j++) { in _set_idle_ioring_wakeup()
601 pad = oh->mux->pads_dynamic[j]; in _set_idle_ioring_wakeup()
617 if (change && oh->_state == _HWMOD_STATE_IDLE) in _set_idle_ioring_wakeup()
618 omap_hwmod_mux(oh->mux, _HWMOD_STATE_IDLE); in _set_idle_ioring_wakeup()
628 static int _enable_wakeup(struct omap_hwmod *oh, u32 *v) in _enable_wakeup() argument
630 if (!oh->class->sysc || in _enable_wakeup()
631 !((oh->class->sysc->sysc_flags & SYSC_HAS_ENAWAKEUP) || in _enable_wakeup()
632 (oh->class->sysc->idlemodes & SIDLE_SMART_WKUP) || in _enable_wakeup()
633 (oh->class->sysc->idlemodes & MSTANDBY_SMART_WKUP))) in _enable_wakeup()
636 if (!oh->class->sysc->sysc_fields) { in _enable_wakeup()
637 WARN(1, "omap_hwmod: %s: offset struct for sysconfig not provided in class\n", oh->name); in _enable_wakeup()
641 if (oh->class->sysc->sysc_flags & SYSC_HAS_ENAWAKEUP) in _enable_wakeup()
642 *v |= 0x1 << oh->class->sysc->sysc_fields->enwkup_shift; in _enable_wakeup()
644 if (oh->class->sysc->idlemodes & SIDLE_SMART_WKUP) in _enable_wakeup()
645 _set_slave_idlemode(oh, HWMOD_IDLEMODE_SMART_WKUP, v); in _enable_wakeup()
646 if (oh->class->sysc->idlemodes & MSTANDBY_SMART_WKUP) in _enable_wakeup()
647 _set_master_standbymode(oh, HWMOD_IDLEMODE_SMART_WKUP, v); in _enable_wakeup()
661 static int _disable_wakeup(struct omap_hwmod *oh, u32 *v) in _disable_wakeup() argument
663 if (!oh->class->sysc || in _disable_wakeup()
664 !((oh->class->sysc->sysc_flags & SYSC_HAS_ENAWAKEUP) || in _disable_wakeup()
665 (oh->class->sysc->idlemodes & SIDLE_SMART_WKUP) || in _disable_wakeup()
666 (oh->class->sysc->idlemodes & MSTANDBY_SMART_WKUP))) in _disable_wakeup()
669 if (!oh->class->sysc->sysc_fields) { in _disable_wakeup()
670 WARN(1, "omap_hwmod: %s: offset struct for sysconfig not provided in class\n", oh->name); in _disable_wakeup()
674 if (oh->class->sysc->sysc_flags & SYSC_HAS_ENAWAKEUP) in _disable_wakeup()
675 *v &= ~(0x1 << oh->class->sysc->sysc_fields->enwkup_shift); in _disable_wakeup()
677 if (oh->class->sysc->idlemodes & SIDLE_SMART_WKUP) in _disable_wakeup()
678 _set_slave_idlemode(oh, HWMOD_IDLEMODE_SMART, v); in _disable_wakeup()
679 if (oh->class->sysc->idlemodes & MSTANDBY_SMART_WKUP) in _disable_wakeup()
680 _set_master_standbymode(oh, HWMOD_IDLEMODE_SMART, v); in _disable_wakeup()
687 static struct clockdomain *_get_clkdm(struct omap_hwmod *oh) in _get_clkdm() argument
691 if (oh->clkdm) { in _get_clkdm()
692 return oh->clkdm; in _get_clkdm()
693 } else if (oh->_clk) { in _get_clkdm()
694 if (__clk_get_flags(oh->_clk) & CLK_IS_BASIC) in _get_clkdm()
696 clk = to_clk_hw_omap(__clk_get_hw(oh->_clk)); in _get_clkdm()
715 static int _add_initiator_dep(struct omap_hwmod *oh, struct omap_hwmod *init_oh) in _add_initiator_dep() argument
719 clkdm = _get_clkdm(oh); in _add_initiator_dep()
744 static int _del_initiator_dep(struct omap_hwmod *oh, struct omap_hwmod *init_oh) in _del_initiator_dep() argument
748 clkdm = _get_clkdm(oh); in _del_initiator_dep()
768 static int _init_main_clk(struct omap_hwmod *oh) in _init_main_clk() argument
772 if (!oh->main_clk) in _init_main_clk()
775 oh->_clk = clk_get(NULL, oh->main_clk); in _init_main_clk()
776 if (IS_ERR(oh->_clk)) { in _init_main_clk()
778 oh->name, oh->main_clk); in _init_main_clk()
789 clk_prepare(oh->_clk); in _init_main_clk()
791 if (!_get_clkdm(oh)) in _init_main_clk()
793 oh->name, oh->main_clk); in _init_main_clk()
805 static int _init_interface_clks(struct omap_hwmod *oh) in _init_interface_clks() argument
813 p = oh->slave_ports.next; in _init_interface_clks()
815 while (i < oh->slaves_cnt) { in _init_interface_clks()
823 oh->name, os->clk); in _init_interface_clks()
849 static int _init_opt_clks(struct omap_hwmod *oh) in _init_opt_clks() argument
856 for (i = oh->opt_clks_cnt, oc = oh->opt_clks; i > 0; i--, oc++) { in _init_opt_clks()
860 oh->name, oc->clk); in _init_opt_clks()
879 static void _enable_optional_clocks(struct omap_hwmod *oh) in _enable_optional_clocks() argument
884 pr_debug("omap_hwmod: %s: enabling optional clocks\n", oh->name); in _enable_optional_clocks()
886 for (i = oh->opt_clks_cnt, oc = oh->opt_clks; i > 0; i--, oc++) in _enable_optional_clocks()
894 static void _disable_optional_clocks(struct omap_hwmod *oh) in _disable_optional_clocks() argument
899 pr_debug("omap_hwmod: %s: disabling optional clocks\n", oh->name); in _disable_optional_clocks()
901 for (i = oh->opt_clks_cnt, oc = oh->opt_clks; i > 0; i--, oc++) in _disable_optional_clocks()
916 static int _enable_clocks(struct omap_hwmod *oh) in _enable_clocks() argument
922 pr_debug("omap_hwmod: %s: enabling clocks\n", oh->name); in _enable_clocks()
924 if (oh->_clk) in _enable_clocks()
925 clk_enable(oh->_clk); in _enable_clocks()
927 p = oh->slave_ports.next; in _enable_clocks()
929 while (i < oh->slaves_cnt) { in _enable_clocks()
936 if (oh->flags & HWMOD_OPT_CLKS_NEEDED) in _enable_clocks()
937 _enable_optional_clocks(oh); in _enable_clocks()
950 static int _disable_clocks(struct omap_hwmod *oh) in _disable_clocks() argument
956 pr_debug("omap_hwmod: %s: disabling clocks\n", oh->name); in _disable_clocks()
958 if (oh->_clk) in _disable_clocks()
959 clk_disable(oh->_clk); in _disable_clocks()
961 p = oh->slave_ports.next; in _disable_clocks()
963 while (i < oh->slaves_cnt) { in _disable_clocks()
970 if (oh->flags & HWMOD_OPT_CLKS_NEEDED) in _disable_clocks()
971 _disable_optional_clocks(oh); in _disable_clocks()
985 static void _omap4_enable_module(struct omap_hwmod *oh) in _omap4_enable_module() argument
987 if (!oh->clkdm || !oh->prcm.omap4.modulemode) in _omap4_enable_module()
991 oh->name, __func__, oh->prcm.omap4.modulemode); in _omap4_enable_module()
993 omap_cm_module_enable(oh->prcm.omap4.modulemode, in _omap4_enable_module()
994 oh->clkdm->prcm_partition, in _omap4_enable_module()
995 oh->clkdm->cm_inst, oh->prcm.omap4.clkctrl_offs); in _omap4_enable_module()
1007 static int _omap4_wait_target_disable(struct omap_hwmod *oh) in _omap4_wait_target_disable() argument
1009 if (!oh) in _omap4_wait_target_disable()
1012 if (oh->_int_flags & _HWMOD_NO_MPU_PORT || !oh->clkdm) in _omap4_wait_target_disable()
1015 if (oh->flags & HWMOD_NO_IDLEST) in _omap4_wait_target_disable()
1018 return omap_cm_wait_module_idle(oh->clkdm->prcm_partition, in _omap4_wait_target_disable()
1019 oh->clkdm->cm_inst, in _omap4_wait_target_disable()
1020 oh->prcm.omap4.clkctrl_offs, 0); in _omap4_wait_target_disable()
1031 static int _count_mpu_irqs(struct omap_hwmod *oh) in _count_mpu_irqs() argument
1036 if (!oh || !oh->mpu_irqs) in _count_mpu_irqs()
1040 ohii = &oh->mpu_irqs[i++]; in _count_mpu_irqs()
1054 static int _count_sdma_reqs(struct omap_hwmod *oh) in _count_sdma_reqs() argument
1059 if (!oh || !oh->sdma_reqs) in _count_sdma_reqs()
1063 ohdi = &oh->sdma_reqs[i++]; in _count_sdma_reqs()
1109 static int _get_mpu_irq_by_name(struct omap_hwmod *oh, const char *name, in _get_mpu_irq_by_name() argument
1115 if (!oh->mpu_irqs) in _get_mpu_irq_by_name()
1119 while (oh->mpu_irqs[i].irq != -1) { in _get_mpu_irq_by_name()
1120 if (name == oh->mpu_irqs[i].name || in _get_mpu_irq_by_name()
1121 !strcmp(name, oh->mpu_irqs[i].name)) { in _get_mpu_irq_by_name()
1131 *irq = oh->mpu_irqs[i].irq; in _get_mpu_irq_by_name()
1152 static int _get_sdma_req_by_name(struct omap_hwmod *oh, const char *name, in _get_sdma_req_by_name() argument
1158 if (!oh->sdma_reqs) in _get_sdma_req_by_name()
1162 while (oh->sdma_reqs[i].dma_req != -1) { in _get_sdma_req_by_name()
1163 if (name == oh->sdma_reqs[i].name || in _get_sdma_req_by_name()
1164 !strcmp(name, oh->sdma_reqs[i].name)) { in _get_sdma_req_by_name()
1174 *dma = oh->sdma_reqs[i].dma_req; in _get_sdma_req_by_name()
1197 static int _get_addr_space_by_name(struct omap_hwmod *oh, const char *name, in _get_addr_space_by_name() argument
1205 p = oh->slave_ports.next; in _get_addr_space_by_name()
1208 while (i < oh->slaves_cnt) { in _get_addr_space_by_name()
1246 static void __init _save_mpu_port_index(struct omap_hwmod *oh) in _save_mpu_port_index() argument
1252 if (!oh) in _save_mpu_port_index()
1255 oh->_int_flags |= _HWMOD_NO_MPU_PORT; in _save_mpu_port_index()
1257 p = oh->slave_ports.next; in _save_mpu_port_index()
1259 while (i < oh->slaves_cnt) { in _save_mpu_port_index()
1262 oh->_mpu_port = os; in _save_mpu_port_index()
1263 oh->_int_flags &= ~_HWMOD_NO_MPU_PORT; in _save_mpu_port_index()
1284 static struct omap_hwmod_ocp_if *_find_mpu_rt_port(struct omap_hwmod *oh) in _find_mpu_rt_port() argument
1286 if (!oh || oh->_int_flags & _HWMOD_NO_MPU_PORT || oh->slaves_cnt == 0) in _find_mpu_rt_port()
1289 return oh->_mpu_port; in _find_mpu_rt_port()
1299 static struct omap_hwmod_addr_space * __init _find_mpu_rt_addr_space(struct omap_hwmod *oh) in _find_mpu_rt_addr_space() argument
1305 os = _find_mpu_rt_port(oh); in _find_mpu_rt_addr_space()
1329 static void _enable_sysc(struct omap_hwmod *oh) in _enable_sysc() argument
1336 if (!oh->class->sysc) in _enable_sysc()
1345 if (oh->flags & HWMOD_CONTROL_OPT_CLKS_IN_RESET) in _enable_sysc()
1346 _enable_optional_clocks(oh); in _enable_sysc()
1347 _wait_softreset_complete(oh); in _enable_sysc()
1348 if (oh->flags & HWMOD_CONTROL_OPT_CLKS_IN_RESET) in _enable_sysc()
1349 _disable_optional_clocks(oh); in _enable_sysc()
1351 v = oh->_sysc_cache; in _enable_sysc()
1352 sf = oh->class->sysc->sysc_flags; in _enable_sysc()
1354 clkdm = _get_clkdm(oh); in _enable_sysc()
1356 if (oh->flags & HWMOD_SWSUP_SIDLE || in _enable_sysc()
1357 oh->flags & HWMOD_SWSUP_SIDLE_ACT) { in _enable_sysc()
1361 _enable_wakeup(oh, &v); in _enable_sysc()
1362 if (oh->class->sysc->idlemodes & SIDLE_SMART_WKUP) in _enable_sysc()
1373 if (clkdm_act && !(oh->class->sysc->idlemodes & in _enable_sysc()
1377 _set_slave_idlemode(oh, idlemode, &v); in _enable_sysc()
1381 if (oh->flags & HWMOD_FORCE_MSTANDBY) { in _enable_sysc()
1383 } else if (oh->flags & HWMOD_SWSUP_MSTANDBY) { in _enable_sysc()
1387 _enable_wakeup(oh, &v); in _enable_sysc()
1388 if (oh->class->sysc->idlemodes & MSTANDBY_SMART_WKUP) in _enable_sysc()
1393 _set_master_standbymode(oh, idlemode, &v); in _enable_sysc()
1401 if ((oh->flags & HWMOD_SET_DEFAULT_CLOCKACT) && in _enable_sysc()
1403 _set_clockactivity(oh, oh->class->sysc->clockact, &v); in _enable_sysc()
1405 _write_sysconfig(v, oh); in _enable_sysc()
1412 idlemode = (oh->flags & HWMOD_NO_OCP_AUTOIDLE) ? in _enable_sysc()
1414 _set_module_autoidle(oh, idlemode, &v); in _enable_sysc()
1415 _write_sysconfig(v, oh); in _enable_sysc()
1428 static void _idle_sysc(struct omap_hwmod *oh) in _idle_sysc() argument
1433 if (!oh->class->sysc) in _idle_sysc()
1436 v = oh->_sysc_cache; in _idle_sysc()
1437 sf = oh->class->sysc->sysc_flags; in _idle_sysc()
1440 if (oh->flags & HWMOD_SWSUP_SIDLE) { in _idle_sysc()
1444 _enable_wakeup(oh, &v); in _idle_sysc()
1445 if (oh->class->sysc->idlemodes & SIDLE_SMART_WKUP) in _idle_sysc()
1450 _set_slave_idlemode(oh, idlemode, &v); in _idle_sysc()
1454 if ((oh->flags & HWMOD_SWSUP_MSTANDBY) || in _idle_sysc()
1455 (oh->flags & HWMOD_FORCE_MSTANDBY)) { in _idle_sysc()
1459 _enable_wakeup(oh, &v); in _idle_sysc()
1460 if (oh->class->sysc->idlemodes & MSTANDBY_SMART_WKUP) in _idle_sysc()
1465 _set_master_standbymode(oh, idlemode, &v); in _idle_sysc()
1469 if (oh->_sysc_cache != v) in _idle_sysc()
1470 _write_sysconfig(v, oh); in _idle_sysc()
1480 static void _shutdown_sysc(struct omap_hwmod *oh) in _shutdown_sysc() argument
1485 if (!oh->class->sysc) in _shutdown_sysc()
1488 v = oh->_sysc_cache; in _shutdown_sysc()
1489 sf = oh->class->sysc->sysc_flags; in _shutdown_sysc()
1492 _set_slave_idlemode(oh, HWMOD_IDLEMODE_FORCE, &v); in _shutdown_sysc()
1495 _set_master_standbymode(oh, HWMOD_IDLEMODE_FORCE, &v); in _shutdown_sysc()
1498 _set_module_autoidle(oh, 1, &v); in _shutdown_sysc()
1500 _write_sysconfig(v, oh); in _shutdown_sysc()
1511 struct omap_hwmod *oh, *temp_oh; in _lookup() local
1513 oh = NULL; in _lookup()
1517 oh = temp_oh; in _lookup()
1522 return oh; in _lookup()
1533 static int _init_clkdm(struct omap_hwmod *oh) in _init_clkdm() argument
1535 if (!oh->clkdm_name) { in _init_clkdm()
1536 pr_debug("omap_hwmod: %s: missing clockdomain\n", oh->name); in _init_clkdm()
1540 oh->clkdm = clkdm_lookup(oh->clkdm_name); in _init_clkdm()
1541 if (!oh->clkdm) { in _init_clkdm()
1543 oh->name, oh->clkdm_name); in _init_clkdm()
1548 oh->name, oh->clkdm_name); in _init_clkdm()
1563 static int _init_clocks(struct omap_hwmod *oh, void *data) in _init_clocks() argument
1567 if (oh->_state != _HWMOD_STATE_REGISTERED) in _init_clocks()
1570 pr_debug("omap_hwmod: %s: looking up clocks\n", oh->name); in _init_clocks()
1573 ret |= soc_ops.init_clkdm(oh); in _init_clocks()
1575 ret |= _init_main_clk(oh); in _init_clocks()
1576 ret |= _init_interface_clks(oh); in _init_clocks()
1577 ret |= _init_opt_clks(oh); in _init_clocks()
1580 oh->_state = _HWMOD_STATE_CLKS_INITED; in _init_clocks()
1582 pr_warn("omap_hwmod: %s: cannot _init_clocks\n", oh->name); in _init_clocks()
1596 static int _lookup_hardreset(struct omap_hwmod *oh, const char *name, in _lookup_hardreset() argument
1601 for (i = 0; i < oh->rst_lines_cnt; i++) { in _lookup_hardreset()
1602 const char *rst_line = oh->rst_lines[i].name; in _lookup_hardreset()
1604 ohri->rst_shift = oh->rst_lines[i].rst_shift; in _lookup_hardreset()
1605 ohri->st_shift = oh->rst_lines[i].st_shift; in _lookup_hardreset()
1607 oh->name, __func__, rst_line, ohri->rst_shift, in _lookup_hardreset()
1630 static int _assert_hardreset(struct omap_hwmod *oh, const char *name) in _assert_hardreset() argument
1635 if (!oh) in _assert_hardreset()
1641 ret = _lookup_hardreset(oh, name, &ohri); in _assert_hardreset()
1645 ret = soc_ops.assert_hardreset(oh, &ohri); in _assert_hardreset()
1663 static int _deassert_hardreset(struct omap_hwmod *oh, const char *name) in _deassert_hardreset() argument
1669 if (!oh) in _deassert_hardreset()
1675 ret = _lookup_hardreset(oh, name, &ohri); in _deassert_hardreset()
1679 if (oh->clkdm) { in _deassert_hardreset()
1685 hwsup = clkdm_in_hwsup(oh->clkdm); in _deassert_hardreset()
1686 ret = clkdm_hwmod_enable(oh->clkdm, oh); in _deassert_hardreset()
1689 oh->name, oh->clkdm->name, ret); in _deassert_hardreset()
1694 _enable_clocks(oh); in _deassert_hardreset()
1696 soc_ops.enable_module(oh); in _deassert_hardreset()
1698 ret = soc_ops.deassert_hardreset(oh, &ohri); in _deassert_hardreset()
1701 soc_ops.disable_module(oh); in _deassert_hardreset()
1702 _disable_clocks(oh); in _deassert_hardreset()
1705 pr_warn("omap_hwmod: %s: failed to hardreset\n", oh->name); in _deassert_hardreset()
1707 if (oh->clkdm) { in _deassert_hardreset()
1713 clkdm_allow_idle(oh->clkdm); in _deassert_hardreset()
1715 clkdm_hwmod_disable(oh->clkdm, oh); in _deassert_hardreset()
1733 static int _read_hardreset(struct omap_hwmod *oh, const char *name) in _read_hardreset() argument
1738 if (!oh) in _read_hardreset()
1744 ret = _lookup_hardreset(oh, name, &ohri); in _read_hardreset()
1748 return soc_ops.is_hardreset_asserted(oh, &ohri); in _read_hardreset()
1761 static bool _are_all_hardreset_lines_asserted(struct omap_hwmod *oh) in _are_all_hardreset_lines_asserted() argument
1765 if (oh->rst_lines_cnt == 0) in _are_all_hardreset_lines_asserted()
1768 for (i = 0; i < oh->rst_lines_cnt; i++) in _are_all_hardreset_lines_asserted()
1769 if (_read_hardreset(oh, oh->rst_lines[i].name) > 0) in _are_all_hardreset_lines_asserted()
1772 if (oh->rst_lines_cnt == rst_cnt) in _are_all_hardreset_lines_asserted()
1789 static bool _are_any_hardreset_lines_asserted(struct omap_hwmod *oh) in _are_any_hardreset_lines_asserted() argument
1794 for (i = 0; i < oh->rst_lines_cnt && rst_cnt == 0; i++) in _are_any_hardreset_lines_asserted()
1795 if (_read_hardreset(oh, oh->rst_lines[i].name) > 0) in _are_any_hardreset_lines_asserted()
1808 static int _omap4_disable_module(struct omap_hwmod *oh) in _omap4_disable_module() argument
1812 if (!oh->clkdm || !oh->prcm.omap4.modulemode) in _omap4_disable_module()
1819 if (_are_any_hardreset_lines_asserted(oh)) in _omap4_disable_module()
1822 pr_debug("omap_hwmod: %s: %s\n", oh->name, __func__); in _omap4_disable_module()
1824 omap_cm_module_disable(oh->clkdm->prcm_partition, oh->clkdm->cm_inst, in _omap4_disable_module()
1825 oh->prcm.omap4.clkctrl_offs); in _omap4_disable_module()
1827 v = _omap4_wait_target_disable(oh); in _omap4_disable_module()
1830 oh->name); in _omap4_disable_module()
1851 static int _ocp_softreset(struct omap_hwmod *oh) in _ocp_softreset() argument
1857 if (!oh->class->sysc || in _ocp_softreset()
1858 !(oh->class->sysc->sysc_flags & SYSC_HAS_SOFTRESET)) in _ocp_softreset()
1862 if (oh->_state != _HWMOD_STATE_ENABLED) { in _ocp_softreset()
1864 oh->name); in _ocp_softreset()
1869 if (oh->flags & HWMOD_CONTROL_OPT_CLKS_IN_RESET) in _ocp_softreset()
1870 _enable_optional_clocks(oh); in _ocp_softreset()
1872 pr_debug("omap_hwmod: %s: resetting via OCP SOFTRESET\n", oh->name); in _ocp_softreset()
1874 v = oh->_sysc_cache; in _ocp_softreset()
1875 ret = _set_softreset(oh, &v); in _ocp_softreset()
1879 _write_sysconfig(v, oh); in _ocp_softreset()
1881 if (oh->class->sysc->srst_udelay) in _ocp_softreset()
1882 udelay(oh->class->sysc->srst_udelay); in _ocp_softreset()
1884 c = _wait_softreset_complete(oh); in _ocp_softreset()
1887 oh->name, MAX_MODULE_SOFTRESET_WAIT); in _ocp_softreset()
1891 pr_debug("omap_hwmod: %s: softreset in %d usec\n", oh->name, c); in _ocp_softreset()
1894 ret = _clear_softreset(oh, &v); in _ocp_softreset()
1898 _write_sysconfig(v, oh); in _ocp_softreset()
1906 if (oh->flags & HWMOD_CONTROL_OPT_CLKS_IN_RESET) in _ocp_softreset()
1907 _disable_optional_clocks(oh); in _ocp_softreset()
1945 static int _reset(struct omap_hwmod *oh) in _reset() argument
1949 pr_debug("omap_hwmod: %s: resetting\n", oh->name); in _reset()
1951 if (oh->class->reset) { in _reset()
1952 r = oh->class->reset(oh); in _reset()
1954 if (oh->rst_lines_cnt > 0) { in _reset()
1955 for (i = 0; i < oh->rst_lines_cnt; i++) in _reset()
1956 _assert_hardreset(oh, oh->rst_lines[i].name); in _reset()
1959 r = _ocp_softreset(oh); in _reset()
1965 _set_dmadisable(oh); in _reset()
1972 if (oh->class->sysc) { in _reset()
1973 _update_sysc_cache(oh); in _reset()
1974 _enable_sysc(oh); in _reset()
2012 static void _omap4_update_context_lost(struct omap_hwmod *oh) in _omap4_update_context_lost() argument
2014 if (oh->prcm.omap4.flags & HWMOD_OMAP4_NO_CONTEXT_LOSS_BIT) in _omap4_update_context_lost()
2017 if (!prm_was_any_context_lost_old(oh->clkdm->pwrdm.ptr->prcm_partition, in _omap4_update_context_lost()
2018 oh->clkdm->pwrdm.ptr->prcm_offs, in _omap4_update_context_lost()
2019 oh->prcm.omap4.context_offs)) in _omap4_update_context_lost()
2022 oh->prcm.omap4.context_lost_counter++; in _omap4_update_context_lost()
2023 prm_clear_context_loss_flags_old(oh->clkdm->pwrdm.ptr->prcm_partition, in _omap4_update_context_lost()
2024 oh->clkdm->pwrdm.ptr->prcm_offs, in _omap4_update_context_lost()
2025 oh->prcm.omap4.context_offs); in _omap4_update_context_lost()
2034 static int _omap4_get_context_lost(struct omap_hwmod *oh) in _omap4_get_context_lost() argument
2036 return oh->prcm.omap4.context_lost_counter; in _omap4_get_context_lost()
2048 static int _enable_preprogram(struct omap_hwmod *oh) in _enable_preprogram() argument
2050 if (!oh->class->enable_preprogram) in _enable_preprogram()
2053 return oh->class->enable_preprogram(oh); in _enable_preprogram()
2064 static int _enable(struct omap_hwmod *oh) in _enable() argument
2069 pr_debug("omap_hwmod: %s: enabling\n", oh->name); in _enable()
2076 if (oh->_int_flags & _HWMOD_SKIP_ENABLE) { in _enable()
2082 if (oh->mux) in _enable()
2083 omap_hwmod_mux(oh->mux, _HWMOD_STATE_ENABLED); in _enable()
2085 oh->_int_flags &= ~_HWMOD_SKIP_ENABLE; in _enable()
2089 if (oh->_state != _HWMOD_STATE_INITIALIZED && in _enable()
2090 oh->_state != _HWMOD_STATE_IDLE && in _enable()
2091 oh->_state != _HWMOD_STATE_DISABLED) { in _enable()
2093 oh->name); in _enable()
2106 if (_are_all_hardreset_lines_asserted(oh)) in _enable()
2110 if (oh->mux && (!oh->mux->enabled || in _enable()
2111 ((oh->_state == _HWMOD_STATE_IDLE) && in _enable()
2112 oh->mux->pads_dynamic))) { in _enable()
2113 omap_hwmod_mux(oh->mux, _HWMOD_STATE_ENABLED); in _enable()
2115 } else if (oh->flags & HWMOD_RECONFIG_IO_CHAIN) { in _enable()
2119 _add_initiator_dep(oh, mpu_oh); in _enable()
2121 if (oh->clkdm) { in _enable()
2127 hwsup = clkdm_in_hwsup(oh->clkdm) && in _enable()
2128 !clkdm_missing_idle_reporting(oh->clkdm); in _enable()
2129 r = clkdm_hwmod_enable(oh->clkdm, oh); in _enable()
2132 oh->name, oh->clkdm->name, r); in _enable()
2137 _enable_clocks(oh); in _enable()
2139 soc_ops.enable_module(oh); in _enable()
2140 if (oh->flags & HWMOD_BLOCK_WFI) in _enable()
2144 soc_ops.update_context_lost(oh); in _enable()
2146 r = (soc_ops.wait_target_ready) ? soc_ops.wait_target_ready(oh) : in _enable()
2153 if (oh->clkdm && hwsup) in _enable()
2154 clkdm_allow_idle(oh->clkdm); in _enable()
2156 oh->_state = _HWMOD_STATE_ENABLED; in _enable()
2159 if (oh->class->sysc) { in _enable()
2160 if (!(oh->_int_flags & _HWMOD_SYSCONFIG_LOADED)) in _enable()
2161 _update_sysc_cache(oh); in _enable()
2162 _enable_sysc(oh); in _enable()
2164 r = _enable_preprogram(oh); in _enable()
2167 soc_ops.disable_module(oh); in _enable()
2168 _disable_clocks(oh); in _enable()
2170 oh->name, r); in _enable()
2172 if (oh->clkdm) in _enable()
2173 clkdm_hwmod_disable(oh->clkdm, oh); in _enable()
2187 static int _idle(struct omap_hwmod *oh) in _idle() argument
2189 if (oh->flags & HWMOD_NO_IDLE) { in _idle()
2190 oh->_int_flags |= _HWMOD_SKIP_ENABLE; in _idle()
2194 pr_debug("omap_hwmod: %s: idling\n", oh->name); in _idle()
2196 if (oh->_state != _HWMOD_STATE_ENABLED) { in _idle()
2198 oh->name); in _idle()
2202 if (_are_all_hardreset_lines_asserted(oh)) in _idle()
2205 if (oh->class->sysc) in _idle()
2206 _idle_sysc(oh); in _idle()
2207 _del_initiator_dep(oh, mpu_oh); in _idle()
2209 if (oh->flags & HWMOD_BLOCK_WFI) in _idle()
2212 soc_ops.disable_module(oh); in _idle()
2220 _disable_clocks(oh); in _idle()
2221 if (oh->clkdm) in _idle()
2222 clkdm_hwmod_disable(oh->clkdm, oh); in _idle()
2225 if (oh->mux && oh->mux->pads_dynamic) { in _idle()
2226 omap_hwmod_mux(oh->mux, _HWMOD_STATE_IDLE); in _idle()
2228 } else if (oh->flags & HWMOD_RECONFIG_IO_CHAIN) { in _idle()
2232 oh->_state = _HWMOD_STATE_IDLE; in _idle()
2246 static int _shutdown(struct omap_hwmod *oh) in _shutdown() argument
2251 if (oh->_state != _HWMOD_STATE_IDLE && in _shutdown()
2252 oh->_state != _HWMOD_STATE_ENABLED) { in _shutdown()
2254 oh->name); in _shutdown()
2258 if (_are_all_hardreset_lines_asserted(oh)) in _shutdown()
2261 pr_debug("omap_hwmod: %s: disabling\n", oh->name); in _shutdown()
2263 if (oh->class->pre_shutdown) { in _shutdown()
2264 prev_state = oh->_state; in _shutdown()
2265 if (oh->_state == _HWMOD_STATE_IDLE) in _shutdown()
2266 _enable(oh); in _shutdown()
2267 ret = oh->class->pre_shutdown(oh); in _shutdown()
2270 _idle(oh); in _shutdown()
2275 if (oh->class->sysc) { in _shutdown()
2276 if (oh->_state == _HWMOD_STATE_IDLE) in _shutdown()
2277 _enable(oh); in _shutdown()
2278 _shutdown_sysc(oh); in _shutdown()
2282 if (oh->_state == _HWMOD_STATE_ENABLED) { in _shutdown()
2283 _del_initiator_dep(oh, mpu_oh); in _shutdown()
2285 if (oh->flags & HWMOD_BLOCK_WFI) in _shutdown()
2288 soc_ops.disable_module(oh); in _shutdown()
2289 _disable_clocks(oh); in _shutdown()
2290 if (oh->clkdm) in _shutdown()
2291 clkdm_hwmod_disable(oh->clkdm, oh); in _shutdown()
2295 for (i = 0; i < oh->rst_lines_cnt; i++) in _shutdown()
2296 _assert_hardreset(oh, oh->rst_lines[i].name); in _shutdown()
2299 if (oh->mux) in _shutdown()
2300 omap_hwmod_mux(oh->mux, _HWMOD_STATE_DISABLED); in _shutdown()
2302 oh->_state = _HWMOD_STATE_DISABLED; in _shutdown()
2308 struct omap_hwmod *oh) in of_dev_find_hwmod() argument
2322 if (!strcmp(p, oh->name)) { in of_dev_find_hwmod()
2324 np->name, i, oh->name); in of_dev_find_hwmod()
2344 struct omap_hwmod *oh, in of_dev_hwmod_lookup() argument
2351 res = of_dev_find_hwmod(np, oh); in of_dev_hwmod_lookup()
2362 res = of_dev_hwmod_lookup(np0, oh, &i, &fc); in of_dev_hwmod_lookup()
2393 static int __init _init_mpu_rt_base(struct omap_hwmod *oh, void *data, in _init_mpu_rt_base() argument
2399 if (!oh) in _init_mpu_rt_base()
2402 _save_mpu_port_index(oh); in _init_mpu_rt_base()
2405 if (!oh->class->sysc) in _init_mpu_rt_base()
2409 if (oh->_int_flags & _HWMOD_NO_MPU_PORT) in _init_mpu_rt_base()
2412 mem = _find_mpu_rt_addr_space(oh); in _init_mpu_rt_base()
2415 oh->name); in _init_mpu_rt_base()
2419 pr_err("omap_hwmod: %s: no dt node\n", oh->name); in _init_mpu_rt_base()
2423 va_start = of_iomap(np, index + oh->mpu_rt_idx); in _init_mpu_rt_base()
2430 pr_err("omap_hwmod: %s: Could not ioremap\n", oh->name); in _init_mpu_rt_base()
2433 oh->name, index, np->full_name); in _init_mpu_rt_base()
2438 oh->name, va_start); in _init_mpu_rt_base()
2440 oh->_mpu_rt_va = va_start; in _init_mpu_rt_base()
2457 static int __init _init(struct omap_hwmod *oh, void *data) in _init() argument
2462 if (oh->_state != _HWMOD_STATE_REGISTERED) in _init()
2472 r = of_dev_hwmod_lookup(bus, oh, &index, &np); in _init()
2474 pr_debug("omap_hwmod: %s missing dt data\n", oh->name); in _init()
2477 oh->name, np->name); in _init()
2480 r = _init_mpu_rt_base(oh, NULL, index, np); in _init()
2483 oh->name); in _init()
2487 r = _init_clocks(oh, NULL); in _init()
2489 WARN(1, "omap_hwmod: %s: couldn't init clocks\n", oh->name); in _init()
2495 oh->flags |= HWMOD_INIT_NO_RESET; in _init()
2497 oh->flags |= HWMOD_INIT_NO_IDLE; in _init()
2499 oh->flags |= HWMOD_NO_IDLE; in _init()
2502 oh->_state = _HWMOD_STATE_INITIALIZED; in _init()
2515 static void __init _setup_iclk_autoidle(struct omap_hwmod *oh) in _setup_iclk_autoidle() argument
2520 if (oh->_state != _HWMOD_STATE_INITIALIZED) in _setup_iclk_autoidle()
2523 p = oh->slave_ports.next; in _setup_iclk_autoidle()
2525 while (i < oh->slaves_cnt) { in _setup_iclk_autoidle()
2550 static int __init _setup_reset(struct omap_hwmod *oh) in _setup_reset() argument
2554 if (oh->_state != _HWMOD_STATE_INITIALIZED) in _setup_reset()
2557 if (oh->flags & HWMOD_EXT_OPT_MAIN_CLK) in _setup_reset()
2560 if (oh->rst_lines_cnt == 0) { in _setup_reset()
2561 r = _enable(oh); in _setup_reset()
2564 oh->name, oh->_state); in _setup_reset()
2569 if (!(oh->flags & HWMOD_INIT_NO_RESET)) in _setup_reset()
2570 r = _reset(oh); in _setup_reset()
2611 static void __init _setup_postsetup(struct omap_hwmod *oh) in _setup_postsetup() argument
2615 if (oh->rst_lines_cnt > 0) in _setup_postsetup()
2618 postsetup_state = oh->_postsetup_state; in _setup_postsetup()
2626 if ((oh->flags & (HWMOD_INIT_NO_IDLE | HWMOD_NO_IDLE)) && in _setup_postsetup()
2628 oh->_int_flags |= _HWMOD_SKIP_ENABLE; in _setup_postsetup()
2633 _idle(oh); in _setup_postsetup()
2635 _shutdown(oh); in _setup_postsetup()
2638 oh->name, postsetup_state); in _setup_postsetup()
2659 static int __init _setup(struct omap_hwmod *oh, void *data) in _setup() argument
2661 if (oh->_state != _HWMOD_STATE_INITIALIZED) in _setup()
2664 if (oh->parent_hwmod) { in _setup()
2667 r = _enable(oh->parent_hwmod); in _setup()
2669 oh->name, oh->parent_hwmod->name); in _setup()
2672 _setup_iclk_autoidle(oh); in _setup()
2674 if (!_setup_reset(oh)) in _setup()
2675 _setup_postsetup(oh); in _setup()
2677 if (oh->parent_hwmod) { in _setup()
2680 postsetup_state = oh->parent_hwmod->_postsetup_state; in _setup()
2683 _idle(oh->parent_hwmod); in _setup()
2685 _shutdown(oh->parent_hwmod); in _setup()
2688 oh->parent_hwmod->name, postsetup_state); in _setup()
2711 static int __init _register(struct omap_hwmod *oh) in _register() argument
2713 if (!oh || !oh->name || !oh->class || !oh->class->name || in _register()
2714 (oh->_state != _HWMOD_STATE_UNKNOWN)) in _register()
2717 pr_debug("omap_hwmod: %s: registering\n", oh->name); in _register()
2719 if (_lookup(oh->name)) in _register()
2722 list_add_tail(&oh->node, &omap_hwmod_list); in _register()
2724 INIT_LIST_HEAD(&oh->master_ports); in _register()
2725 INIT_LIST_HEAD(&oh->slave_ports); in _register()
2726 spin_lock_init(&oh->_lock); in _register()
2727 lockdep_set_class(&oh->_lock, &oh->hwmod_key); in _register()
2729 oh->_state = _HWMOD_STATE_REGISTERED; in _register()
2735 if (!strcmp(oh->name, MPU_INITIATOR_NAME)) in _register()
2736 mpu_oh = oh; in _register()
2901 static int _omap2xxx_3xxx_wait_target_ready(struct omap_hwmod *oh) in _omap2xxx_3xxx_wait_target_ready() argument
2903 if (!oh) in _omap2xxx_3xxx_wait_target_ready()
2906 if (oh->flags & HWMOD_NO_IDLEST) in _omap2xxx_3xxx_wait_target_ready()
2909 if (!_find_mpu_rt_port(oh)) in _omap2xxx_3xxx_wait_target_ready()
2914 return omap_cm_wait_module_ready(0, oh->prcm.omap2.module_offs, in _omap2xxx_3xxx_wait_target_ready()
2915 oh->prcm.omap2.idlest_reg_id, in _omap2xxx_3xxx_wait_target_ready()
2916 oh->prcm.omap2.idlest_idle_bit); in _omap2xxx_3xxx_wait_target_ready()
2928 static int _omap4_wait_target_ready(struct omap_hwmod *oh) in _omap4_wait_target_ready() argument
2930 if (!oh) in _omap4_wait_target_ready()
2933 if (oh->flags & HWMOD_NO_IDLEST || !oh->clkdm) in _omap4_wait_target_ready()
2936 if (!_find_mpu_rt_port(oh)) in _omap4_wait_target_ready()
2941 return omap_cm_wait_module_ready(oh->clkdm->prcm_partition, in _omap4_wait_target_ready()
2942 oh->clkdm->cm_inst, in _omap4_wait_target_ready()
2943 oh->prcm.omap4.clkctrl_offs, 0); in _omap4_wait_target_ready()
2957 static int _omap2_assert_hardreset(struct omap_hwmod *oh, in _omap2_assert_hardreset() argument
2961 oh->prcm.omap2.module_offs, 0); in _omap2_assert_hardreset()
2975 static int _omap2_deassert_hardreset(struct omap_hwmod *oh, in _omap2_deassert_hardreset() argument
2979 oh->prcm.omap2.module_offs, 0, 0); in _omap2_deassert_hardreset()
2994 static int _omap2_is_hardreset_asserted(struct omap_hwmod *oh, in _omap2_is_hardreset_asserted() argument
2998 oh->prcm.omap2.module_offs, 0); in _omap2_is_hardreset_asserted()
3013 static int _omap4_assert_hardreset(struct omap_hwmod *oh, in _omap4_assert_hardreset() argument
3016 if (!oh->clkdm) in _omap4_assert_hardreset()
3020 oh->clkdm->pwrdm.ptr->prcm_partition, in _omap4_assert_hardreset()
3021 oh->clkdm->pwrdm.ptr->prcm_offs, in _omap4_assert_hardreset()
3022 oh->prcm.omap4.rstctrl_offs); in _omap4_assert_hardreset()
3037 static int _omap4_deassert_hardreset(struct omap_hwmod *oh, in _omap4_deassert_hardreset() argument
3040 if (!oh->clkdm) in _omap4_deassert_hardreset()
3045 oh->name, ohri->name); in _omap4_deassert_hardreset()
3047 oh->clkdm->pwrdm.ptr->prcm_partition, in _omap4_deassert_hardreset()
3048 oh->clkdm->pwrdm.ptr->prcm_offs, in _omap4_deassert_hardreset()
3049 oh->prcm.omap4.rstctrl_offs, in _omap4_deassert_hardreset()
3050 oh->prcm.omap4.rstctrl_offs + in _omap4_deassert_hardreset()
3066 static int _omap4_is_hardreset_asserted(struct omap_hwmod *oh, in _omap4_is_hardreset_asserted() argument
3069 if (!oh->clkdm) in _omap4_is_hardreset_asserted()
3073 oh->clkdm->pwrdm.ptr-> in _omap4_is_hardreset_asserted()
3075 oh->clkdm->pwrdm.ptr->prcm_offs, in _omap4_is_hardreset_asserted()
3076 oh->prcm.omap4.rstctrl_offs); in _omap4_is_hardreset_asserted()
3091 static int _am33xx_deassert_hardreset(struct omap_hwmod *oh, in _am33xx_deassert_hardreset() argument
3095 oh->clkdm->pwrdm.ptr->prcm_partition, in _am33xx_deassert_hardreset()
3096 oh->clkdm->pwrdm.ptr->prcm_offs, in _am33xx_deassert_hardreset()
3097 oh->prcm.omap4.rstctrl_offs, in _am33xx_deassert_hardreset()
3098 oh->prcm.omap4.rstst_offs); in _am33xx_deassert_hardreset()
3103 u32 omap_hwmod_read(struct omap_hwmod *oh, u16 reg_offs) in omap_hwmod_read() argument
3105 if (oh->flags & HWMOD_16BIT_REG) in omap_hwmod_read()
3106 return readw_relaxed(oh->_mpu_rt_va + reg_offs); in omap_hwmod_read()
3108 return readl_relaxed(oh->_mpu_rt_va + reg_offs); in omap_hwmod_read()
3111 void omap_hwmod_write(u32 v, struct omap_hwmod *oh, u16 reg_offs) in omap_hwmod_write() argument
3113 if (oh->flags & HWMOD_16BIT_REG) in omap_hwmod_write()
3114 writew_relaxed(v, oh->_mpu_rt_va + reg_offs); in omap_hwmod_write()
3116 writel_relaxed(v, oh->_mpu_rt_va + reg_offs); in omap_hwmod_write()
3128 int omap_hwmod_softreset(struct omap_hwmod *oh) in omap_hwmod_softreset() argument
3133 if (!oh || !(oh->_sysc_cache)) in omap_hwmod_softreset()
3136 v = oh->_sysc_cache; in omap_hwmod_softreset()
3137 ret = _set_softreset(oh, &v); in omap_hwmod_softreset()
3140 _write_sysconfig(v, oh); in omap_hwmod_softreset()
3142 ret = _clear_softreset(oh, &v); in omap_hwmod_softreset()
3145 _write_sysconfig(v, oh); in omap_hwmod_softreset()
3160 struct omap_hwmod *oh; in omap_hwmod_lookup() local
3165 oh = _lookup(name); in omap_hwmod_lookup()
3167 return oh; in omap_hwmod_lookup()
3182 int omap_hwmod_for_each(int (*fn)(struct omap_hwmod *oh, void *data), in omap_hwmod_for_each() argument
3252 static void __init _ensure_mpu_hwmod_is_setup(struct omap_hwmod *oh) in _ensure_mpu_hwmod_is_setup() argument
3257 else if (mpu_oh->_state == _HWMOD_STATE_REGISTERED && oh != mpu_oh) in _ensure_mpu_hwmod_is_setup()
3274 struct omap_hwmod *oh; in omap_hwmod_setup_one() local
3278 oh = _lookup(oh_name); in omap_hwmod_setup_one()
3279 if (!oh) { in omap_hwmod_setup_one()
3284 _ensure_mpu_hwmod_is_setup(oh); in omap_hwmod_setup_one()
3286 _init(oh, NULL); in omap_hwmod_setup_one()
3287 _setup(oh, NULL); in omap_hwmod_setup_one()
3318 int omap_hwmod_enable(struct omap_hwmod *oh) in omap_hwmod_enable() argument
3323 if (!oh) in omap_hwmod_enable()
3326 spin_lock_irqsave(&oh->_lock, flags); in omap_hwmod_enable()
3327 r = _enable(oh); in omap_hwmod_enable()
3328 spin_unlock_irqrestore(&oh->_lock, flags); in omap_hwmod_enable()
3340 int omap_hwmod_idle(struct omap_hwmod *oh) in omap_hwmod_idle() argument
3344 if (!oh) in omap_hwmod_idle()
3347 spin_lock_irqsave(&oh->_lock, flags); in omap_hwmod_idle()
3348 _idle(oh); in omap_hwmod_idle()
3349 spin_unlock_irqrestore(&oh->_lock, flags); in omap_hwmod_idle()
3362 int omap_hwmod_shutdown(struct omap_hwmod *oh) in omap_hwmod_shutdown() argument
3366 if (!oh) in omap_hwmod_shutdown()
3369 spin_lock_irqsave(&oh->_lock, flags); in omap_hwmod_shutdown()
3370 _shutdown(oh); in omap_hwmod_shutdown()
3371 spin_unlock_irqrestore(&oh->_lock, flags); in omap_hwmod_shutdown()
3396 int omap_hwmod_count_resources(struct omap_hwmod *oh, unsigned long flags) in omap_hwmod_count_resources() argument
3401 ret += _count_mpu_irqs(oh); in omap_hwmod_count_resources()
3404 ret += _count_sdma_reqs(oh); in omap_hwmod_count_resources()
3409 struct list_head *p = oh->slave_ports.next; in omap_hwmod_count_resources()
3411 while (i < oh->slaves_cnt) { in omap_hwmod_count_resources()
3430 int omap_hwmod_fill_resources(struct omap_hwmod *oh, struct resource *res) in omap_hwmod_fill_resources() argument
3439 mpu_irqs_cnt = _count_mpu_irqs(oh); in omap_hwmod_fill_resources()
3443 if (oh->xlate_irq) in omap_hwmod_fill_resources()
3444 irq = oh->xlate_irq((oh->mpu_irqs + i)->irq); in omap_hwmod_fill_resources()
3446 irq = (oh->mpu_irqs + i)->irq; in omap_hwmod_fill_resources()
3447 (res + r)->name = (oh->mpu_irqs + i)->name; in omap_hwmod_fill_resources()
3454 sdma_reqs_cnt = _count_sdma_reqs(oh); in omap_hwmod_fill_resources()
3456 (res + r)->name = (oh->sdma_reqs + i)->name; in omap_hwmod_fill_resources()
3457 (res + r)->start = (oh->sdma_reqs + i)->dma_req; in omap_hwmod_fill_resources()
3458 (res + r)->end = (oh->sdma_reqs + i)->dma_req; in omap_hwmod_fill_resources()
3463 p = oh->slave_ports.next; in omap_hwmod_fill_resources()
3466 while (i < oh->slaves_cnt) { in omap_hwmod_fill_resources()
3492 int omap_hwmod_fill_dma_resources(struct omap_hwmod *oh, struct resource *res) in omap_hwmod_fill_dma_resources() argument
3497 sdma_reqs_cnt = _count_sdma_reqs(oh); in omap_hwmod_fill_dma_resources()
3499 (res + r)->name = (oh->sdma_reqs + i)->name; in omap_hwmod_fill_dma_resources()
3500 (res + r)->start = (oh->sdma_reqs + i)->dma_req; in omap_hwmod_fill_dma_resources()
3501 (res + r)->end = (oh->sdma_reqs + i)->dma_req; in omap_hwmod_fill_dma_resources()
3531 int omap_hwmod_get_resource_byname(struct omap_hwmod *oh, unsigned int type, in omap_hwmod_get_resource_byname() argument
3538 if (!oh || !rsrc) in omap_hwmod_get_resource_byname()
3542 r = _get_mpu_irq_by_name(oh, name, &irq); in omap_hwmod_get_resource_byname()
3549 r = _get_sdma_req_by_name(oh, name, &dma); in omap_hwmod_get_resource_byname()
3556 r = _get_addr_space_by_name(oh, name, &pa_start, &pa_end); in omap_hwmod_get_resource_byname()
3583 struct powerdomain *omap_hwmod_get_pwrdm(struct omap_hwmod *oh) in omap_hwmod_get_pwrdm() argument
3590 if (!oh) in omap_hwmod_get_pwrdm()
3593 if (oh->clkdm) in omap_hwmod_get_pwrdm()
3594 return oh->clkdm->pwrdm.ptr; in omap_hwmod_get_pwrdm()
3596 if (oh->_clk) { in omap_hwmod_get_pwrdm()
3597 c = oh->_clk; in omap_hwmod_get_pwrdm()
3599 oi = _find_mpu_rt_port(oh); in omap_hwmod_get_pwrdm()
3622 void __iomem *omap_hwmod_get_mpu_rt_va(struct omap_hwmod *oh) in omap_hwmod_get_mpu_rt_va() argument
3624 if (!oh) in omap_hwmod_get_mpu_rt_va()
3627 if (oh->_int_flags & _HWMOD_NO_MPU_PORT) in omap_hwmod_get_mpu_rt_va()
3630 if (oh->_state == _HWMOD_STATE_UNKNOWN) in omap_hwmod_get_mpu_rt_va()
3633 return oh->_mpu_rt_va; in omap_hwmod_get_mpu_rt_va()
3654 int omap_hwmod_enable_wakeup(struct omap_hwmod *oh) in omap_hwmod_enable_wakeup() argument
3659 spin_lock_irqsave(&oh->_lock, flags); in omap_hwmod_enable_wakeup()
3661 if (oh->class->sysc && in omap_hwmod_enable_wakeup()
3662 (oh->class->sysc->sysc_flags & SYSC_HAS_ENAWAKEUP)) { in omap_hwmod_enable_wakeup()
3663 v = oh->_sysc_cache; in omap_hwmod_enable_wakeup()
3664 _enable_wakeup(oh, &v); in omap_hwmod_enable_wakeup()
3665 _write_sysconfig(v, oh); in omap_hwmod_enable_wakeup()
3668 _set_idle_ioring_wakeup(oh, true); in omap_hwmod_enable_wakeup()
3669 spin_unlock_irqrestore(&oh->_lock, flags); in omap_hwmod_enable_wakeup()
3687 int omap_hwmod_disable_wakeup(struct omap_hwmod *oh) in omap_hwmod_disable_wakeup() argument
3692 spin_lock_irqsave(&oh->_lock, flags); in omap_hwmod_disable_wakeup()
3694 if (oh->class->sysc && in omap_hwmod_disable_wakeup()
3695 (oh->class->sysc->sysc_flags & SYSC_HAS_ENAWAKEUP)) { in omap_hwmod_disable_wakeup()
3696 v = oh->_sysc_cache; in omap_hwmod_disable_wakeup()
3697 _disable_wakeup(oh, &v); in omap_hwmod_disable_wakeup()
3698 _write_sysconfig(v, oh); in omap_hwmod_disable_wakeup()
3701 _set_idle_ioring_wakeup(oh, false); in omap_hwmod_disable_wakeup()
3702 spin_unlock_irqrestore(&oh->_lock, flags); in omap_hwmod_disable_wakeup()
3719 int omap_hwmod_assert_hardreset(struct omap_hwmod *oh, const char *name) in omap_hwmod_assert_hardreset() argument
3724 if (!oh) in omap_hwmod_assert_hardreset()
3727 spin_lock_irqsave(&oh->_lock, flags); in omap_hwmod_assert_hardreset()
3728 ret = _assert_hardreset(oh, name); in omap_hwmod_assert_hardreset()
3729 spin_unlock_irqrestore(&oh->_lock, flags); in omap_hwmod_assert_hardreset()
3746 int omap_hwmod_deassert_hardreset(struct omap_hwmod *oh, const char *name) in omap_hwmod_deassert_hardreset() argument
3751 if (!oh) in omap_hwmod_deassert_hardreset()
3754 spin_lock_irqsave(&oh->_lock, flags); in omap_hwmod_deassert_hardreset()
3755 ret = _deassert_hardreset(oh, name); in omap_hwmod_deassert_hardreset()
3756 spin_unlock_irqrestore(&oh->_lock, flags); in omap_hwmod_deassert_hardreset()
3774 int (*fn)(struct omap_hwmod *oh, in omap_hwmod_for_each_by_class() argument
3815 int omap_hwmod_set_postsetup_state(struct omap_hwmod *oh, u8 state) in omap_hwmod_set_postsetup_state() argument
3820 if (!oh) in omap_hwmod_set_postsetup_state()
3828 spin_lock_irqsave(&oh->_lock, flags); in omap_hwmod_set_postsetup_state()
3830 if (oh->_state != _HWMOD_STATE_REGISTERED) { in omap_hwmod_set_postsetup_state()
3835 oh->_postsetup_state = state; in omap_hwmod_set_postsetup_state()
3839 spin_unlock_irqrestore(&oh->_lock, flags); in omap_hwmod_set_postsetup_state()
3855 int omap_hwmod_get_context_loss_count(struct omap_hwmod *oh) in omap_hwmod_get_context_loss_count() argument
3861 return soc_ops.get_context_lost(oh); in omap_hwmod_get_context_loss_count()
3863 pwrdm = omap_hwmod_get_pwrdm(oh); in omap_hwmod_get_context_loss_count()
3922 const char *omap_hwmod_get_main_clk(struct omap_hwmod *oh) in omap_hwmod_get_main_clk() argument
3924 if (!oh) in omap_hwmod_get_main_clk()
3927 return oh->main_clk; in omap_hwmod_get_main_clk()