Banajit Goswami | de8271c | 2017-01-18 00:28:59 -0800 | [diff] [blame] | 1 | /* |
Walter Yang | a21e9ff | 2018-01-12 13:39:39 +0800 | [diff] [blame] | 2 | * Copyright (c) 2016-2018, The Linux Foundation. All rights reserved. |
Banajit Goswami | de8271c | 2017-01-18 00:28:59 -0800 | [diff] [blame] | 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> |
Karthikeyan Mani | 858132b | 2017-06-27 20:03:08 -0700 | [diff] [blame] | 18 | #include <linux/device.h> |
Banajit Goswami | de8271c | 2017-01-18 00:28:59 -0800 | [diff] [blame] | 19 | |
| 20 | /* |
| 21 | * These enums correspond to the component types |
| 22 | * that wcd-dsp-manager driver will use. The order |
| 23 | * of the enums specifies the order in which the |
| 24 | * manager driver will perform the sequencing. |
| 25 | * Changing this will cause the sequencing order |
| 26 | * to be changed as well. |
| 27 | */ |
| 28 | enum wdsp_cmpnt_type { |
| 29 | /* Component to control the DSP */ |
| 30 | WDSP_CMPNT_CONTROL = 0, |
| 31 | /* Component to perform data transfer to/from DSP */ |
| 32 | WDSP_CMPNT_TRANSPORT, |
| 33 | /* Component that performs high level IPC */ |
| 34 | WDSP_CMPNT_IPC, |
| 35 | |
| 36 | WDSP_CMPNT_TYPE_MAX, |
| 37 | }; |
| 38 | |
| 39 | enum wdsp_event_type { |
| 40 | /* Initialization related */ |
| 41 | WDSP_EVENT_POST_INIT, |
| 42 | |
| 43 | /* Image download related */ |
| 44 | WDSP_EVENT_PRE_DLOAD_CODE, |
| 45 | WDSP_EVENT_DLOAD_SECTION, |
| 46 | WDSP_EVENT_POST_DLOAD_CODE, |
| 47 | WDSP_EVENT_PRE_DLOAD_DATA, |
| 48 | WDSP_EVENT_POST_DLOAD_DATA, |
| 49 | WDSP_EVENT_DLOAD_FAILED, |
| 50 | |
| 51 | WDSP_EVENT_READ_SECTION, |
| 52 | |
| 53 | /* DSP boot related */ |
| 54 | WDSP_EVENT_PRE_BOOTUP, |
| 55 | WDSP_EVENT_DO_BOOT, |
| 56 | WDSP_EVENT_POST_BOOTUP, |
| 57 | WDSP_EVENT_PRE_SHUTDOWN, |
| 58 | WDSP_EVENT_DO_SHUTDOWN, |
| 59 | WDSP_EVENT_POST_SHUTDOWN, |
| 60 | |
| 61 | /* IRQ handling related */ |
| 62 | WDSP_EVENT_IPC1_INTR, |
| 63 | |
| 64 | /* Suspend/Resume related */ |
| 65 | WDSP_EVENT_SUSPEND, |
| 66 | WDSP_EVENT_RESUME, |
Bhalchandra Gajare | 6c1fed3 | 2017-06-27 13:04:06 -0700 | [diff] [blame] | 67 | |
| 68 | /* Misc */ |
| 69 | WDSP_EVENT_GET_DEVOPS |
Banajit Goswami | de8271c | 2017-01-18 00:28:59 -0800 | [diff] [blame] | 70 | }; |
| 71 | |
| 72 | enum wdsp_signal { |
| 73 | /* Hardware generated interrupts signalled to manager */ |
| 74 | WDSP_IPC1_INTR, |
| 75 | WDSP_ERR_INTR, |
| 76 | |
| 77 | /* Other signals */ |
| 78 | WDSP_CDC_DOWN_SIGNAL, |
| 79 | WDSP_CDC_UP_SIGNAL, |
Walter Yang | 5d43c87 | 2017-11-21 11:35:06 +0800 | [diff] [blame] | 80 | |
| 81 | /* Software generated signal indicating debug dumps to be collected */ |
| 82 | WDSP_DEBUG_DUMP, |
Walter Yang | a21e9ff | 2018-01-12 13:39:39 +0800 | [diff] [blame] | 83 | WDSP_DEBUG_DUMP_INTERNAL, |
Banajit Goswami | de8271c | 2017-01-18 00:28:59 -0800 | [diff] [blame] | 84 | }; |
| 85 | |
| 86 | /* |
| 87 | * wdsp_cmpnt_ops: ops/function callbacks for components |
| 88 | * @init: called by manager driver, component is expected |
| 89 | * to initialize itself in this callback |
| 90 | * @deinit: called by manager driver, component should |
| 91 | * de-initialize itself in this callback |
| 92 | * @event_handler: Event handler for each component, called |
| 93 | * by the manager as per sequence |
| 94 | */ |
| 95 | struct wdsp_cmpnt_ops { |
| 96 | int (*init)(struct device *, void *priv_data); |
| 97 | int (*deinit)(struct device *, void *priv_data); |
| 98 | int (*event_handler)(struct device *, void *priv_data, |
| 99 | enum wdsp_event_type, void *data); |
| 100 | }; |
| 101 | |
| 102 | struct wdsp_img_section { |
| 103 | u32 addr; |
| 104 | size_t size; |
| 105 | u8 *data; |
| 106 | }; |
| 107 | |
| 108 | struct wdsp_err_signal_arg { |
| 109 | bool mem_dumps_enabled; |
| 110 | u32 remote_start_addr; |
| 111 | size_t dump_size; |
| 112 | }; |
| 113 | |
| 114 | /* |
| 115 | * wdsp_ops: ops/function callbacks for manager driver |
| 116 | * @register_cmpnt_ops: components will use this to register |
| 117 | * their own ops to manager driver |
| 118 | * @get_dev_for_cmpnt: components can use this to get handle |
| 119 | * to struct device * of any other component |
Bhalchandra Gajare | 6c1fed3 | 2017-06-27 13:04:06 -0700 | [diff] [blame] | 120 | * @get_devops_for_cmpnt: components can use this to get ops |
| 121 | * from other related components. |
Banajit Goswami | de8271c | 2017-01-18 00:28:59 -0800 | [diff] [blame] | 122 | * @signal_handler: callback to notify manager driver that signal |
| 123 | * has occurred. Cannot be called from interrupt |
| 124 | * context as this can sleep |
| 125 | * @vote_for_dsp: notifies manager that dsp should be booted up |
| 126 | * @suspend: notifies manager that one component wants to suspend. |
| 127 | * Manager will make sure to suspend all components in order |
| 128 | * @resume: notifies manager that one component wants to resume. |
| 129 | * Manager will make sure to resume all components in order |
| 130 | */ |
| 131 | |
| 132 | struct wdsp_mgr_ops { |
| 133 | int (*register_cmpnt_ops)(struct device *wdsp_dev, |
| 134 | struct device *cdev, |
| 135 | void *priv_data, |
| 136 | struct wdsp_cmpnt_ops *ops); |
| 137 | struct device *(*get_dev_for_cmpnt)(struct device *wdsp_dev, |
| 138 | enum wdsp_cmpnt_type type); |
Bhalchandra Gajare | 6c1fed3 | 2017-06-27 13:04:06 -0700 | [diff] [blame] | 139 | int (*get_devops_for_cmpnt)(struct device *wdsp_dev, |
| 140 | enum wdsp_cmpnt_type type, void *data); |
Banajit Goswami | de8271c | 2017-01-18 00:28:59 -0800 | [diff] [blame] | 141 | int (*signal_handler)(struct device *wdsp_dev, |
| 142 | enum wdsp_signal signal, void *arg); |
| 143 | int (*vote_for_dsp)(struct device *wdsp_dev, bool vote); |
| 144 | int (*suspend)(struct device *wdsp_dev); |
| 145 | int (*resume)(struct device *wdsp_dev); |
| 146 | }; |
| 147 | |
Karthikeyan Mani | 858132b | 2017-06-27 20:03:08 -0700 | [diff] [blame] | 148 | int wcd_dsp_mgr_init(void); |
| 149 | void wcd_dsp_mgr_exit(void); |
Banajit Goswami | de8271c | 2017-01-18 00:28:59 -0800 | [diff] [blame] | 150 | #endif /* end of __WCD_DSP_MGR_H__ */ |