xref: /wlan-dirver/qca-wifi-host-cmn/qal/linux/src/i_qal_devnode.h (revision 2f4b444fb7e689b83a4ab0e7b3b38f0bf4def8e0)
1 /*
2  * Copyright (c) 2021 The Linux Foundation. All rights reserved.
3  *
4  * Permission to use, copy, modify, and/or distribute this software for
5  * any purpose with or without fee is hereby granted, provided that the
6  * above copyright notice and this permission notice appear in all
7  * copies.
8  *
9  * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
10  * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
11  * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
12  * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
13  * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
14  * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
15  * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
16  * PERFORMANCE OF THIS SOFTWARE.
17  */
18 
19 /**
20  * DOC: qal_devnode
21  * QCA abstraction layer (QAL) device config APIs
22  */
23 
24 #if !defined(__I_QAL_DEVNODE_H)
25 #define __I_QAL_DEVNODE_H
26 
27 /* Include Files */
28 #include <linux/of_pci.h>
29 #include <linux/of.h>
30 #include "qdf_types.h"
31 
32 #define PCI_DOMAIN_ID_MIN   0x0000
33 #define PCI_DOMAIN_ID_MAX   0xFFFF
34 
35 typedef struct device_node *__qdf_devnode_t;
36 
37 /**
38  * __qal_devnode_read_u32_array() - Find and read an array of 32 bit integers
39  * from a property.
40  * @devnode: device node from which the property value is to be read.
41  * @pname: name of the property to be searched.
42  * @u32_val: pointer to return value, modified only if return value is 0.
43  * @elem: number of array elements to read
44  *
45  * Return: QDF_STATUS_SUCCESS if valid value can be decoded,
46  * error code otherwise
47  */
48 static inline QDF_STATUS
49 __qal_devnode_read_u32_array(const __qdf_devnode_t devnode,
50 			     const char *pname, u32 *u32_val, size_t elem)
51 {
52 	int ret;
53 
54 	ret = of_property_read_u32_array(devnode, pname, u32_val, elem);
55 
56 	return qdf_status_from_os_return(ret);
57 }
58 
59 /**
60  * __qal_devnode_read_u32() - Find and read 32 bit integer from a property.
61  * @devnode: device node from which the property value is to be read.
62  * @pname: name of the property to be searched.
63  * @u32_val: pointer to return value, modified only if return value is 0.
64  *
65  * Return: QDF_STATUS_SUCCESS if valid value can be decoded,
66  * error code otherwise
67  */
68 static inline QDF_STATUS
69 __qal_devnode_read_u32(const __qdf_devnode_t devnode,
70 		       const char *pname, u32 *u32_val)
71 {
72 	int ret;
73 
74 	ret = of_property_read_u32(devnode, pname, u32_val);
75 
76 	return qdf_status_from_os_return(ret);
77 }
78 
79 #endif /* __I_QAL_DEVNODE_H */
80