OSDN Git Service

Merge android-4.4-p.194 (2b29211) into msm-4.4
[sagit-ice-cold/kernel_xiaomi_msm8998.git] / include / sound / wcd-dsp-mgr.h
1 /*
2  * Copyright (c) 2016, The Linux Foundation. All rights reserved.
3  *
4  * This program is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License version 2 and
6  * only version 2 as published by the Free Software Foundation.
7  *
8  * This program is distributed in the hope that it will be useful,
9  * but WITHOUT ANY WARRANTY; without even the implied warranty of
10  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
11  * GNU General Public License for more details.
12  */
13
14 #ifndef __WCD_DSP_MGR_H__
15 #define __WCD_DSP_MGR_H__
16
17 #include <linux/types.h>
18
19 /*
20  * These enums correspond to the component types
21  * that wcd-dsp-manager driver will use. The order
22  * of the enums specifies the order in which the
23  * manager driver will perform the sequencing.
24  * Changing this will cause the sequencing order
25  * to be changed as well.
26  */
27 enum wdsp_cmpnt_type {
28         /* Component to control the DSP */
29         WDSP_CMPNT_CONTROL = 0,
30         /* Component to perform data transfer to/from DSP */
31         WDSP_CMPNT_TRANSPORT,
32         /* Component that performs high level IPC */
33         WDSP_CMPNT_IPC,
34
35         WDSP_CMPNT_TYPE_MAX,
36 };
37
38 enum wdsp_event_type {
39         /* Initialization related */
40         WDSP_EVENT_POST_INIT,
41
42         /* Image download related */
43         WDSP_EVENT_PRE_DLOAD_CODE,
44         WDSP_EVENT_DLOAD_SECTION,
45         WDSP_EVENT_POST_DLOAD_CODE,
46         WDSP_EVENT_PRE_DLOAD_DATA,
47         WDSP_EVENT_POST_DLOAD_DATA,
48         WDSP_EVENT_DLOAD_FAILED,
49
50         WDSP_EVENT_READ_SECTION,
51
52         /* DSP boot related */
53         WDSP_EVENT_PRE_BOOTUP,
54         WDSP_EVENT_DO_BOOT,
55         WDSP_EVENT_POST_BOOTUP,
56         WDSP_EVENT_PRE_SHUTDOWN,
57         WDSP_EVENT_DO_SHUTDOWN,
58         WDSP_EVENT_POST_SHUTDOWN,
59
60         /* IRQ handling related */
61         WDSP_EVENT_IPC1_INTR,
62
63         /* Suspend/Resume related */
64         WDSP_EVENT_SUSPEND,
65         WDSP_EVENT_RESUME,
66 };
67
68 enum wdsp_signal {
69         /* Hardware generated interrupts signalled to manager */
70         WDSP_IPC1_INTR,
71         WDSP_ERR_INTR,
72
73         /* Other signals */
74         WDSP_CDC_DOWN_SIGNAL,
75         WDSP_CDC_UP_SIGNAL,
76 };
77
78 /*
79  * wdsp_cmpnt_ops: ops/function callbacks for components
80  * @init: called by manager driver, component is expected
81  *        to initialize itself in this callback
82  * @deinit: called by manager driver, component should
83  *          de-initialize itself in this callback
84  * @event_handler: Event handler for each component, called
85  *                 by the manager as per sequence
86  */
87 struct wdsp_cmpnt_ops {
88         int (*init)(struct device *, void *priv_data);
89         int (*deinit)(struct device *, void *priv_data);
90         int (*event_handler)(struct device *, void *priv_data,
91                              enum wdsp_event_type, void *data);
92 };
93
94 struct wdsp_img_section {
95         u32 addr;
96         size_t size;
97         u8 *data;
98 };
99
100 struct wdsp_err_signal_arg {
101         bool mem_dumps_enabled;
102         u32 remote_start_addr;
103         size_t dump_size;
104 };
105
106 /*
107  * wdsp_ops: ops/function callbacks for manager driver
108  * @register_cmpnt_ops: components will use this to register
109  *                      their own ops to manager driver
110  * @get_dev_for_cmpnt: components can use this to get handle
111  *                     to struct device * of any other component
112  * @signal_handler: callback to notify manager driver that signal
113  *                  has occurred. Cannot be called from interrupt
114  *                  context as this can sleep
115  * @vote_for_dsp: notifies manager that dsp should be booted up
116  * @suspend: notifies manager that one component wants to suspend.
117  *           Manager will make sure to suspend all components in order
118  * @resume: notifies manager that one component wants to resume.
119  *          Manager will make sure to resume all components in order
120  */
121
122 struct wdsp_mgr_ops {
123         int (*register_cmpnt_ops)(struct device *wdsp_dev,
124                                   struct device *cdev,
125                                   void *priv_data,
126                                   struct wdsp_cmpnt_ops *ops);
127         struct device *(*get_dev_for_cmpnt)(struct device *wdsp_dev,
128                                             enum wdsp_cmpnt_type type);
129         int (*signal_handler)(struct device *wdsp_dev,
130                               enum wdsp_signal signal, void *arg);
131         int (*vote_for_dsp)(struct device *wdsp_dev, bool vote);
132         int (*suspend)(struct device *wdsp_dev);
133         int (*resume)(struct device *wdsp_dev);
134 };
135
136 #endif /* end of __WCD_DSP_MGR_H__ */