xref: /freebsd/sys/dev/bnxt/bnxt_en/bnxt_auxbus_compat.h (revision a90b9d0159070121c221b966469c3e36d912bf82)
1 /*-
2  * Broadcom NetXtreme-C/E network driver.
3  *
4  * Copyright (c) 2024 Broadcom, All Rights Reserved.
5  * The term Broadcom refers to Broadcom Limited and/or its subsidiaries
6  *
7  * Redistribution and use in source and binary forms, with or without
8  * modification, are permitted provided that the following conditions
9  * are met:
10  * 1. Redistributions of source code must retain the above copyright
11  *    notice, this list of conditions and the following disclaimer.
12  * 2. Redistributions in binary form must reproduce the above copyright
13  *    notice, this list of conditions and the following disclaimer in the
14  *    documentation and/or other materials provided with the distribution.
15  *
16  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS'
17  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19  * ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
20  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
21  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
22  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
23  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
24  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
25  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
26  * THE POSSIBILITY OF SUCH DAMAGE.
27  */
28 
29 #ifndef _BNXT_AUXILIARY_COMPAT_H_
30 #define _BNXT_AUXILIARY_COMPAT_H_
31 
32 #include <linux/device.h>
33 #include <linux/idr.h>
34 
35 #define KBUILD_MODNAME		"if_bnxt"
36 #define AUXILIARY_NAME_SIZE	32
37 
38 struct auxiliary_device_id {
39 	char name[AUXILIARY_NAME_SIZE];
40 	uint64_t driver_data;
41 };
42 
43 struct auxiliary_device {
44 	struct device dev;
45 	const char *name;
46 	uint32_t id;
47 	struct list_head list;
48 };
49 
50 struct auxiliary_driver {
51 	int (*probe)(struct auxiliary_device *auxdev, const struct auxiliary_device_id *id);
52 	void (*remove)(struct auxiliary_device *auxdev);
53 	const char *name;
54 	struct device_driver driver;
55 	const struct auxiliary_device_id *id_table;
56 	struct list_head list;
57 };
58 
59 int auxiliary_device_init(struct auxiliary_device *auxdev);
60 int auxiliary_device_add(struct auxiliary_device *auxdev);
61 void auxiliary_device_uninit(struct auxiliary_device *auxdev);
62 void auxiliary_device_delete(struct auxiliary_device *auxdev);
63 int auxiliary_driver_register(struct auxiliary_driver *auxdrv);
64 void auxiliary_driver_unregister(struct auxiliary_driver *auxdrv);
65 
66 static inline void *auxiliary_get_drvdata(struct auxiliary_device *auxdev)
67 {
68 	return dev_get_drvdata(&auxdev->dev);
69 }
70 
71 static inline void auxiliary_set_drvdata(struct auxiliary_device *auxdev, void *data)
72 {
73 	dev_set_drvdata(&auxdev->dev, data);
74 }
75 #endif /* _BNXT_AUXILIARY_COMPAT_H_ */
76