xref: /freebsd/sys/dev/bnxt/bnxt_en/bnxt_auxbus_compat.h (revision 2f5666c1727c949491f73e6c3277b7b542131714)
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 #define	MODULE_DEVICE_TABLE_BUS_auxiliary(_bus, _table)
43 
44 struct auxiliary_device {
45 	struct device dev;
46 	const char *name;
47 	uint32_t id;
48 	struct list_head list;
49 };
50 
51 struct auxiliary_driver {
52 	int (*probe)(struct auxiliary_device *auxdev, const struct auxiliary_device_id *id);
53 	void (*remove)(struct auxiliary_device *auxdev);
54 	const char *name;
55 	struct device_driver driver;
56 	const struct auxiliary_device_id *id_table;
57 	struct list_head list;
58 };
59 
60 int auxiliary_device_init(struct auxiliary_device *auxdev);
61 int auxiliary_device_add(struct auxiliary_device *auxdev);
62 void auxiliary_device_uninit(struct auxiliary_device *auxdev);
63 void auxiliary_device_delete(struct auxiliary_device *auxdev);
64 int auxiliary_driver_register(struct auxiliary_driver *auxdrv);
65 void auxiliary_driver_unregister(struct auxiliary_driver *auxdrv);
66 
auxiliary_get_drvdata(struct auxiliary_device * auxdev)67 static inline void *auxiliary_get_drvdata(struct auxiliary_device *auxdev)
68 {
69 	return dev_get_drvdata(&auxdev->dev);
70 }
71 
auxiliary_set_drvdata(struct auxiliary_device * auxdev,void * data)72 static inline void auxiliary_set_drvdata(struct auxiliary_device *auxdev, void *data)
73 {
74 	dev_set_drvdata(&auxdev->dev, data);
75 }
76 #endif /* _BNXT_AUXILIARY_COMPAT_H_ */
77