Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion platform/pddf/i2c/debian/rules
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ PACKAGE_PRE_NAME := sonic-platform-pddf
KVERSION ?= $(shell uname -r)
KERNEL_SRC := /lib/modules/$(KVERSION)
MOD_SRC_DIR:= $(shell pwd)
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
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
MODULE_DIR:= modules
UTILS_DIR := utils
SERVICE_DIR := service
Expand Down
2 changes: 1 addition & 1 deletion platform/pddf/i2c/modules/Makefile
Original file line number Diff line number Diff line change
@@ -1 +1 @@
obj-m := client/ cpld/ cpldmux/ fpgai2c/ fpgapci/ xcvr/ mux/ gpio/ psu/ fan/ led/ sysstatus/
obj-m := client/ cpld/ cpldmux/ fpgai2c/ fpgapci/ multifpgapci/ xcvr/ mux/ gpio/ psu/ fan/ led/ sysstatus/
1 change: 1 addition & 0 deletions platform/pddf/i2c/modules/include/pddf_client_defs.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
#define SYSSTATUS "PDDF_SYSSTATUS"
#define XCVR "PDDF_XCVR"
#define FPGA "PDDF_FPGAPCI"
#define MULTIFPGA "PDDF_MULTIFPGAPCI"


#define PDDF_DEBUG
Expand Down
2 changes: 1 addition & 1 deletion platform/pddf/i2c/modules/include/pddf_i2c_algo.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
#include "pddf_client_defs.h"

/* max number of adapters */
#define I2C_PCI_MAX_BUS 16
#define I2C_PCI_MAX_BUS 512

/**
* struct fpgapci_devdata - PCI device data structure
Expand Down
7 changes: 5 additions & 2 deletions platform/pddf/i2c/modules/include/pddf_led_defs.h
Original file line number Diff line number Diff line change
Expand Up @@ -123,9 +123,11 @@ typedef enum{
LED_FANTRAY,
LED_DIAG,
LED_LOC,
LED_BMC,
LED_BMC,
LED_PORT,
LED_TYPE_MAX
} LED_TYPE;

char* LED_TYPE_STR[LED_TYPE_MAX] =
{
"LED_SYS",
Expand All @@ -134,7 +136,8 @@ char* LED_TYPE_STR[LED_TYPE_MAX] =
"LED_FANTRAY",
"LED_DIAG",
"LED_LOC",
"LED_BMC"
"LED_BMC",
"LED_PORT",
};

/*****************************************
Expand Down
57 changes: 57 additions & 0 deletions platform/pddf/i2c/modules/include/pddf_multifpgapci_defs.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
/*
* Copyright 2025 Nexthop Systems Inc.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* Description:
* Platform MULTIFPGAPCI defines/structures header file
*/

#ifndef __PDDF_MULTIFPGAPCI_DEFS_H__
#define __PDDF_MULTIFPGAPCI_DEFS_H__

#include "linux/types.h"
#include <linux/pci.h>

#include "pddf_multifpgapci_i2c_defs.h"

#define NAME_SIZE 32
#define KOBJ_FREE(obj) \
if (obj) \
kobject_put(obj);

struct pddf_multifpgapci_drvdata {
struct pci_dev *pci_dev;
resource_size_t bar_start;
void *__iomem fpga_data_base_addr;
// i2c
size_t bar_length;
struct kobject *i2c_kobj;
struct i2c_adapter_drvdata i2c_adapter_drvdata;
bool i2c_adapter_drvdata_initialized;
};

// FPGA
typedef struct {
uint32_t data_base_offset;
uint32_t data_size;
} FPGA_OPS_DATA;

struct pddf_multi_fpgapci_ops_t {
int (*post_device_operation)(struct pci_dev *);
};

extern struct pddf_multi_fpgapci_ops_t pddf_multi_fpgapci_ops;

extern int (*ptr_multifpgapci_readpci)(struct pci_dev *, uint32_t, uint32_t *);
extern int (*ptr_multifpgapci_writepci)(struct pci_dev *, uint32_t, uint32_t);

#endif
73 changes: 73 additions & 0 deletions platform/pddf/i2c/modules/include/pddf_multifpgapci_i2c_defs.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
/*
* Copyright 2025 Nexthop Systems Inc.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*/

#ifndef __PDDF_MULTIFPGAPCI_I2C_DEFS_H__
#define __PDDF_MULTIFPGAPCI_I2C_DEFS_H__

#include <linux/i2c.h>
#include "linux/types.h"
#include <linux/kobject.h>
#include <linux/pci.h>
#include <linux/sysfs.h>

#include "pddf_client_defs.h"

#define I2C_PCI_MAX_BUS 512

struct i2c_adapter_attrs {
PDDF_ATTR attr_virt_bus;
PDDF_ATTR attr_ch_base_offset;
PDDF_ATTR attr_ch_size;
PDDF_ATTR attr_num_virt_ch;
PDDF_ATTR attr_new_i2c_adapter;
PDDF_ATTR attr_del_i2c_adapter;
};

#define NUM_I2C_ADAPTER_ATTRS \
(sizeof(struct i2c_adapter_attrs) / sizeof(PDDF_ATTR))

struct i2c_adapter_sysfs_vals {
uint32_t virt_bus;
uint32_t ch_base_offset;
uint32_t ch_size;
uint32_t num_virt_ch;
};

struct i2c_adapter_drvdata {
// temp_sysfs_vals store temporary values provided by sysfs,
// which are eventually copied/saved to I2C adapter platform data.
struct i2c_adapter_sysfs_vals temp_sysfs_vals;

// platform data
struct i2c_adapter i2c_adapters[I2C_PCI_MAX_BUS];
bool i2c_adapter_registered[I2C_PCI_MAX_BUS];
int virt_bus;
void *__iomem ch_base_addr;
int ch_size;
int num_virt_ch;

// sysfs attrs
struct i2c_adapter_attrs attrs;
struct attribute *i2c_adapter_attrs[NUM_I2C_ADAPTER_ATTRS + 1];
struct attribute_group i2c_adapter_attr_group;
};

extern int pddf_multifpgapci_i2c_module_init(struct pci_dev *pci_dev,
struct kobject *kobj);

// Only called if multifpgapci_i2c_module_init succeeded
extern void pddf_multifpgapci_i2c_module_exit(struct pci_dev *pci_dev,
struct kobject *kobj);

#endif
Loading
Loading