4 * DSP-BIOS Bridge driver support functions for TI OMAP processors.
6 * PWR API for controlling DSP power states.
8 * Copyright (C) 2005-2006 Texas Instruments, Inc.
10 * This package is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License version 2 as
12 * published by the Free Software Foundation.
14 * THIS PACKAGE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
15 * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
16 * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
19 /* ----------------------------------- Host OS */
20 #include <dspbridge/host_os.h>
22 /* ----------------------------------- This */
23 #include <dspbridge/pwr.h>
25 /* ----------------------------------- Resource Manager */
26 #include <dspbridge/devdefs.h>
27 #include <dspbridge/drv.h>
29 /* ----------------------------------- Platform Manager */
30 #include <dspbridge/dev.h>
32 /* ----------------------------------- Link Driver */
33 #include <dspbridge/dspioctl.h>
36 * ======== pwr_sleep_dsp ========
37 * Send command to DSP to enter sleep state.
39 int pwr_sleep_dsp(IN CONST u32 sleepCode
, IN CONST u32 timeout
)
41 struct bridge_drv_interface
*intf_fxns
;
42 struct bridge_dev_context
*dw_context
;
44 struct dev_object
*hdev_obj
= NULL
;
48 for (hdev_obj
= (struct dev_object
*)drv_get_first_dev_object();
51 (struct dev_object
*)drv_get_next_dev_object((u32
) hdev_obj
)) {
52 if (DSP_FAILED(dev_get_bridge_context(hdev_obj
,
53 (struct bridge_dev_context
**)
57 if (DSP_FAILED(dev_get_intf_fxns(hdev_obj
,
58 (struct bridge_drv_interface
**)
62 if (sleepCode
== PWR_DEEPSLEEP
)
63 ioctlcode
= BRDIOCTL_DEEPSLEEP
;
64 else if (sleepCode
== PWR_EMERGENCYDEEPSLEEP
)
65 ioctlcode
= BRDIOCTL_EMERGENCYSLEEP
;
69 if (status
!= -EINVAL
) {
70 status
= (*intf_fxns
->pfn_dev_cntrl
) (dw_context
,
79 * ======== pwr_wake_dsp ========
80 * Send command to DSP to wake it from sleep.
82 int pwr_wake_dsp(IN CONST u32 timeout
)
84 struct bridge_drv_interface
*intf_fxns
;
85 struct bridge_dev_context
*dw_context
;
87 struct dev_object
*hdev_obj
= NULL
;
90 for (hdev_obj
= (struct dev_object
*)drv_get_first_dev_object();
92 hdev_obj
= (struct dev_object
*)drv_get_next_dev_object
94 if (DSP_SUCCEEDED(dev_get_bridge_context(hdev_obj
,
95 (struct bridge_dev_context
100 (struct bridge_drv_interface
**)&intf_fxns
))) {
102 (*intf_fxns
->pfn_dev_cntrl
) (dw_context
,
112 * ======== pwr_pm_pre_scale========
113 * Sends pre-notification message to DSP.
115 int pwr_pm_pre_scale(IN u16 voltage_domain
, u32 level
)
117 struct bridge_drv_interface
*intf_fxns
;
118 struct bridge_dev_context
*dw_context
;
120 struct dev_object
*hdev_obj
= NULL
;
123 arg
[0] = voltage_domain
;
126 for (hdev_obj
= (struct dev_object
*)drv_get_first_dev_object();
128 hdev_obj
= (struct dev_object
*)drv_get_next_dev_object
130 if (DSP_SUCCEEDED(dev_get_bridge_context(hdev_obj
,
131 (struct bridge_dev_context
136 (struct bridge_drv_interface
**)&intf_fxns
))) {
138 (*intf_fxns
->pfn_dev_cntrl
) (dw_context
,
139 BRDIOCTL_PRESCALE_NOTIFY
,
148 * ======== pwr_pm_post_scale========
149 * Sends post-notification message to DSP.
151 int pwr_pm_post_scale(IN u16 voltage_domain
, u32 level
)
153 struct bridge_drv_interface
*intf_fxns
;
154 struct bridge_dev_context
*dw_context
;
156 struct dev_object
*hdev_obj
= NULL
;
159 arg
[0] = voltage_domain
;
162 for (hdev_obj
= (struct dev_object
*)drv_get_first_dev_object();
164 hdev_obj
= (struct dev_object
*)drv_get_next_dev_object
166 if (DSP_SUCCEEDED(dev_get_bridge_context(hdev_obj
,
167 (struct bridge_dev_context
172 (struct bridge_drv_interface
**)&intf_fxns
))) {
174 (*intf_fxns
->pfn_dev_cntrl
) (dw_context
,
175 BRDIOCTL_POSTSCALE_NOTIFY
,