1+ /*
2+ * Copyright 2025 Nexthop Systems Inc.
3+ *
4+ * This program is free software; you can redistribute it and/or modify
5+ * it under the terms of the GNU General Public License as published by
6+ * the Free Software Foundation; either version 2 of the License, or
7+ * (at your option) any later version.
8+ *
9+ * This program is distributed in the hope that it will be useful,
10+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
11+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12+ * GNU General Public License for more details.
13+ */
14+
15+ #ifndef __PDDF_MULTIFPGAPCI_I2C_DEFS_H__
16+ #define __PDDF_MULTIFPGAPCI_I2C_DEFS_H__
17+
18+ #include <linux/i2c.h>
19+ #include "linux/types.h"
20+ #include <linux/kobject.h>
21+ #include <linux/pci.h>
22+ #include <linux/sysfs.h>
23+
24+ #include "pddf_client_defs.h"
25+
26+ #define I2C_PCI_MAX_BUS 512
27+
28+ struct i2c_adapter_attrs {
29+ PDDF_ATTR attr_virt_bus ;
30+ PDDF_ATTR attr_ch_base_offset ;
31+ PDDF_ATTR attr_ch_size ;
32+ PDDF_ATTR attr_num_virt_ch ;
33+ PDDF_ATTR attr_new_i2c_adapter ;
34+ PDDF_ATTR attr_del_i2c_adapter ;
35+ };
36+
37+ #define NUM_I2C_ADAPTER_ATTRS \
38+ (sizeof(struct i2c_adapter_attrs) / sizeof(PDDF_ATTR))
39+
40+ struct i2c_adapter_sysfs_vals {
41+ uint32_t virt_bus ;
42+ uint32_t ch_base_offset ;
43+ uint32_t ch_size ;
44+ uint32_t num_virt_ch ;
45+ };
46+
47+ struct i2c_adapter_drvdata {
48+ // temp_sysfs_vals store temporary values provided by sysfs,
49+ // which are eventually copied/saved to I2C adapter platform data.
50+ struct i2c_adapter_sysfs_vals temp_sysfs_vals ;
51+
52+ // platform data
53+ struct i2c_adapter i2c_adapters [I2C_PCI_MAX_BUS ];
54+ bool i2c_adapter_registered [I2C_PCI_MAX_BUS ];
55+ int virt_bus ;
56+ void * __iomem ch_base_addr ;
57+ int ch_size ;
58+ int num_virt_ch ;
59+
60+ // sysfs attrs
61+ struct i2c_adapter_attrs attrs ;
62+ struct attribute * i2c_adapter_attrs [NUM_I2C_ADAPTER_ATTRS + 1 ];
63+ struct attribute_group i2c_adapter_attr_group ;
64+ };
65+
66+ extern int pddf_multifpgapci_i2c_module_init (struct pci_dev * pci_dev ,
67+ struct kobject * kobj );
68+
69+ // Only called if multifpgapci_i2c_module_init succeeded
70+ extern void pddf_multifpgapci_i2c_module_exit (struct pci_dev * pci_dev ,
71+ struct kobject * kobj );
72+
73+ #endif
0 commit comments