Lines Matching +full:no +full:- +full:idle +full:- +full:on +full:- +full:init

1 // SPDX-License-Identifier: GPL-2.0-only
5 * Copyright (C) 2009-2011 Nokia Corporation
6 * Copyright (C) 2011-2012 Texas Instruments, Inc.
15 * ------------
21 * TI's documentation, on-chip devices are referred to as "OMAP
26 * Most of the address and data flow between modules is via OCP-based
28 * interconnects that distribute the hardware clock tree, handle idle
30 * various pads or balls on the OMAP package.
32 * OMAP hwmod provides a consistent way to describe the on-chip
36 * to reset, enable, idle, and disable these hardware blocks. And
42 * -----------
54 * +-------------------------------+
57 * +-------------------------------+
61 * +-------------------------------+
62 * | OMAP core-driver integration |
63 * |(arch/arm/mach-omap2/devices.c)|
64 * +-------------------------------+
66 * | (../plat-omap/omap_device.c) |
67 * +-------------------------------+
68 * ----> | omap_hwmod code/data | <-----
69 * | (../mach-omap2/omap_hwmod*) |
70 * +-------------------------------+
73 * +-------------------------------+
75 * Device drivers should not contain any OMAP-specific code or data in
82 * The OMAP hwmod code also will attempt to reset and idle all on-chip
84 * completely self-reliant and independent from bootloaders. This is
90 * ---------------------------
98 * the IDLE state to save power, or in the case of a critical system
102 * directly to move the module between the IDLE, ENABLED, and DISABLED
103 * states, as needed. This is done during both the PM idle loop, and
108 * ----------
110 * - OMAP2420 Multimedia Processor Silicon Revision 2.1.1, 2.2 (SWPU064)
111 * - OMAP2430 Multimedia Device POP Silicon Revision 2.1 (SWPU090)
112 * - OMAP34xx Multimedia Device Silicon Revision 3.1 (SWPU108)
113 * - OMAP4430 Multimedia Device Silicon Revision 1.0 (SWPU140)
114 * - Open Core Protocol Specification 2.2
117 * - handle IO mapping
118 * - bus throughput & module latency measurement code
131 #include <linux/clk-provider.h>
143 #include <linux/platform_data/ti-sysc.h>
145 #include <dt-bindings/bus/ti-sysc.h>
174 * omap_hwmod_ocp_if record (master->slave and slave->master)
180 * status registers: 4 bytes on OMAP4
190 * struct clkctrl_provider - clkctrl provider mapping data
208 * struct omap_hwmod_reset - IP specific reset functions
222 * struct omap_hwmod_soc_ops - fn ptrs for some SoC-specific operations
247 /* soc_ops: adapts the omap_hwmod code to the currently-booted SoC */
263 * _update_sysc_cache - return the module OCP_SYSCONFIG register, keep copy
267 * struct omap_hwmod for later use. Returns -EINVAL if the hwmod has no
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()
274 return -EINVAL; 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()
288 * _write_sysconfig - write a value to the module's OCP_SYSCONFIG register
293 * one. No return value.
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()
329 * the @oh hwmod. Does not write to the hardware. Returns -EINVAL
338 if (!oh->class->sysc || in _set_master_standbymode()
339 !(oh->class->sysc->sysc_flags & SYSC_HAS_MIDLEMODE)) in _set_master_standbymode()
340 return -EINVAL; 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()
344 return -EINVAL; in _set_master_standbymode()
347 mstandby_shift = oh->class->sysc->sysc_fields->midle_shift; in _set_master_standbymode()
362 * Update the slave idle mode bits in @v to be @idlemode for the @oh
363 * hwmod. Does not write to the hardware. Returns -EINVAL upon error
371 if (!oh->class->sysc || in _set_slave_idlemode()
372 !(oh->class->sysc->sysc_flags & SYSC_HAS_SIDLEMODE)) in _set_slave_idlemode()
373 return -EINVAL; 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()
377 return -EINVAL; in _set_slave_idlemode()
380 sidle_shift = oh->class->sysc->sysc_fields->sidle_shift; in _set_slave_idlemode()
396 * @oh hwmod. Used for additional powersaving on some modules. Does
397 * not write to the hardware. Returns -EINVAL upon error or 0 upon
405 if (!oh->class->sysc || in _set_clockactivity()
406 !(oh->class->sysc->sysc_flags & SYSC_HAS_CLOCKACTIVITY)) in _set_clockactivity()
407 return -EINVAL; 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()
411 return -EINVAL; in _set_clockactivity()
414 clkact_shift = oh->class->sysc->sysc_fields->clkact_shift; in _set_clockactivity()
428 * Set the SOFTRESET bit in @v for hwmod @oh. Returns -EINVAL upon
435 if (!oh->class->sysc || in _set_softreset()
436 !(oh->class->sysc->sysc_flags & SYSC_HAS_SOFTRESET)) in _set_softreset()
437 return -EINVAL; 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()
441 return -EINVAL; in _set_softreset()
444 softrst_mask = (0x1 << oh->class->sysc->sysc_fields->srst_shift); in _set_softreset()
456 * Clear the SOFTRESET bit in @v for hwmod @oh. Returns -EINVAL upon
463 if (!oh->class->sysc || in _clear_softreset()
464 !(oh->class->sysc->sysc_flags & SYSC_HAS_SOFTRESET)) in _clear_softreset()
465 return -EINVAL; in _clear_softreset()
467 if (!oh->class->sysc->sysc_fields) { in _clear_softreset()
470 oh->name); in _clear_softreset()
471 return -EINVAL; in _clear_softreset()
474 softrst_mask = (0x1 << oh->class->sysc->sysc_fields->srst_shift); in _clear_softreset()
482 * _wait_softreset_complete - wait for an OCP softreset to complete
483 * @oh: struct omap_hwmod * to wait on
487 * _ocp_softreset()) or by hardware upon returning from off-mode (one
497 sysc = oh->class->sysc; in _wait_softreset_complete()
499 if (sysc->sysc_flags & SYSS_HAS_RESET_STATUS && sysc->syss_offs > 0) in _wait_softreset_complete()
500 omap_test_timeout((omap_hwmod_read(oh, sysc->syss_offs) in _wait_softreset_complete()
503 else if (sysc->sysc_flags & SYSC_HAS_RESET_STATUS) { in _wait_softreset_complete()
504 softrst_mask = (0x1 << sysc->sysc_fields->srst_shift); in _wait_softreset_complete()
505 omap_test_timeout(!(omap_hwmod_read(oh, sysc->sysc_offs) in _wait_softreset_complete()
517 * The DMADISABLE bit is a semi-automatic bit present in sysconfig register
522 * Set the DMADISABLE bit in @v for hwmod @oh. Returns -EINVAL upon
530 if (!oh->class->sysc || in _set_dmadisable()
531 !(oh->class->sysc->sysc_flags & SYSC_HAS_DMADISABLE)) in _set_dmadisable()
532 return -EINVAL; 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()
536 return -EINVAL; in _set_dmadisable()
539 /* clocks must be on for this operation */ 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()
542 return -EINVAL; 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()
565 * exact function of this bit varies on a per-module basis. This
566 * function does not write to the hardware. Returns -EINVAL upon
575 if (!oh->class->sysc || in _set_module_autoidle()
576 !(oh->class->sysc->sysc_flags & SYSC_HAS_AUTOIDLE)) in _set_module_autoidle()
577 return -EINVAL; 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()
581 return -EINVAL; in _set_module_autoidle()
584 autoidle_shift = oh->class->sysc->sysc_fields->autoidle_shift; in _set_module_autoidle()
597 * Allow the hardware module @oh to send wakeups. Returns -EINVAL
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()
606 return -EINVAL; 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()
610 return -EINVAL; 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()
618 if (oh->class->sysc->idlemodes & MSTANDBY_SMART_WKUP) in _enable_wakeup()
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()
639 return clk->clkdm; in _get_clkdm()
645 * _add_initiator_dep: prevent @oh from smart-idling while @init_oh is active
648 * Prevent the hardware module @oh from entering idle while the
652 * initiator and the module). Only applies to modules in smart-idle
654 * 0 without doing anything. Otherwise, returns -EINVAL upon error or
665 return -EINVAL; in _add_initiator_dep()
667 if (clkdm && clkdm->flags & CLKDM_NO_AUTODEPS) in _add_initiator_dep()
674 * _del_initiator_dep: allow @oh to smart-idle even if @init_oh is active
677 * Allow the hardware module @oh to enter idle while the hardare
680 * be accessed by the IVA, there should be no sleepdep between the IVA
681 * initiator and the module). Only applies to modules in smart-idle
683 * 0 without doing anything. Returns -EINVAL upon error or passes
694 return -EINVAL; in _del_initiator_dep()
696 if (clkdm && clkdm->flags & CLKDM_NO_AUTODEPS) in _del_initiator_dep()
716 return -ENOMEM; in _setup_clkctrl_provider()
718 provider->node = np; in _setup_clkctrl_provider()
720 provider->num_addrs = in _setup_clkctrl_provider()
723 provider->addr = in _setup_clkctrl_provider()
724 memblock_alloc(sizeof(void *) * provider->num_addrs, in _setup_clkctrl_provider()
726 if (!provider->addr) in _setup_clkctrl_provider()
727 return -ENOMEM; in _setup_clkctrl_provider()
729 provider->size = in _setup_clkctrl_provider()
730 memblock_alloc(sizeof(u32) * provider->num_addrs, in _setup_clkctrl_provider()
732 if (!provider->size) in _setup_clkctrl_provider()
733 return -ENOMEM; in _setup_clkctrl_provider()
735 for (i = 0; i < provider->num_addrs; i++) { in _setup_clkctrl_provider()
737 provider->addr[i] = (u32)of_translate_address(np, addrp); in _setup_clkctrl_provider()
738 provider->size[i] = size; in _setup_clkctrl_provider()
739 pr_debug("%s: %pOF: %x...%x\n", __func__, np, provider->addr[i], in _setup_clkctrl_provider()
740 provider->addr[i] + provider->size[i]); in _setup_clkctrl_provider()
743 list_add(&provider->link, &clkctrl_providers); in _setup_clkctrl_provider()
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()
787 pr_debug("%s: %s: addr=%x\n", __func__, oh->name, addr); in _lookup_clkctrl_clk()
792 for (i = 0; i < provider->num_addrs; i++) { in _lookup_clkctrl_clk()
793 if (provider->addr[i] <= addr && in _lookup_clkctrl_clk()
794 provider->addr[i] + provider->size[i] > addr) { in _lookup_clkctrl_clk()
797 clkspec.np = provider->node; in _lookup_clkctrl_clk()
799 clkspec.args[0] = addr - provider->addr[0]; in _lookup_clkctrl_clk()
805 __func__, oh->name, clk, in _lookup_clkctrl_clk()
806 clkspec.args[0], provider->node); in _lookup_clkctrl_clk()
817 * _init_main_clk - get a struct clk * for the hwmod's main functional clk
822 * or a main_clk is present. Returns 0 on success or -EINVAL on error.
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()
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()
847 return -EINVAL; in _init_main_clk()
850 * HACK: This needs a re-visit once clk_prepare() is implemented in _init_main_clk()
851 * to do something meaningful. Today its just a no-op. in _init_main_clk()
857 clk_prepare(oh->_clk); in _init_main_clk()
861 oh->name, oh->main_clk); in _init_main_clk()
867 * _init_interface_clks - get a struct clk * for the hwmod's interface clks
871 * clock pointers. Returns 0 on success or -EINVAL on error.
879 list_for_each_entry(os, &oh->slave_ports, node) { in _init_interface_clks()
880 if (!os->clk) in _init_interface_clks()
883 c = clk_get(NULL, os->clk); in _init_interface_clks()
886 oh->name, os->clk); in _init_interface_clks()
887 ret = -EINVAL; in _init_interface_clks()
890 os->_clk = c; in _init_interface_clks()
892 * HACK: This needs a re-visit once clk_prepare() is implemented in _init_interface_clks()
893 * to do something meaningful. Today its just a no-op. in _init_interface_clks()
899 clk_prepare(os->_clk); in _init_interface_clks()
906 * _init_opt_clk - get a struct clk * for the hwmod's optional clocks
910 * clock pointers. Returns 0 on success or -EINVAL on error.
919 for (i = oh->opt_clks_cnt, oc = oh->opt_clks; i > 0; i--, oc++) { in _init_opt_clks()
920 c = clk_get(NULL, oc->clk); in _init_opt_clks()
923 oh->name, oc->clk); in _init_opt_clks()
924 ret = -EINVAL; in _init_opt_clks()
927 oc->_clk = c; in _init_opt_clks()
929 * HACK: This needs a re-visit once clk_prepare() is implemented in _init_opt_clks()
930 * to do something meaningful. Today its just a no-op. in _init_opt_clks()
936 clk_prepare(oc->_clk); in _init_opt_clks()
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()
950 if (oc->_clk) { in _enable_optional_clocks()
951 pr_debug("omap_hwmod: enable %s:%s\n", oc->role, in _enable_optional_clocks()
952 __clk_get_name(oc->_clk)); in _enable_optional_clocks()
953 clk_enable(oc->_clk); in _enable_optional_clocks()
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()
965 if (oc->_clk) { in _disable_optional_clocks()
966 pr_debug("omap_hwmod: disable %s:%s\n", oc->role, in _disable_optional_clocks()
967 __clk_get_name(oc->_clk)); in _disable_optional_clocks()
968 clk_disable(oc->_clk); in _disable_optional_clocks()
973 * _enable_clocks - enable hwmod main clock and interface clocks
977 * on the hwmod @oh. Returns 0.
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()
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()
992 if (os->_clk && (os->flags & OCPIF_SWSUP_IDLE)) { in _enable_clocks()
993 omap2_clk_deny_idle(os->_clk); in _enable_clocks()
994 clk_enable(os->_clk); in _enable_clocks()
1004 * _omap4_clkctrl_managed_by_clkfwk - true if clkctrl managed by clock framework
1009 if (oh->prcm.omap4.flags & HWMOD_OMAP4_CLKFWK_CLKCTR_CLOCK) in _omap4_clkctrl_managed_by_clkfwk()
1016 * _omap4_has_clkctrl_clock - returns true if a module has clkctrl clock
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()
1032 * _disable_clocks - disable hwmod main clock and interface clocks
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()
1047 if (os->_clk && (os->flags & OCPIF_SWSUP_IDLE)) { in _disable_clocks()
1048 clk_disable(os->_clk); in _disable_clocks()
1049 omap2_clk_allow_idle(os->_clk); in _disable_clocks()
1053 if (oh->flags & HWMOD_OPT_CLKS_NEEDED) in _disable_clocks()
1062 * _omap4_enable_module - enable CLKCTRL modulemode on OMAP4
1066 * No return value.
1070 if (!oh->clkdm || !oh->prcm.omap4.modulemode || 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()
1083 * _omap4_wait_target_disable - wait for a module to be disabled on OMAP4
1086 * Wait for a module @oh to enter slave idle. Returns 0 if the module
1088 * slave idle; otherwise, pass along the return value of the
1094 return -EINVAL; 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()
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()
1114 * _save_mpu_port_index - find and save the index to @oh's MPU port
1119 * Intended to be called during hwmod registration only. No return
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()
1132 if (os->user & OCP_USER_MPU) { 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()
1143 * _find_mpu_rt_port - return omap_hwmod_ocp_if accessible by the MPU
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()
1164 * _enable_sysc - try to bring a module out of idle via OCP_SYSCONFIG
1169 * Usually this means placing the module into smart-idle mode and
1170 * smart-standby, but if there is a bug in the automatic idle handling
1171 * for the IP block, it may need to be placed into the force-idle or
1172 * no-idle variants of these modes. No return value.
1181 if (!oh->class->sysc) in _enable_sysc()
1187 * (off-mode for example), and the drivers require the in _enable_sysc()
1190 if (oh->flags & HWMOD_CONTROL_OPT_CLKS_IN_RESET) in _enable_sysc()
1193 if (oh->flags & HWMOD_CONTROL_OPT_CLKS_IN_RESET) in _enable_sysc()
1196 v = oh->_sysc_cache; in _enable_sysc()
1197 sf = oh->class->sysc->sysc_flags; in _enable_sysc()
1201 if (oh->flags & HWMOD_SWSUP_SIDLE || in _enable_sysc()
1202 oh->flags & HWMOD_SWSUP_SIDLE_ACT) { in _enable_sysc()
1207 if (oh->class->sysc->idlemodes & SIDLE_SMART_WKUP) in _enable_sysc()
1215 * 32k sync timer. Force them to idle! in _enable_sysc()
1217 clkdm_act = (clkdm && clkdm->flags & CLKDM_ACTIVE_WITH_MPU); in _enable_sysc()
1218 if (clkdm_act && !(oh->class->sysc->idlemodes & in _enable_sysc()
1226 if (oh->flags & HWMOD_FORCE_MSTANDBY) { in _enable_sysc()
1228 } else if (oh->flags & HWMOD_SWSUP_MSTANDBY) { in _enable_sysc()
1233 if (oh->class->sysc->idlemodes & MSTANDBY_SMART_WKUP) in _enable_sysc()
1246 if ((oh->flags & HWMOD_SET_DEFAULT_CLOCKACT) && in _enable_sysc()
1254 * Setting this will not have any impact on the other modules. in _enable_sysc()
1257 idlemode = (oh->flags & HWMOD_NO_OCP_AUTOIDLE) ? in _enable_sysc()
1265 * _idle_sysc - try to put a module into idle via OCP_SYSCONFIG
1269 * idle; otherwise, configure it for smart-idle. If module is marked
1271 * configure it for smart-standby. No return value.
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()
1290 if (oh->class->sysc->idlemodes & SIDLE_SMART_WKUP) in _idle_sysc()
1299 if ((oh->flags & HWMOD_SWSUP_MSTANDBY) || in _idle_sysc()
1300 (oh->flags & HWMOD_FORCE_MSTANDBY)) { in _idle_sysc()
1305 if (oh->class->sysc->idlemodes & MSTANDBY_SMART_WKUP) in _idle_sysc()
1314 if (oh->_sysc_cache != v) in _idle_sysc()
1319 * _shutdown_sysc - force a module into idle via OCP_SYSCONFIG
1322 * Force the module into slave idle and master suspend. No return
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()
1349 * _lookup - find an omap_hwmod by name
1361 if (!strcmp(name, temp_oh->name)) { in _lookup()
1371 * _init_clkdm - look up a clockdomain name, store pointer in omap_hwmod
1376 * Return -EINVAL if the clkdm_name lookup failed.
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()
1399 * _init_clocks - clk_get() all clocks associated with this hwmod. Retrieve as
1405 * Resolves all clock names embedded in the hwmod. Returns 0 on
1406 * success, or a negative error code on failure.
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()
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()
1433 * _lookup_hardreset - fill register bit info for this hwmod/reset line
1439 * input name. Return -ENOENT if not found.
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()
1453 ohri->st_shift); in _lookup_hardreset()
1459 return -ENOENT; in _lookup_hardreset()
1463 * _assert_hardreset - assert the HW reset line of submodules
1470 * Returns -EINVAL if @oh is null, -ENOSYS if we have no way of
1471 * asserting the hardreset line on the currently-booted SoC, or passes
1478 int ret = -EINVAL; in _assert_hardreset()
1481 return -EINVAL; in _assert_hardreset()
1484 return -ENOSYS; in _assert_hardreset()
1496 * _deassert_hardreset - deassert the HW reset line of submodules contained
1503 * Returns -EINVAL if @oh is null, -ENOSYS if we have no way of
1504 * deasserting the hardreset line on the currently-booted SoC, or passes
1511 int ret = -EINVAL; in _deassert_hardreset()
1514 return -EINVAL; in _deassert_hardreset()
1517 return -ENOSYS; 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()
1548 if (ret == -EBUSY) 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()
1565 * _read_hardreset - read the HW reset line state of submodules
1570 * Return the state of the reset line. Returns -EINVAL if @oh is
1571 * null, -ENOSYS if we have no way of reading the hardreset line
1572 * status on the currently-booted SoC, or passes along the return
1579 int ret = -EINVAL; in _read_hardreset()
1582 return -EINVAL; in _read_hardreset()
1585 return -ENOSYS; in _read_hardreset()
1595 * _are_all_hardreset_lines_asserted - return true if the @oh is hard-reset
1599 * Otherwise, if part of @oh is out hardreset or if no hardreset lines
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()
1622 * _are_any_hardreset_lines_asserted - return true if any part of @oh is
1623 * hard-reset
1627 * return true. Otherwise, if no hardreset lines associated with @oh
1628 * are asserted, or if @oh has no hardreset lines, then return false.
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()
1645 * _omap4_disable_module - enable CLKCTRL modulemode on OMAP4
1655 if (!oh->clkdm || !oh->prcm.omap4.modulemode || in _omap4_disable_module()
1657 return -EINVAL; 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()
1674 oh->name); in _omap4_disable_module()
1680 * _ocp_softreset - reset an omap_hwmod via the OCP_SYSCONFIG bit
1684 * enabled for this to work. Returns -ENOENT if the hwmod cannot be
1685 * reset this way, -EINVAL if the hwmod is in the wrong state,
1686 * -ETIMEDOUT if the module did not reset in time, or 0 upon success.
1701 if (!oh->class->sysc || in _ocp_softreset()
1702 !(oh->class->sysc->sysc_flags & SYSC_HAS_SOFTRESET)) in _ocp_softreset()
1703 return -ENOENT; in _ocp_softreset()
1705 /* clocks must be on for this operation */ in _ocp_softreset()
1706 if (oh->_state != _HWMOD_STATE_ENABLED) { in _ocp_softreset()
1708 oh->name); in _ocp_softreset()
1709 return -EINVAL; in _ocp_softreset()
1713 if (oh->flags & HWMOD_CONTROL_OPT_CLKS_IN_RESET) 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()
1725 if (oh->class->sysc->srst_udelay) in _ocp_softreset()
1726 udelay(oh->class->sysc->srst_udelay); in _ocp_softreset()
1731 oh->name, MAX_MODULE_SOFTRESET_WAIT); in _ocp_softreset()
1732 ret = -ETIMEDOUT; in _ocp_softreset()
1735 pr_debug("omap_hwmod: %s: softreset in %d usec\n", oh->name, c); in _ocp_softreset()
1750 if (oh->flags & HWMOD_CONTROL_OPT_CLKS_IN_RESET) in _ocp_softreset()
1757 * _reset - reset an omap_hwmod
1774 * therefore have no OCP header registers to access. Others (like the
1785 * custom reset function - these must return -EINVAL if the hwmod
1787 * -ETIMEDOUT if the module did not reset in time, or 0 upon success.
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()
1804 if (r == -ENOENT) in _reset()
1816 if (oh->class->sysc) { in _reset()
1825 * _omap4_update_context_lost - increment hwmod context loss counter if
1830 * our in-memory context loss counter, and clear the RM_*_CONTEXT
1831 * bits. No return value.
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()
1850 * _omap4_get_context_lost - get context loss counter for a hwmod
1853 * Returns the in-memory context loss counter for a hwmod.
1857 return oh->prcm.omap4.context_lost_counter; in _omap4_get_context_lost()
1861 * _enable - enable an omap_hwmod
1865 * register target. Returns -EINVAL if the hwmod is in the wrong
1872 pr_debug("omap_hwmod: %s: enabling\n", oh->name); in _enable()
1876 * state at init. 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()
1886 …WARN(1, "omap_hwmod: %s: enabled state can only be entered from initialized, idle, or disabled sta… in _enable()
1887 oh->name); in _enable()
1888 return -EINVAL; in _enable()
1895 * information on what those driver authors need, and until 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()
1923 if (oh->flags & HWMOD_BLOCK_WFI) in _enable()
1930 -EINVAL; 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()
1948 oh->name, r); in _enable()
1950 if (oh->clkdm) in _enable()
1951 clkdm_hwmod_disable(oh->clkdm, oh); in _enable()
1958 * _idle - idle an omap_hwmod
1962 * no further work. Returns -EINVAL if the hwmod is in the wrong
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()
1977 if (oh->_state != _HWMOD_STATE_ENABLED) { in _idle()
1978 WARN(1, "omap_hwmod: %s: idle state can only be entered from enabled state\n", in _idle()
1979 oh->name); in _idle()
1980 return -EINVAL; in _idle()
1983 if (oh->class->sysc) in _idle()
1989 * deny idle the clkdm again since idle was already denied 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()
2001 * The module must be in idle mode before disabling any parents 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()
2018 * _shutdown - shutdown an omap_hwmod
2023 * used by the system. Returns -EINVAL if the hwmod is in the wrong
2034 if (oh->_state != _HWMOD_STATE_IDLE && in _shutdown()
2035 oh->_state != _HWMOD_STATE_ENABLED) { in _shutdown()
2036 WARN(1, "omap_hwmod: %s: disabled state can only be entered from idle, or enabled state\n", in _shutdown()
2037 oh->name); in _shutdown()
2038 return -EINVAL; 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()
2047 ret = oh->class->pre_shutdown(oh); in _shutdown()
2055 if (oh->class->sysc) { in _shutdown()
2056 if (oh->_state == _HWMOD_STATE_IDLE) in _shutdown()
2061 /* clocks and deps are already disabled in idle */ in _shutdown()
2062 if (oh->_state == _HWMOD_STATE_ENABLED) { in _shutdown()
2065 if (oh->flags & HWMOD_BLOCK_WFI) in _shutdown()
2070 if (oh->clkdm) in _shutdown()
2071 clkdm_hwmod_disable(oh->clkdm, oh); in _shutdown()
2073 /* XXX Should this code also force-disable the optional clocks? */ 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()
2091 return -ENODEV; in of_dev_find_hwmod()
2098 if (!strcmp(p, oh->name)) { in of_dev_find_hwmod()
2100 np, i, oh->name); in of_dev_find_hwmod()
2105 return -ENODEV; in of_dev_find_hwmod()
2109 * of_dev_hwmod_lookup - look up needed hwmod from dt blob
2117 * Return: Returns 0 on success, -ENODEV when not found.
2150 return -ENODEV; in of_dev_hwmod_lookup()
2154 * omap_hwmod_fix_mpu_rt_idx - fix up mpu_rt_idx register offsets
2178 error = of_address_to_resource(child, oh->mpu_rt_idx, res); in omap_hwmod_fix_mpu_rt_idx()
2185 * omap_hwmod_parse_module_range - map module IO range from device tree
2207 return -EINVAL; in omap_hwmod_parse_module_range()
2211 return -ENOENT; in omap_hwmod_parse_module_range()
2216 return -EINVAL; in omap_hwmod_parse_module_range()
2219 if (!strncmp("ti,sysc-", name, 8)) in omap_hwmod_parse_module_range()
2223 return -ENOENT; in omap_hwmod_parse_module_range()
2225 error = of_property_read_u32(np, "#address-cells", &nr_addr); in omap_hwmod_parse_module_range()
2227 return -ENOENT; in omap_hwmod_parse_module_range()
2229 error = of_property_read_u32(np, "#size-cells", &nr_size); in omap_hwmod_parse_module_range()
2231 return -ENOENT; in omap_hwmod_parse_module_range()
2234 pr_err("%s: invalid range for %s->%pOFn\n", __func__, in omap_hwmod_parse_module_range()
2235 oh->name, np); in omap_hwmod_parse_module_range()
2236 return -EINVAL; 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()
2252 res->start = base; in omap_hwmod_parse_module_range()
2253 res->end = base + size - 1; in omap_hwmod_parse_module_range()
2254 res->flags = IORESOURCE_MEM; in omap_hwmod_parse_module_range()
2260 * _init_mpu_rt_base - populate the virtual address for a hwmod
2271 * and non-availability of MPU access is not treated as an error.
2273 * Returns 0 on success, -EINVAL if an invalid hwmod is passed, and
2274 * -ENXIO on absent or invalid register target address space.
2284 return -EINVAL; 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()
2294 return -ENXIO; in _init_mpu_rt_base()
2297 pr_err("omap_hwmod: %s: no dt node\n", oh->name); in _init_mpu_rt_base()
2298 return -ENXIO; in _init_mpu_rt_base()
2306 /* No ranges, rely on device reg entry */ 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()
2312 return -ENXIO; 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()
2325 if (of_find_property(np, "ti,no-reset-on-init", NULL)) in parse_module_flags()
2326 oh->flags |= HWMOD_INIT_NO_RESET; in parse_module_flags()
2327 if (of_find_property(np, "ti,no-idle-on-init", NULL)) in parse_module_flags()
2328 oh->flags |= HWMOD_INIT_NO_IDLE; in parse_module_flags()
2329 if (of_find_property(np, "ti,no-idle", NULL)) in parse_module_flags()
2330 oh->flags |= HWMOD_NO_IDLE; in parse_module_flags()
2334 * _init - initialize internal data for the hwmod @oh
2344 * address space is not defined, or -EINVAL upon failure.
2352 if (oh->_state != _HWMOD_STATE_REGISTERED) in _init()
2357 return -ENODEV; in _init()
2361 pr_debug("omap_hwmod: %s missing dt data\n", oh->name); in _init()
2364 oh->name, np); in _init()
2369 oh->name); in _init()
2375 WARN(1, "omap_hwmod: %s: couldn't init clocks\n", oh->name); in _init()
2376 return -EINVAL; in _init()
2388 oh->_state = _HWMOD_STATE_INITIALIZED; in _init()
2394 * _setup_iclk_autoidle - configure an IP block's interface clocks
2399 * the clock code. No return value.
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()
2409 if (!os->_clk) in _setup_iclk_autoidle()
2412 if (os->flags & OCPIF_SWSUP_IDLE) { in _setup_iclk_autoidle()
2420 clk_enable(os->_clk); in _setup_iclk_autoidle()
2428 * _setup_reset - reset an IP block during the setup process
2440 if (oh->_state != _HWMOD_STATE_INITIALIZED) in _setup_reset()
2441 return -EINVAL; in _setup_reset()
2443 if (oh->flags & HWMOD_EXT_OPT_MAIN_CLK) in _setup_reset()
2444 return -EPERM; in _setup_reset()
2446 if (oh->rst_lines_cnt == 0) { in _setup_reset()
2450 oh->name, oh->_state); in _setup_reset()
2451 return -EINVAL; in _setup_reset()
2455 if (!(oh->flags & HWMOD_INIT_NO_RESET)) in _setup_reset()
2462 * _setup_postsetup - transition to the appropriate state after _setup
2465 * Place an IP block represented by @oh into a "post-setup" state --
2466 * either IDLE, ENABLED, or DISABLED. ("post-setup" simply means that
2473 * The IP block stays in this state until a PM runtime-based driver is
2474 * loaded for that IP block. A post-setup state of IDLE is
2475 * appropriate for almost all IP blocks with runtime PM-enabled
2477 * post-setup state of ENABLED is appropriate for kernels with PM
2479 * blocks such as the MPU WDTIMER on kernels without WDTIMER drivers
2480 * included, since the WDTIMER starts running on reset and will reset
2483 * This post-setup mechanism is deprecated. Once all of the OMAP
2492 * has no way of knowing which IP blocks are in use by drivers, and
2495 * No return value.
2501 if (oh->rst_lines_cnt > 0) in _setup_postsetup()
2504 postsetup_state = oh->_postsetup_state; in _setup_postsetup()
2509 * XXX HWMOD_INIT_NO_IDLE does not belong in hwmod data - 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()
2524 oh->name, postsetup_state); in _setup_postsetup()
2530 * _setup - prepare IP block hardware for use
2536 * post-setup state, depending on the type of IP block and applicable
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()
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()
2581 * _register - register a struct omap_hwmod
2584 * Registers the omap_hwmod @oh. Returns -EEXIST if an omap_hwmod
2585 * already has been registered by the same name; -EINVAL if the
2592 * should be marked __initdata and freed after init. This would allow
2593 * unneeded omap_hwmods to be freed on multi-OMAP configurations. Note
2599 if (!oh || !oh->name || !oh->class || !oh->class->name || in _register()
2600 (oh->_state != _HWMOD_STATE_UNKNOWN)) in _register()
2601 return -EINVAL; in _register()
2603 pr_debug("omap_hwmod: %s: registering\n", oh->name); in _register()
2605 if (_lookup(oh->name)) in _register()
2606 return -EEXIST; 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()
2627 * _add_link - add an interconnect between two IP blocks
2631 * specified in @oi->slave to @oi. This code is assumed to run before
2638 pr_debug("omap_hwmod: %s -> %s: adding link\n", oi->master->name, in _add_link()
2639 oi->slave->name); in _add_link()
2641 list_add(&oi->node, &oi->slave->slave_ports); in _add_link()
2642 oi->slave->slaves_cnt++; in _add_link()
2648 * _register_link - register a struct omap_hwmod_ocp_if
2651 * Registers the omap_hwmod_ocp_if record @oi. Returns -EEXIST if it
2652 * has already been registered; -EINVAL if @oi is NULL or if the
2657 * should be marked __initdata and freed after init. This would allow
2658 * unneeded omap_hwmods to be freed on multi-OMAP configurations.
2662 if (!oi || !oi->master || !oi->slave || !oi->user) in _register_link()
2663 return -EINVAL; in _register_link()
2665 if (oi->_int_flags & _OCPIF_INT_FLAGS_REGISTERED) in _register_link()
2666 return -EEXIST; in _register_link()
2669 oi->master->name, oi->slave->name); in _register_link()
2675 if (oi->master->_state != _HWMOD_STATE_REGISTERED) in _register_link()
2676 _register(oi->master); in _register_link()
2678 if (oi->slave->_state != _HWMOD_STATE_REGISTERED) in _register_link()
2679 _register(oi->slave); in _register_link()
2683 oi->_int_flags |= _OCPIF_INT_FLAGS_REGISTERED; in _register_link()
2691 * _omap2xxx_3xxx_wait_target_ready - wait for a module to leave slave idle
2694 * Wait for a module @oh to leave slave idle. Returns 0 if the module
2696 * slave idle; otherwise, pass along the return value of the
2702 return -EINVAL; in _omap2xxx_3xxx_wait_target_ready()
2704 if (oh->flags & HWMOD_NO_IDLEST) 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()
2718 * _omap4_wait_target_ready - wait for a module to leave slave idle
2721 * Wait for a module @oh to leave slave idle. Returns 0 if the module
2723 * slave idle; otherwise, pass along the return value of the
2729 return -EINVAL; in _omap4_wait_target_ready()
2731 if (oh->flags & HWMOD_NO_IDLEST || !oh->clkdm) 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()
2751 * _omap2_assert_hardreset - call OMAP2 PRM hardreset fn with hwmod args
2764 return omap_prm_assert_hardreset(ohri->rst_shift, 0, in _omap2_assert_hardreset()
2765 oh->prcm.omap2.module_offs, 0); in _omap2_assert_hardreset()
2769 * _omap2_deassert_hardreset - call OMAP2 PRM hardreset fn with hwmod args
2782 return omap_prm_deassert_hardreset(ohri->rst_shift, ohri->st_shift, 0, in _omap2_deassert_hardreset()
2783 oh->prcm.omap2.module_offs, 0, 0); in _omap2_deassert_hardreset()
2787 * _omap2_is_hardreset_asserted - call OMAP2 PRM hardreset fn with hwmod args
2801 return omap_prm_is_hardreset_asserted(ohri->st_shift, 0, in _omap2_is_hardreset_asserted()
2802 oh->prcm.omap2.module_offs, 0); in _omap2_is_hardreset_asserted()
2806 * _omap4_assert_hardreset - call OMAP4 PRM hardreset fn with hwmod args
2820 if (!oh->clkdm) in _omap4_assert_hardreset()
2821 return -EINVAL; in _omap4_assert_hardreset()
2823 return omap_prm_assert_hardreset(ohri->rst_shift, 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()
2830 * _omap4_deassert_hardreset - call OMAP4 PRM hardreset fn with hwmod args
2844 if (!oh->clkdm) in _omap4_deassert_hardreset()
2845 return -EINVAL; in _omap4_deassert_hardreset()
2847 if (ohri->st_shift) in _omap4_deassert_hardreset()
2849 oh->name, ohri->name); in _omap4_deassert_hardreset()
2850 return omap_prm_deassert_hardreset(ohri->rst_shift, ohri->rst_shift, 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()
2859 * _omap4_is_hardreset_asserted - call OMAP4 PRM hardreset fn with hwmod args
2873 if (!oh->clkdm) in _omap4_is_hardreset_asserted()
2874 return -EINVAL; in _omap4_is_hardreset_asserted()
2876 return omap_prm_is_hardreset_asserted(ohri->rst_shift, 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()
2884 * _omap4_disable_direct_prcm - disable direct PRCM control for hwmod
2894 return -EINVAL; in _omap4_disable_direct_prcm()
2896 oh->prcm.omap4.flags |= HWMOD_OMAP4_CLKFWK_CLKCTR_CLOCK; in _omap4_disable_direct_prcm()
2902 * _am33xx_deassert_hardreset - call AM33XX PRM hardreset fn with hwmod args
2916 return omap_prm_deassert_hardreset(ohri->rst_shift, ohri->st_shift, in _am33xx_deassert_hardreset()
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()
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()
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()
2942 * omap_hwmod_softreset - reset a module via SYSCONFIG.SOFTRESET bit
2955 if (!oh || !(oh->_sysc_cache)) in omap_hwmod_softreset()
2956 return -EINVAL; in omap_hwmod_softreset()
2958 v = oh->_sysc_cache; in omap_hwmod_softreset()
2974 * omap_hwmod_lookup - look up a registered omap_hwmod by name
2993 * omap_hwmod_for_each - call function for each registered omap_hwmod
2999 * failure. If @fn returns non-zero, the iteration across omap_hwmods
3000 * will stop and the non-zero return value will be passed to the
3011 return -EINVAL; in omap_hwmod_for_each()
3023 * omap_hwmod_register_links - register an array of hwmod links
3028 * listed in @ois that are valid for this chip. Returns -EINVAL if
3030 * -ENOMEM if the link memory area can't be allocated, or 0 upon
3038 return -EINVAL; in omap_hwmod_register_links()
3049 WARN(r && r != -EEXIST, in omap_hwmod_register_links()
3050 "omap_hwmod: _register_link(%s -> %s) returned %d\n", in omap_hwmod_register_links()
3051 ois[i]->master->name, ois[i]->slave->name, r); in omap_hwmod_register_links()
3058 * _ensure_mpu_hwmod_is_setup - ensure the MPU SS hwmod is init'ed and set up
3064 * to the MPU. Intended to be called only by omap_hwmod_setup*(). No
3069 if (!mpu_oh || mpu_oh->_state == _HWMOD_STATE_UNKNOWN) in _ensure_mpu_hwmod_is_setup()
3072 else if (mpu_oh->_state == _HWMOD_STATE_REGISTERED && oh != mpu_oh) in _ensure_mpu_hwmod_is_setup()
3077 * omap_hwmod_setup_one - set up a single hwmod
3078 * @oh_name: const char * name of the already-registered hwmod to set up
3084 * registered omap_hwmod. Also calls _setup() on each hwmod. Returns
3085 * -EINVAL upon error or 0 upon success.
3096 return -EINVAL; in omap_hwmod_setup_one()
3118 * omap_hwmod_check_sysc - check sysc against platform sysc
3127 const struct sysc_regbits *regbits = data->cap->regbits; in omap_hwmod_check_sysc()
3130 regbits->dmadisable_shift, in omap_hwmod_check_sysc()
3131 sysc_fields->dmadisable_shift); in omap_hwmod_check_sysc()
3133 regbits->midle_shift, in omap_hwmod_check_sysc()
3134 sysc_fields->midle_shift); in omap_hwmod_check_sysc()
3136 regbits->sidle_shift, in omap_hwmod_check_sysc()
3137 sysc_fields->sidle_shift); in omap_hwmod_check_sysc()
3139 regbits->clkact_shift, in omap_hwmod_check_sysc()
3140 sysc_fields->clkact_shift); in omap_hwmod_check_sysc()
3142 regbits->enwkup_shift, in omap_hwmod_check_sysc()
3143 sysc_fields->enwkup_shift); in omap_hwmod_check_sysc()
3145 regbits->srst_shift, in omap_hwmod_check_sysc()
3146 sysc_fields->srst_shift); in omap_hwmod_check_sysc()
3148 regbits->autoidle_shift, in omap_hwmod_check_sysc()
3149 sysc_fields->autoidle_shift); in omap_hwmod_check_sysc()
3155 * omap_hwmod_init_regbits - init sysconfig specific register bits
3165 switch (data->cap->type) { in omap_hwmod_init_regbits()
3200 if (!oh->class->sysc->sysc_fields) in omap_hwmod_init_regbits()
3205 return -EINVAL; in omap_hwmod_init_regbits()
3212 * omap_hwmod_init_reg_offs - initialize sysconfig register offsets
3224 *rev_offs = -ENODEV; in omap_hwmod_init_reg_offs()
3228 if (data->offsets[SYSC_REVISION] >= 0) in omap_hwmod_init_reg_offs()
3229 *rev_offs = data->offsets[SYSC_REVISION]; in omap_hwmod_init_reg_offs()
3231 if (data->offsets[SYSC_SYSCONFIG] >= 0) in omap_hwmod_init_reg_offs()
3232 *sysc_offs = data->offsets[SYSC_SYSCONFIG]; in omap_hwmod_init_reg_offs()
3234 if (data->offsets[SYSC_SYSSTATUS] >= 0) in omap_hwmod_init_reg_offs()
3235 *syss_offs = data->offsets[SYSC_SYSSTATUS]; in omap_hwmod_init_reg_offs()
3241 * omap_hwmod_init_sysc_flags - initialize sysconfig features
3252 switch (data->cap->type) { in omap_hwmod_init_sysc_flags()
3255 /* See SYSC_OMAP2_* in include/dt-bindings/bus/ti-sysc.h */ in omap_hwmod_init_sysc_flags()
3256 if (data->cfg->sysc_val & SYSC_OMAP2_CLOCKACTIVITY) in omap_hwmod_init_sysc_flags()
3258 if (data->cfg->sysc_val & SYSC_OMAP2_EMUFREE) in omap_hwmod_init_sysc_flags()
3260 if (data->cfg->sysc_val & SYSC_OMAP2_ENAWAKEUP) in omap_hwmod_init_sysc_flags()
3262 if (data->cfg->sysc_val & SYSC_OMAP2_SOFTRESET) in omap_hwmod_init_sysc_flags()
3264 if (data->cfg->sysc_val & SYSC_OMAP2_AUTOIDLE) in omap_hwmod_init_sysc_flags()
3269 /* See SYSC_OMAP4_* in include/dt-bindings/bus/ti-sysc.h */ in omap_hwmod_init_sysc_flags()
3270 if (data->cfg->sysc_val & SYSC_OMAP4_DMADISABLE) in omap_hwmod_init_sysc_flags()
3272 if (data->cfg->sysc_val & SYSC_OMAP4_FREEEMU) in omap_hwmod_init_sysc_flags()
3274 if (data->cfg->sysc_val & SYSC_OMAP4_SOFTRESET) in omap_hwmod_init_sysc_flags()
3279 /* See SYSC_OMAP3_SR_* in include/dt-bindings/bus/ti-sysc.h */ in omap_hwmod_init_sysc_flags()
3280 if (data->cfg->sysc_val & SYSC_OMAP3_SR_ENAWAKEUP) in omap_hwmod_init_sysc_flags()
3284 if (data->cap->regbits->emufree_shift >= 0) in omap_hwmod_init_sysc_flags()
3286 if (data->cap->regbits->enwkup_shift >= 0) in omap_hwmod_init_sysc_flags()
3288 if (data->cap->regbits->srst_shift >= 0) in omap_hwmod_init_sysc_flags()
3290 if (data->cap->regbits->autoidle_shift >= 0) in omap_hwmod_init_sysc_flags()
3295 if (data->cap->regbits->midle_shift >= 0 && in omap_hwmod_init_sysc_flags()
3296 data->cfg->midlemodes) in omap_hwmod_init_sysc_flags()
3299 if (data->cap->regbits->sidle_shift >= 0 && in omap_hwmod_init_sysc_flags()
3300 data->cfg->sidlemodes) in omap_hwmod_init_sysc_flags()
3303 if (data->cfg->quirks & SYSC_QUIRK_UNCACHED) in omap_hwmod_init_sysc_flags()
3305 if (data->cfg->quirks & SYSC_QUIRK_RESET_STATUS) in omap_hwmod_init_sysc_flags()
3308 if (data->cfg->syss_mask & 1) in omap_hwmod_init_sysc_flags()
3315 * omap_hwmod_init_idlemodes - initialize module idle modes
3318 * @idlemodes: module supported idle modes
3326 if (data->cfg->midlemodes & BIT(SYSC_IDLE_FORCE)) in omap_hwmod_init_idlemodes()
3328 if (data->cfg->midlemodes & BIT(SYSC_IDLE_NO)) in omap_hwmod_init_idlemodes()
3330 if (data->cfg->midlemodes & BIT(SYSC_IDLE_SMART)) in omap_hwmod_init_idlemodes()
3332 if (data->cfg->midlemodes & BIT(SYSC_IDLE_SMART_WKUP)) in omap_hwmod_init_idlemodes()
3335 if (data->cfg->sidlemodes & BIT(SYSC_IDLE_FORCE)) in omap_hwmod_init_idlemodes()
3337 if (data->cfg->sidlemodes & BIT(SYSC_IDLE_NO)) in omap_hwmod_init_idlemodes()
3339 if (data->cfg->sidlemodes & BIT(SYSC_IDLE_SMART)) in omap_hwmod_init_idlemodes()
3341 if (data->cfg->sidlemodes & BIT(SYSC_IDLE_SMART_WKUP)) in omap_hwmod_init_idlemodes()
3348 * omap_hwmod_check_module - check new module against platform data
3367 if (!oh->class->sysc) in omap_hwmod_check_module()
3368 return -ENODEV; in omap_hwmod_check_module()
3370 if (oh->class->sysc->sysc_fields && in omap_hwmod_check_module()
3371 sysc_fields != oh->class->sysc->sysc_fields) in omap_hwmod_check_module()
3374 if (rev_offs != oh->class->sysc->rev_offs) in omap_hwmod_check_module()
3376 oh->class->sysc->rev_offs); in omap_hwmod_check_module()
3377 if (sysc_offs != oh->class->sysc->sysc_offs) in omap_hwmod_check_module()
3379 oh->class->sysc->sysc_offs); in omap_hwmod_check_module()
3380 if (syss_offs != oh->class->sysc->syss_offs) in omap_hwmod_check_module()
3382 oh->class->sysc->syss_offs); in omap_hwmod_check_module()
3384 if (sysc_flags != oh->class->sysc->sysc_flags) in omap_hwmod_check_module()
3386 oh->class->sysc->sysc_flags); in omap_hwmod_check_module()
3388 if (idlemodes != oh->class->sysc->idlemodes) in omap_hwmod_check_module()
3390 oh->class->sysc->idlemodes); in omap_hwmod_check_module()
3392 if (data->cfg->srst_udelay != oh->class->sysc->srst_udelay) in omap_hwmod_check_module()
3394 data->cfg->srst_udelay, in omap_hwmod_check_module()
3395 oh->class->sysc->srst_udelay); in omap_hwmod_check_module()
3401 * omap_hwmod_allocate_module - allocate new module
3412 * Note that the allocations here cannot use devm as ti-sysc can rebind.
3430 return -ENOMEM; in omap_hwmod_allocate_module()
3432 sysc->sysc_fields = sysc_fields; in omap_hwmod_allocate_module()
3433 sysc->rev_offs = rev_offs; in omap_hwmod_allocate_module()
3434 sysc->sysc_offs = sysc_offs; in omap_hwmod_allocate_module()
3435 sysc->syss_offs = syss_offs; in omap_hwmod_allocate_module()
3436 sysc->sysc_flags = sysc_flags; in omap_hwmod_allocate_module()
3437 sysc->idlemodes = idlemodes; in omap_hwmod_allocate_module()
3438 sysc->srst_udelay = data->cfg->srst_udelay; in omap_hwmod_allocate_module()
3440 if (!oh->_mpu_rt_va) { in omap_hwmod_allocate_module()
3441 regs = ioremap(data->module_pa, in omap_hwmod_allocate_module()
3442 data->module_size); in omap_hwmod_allocate_module()
3448 * We may need a new oh->class as the other devices in the same class in omap_hwmod_allocate_module()
3451 if (oh->class->name && strcmp(oh->class->name, data->name)) { in omap_hwmod_allocate_module()
3452 class = kmemdup(oh->class, sizeof(*oh->class), GFP_KERNEL); in omap_hwmod_allocate_module()
3457 if (list_empty(&oh->slave_ports)) { in omap_hwmod_allocate_module()
3465 * on omap24xx and omap3. in omap_hwmod_allocate_module()
3467 oi->slave = oh; in omap_hwmod_allocate_module()
3468 oi->user = OCP_USER_MPU | OCP_USER_SDMA; in omap_hwmod_allocate_module()
3471 spin_lock_irqsave(&oh->_lock, flags); in omap_hwmod_allocate_module()
3473 oh->_mpu_rt_va = regs; in omap_hwmod_allocate_module()
3475 oh->class = class; in omap_hwmod_allocate_module()
3476 oh->class->sysc = sysc; in omap_hwmod_allocate_module()
3480 oh->clkdm = clkdm; in omap_hwmod_allocate_module()
3481 oh->_state = _HWMOD_STATE_INITIALIZED; in omap_hwmod_allocate_module()
3482 oh->_postsetup_state = _HWMOD_STATE_DEFAULT; in omap_hwmod_allocate_module()
3484 spin_unlock_irqrestore(&oh->_lock, flags); in omap_hwmod_allocate_module()
3494 return -ENOMEM; in omap_hwmod_allocate_module()
3519 if (!strncmp(data->name, quirk->match, quirk->len)) { in omap_hwmod_init_reset_quirk()
3520 oh->class->reset = quirk->reset; in omap_hwmod_init_reset_quirk()
3541 * omap_hwmod_init_module - initialize new module
3556 if (!dev || !data || !data->name || !cookie) in omap_hwmod_init_module()
3557 return -EINVAL; in omap_hwmod_init_module()
3559 oh = _lookup(data->name); in omap_hwmod_init_module()
3563 return -ENOMEM; in omap_hwmod_init_module()
3565 oh->name = data->name; in omap_hwmod_init_module()
3566 oh->_state = _HWMOD_STATE_UNKNOWN; in omap_hwmod_init_module()
3567 lockdep_register_key(&oh->hwmod_key); in omap_hwmod_init_module()
3570 oh->prcm.omap4.flags = HWMOD_OMAP4_NO_CONTEXT_LOSS_BIT; in omap_hwmod_init_module()
3572 oh->class = kzalloc(sizeof(*oh->class), GFP_KERNEL); in omap_hwmod_init_module()
3573 if (!oh->class) { in omap_hwmod_init_module()
3575 return -ENOMEM; in omap_hwmod_init_module()
3580 oh->class->name = data->name; in omap_hwmod_init_module()
3586 cookie->data = oh; in omap_hwmod_init_module()
3605 if (data->cfg->quirks & SYSC_QUIRK_NO_IDLE) in omap_hwmod_init_module()
3606 oh->flags |= HWMOD_NO_IDLE; in omap_hwmod_init_module()
3607 if (data->cfg->quirks & SYSC_QUIRK_NO_IDLE_ON_INIT) in omap_hwmod_init_module()
3608 oh->flags |= HWMOD_INIT_NO_IDLE; in omap_hwmod_init_module()
3609 if (data->cfg->quirks & SYSC_QUIRK_NO_RESET_ON_INIT) in omap_hwmod_init_module()
3610 oh->flags |= HWMOD_INIT_NO_RESET; in omap_hwmod_init_module()
3611 if (data->cfg->quirks & SYSC_QUIRK_USE_CLOCKACT) in omap_hwmod_init_module()
3612 oh->flags |= HWMOD_SET_DEFAULT_CLOCKACT; in omap_hwmod_init_module()
3613 if (data->cfg->quirks & SYSC_QUIRK_SWSUP_SIDLE) in omap_hwmod_init_module()
3614 oh->flags |= HWMOD_SWSUP_SIDLE; in omap_hwmod_init_module()
3615 if (data->cfg->quirks & SYSC_QUIRK_SWSUP_SIDLE_ACT) in omap_hwmod_init_module()
3616 oh->flags |= HWMOD_SWSUP_SIDLE_ACT; in omap_hwmod_init_module()
3617 if (data->cfg->quirks & SYSC_QUIRK_SWSUP_MSTANDBY) in omap_hwmod_init_module()
3618 oh->flags |= HWMOD_SWSUP_MSTANDBY; in omap_hwmod_init_module()
3619 if (data->cfg->quirks & SYSC_QUIRK_CLKDM_NOAUTO) in omap_hwmod_init_module()
3620 oh->flags |= HWMOD_CLKDM_NOAUTO; in omap_hwmod_init_module()
3629 cookie->clkdm, rev_offs, in omap_hwmod_init_module()
3635 * omap_hwmod_setup_earlycon_flags - set up flags for early console
3638 * early concole so that hwmod core doesn't reset and keep it in idle
3650 uart = of_get_property(np, "stdout-path", NULL); in omap_hwmod_setup_earlycon_flags()
3657 uart = of_get_property(np->parent, in omap_hwmod_setup_earlycon_flags()
3663 oh->flags |= DEBUG_OMAPUART_FLAGS; in omap_hwmod_setup_earlycon_flags()
3671 * omap_hwmod_setup_all - set up all registered IP blocks
3676 * calls _setup() on each hwmod. Returns 0 upon success.
3696 * omap_hwmod_enable - enable an omap_hwmod
3700 * Returns -EINVAL on error or passes along the return value from _enable().
3708 return -EINVAL; in omap_hwmod_enable()
3710 spin_lock_irqsave(&oh->_lock, flags); in omap_hwmod_enable()
3712 spin_unlock_irqrestore(&oh->_lock, flags); in omap_hwmod_enable()
3718 * omap_hwmod_idle - idle an omap_hwmod
3721 * Idle an omap_hwmod @oh. Intended to be called by omap_device_idle().
3722 * Returns -EINVAL on error or passes along the return value from _idle().
3730 return -EINVAL; in omap_hwmod_idle()
3732 spin_lock_irqsave(&oh->_lock, flags); in omap_hwmod_idle()
3734 spin_unlock_irqrestore(&oh->_lock, flags); in omap_hwmod_idle()
3740 * omap_hwmod_shutdown - shutdown an omap_hwmod
3744 * omap_device_shutdown(). Returns -EINVAL on error or passes along
3753 return -EINVAL; in omap_hwmod_shutdown()
3755 spin_lock_irqsave(&oh->_lock, flags); in omap_hwmod_shutdown()
3757 spin_unlock_irqrestore(&oh->_lock, flags); in omap_hwmod_shutdown()
3767 * omap_hwmod_get_pwrdm - return pointer to this module's main powerdomain
3774 * instead?) Returns NULL on error, or a struct powerdomain * on
3788 if (oh->clkdm) in omap_hwmod_get_pwrdm()
3789 return oh->clkdm->pwrdm.ptr; in omap_hwmod_get_pwrdm()
3791 if (oh->_clk) { in omap_hwmod_get_pwrdm()
3792 c = oh->_clk; in omap_hwmod_get_pwrdm()
3797 c = oi->_clk; in omap_hwmod_get_pwrdm()
3808 clkdm = clk->clkdm; in omap_hwmod_get_pwrdm()
3812 return clkdm->pwrdm.ptr; in omap_hwmod_get_pwrdm()
3816 * omap_hwmod_get_mpu_rt_va - return the module's base address (for the MPU)
3829 if (oh->_int_flags & _HWMOD_NO_MPU_PORT) in omap_hwmod_get_mpu_rt_va()
3832 if (oh->_state == _HWMOD_STATE_UNKNOWN) in omap_hwmod_get_mpu_rt_va()
3835 return oh->_mpu_rt_va; in omap_hwmod_get_mpu_rt_va()
3844 * omap_hwmod_assert_hardreset - assert the HW reset line of submodules
3851 * the IP. Returns -EINVAL if @oh is null or if the operation is not
3852 * yet supported on this OMAP; otherwise, passes along the return value
3861 return -EINVAL; in omap_hwmod_assert_hardreset()
3863 spin_lock_irqsave(&oh->_lock, flags); in omap_hwmod_assert_hardreset()
3865 spin_unlock_irqrestore(&oh->_lock, flags); in omap_hwmod_assert_hardreset()
3871 * omap_hwmod_deassert_hardreset - deassert the HW reset line of submodules
3878 * the IP. Returns -EINVAL if @oh is null or if the operation is not
3879 * yet supported on this OMAP; otherwise, passes along the return value
3888 return -EINVAL; in omap_hwmod_deassert_hardreset()
3890 spin_lock_irqsave(&oh->_lock, flags); in omap_hwmod_deassert_hardreset()
3892 spin_unlock_irqrestore(&oh->_lock, flags); in omap_hwmod_deassert_hardreset()
3898 * omap_hwmod_for_each_by_class - call @fn for each hwmod of class @classname
3906 * value is passed back to the caller. Returns 0 upon success, -EINVAL
3918 return -EINVAL; in omap_hwmod_for_each_by_class()
3924 if (!strcmp(temp_oh->class->name, classname)) { in omap_hwmod_for_each_by_class()
3926 __func__, temp_oh->name); in omap_hwmod_for_each_by_class()
3941 * omap_hwmod_set_postsetup_state - set the post-_setup() state for this hwmod
3948 * -EINVAL if there is a problem with the arguments or if the hwmod is
3957 return -EINVAL; in omap_hwmod_set_postsetup_state()
3962 return -EINVAL; in omap_hwmod_set_postsetup_state()
3964 spin_lock_irqsave(&oh->_lock, flags); in omap_hwmod_set_postsetup_state()
3966 if (oh->_state != _HWMOD_STATE_REGISTERED) { in omap_hwmod_set_postsetup_state()
3967 ret = -EINVAL; in omap_hwmod_set_postsetup_state()
3971 oh->_postsetup_state = state; in omap_hwmod_set_postsetup_state()
3975 spin_unlock_irqrestore(&oh->_lock, flags); in omap_hwmod_set_postsetup_state()
3981 * omap_hwmod_get_context_loss_count - get lost context count
3985 * upon success, or zero if no context loss data is available.
3987 * On OMAP4, this queries the per-hwmod context loss register,
3988 * assuming one exists. If not, or on OMAP2/3, this queries the
4007 * omap_hwmod_init - initialize the hwmod code
4009 * Sets up some function pointers needed by the hwmod code to operate on the
4010 * currently-booted SoC. Intended to be called once during kernel init
4011 * before any hwmods are registered. No return value.
4059 * omap_hwmod_get_main_clk - get pointer to main clock name
4070 return oh->main_clk; in omap_hwmod_get_main_clk()