blob: 3c2aff36edde59e98cf4ad60d407629e9d85a22e [file] [log] [blame]
Lina Iyer1c5ab792017-02-01 13:34:54 -07001/* Copyright (c) 2016-2017, The Linux Foundation. All rights reserved.
Mahesh Sivasubramaniancb649522016-08-19 14:04:44 -06002 *
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
17enum 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 */
36u32 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 */
51bool 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 */
63int 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 */
72int 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 */
82u16 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 */
89int 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 */
98int cmd_db_get_slave_id(const char *resource_id);
Lina Iyer1c5ab792017-02-01 13:34:54 -070099
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 */
105int cmd_db_is_standalone(void);
Mahesh Sivasubramaniancb649522016-08-19 14:04:44 -0600106#else
107
108static inline u32 cmd_db_get_addr(const char *resource_id)
109{
110 return 0;
111}
112
Hareesh Gundu70200892017-11-22 11:42:28 +0530113static inline bool cmd_db_get_priority(u32 addr, u8 drv_id)
Mahesh Sivasubramaniancb649522016-08-19 14:04:44 -0600114{
115 return false;
116}
117
Hareesh Gundu70200892017-11-22 11:42:28 +0530118static inline int cmd_db_get_aux_data(const char *resource_id,
119 u8 *data, int len)
Mahesh Sivasubramaniancb649522016-08-19 14:04:44 -0600120{
121 return -ENODEV;
122}
123
Hareesh Gundu70200892017-11-22 11:42:28 +0530124static inline int cmd_db_get_aux_data_len(const char *resource_id)
Mahesh Sivasubramaniancb649522016-08-19 14:04:44 -0600125{
126 return -ENODEV;
127}
128
129u16 cmd_db_get_version(const char *resource_id)
130{
131 return 0;
132}
133
134int cmd_db_ready(void)
135{
136 return -ENODEV;
137}
138
139int cmd_db_get_slave_id(const char *resource_id)
140{
141 return -ENODEV;
142}
Lina Iyer1c5ab792017-02-01 13:34:54 -0700143
144int cmd_db_is_standalone(void)
145{
146 return -ENODEV;
147}
Mahesh Sivasubramaniancb649522016-08-19 14:04:44 -0600148#endif
149#endif