Skip to content

Commit 882146c

Browse files
committed
IGNORE THIS COMMIT: Multiple FPGAs w/ I2C IP block (PR sonic-net#22748)
1 parent e5734f0 commit 882146c

14 files changed

Lines changed: 1402 additions & 6 deletions

File tree

platform/pddf/i2c/debian/rules

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ PACKAGE_PRE_NAME := sonic-platform-pddf
1919
KVERSION ?= $(shell uname -r)
2020
KERNEL_SRC := /lib/modules/$(KVERSION)
2121
MOD_SRC_DIR:= $(shell pwd)
22-
MODULE_DIRS:= client cpld cpld/driver cpldmux cpldmux/driver fpgai2c fpgai2c/driver fpgapci fpgapci/driver fpgapci/algos fan fan/driver mux gpio led psu psu/driver sysstatus xcvr xcvr/driver
22+
MODULE_DIRS:= client cpld cpld/driver cpldmux cpldmux/driver fpgai2c fpgai2c/driver fpgapci fpgapci/driver fpgapci/algos multifpgapci multifpgapci/driver multifpgapci/i2c fan fan/driver mux gpio led psu psu/driver sysstatus xcvr xcvr/driver
2323
MODULE_DIR:= modules
2424
UTILS_DIR := utils
2525
SERVICE_DIR := service

platform/pddf/i2c/modules/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
obj-m := client/ cpld/ cpldmux/ fpgai2c/ fpgapci/ xcvr/ mux/ gpio/ psu/ fan/ led/ sysstatus/
1+
obj-m := client/ cpld/ cpldmux/ fpgai2c/ fpgapci/ multifpgapci/ xcvr/ mux/ gpio/ psu/ fan/ led/ sysstatus/

platform/pddf/i2c/modules/include/pddf_client_defs.h

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
#define SYSSTATUS "PDDF_SYSSTATUS"
3535
#define XCVR "PDDF_XCVR"
3636
#define FPGA "PDDF_FPGAPCI"
37+
#define MULTIFPGA "PDDF_MULTIFPGAPCI"
3738

3839

3940
#define PDDF_DEBUG
@@ -63,6 +64,15 @@ typedef struct pddf_data_attribute{
6364
.addr = _addr, \
6465
.data = _data }
6566

67+
#define PDDF_DATA_ATTR_VAL(_name, _mode, _show, _store, _type, _len, _addr, _data) \
68+
(PDDF_ATTR){ \
69+
.dev_attr = __ATTR(_name, _mode, _show, _store), \
70+
.type = _type, \
71+
.len = _len, \
72+
.addr = _addr, \
73+
.data = _data \
74+
}
75+
6676

6777
enum attribute_data_type {
6878
PDDF_CHAR,

platform/pddf/i2c/modules/include/pddf_i2c_algo.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
#include "pddf_client_defs.h"
1010

1111
/* max number of adapters */
12-
#define I2C_PCI_MAX_BUS 16
12+
#define I2C_PCI_MAX_BUS 512
1313

1414
/**
1515
* struct fpgapci_devdata - PCI device data structure
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
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+
* Description:
15+
* Platform MULTIFPGAPCI defines/structures header file
16+
*/
17+
18+
#ifndef __PDDF_MULTIFPGAPCI_DEFS_H__
19+
#define __PDDF_MULTIFPGAPCI_DEFS_H__
20+
21+
#include "linux/types.h"
22+
#include <linux/pci.h>
23+
24+
#include "pddf_multifpgapci_i2c_defs.h"
25+
26+
#define NAME_SIZE 32
27+
#define KOBJ_FREE(obj) \
28+
if (obj) \
29+
kobject_put(obj);
30+
31+
struct pddf_multifpgapci_drvdata {
32+
struct pci_dev *pci_dev;
33+
resource_size_t bar_start;
34+
void *__iomem fpga_data_base_addr;
35+
// i2c
36+
size_t bar_length;
37+
struct kobject *i2c_kobj;
38+
struct i2c_adapter_drvdata i2c_adapter_drvdata;
39+
bool i2c_adapter_drvdata_initialized;
40+
};
41+
42+
// FPGA
43+
typedef struct {
44+
uint32_t data_base_offset;
45+
uint32_t data_size;
46+
} FPGA_OPS_DATA;
47+
48+
struct pddf_multi_fpgapci_ops_t {
49+
int (*post_device_operation)(struct pci_dev *);
50+
};
51+
52+
extern struct pddf_multi_fpgapci_ops_t pddf_multi_fpgapci_ops;
53+
54+
struct pci_dev *multifpgapci_get_pci_dev(const char *bdf);
55+
extern int (*ptr_multifpgapci_readpci)(struct pci_dev *, uint32_t, uint32_t *);
56+
extern int (*ptr_multifpgapci_writepci)(struct pci_dev *, uint32_t, uint32_t);
57+
58+
#endif
Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
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
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
obj-m := driver/ i2c/
2+
obj-m += pddf_multifpgapci_module.o
3+
4+
ccflags-y:= -I$(M)/modules/include
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
TARGET = pddf_multifpgapci_driver
2+
obj-m := $(TARGET).o
3+
4+
ccflags-y := -I$(M)/modules/include

0 commit comments

Comments
 (0)