Lina Iyer | 1c5ab79 | 2017-02-01 13:34:54 -0700 | [diff] [blame] | 1 | /* Copyright (c) 2016-2017, The Linux Foundation. All rights reserved. |
Mahesh Sivasubramanian | cb64952 | 2016-08-19 14:04:44 -0600 | [diff] [blame] | 2 | * |
| 3 | * This program is free software; you can redistribute it and/or modify |
| 4 | * it under the terms of the GNU General Public License version 2 and |
| 5 | * only version 2 as published by the Free Software Foundation. |
| 6 | * |
| 7 | * This program is distributed in the hope that it will be useful, |
| 8 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 9 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 10 | * GNU General Public License for more details. |
| 11 | */ |
| 12 | |
| 13 | #ifndef COMMAND_DB_H |
| 14 | #define COMMAND_DB_H |
| 15 | |
| 16 | |
| 17 | enum cmd_db_hw_type { |
| 18 | CMD_DB_HW_MIN = 3, |
| 19 | CMD_DB_HW_ARC = CMD_DB_HW_MIN, |
| 20 | CMD_DB_HW_VRM = 4, |
| 21 | CMD_DB_HW_BCM = 5, |
| 22 | CMD_DB_HW_MAX = CMD_DB_HW_BCM, |
| 23 | CMD_DB_HW_ALL = 0xff, |
| 24 | }; |
| 25 | #ifdef CONFIG_QCOM_COMMAND_DB |
| 26 | /** |
| 27 | * cmd_db_get_addr() - Query command db for resource id address. |
| 28 | * |
| 29 | * This is used to retrieve resource address based on resource |
| 30 | * id. |
| 31 | * |
| 32 | * @resource_id : resource id to query for address |
| 33 | * |
| 34 | * @return address on success or 0 on error otherwise |
| 35 | */ |
| 36 | u32 cmd_db_get_addr(const char *resource_id); |
| 37 | |
| 38 | /** |
| 39 | * cmd_db_get_priority() - Query command db for resource address priority |
| 40 | * from command DB. |
| 41 | * |
| 42 | * This is used to retrieve a command DB entry based resource address. |
| 43 | * |
| 44 | * @addr : resource addr to query for priority. |
| 45 | * @drv_id : DRV ID to query resource for priority on. |
| 46 | * @type: HW type of ID being queried for faster lookups. Clients could |
| 47 | * pass in CMD_DB_HW_ALL if type field is unknown |
| 48 | * |
| 49 | * @return true if priority bit is set for the DRV ID/address |
| 50 | */ |
| 51 | bool cmd_db_get_priority(u32 addr, u8 drv_id); |
| 52 | |
| 53 | /** |
| 54 | * cmd_db_get_aux_data() - Query command db for aux data. This is used to |
| 55 | * retrieve a command DB entry based resource address. |
| 56 | * |
| 57 | * @resource_id : Resource to retrieve AUX Data on. |
| 58 | * @data : Data buffer to copy returned aux data to. Returns size on NULL |
| 59 | * @len : Caller provides size of data buffer passed in. |
| 60 | * |
| 61 | * returns size of data on success, errno on error |
| 62 | */ |
| 63 | int cmd_db_get_aux_data(const char *resource_id, u8 *data, int len); |
| 64 | |
| 65 | /** |
| 66 | * cmd_db_get_aux_data_len - Get the length of the auxllary data stored in DB. |
| 67 | * |
| 68 | * @resource_id: Resource to retrieve AUX Data. |
| 69 | * |
| 70 | * returns size on success, errno on error |
| 71 | */ |
| 72 | int cmd_db_get_aux_data_len(const char *resource_id); |
| 73 | |
| 74 | /** |
| 75 | * cmd_db_get_version - Get the version of the command DB data |
| 76 | * |
| 77 | * @resource_id: Resource id to query the DB for version |
| 78 | * |
| 79 | * returns version on success, 0 on error. |
| 80 | * Major number in MSB, minor number in LSB |
| 81 | */ |
| 82 | u16 cmd_db_get_version(const char *resource_id); |
| 83 | |
| 84 | /** |
| 85 | * cmd_db_ready - Indicates if command DB is probed |
| 86 | * |
| 87 | * returns 0 on success , errno otherwise |
| 88 | */ |
| 89 | int cmd_db_ready(void); |
| 90 | |
| 91 | /** |
| 92 | * cmd_db_get_slave_id - Get the slave ID for a given resource address |
| 93 | * |
| 94 | * @resource_id: Resource id to query the DB for version |
| 95 | * |
| 96 | * return cmd_db_hw_type enum on success, errno on error |
| 97 | */ |
| 98 | int cmd_db_get_slave_id(const char *resource_id); |
Lina Iyer | 1c5ab79 | 2017-02-01 13:34:54 -0700 | [diff] [blame] | 99 | |
| 100 | /** |
| 101 | * cmd_db_is_standalone - Returns if the command DB is standalone |
| 102 | * |
| 103 | * return 1 if command DB is standalone, 0 if not, errno otherwise. |
| 104 | */ |
| 105 | int cmd_db_is_standalone(void); |
Mahesh Sivasubramanian | cb64952 | 2016-08-19 14:04:44 -0600 | [diff] [blame] | 106 | #else |
| 107 | |
| 108 | static inline u32 cmd_db_get_addr(const char *resource_id) |
| 109 | { |
| 110 | return 0; |
| 111 | } |
| 112 | |
Hareesh Gundu | 7020089 | 2017-11-22 11:42:28 +0530 | [diff] [blame] | 113 | static inline bool cmd_db_get_priority(u32 addr, u8 drv_id) |
Mahesh Sivasubramanian | cb64952 | 2016-08-19 14:04:44 -0600 | [diff] [blame] | 114 | { |
| 115 | return false; |
| 116 | } |
| 117 | |
Hareesh Gundu | 7020089 | 2017-11-22 11:42:28 +0530 | [diff] [blame] | 118 | static inline int cmd_db_get_aux_data(const char *resource_id, |
| 119 | u8 *data, int len) |
Mahesh Sivasubramanian | cb64952 | 2016-08-19 14:04:44 -0600 | [diff] [blame] | 120 | { |
| 121 | return -ENODEV; |
| 122 | } |
| 123 | |
Hareesh Gundu | 7020089 | 2017-11-22 11:42:28 +0530 | [diff] [blame] | 124 | static inline int cmd_db_get_aux_data_len(const char *resource_id) |
Mahesh Sivasubramanian | cb64952 | 2016-08-19 14:04:44 -0600 | [diff] [blame] | 125 | { |
| 126 | return -ENODEV; |
| 127 | } |
| 128 | |
| 129 | u16 cmd_db_get_version(const char *resource_id) |
| 130 | { |
| 131 | return 0; |
| 132 | } |
| 133 | |
| 134 | int cmd_db_ready(void) |
| 135 | { |
| 136 | return -ENODEV; |
| 137 | } |
| 138 | |
| 139 | int cmd_db_get_slave_id(const char *resource_id) |
| 140 | { |
| 141 | return -ENODEV; |
| 142 | } |
Lina Iyer | 1c5ab79 | 2017-02-01 13:34:54 -0700 | [diff] [blame] | 143 | |
| 144 | int cmd_db_is_standalone(void) |
| 145 | { |
| 146 | return -ENODEV; |
| 147 | } |
Mahesh Sivasubramanian | cb64952 | 2016-08-19 14:04:44 -0600 | [diff] [blame] | 148 | #endif |
| 149 | #endif |