Lines Matching +full:activate +full:- +full:to +full:- +full:activate

4  * Copyright (C) 2009-2010 Nokia Corporation
17 * to control power management and interconnect properties of their
20 * In the medium- to long-term, this code should either be
21 * a) implemented via arch-specific pointers in platform_data
29 * 1. These functions are intended to be used by device drivers via
31 * omap_device_enable() should be passed to the driver as
46 * pdata->device_enable = omap_device_enable;
49 * 2. Drivers should first check to ensure the function pointer is not null
52 * if (pdata->device_enable)
53 * pdata->device_enable(pdev);
56 * device_shutdown() functions to execute normally.
75 * (device must be reinitialized at this point to use it again)
96 /* These parameters are passed to _omap_device_{de,}activate() */
120 * _omap_device_activate - increase device readiness
122 * @ignore_lat: increase to latency target (0) or full readiness (1)?
129 * backwards in the omap_device_pm_latency table to ensure the
130 * device's maximum wakeup latency is less than or equal to the
137 dev_dbg(&od->pdev->dev, "omap_device: activating\n"); in _omap_device_activate()
139 while (od->pm_lat_level > 0) { in _omap_device_activate()
143 od->pm_lat_level--; in _omap_device_activate()
145 odpl = od->pm_lats + od->pm_lat_level; in _omap_device_activate()
148 (od->dev_wakeup_lat <= od->_dev_wakeup_lat_limit)) in _omap_device_activate()
154 odpl->activate_func(od); in _omap_device_activate()
161 dev_dbg(&od->pdev->dev, in _omap_device_activate()
162 "omap_device: pm_lat %d: activate: elapsed time " in _omap_device_activate()
163 "%llu nsec\n", od->pm_lat_level, act_lat); in _omap_device_activate()
165 if (act_lat > odpl->activate_lat) { in _omap_device_activate()
166 odpl->activate_lat_worst = act_lat; in _omap_device_activate()
167 if (odpl->flags & OMAP_DEVICE_LATENCY_AUTO_ADJUST) { in _omap_device_activate()
168 odpl->activate_lat = act_lat; in _omap_device_activate()
169 dev_dbg(&od->pdev->dev, in _omap_device_activate()
170 "new worst case activate latency " in _omap_device_activate()
172 od->pm_lat_level, act_lat); in _omap_device_activate()
174 dev_warn(&od->pdev->dev, in _omap_device_activate()
175 "activate latency %d " in _omap_device_activate()
177 od->pm_lat_level, act_lat, in _omap_device_activate()
178 odpl->activate_lat); in _omap_device_activate()
181 od->dev_wakeup_lat -= odpl->activate_lat; in _omap_device_activate()
188 * _omap_device_deactivate - decrease device readiness
190 * @ignore_lat: decrease to latency target (0) or full inactivity (1)?
197 * forwards in the omap_device_pm_latency table to ensure the device's
198 * maximum wakeup latency is less than or equal to the requested
205 dev_dbg(&od->pdev->dev, "omap_device: deactivating\n"); in _omap_device_deactivate()
207 while (od->pm_lat_level < od->pm_lats_cnt) { in _omap_device_deactivate()
211 odpl = od->pm_lats + od->pm_lat_level; in _omap_device_deactivate()
214 ((od->dev_wakeup_lat + odpl->activate_lat) > in _omap_device_deactivate()
215 od->_dev_wakeup_lat_limit)) in _omap_device_deactivate()
221 odpl->deactivate_func(od); in _omap_device_deactivate()
228 dev_dbg(&od->pdev->dev, in _omap_device_deactivate()
230 "%llu nsec\n", od->pm_lat_level, deact_lat); in _omap_device_deactivate()
232 if (deact_lat > odpl->deactivate_lat) { in _omap_device_deactivate()
233 odpl->deactivate_lat_worst = deact_lat; in _omap_device_deactivate()
234 if (odpl->flags & OMAP_DEVICE_LATENCY_AUTO_ADJUST) { in _omap_device_deactivate()
235 odpl->deactivate_lat = deact_lat; in _omap_device_deactivate()
236 dev_dbg(&od->pdev->dev, in _omap_device_deactivate()
239 od->pm_lat_level, deact_lat); in _omap_device_deactivate()
241 dev_warn(&od->pdev->dev, in _omap_device_deactivate()
244 od->pm_lat_level, deact_lat, in _omap_device_deactivate()
245 odpl->deactivate_lat); in _omap_device_deactivate()
248 od->dev_wakeup_lat += odpl->activate_lat; in _omap_device_deactivate()
250 od->pm_lat_level++; in _omap_device_deactivate()
265 dev_dbg(&od->pdev->dev, "Creating %s -> %s\n", clk_alias, clk_name); in _add_clkdev()
267 r = clk_get_sys(dev_name(&od->pdev->dev), clk_alias); in _add_clkdev()
269 dev_warn(&od->pdev->dev, in _add_clkdev()
277 dev_err(&od->pdev->dev, in _add_clkdev()
282 l = clkdev_alloc(r, clk_alias, dev_name(&od->pdev->dev)); in _add_clkdev()
284 dev_err(&od->pdev->dev, in _add_clkdev()
293 * _add_hwmod_clocks_clkdev - Add clkdev entry for hwmod optional clocks
300 * form <dev-id=dev_name, con-id=role> if it does not exist already.
305 * This allows drivers to get a pointer to its optional clocks based on its role
316 _add_clkdev(od, "fck", oh->main_clk); in _add_hwmod_clocks_clkdev()
318 for (i = 0; i < oh->opt_clks_cnt; i++) in _add_hwmod_clocks_clkdev()
319 _add_clkdev(od, oh->opt_clks[i].role, oh->opt_clks[i].clk); in _add_hwmod_clocks_clkdev()
326 * omap_device_build_from_dt - build an omap_device with multiple hwmods
327 * @pdev_name: name of the platform_device driver to use
329 * @oh: ptr to the single omap_hwmod that backs this omap_device
330 * @pdata: platform_data ptr to associate with the platform_device
331 * @pdata_len: amount of memory pointed to by @pdata
332 * @pm_lats: pointer to a omap_device_pm_latency array for this device
336 * Function for building an omap_device already registered from device-tree
345 struct device_node *node = pdev->dev.of_node; in omap_device_build_from_dt()
351 dev_warn(&pdev->dev, "No 'hwmods' to build omap_device\n"); in omap_device_build_from_dt()
352 return -ENODEV; in omap_device_build_from_dt()
357 ret = -ENOMEM; in omap_device_build_from_dt()
365 dev_err(&pdev->dev, "Cannot lookup hwmod '%s'\n", in omap_device_build_from_dt()
367 ret = -EINVAL; in omap_device_build_from_dt()
375 dev_err(&pdev->dev, "Cannot allocate omap_device for :%s\n", in omap_device_build_from_dt()
384 pdev->dev.pm_domain = &omap_device_pm_domain; in omap_device_build_from_dt()
399 if (pdev->dev.of_node) in _omap_device_notifier_call()
404 if (pdev->archdata.od) in _omap_device_notifier_call()
405 omap_device_delete(pdev->archdata.od); in _omap_device_notifier_call()
416 * omap_device_get_context_loss_count - get lost context count
437 if (od->hwmods_cnt) in omap_device_get_context_loss_count()
438 ret = omap_hwmod_get_context_loss_count(od->hwmods[0]); in omap_device_get_context_loss_count()
444 * omap_device_count_resources - count number of struct resource entries needed
448 * omap_device @od. Used by omap_device_build_ss() to determine how
449 * much memory to allocate before calling
457 for (i = 0; i < od->hwmods_cnt; i++) in omap_device_count_resources()
458 c += omap_hwmod_count_resources(od->hwmods[i]); in omap_device_count_resources()
461 "hwmods\n", od->pdev->name, c, od->hwmods_cnt); in omap_device_count_resources()
467 * omap_device_fill_resources - fill in array of struct resource
469 * @res: pointer to an array of struct resource to be filled in
471 * Populate one or more empty struct resource pointed to by @res with
477 * omap_hwmod information. Or if platform_device is extended to use
478 * subarchitecture-specific function pointers, the various
480 * functions to get device resources. Hacking around the existing
489 for (i = 0; i < od->hwmods_cnt; i++) { in omap_device_fill_resources()
490 r = omap_hwmod_fill_resources(od->hwmods[i], res); in omap_device_fill_resources()
499 * omap_device_alloc - allocate an omap_device
501 * @oh: ptr to the single omap_hwmod that backs this omap_device
502 * @pdata: platform_data ptr to associate with the platform_device
503 * @pdata_len: amount of memory pointed to by @pdata
504 * @pm_lats: pointer to a omap_device_pm_latency array for this device
517 int ret = -ENOMEM; in omap_device_alloc()
525 ret = -ENOMEM; in omap_device_alloc()
528 od->hwmods_cnt = oh_cnt; in omap_device_alloc()
534 od->hwmods = hwmods; in omap_device_alloc()
535 od->pdev = pdev; in omap_device_alloc()
540 * properly populated by DT, stick to hwmod resources only. in omap_device_alloc()
542 if (pdev->num_resources && pdev->resource) in omap_device_alloc()
543 dev_warn(&pdev->dev, "%s(): resources already allocated %d\n", in omap_device_alloc()
544 __func__, pdev->num_resources); in omap_device_alloc()
548 dev_dbg(&pdev->dev, "%s(): resources allocated from hwmod %d\n", in omap_device_alloc()
568 od->pm_lats_cnt = pm_lats_cnt; in omap_device_alloc()
569 od->pm_lats = kmemdup(pm_lats, in omap_device_alloc()
572 if (!od->pm_lats) in omap_device_alloc()
575 pdev->archdata.od = od; in omap_device_alloc()
578 hwmods[i]->od = od; in omap_device_alloc()
589 dev_err(&pdev->dev, "omap_device: build failed (%d)\n", ret); in omap_device_alloc()
599 od->pdev->archdata.od = NULL; in omap_device_delete()
600 kfree(od->pm_lats); in omap_device_delete()
601 kfree(od->hwmods); in omap_device_delete()
606 * omap_device_build - build and register an omap_device with one omap_hwmod
607 * @pdev_name: name of the platform_device driver to use
609 * @oh: ptr to the single omap_hwmod that backs this omap_device
610 * @pdata: platform_data ptr to associate with the platform_device
611 * @pdata_len: amount of memory pointed to by @pdata
612 * @pm_lats: pointer to a omap_device_pm_latency array for this device
619 * information. Returns ERR_PTR(-EINVAL) if @oh is NULL; otherwise,
631 return ERR_PTR(-EINVAL); in omap_device_build()
639 * omap_device_build_ss - build and register an omap_device with multiple hwmods
640 * @pdev_name: name of the platform_device driver to use
642 * @oh: ptr to the single omap_hwmod that backs this omap_device
643 * @pdata: platform_data ptr to associate with the platform_device
644 * @pdata_len: amount of memory pointed to by @pdata
645 * @pm_lats: pointer to a omap_device_pm_latency array for this device
661 int ret = -ENOMEM; in omap_device_build_ss()
666 return ERR_PTR(-EINVAL); in omap_device_build_ss()
669 return ERR_PTR(-EINVAL); in omap_device_build_ss()
673 ret = -ENOMEM; in omap_device_build_ss()
677 /* Set the dev_name early to allow dev_xxx in omap_device_alloc */ in omap_device_build_ss()
678 if (pdev->id != -1) in omap_device_build_ss()
679 dev_set_name(&pdev->dev, "%s.%d", pdev->name, pdev->id); in omap_device_build_ss()
681 dev_set_name(&pdev->dev, "%s", pdev->name); in omap_device_build_ss()
712 * omap_early_device_register - register an omap_device as an early platform
714 * @od: struct omap_device * to register
765 if (od->flags & OMAP_DEVICE_NO_IDLE_ON_SUSPEND) in _od_suspend_noirq()
773 od->flags |= OMAP_DEVICE_SUSPENDED; in _od_suspend_noirq()
785 if (od->flags & OMAP_DEVICE_NO_IDLE_ON_SUSPEND) in _od_resume_noirq()
788 if ((od->flags & OMAP_DEVICE_SUSPENDED) && in _od_resume_noirq()
790 od->flags &= ~OMAP_DEVICE_SUSPENDED; in _od_resume_noirq()
813 * omap_device_register - register an omap_device with one omap_hwmod
814 * @od: struct omap_device * to register
822 pr_debug("omap_device: %s: registering\n", pdev->name); in omap_device_register()
824 pdev->dev.parent = &omap_device_parent; in omap_device_register()
825 pdev->dev.pm_domain = &omap_device_pm_domain; in omap_device_register()
833 * omap_device_enable - fully activate an omap_device
834 * @od: struct omap_device * to activate
837 * to be accessible and ready to operate. This generally involves
841 * enable clocks, etc. Returns -EINVAL if called when the omap_device
852 if (od->_state == OMAP_DEVICE_STATE_ENABLED) { in omap_device_enable()
853 dev_warn(&pdev->dev, in omap_device_enable()
855 __func__, od->_state); in omap_device_enable()
856 return -EINVAL; in omap_device_enable()
860 if (od->_state == OMAP_DEVICE_STATE_UNKNOWN) in omap_device_enable()
861 od->pm_lat_level = od->pm_lats_cnt; in omap_device_enable()
865 od->dev_wakeup_lat = 0; in omap_device_enable()
866 od->_dev_wakeup_lat_limit = UINT_MAX; in omap_device_enable()
867 od->_state = OMAP_DEVICE_STATE_ENABLED; in omap_device_enable()
873 * omap_device_idle - idle an omap_device
874 * @od: struct omap_device * to idle
881 * complete, etc.. Returns -EINVAL if the omap_device is not
892 if (od->_state != OMAP_DEVICE_STATE_ENABLED) { in omap_device_idle()
893 dev_warn(&pdev->dev, in omap_device_idle()
895 __func__, od->_state); in omap_device_idle()
896 return -EINVAL; in omap_device_idle()
901 od->_state = OMAP_DEVICE_STATE_IDLE; in omap_device_idle()
907 * omap_device_shutdown - shut down an omap_device
908 * @od: struct omap_device * to shut down
913 * or a device driver is being unloaded. Returns -EINVAL if the
924 if (od->_state != OMAP_DEVICE_STATE_ENABLED && in omap_device_shutdown()
925 od->_state != OMAP_DEVICE_STATE_IDLE) { in omap_device_shutdown()
926 dev_warn(&pdev->dev, in omap_device_shutdown()
928 __func__, od->_state); in omap_device_shutdown()
929 return -EINVAL; in omap_device_shutdown()
934 for (i = 0; i < od->hwmods_cnt; i++) in omap_device_shutdown()
935 omap_hwmod_shutdown(od->hwmods[i]); in omap_device_shutdown()
937 od->_state = OMAP_DEVICE_STATE_SHUTDOWN; in omap_device_shutdown()
943 * omap_device_align_pm_lat - activate/deactivate device to match wakeup lat lim
948 * omap_device's pm_lats array to ensure that the device's maximum
949 * wakeup latency is less than or equal to the new latency limit.
950 * Intended to be called by OMAP PM code whenever a device's maximum
952 * omap_pm_set_dev_wakeup_lat()). Returns 0 if nothing needs to be
961 int ret = -EINVAL; in omap_device_align_pm_lat()
966 if (new_wakeup_lat_limit == od->dev_wakeup_lat) in omap_device_align_pm_lat()
969 od->_dev_wakeup_lat_limit = new_wakeup_lat_limit; in omap_device_align_pm_lat()
971 if (od->_state != OMAP_DEVICE_STATE_IDLE) in omap_device_align_pm_lat()
973 else if (new_wakeup_lat_limit > od->dev_wakeup_lat) in omap_device_align_pm_lat()
975 else if (new_wakeup_lat_limit < od->dev_wakeup_lat) in omap_device_align_pm_lat()
982 * omap_device_get_pwrdm - return the powerdomain * associated with @od
995 * check in here to WARN() if any difference appears. in omap_device_get_pwrdm()
997 if (!od->hwmods_cnt) in omap_device_get_pwrdm()
1000 return omap_hwmod_get_pwrdm(od->hwmods[0]); in omap_device_get_pwrdm()
1004 * omap_device_get_mpu_rt_va - return the MPU's virtual addr for the hwmod base
1016 if (od->hwmods_cnt != 1) in omap_device_get_rt_va()
1019 return omap_hwmod_get_mpu_rt_va(od->hwmods[0]); in omap_device_get_rt_va()
1023 * omap_device_get_by_hwmod_name() - convert a hwmod name to
1036 return ERR_PTR(-EINVAL); in omap_device_get_by_hwmod_name()
1043 return ERR_PTR(oh ? PTR_ERR(oh) : -ENODEV); in omap_device_get_by_hwmod_name()
1045 if (IS_ERR_OR_NULL(oh->od)) { in omap_device_get_by_hwmod_name()
1048 return ERR_PTR(oh->od ? PTR_ERR(oh->od) : -ENODEV); in omap_device_get_by_hwmod_name()
1051 if (IS_ERR_OR_NULL(oh->od->pdev)) in omap_device_get_by_hwmod_name()
1052 return ERR_PTR(oh->od->pdev ? PTR_ERR(oh->od->pdev) : -ENODEV); in omap_device_get_by_hwmod_name()
1054 return &oh->od->pdev->dev; in omap_device_get_by_hwmod_name()
1064 * omap_device_enable_hwmods - call omap_hwmod_enable() on all hwmods
1073 for (i = 0; i < od->hwmods_cnt; i++) in omap_device_enable_hwmods()
1074 omap_hwmod_enable(od->hwmods[i]); in omap_device_enable_hwmods()
1081 * omap_device_idle_hwmods - call omap_hwmod_idle() on all hwmods
1090 for (i = 0; i < od->hwmods_cnt; i++) in omap_device_idle_hwmods()
1091 omap_hwmod_idle(od->hwmods[i]); in omap_device_idle_hwmods()
1098 * omap_device_disable_clocks - disable all main and interface clocks
1108 for (i = 0; i < od->hwmods_cnt; i++) in omap_device_disable_clocks()
1109 omap_hwmod_disable_clocks(od->hwmods[i]); in omap_device_disable_clocks()
1116 * omap_device_enable_clocks - enable all main and interface clocks
1126 for (i = 0; i < od->hwmods_cnt; i++) in omap_device_enable_clocks()
1127 omap_hwmod_enable_clocks(od->hwmods[i]); in omap_device_enable_clocks()