Skip to content

Commit

Permalink
Merge pull request #80 from devenrao/ody
Browse files Browse the repository at this point in the history
get & put scom, getcfam, dump and ffdc support with sbefifo and kernel backend
  • Loading branch information
aravynd authored Dec 14, 2023
2 parents 006917c + b3cd977 commit 944045b
Show file tree
Hide file tree
Showing 14 changed files with 806 additions and 56 deletions.
125 changes: 125 additions & 0 deletions bmc-kernel.dts.m4
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,26 @@ define(`PIB',
};
')dnl


dnl
dnl PIB_ODY([index], [proc], [path-index], port)
dnl
define(`PIB_ODY',
`
pib_ody@$3$4 {
#address-cells = <0x2>;
#size-cells = <0x1>;
reg = <0x0 0x$1 0x8000>; /*dummy to fix dts warning*/
compatible = "ibm,kernel-pib-ody";
index = <0x$1>;
proc = <0x$2>;
port = <$4>;
device-path = "/dev/scom$3$4";
system-path = "/proc$2/ocmb$1";
};
')dnl


dnl
dnl SBEFIFO([index], [path-index])
dnl
Expand Down Expand Up @@ -106,6 +126,38 @@ define(`HMFSI',
};
')dnl

//ody ocmb chips are defined in system device tree. The pdbg targets
//that captures the device path to communicate with system ody ocmb
//chips will be defined in backend device tree.

//ody ocmb system device tree targets need to be mapped to backend
//ody pib device tree targets for communication with the ody ocmb targets.
//Mapping is done based on proc, ocmb chip index of the ody ocmb system target
//with the proc, ocmb index and port number defined in the backend kernel device
//tree

//for get or put scom in kernel mode device path defined in PIBODY will be used
//for cfam device-path specified in HMFSIODY will be used
dnl
dnl HMFSI_ODY([index], [proc], [path-index], [port])
dnl
define(`HMFSI_ODY',
`
hmfsi-ody@$3$4 {
#address-cells = <0x2>;
#size-cells = <0x1>;
compatible = "ibm,kernel-fsi-ody";
device-path = "/i2cr$3$4/slave@00:00/raw";
reg = <0x0 0x$1 0x8000>; /*dummy to fix dts warning*/
index = <0x$1>;
proc = <0x$2>;
port = <$4>;
system-path = "/proc$2/ocmb$1/fsi";

PIB_ODY($1, $2, $3, $4)
/*SBE_FIFO not required in kernel mode */
};
')dnl

/d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Y(3, 5, 6, 11)
HMFSI_ODY(4, 5, 6, 14)
HMFSI_ODY(5, 5, 6, 15)
HMFSI_ODY(6, 5, 6, 16)
HMFSI_ODY(7, 5, 6, 17)

HMFSI_ODY(0, 6, 7, 00)
HMFSI_ODY(1, 6, 7, 01)
HMFSI_ODY(2, 6, 7, 10)
HMFSI_ODY(3, 6, 7, 11)
HMFSI_ODY(4, 6, 7, 12)
HMFSI_ODY(5, 6, 7, 13)
HMFSI_ODY(6, 6, 7, 14)
HMFSI_ODY(7, 6, 7, 15)

HMFSI_ODY(0, 7, 8, 02)
HMFSI_ODY(1, 7, 8, 03)
HMFSI_ODY(2, 7, 8, 10)
HMFSI_ODY(3, 7, 8, 11)
HMFSI_ODY(4, 7, 8, 14)
HMFSI_ODY(5, 7, 8, 15)
HMFSI_ODY(6, 7, 8, 16)
HMFSI_ODY(7, 7, 8, 17)
};
127 changes: 127 additions & 0 deletions bmc-sbefifo.dts.m4
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,60 @@ define(`HMFSI',
};
')dnl

//ocmb ody ddr5 chip SBE instance will be mapped to /dev/sbefifoXYY
//device path where X is proc and YY is port. BMC need to use this
//path for get/put scom to SBE instance of the ocmb ddr5 chip.

//ody ocmb chips will be defined in system device tree, where as how
//the sbe instances of these ody ocmb chips will be defined in this
//backend device tree

//ody ocmb system device tree targets will be mapped to backend
//ody sbefifo device tree targets based on proc, ocmb chip index
dnl
dnl HMFSI_ODY([index], [proc], [path-index], [port])
dnl
define(`HMFSI_ODY',
`
hmfsi-ody@$3$4 {
#address-cells = <0x2>;
#size-cells = <0x1>;
compatible = "ibm,kernel-fsi-ody";
device-path = "/i2cr$3$4/slave@00:00/raw";
reg = <0x0 0x$1 0x8000>; /*dummy to fix dts warning*/
index = <0x$1>;
proc = <0x$2>;
port = <$4>;

SBEFIFO_ODY($1, $2, $3, $4)
};
')dnl

dnl
dnl SBEFIFO_ODY([index], [proc], [path-index], [port] [])
dnl
define(`SBEFIFO_ODY',
`
sbefifo-ody@$3$4{ /* Bogus address */
#address-cells = <0x2>;
#size-cells = <0x1>;
compatible = "ibm,kernel-sbefifo-ody";
reg = <0x0 0x$1 0x8000>; /*dummy to fix dts warning*/
index = <0x$1>;
proc = <0x$2>;
port = <$4>;
device-path = "/dev/sbefifo$3$4";

sbefifo-chipop-ody {
compatible = "ibm,sbefifo-chipop-ody";
index = <0x$1>;
proc = <0x$2>;
port = <$4>;
};
};

')dnl

dnl
dnl BMC_I2CBUS([index])
dnl
Expand Down Expand Up @@ -131,4 +185,77 @@ define(`BMC_I2CBUS',
HMFSI(400000, 7, 7, 8)

FSI_POST()

HMFSI_ODY(0, 0, 1, 00)
HMFSI_ODY(1, 0, 1, 01)
HMFSI_ODY(2, 0, 1, 10)
HMFSI_ODY(3, 0, 1, 11)
HMFSI_ODY(4, 0, 1, 12)
HMFSI_ODY(5, 0, 1, 13)
HMFSI_ODY(6, 0, 1, 14)
HMFSI_ODY(7, 0, 1, 15)

HMFSI_ODY(0, 1, 2, 02)
HMFSI_ODY(1, 1, 2, 03)
HMFSI_ODY(2, 1, 2, 10)
HMFSI_ODY(3, 1, 2, 11)
HMFSI_ODY(4, 1, 2, 14)
HMFSI_ODY(5, 1, 2, 15)
HMFSI_ODY(6, 1, 2, 16)
HMFSI_ODY(7, 1, 2, 17)


HMFSI_ODY(0, 2, 3, 00)
HMFSI_ODY(1, 2, 3, 01)
HMFSI_ODY(2, 2, 3, 10)
HMFSI_ODY(3, 2, 3, 11)
HMFSI_ODY(4, 2, 3, 12)
HMFSI_ODY(5, 2, 3, 13)
HMFSI_ODY(6, 2, 3, 14)
HMFSI_ODY(7, 2, 3, 15)

HMFSI_ODY(0, 3, 4, 02)
HMFSI_ODY(1, 3, 4, 03)
HMFSI_ODY(2, 3, 4, 10)
HMFSI_ODY(3, 3, 4, 11)
HMFSI_ODY(4, 3, 4, 14)
HMFSI_ODY(5, 3, 4, 15)
HMFSI_ODY(6, 3, 4, 16)
HMFSI_ODY(7, 3, 4, 17)

HMFSI_ODY(0, 4, 5, 00)
HMFSI_ODY(1, 4, 5, 01)
HMFSI_ODY(2, 4, 5, 10)
HMFSI_ODY(3, 4, 5, 11)
HMFSI_ODY(4, 4, 5, 12)
HMFSI_ODY(5, 4, 5, 13)
HMFSI_ODY(6, 4, 5, 14)
HMFSI_ODY(7, 4, 5, 15)

HMFSI_ODY(0, 5, 6, 02)
HMFSI_ODY(1, 5, 6, 03)
HMFSI_ODY(2, 5, 6, 10)
HMFSI_ODY(3, 5, 6, 11)
HMFSI_ODY(4, 5, 6, 14)
HMFSI_ODY(5, 5, 6, 15)
HMFSI_ODY(6, 5, 6, 16)
HMFSI_ODY(7, 5, 6, 17)

HMFSI_ODY(0, 6, 7, 00)
HMFSI_ODY(1, 6, 7, 01)
HMFSI_ODY(2, 6, 7, 10)
HMFSI_ODY(3, 6, 7, 11)
HMFSI_ODY(4, 6, 7, 12)
HMFSI_ODY(5, 6, 7, 13)
HMFSI_ODY(6, 6, 7, 14)
HMFSI_ODY(7, 6, 7, 15)

HMFSI_ODY(0, 7, 8, 02)
HMFSI_ODY(1, 7, 8, 03)
HMFSI_ODY(2, 7, 8, 10)
HMFSI_ODY(3, 7, 8, 11)
HMFSI_ODY(4, 7, 8, 14)
HMFSI_ODY(5, 7, 8, 15)
HMFSI_ODY(6, 7, 8, 16)
HMFSI_ODY(7, 7, 8, 17)
};
19 changes: 19 additions & 0 deletions libpdbg/dtb.c
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,10 @@
static enum pdbg_proc pdbg_proc = PDBG_PROC_UNKNOWN;
static enum pdbg_backend pdbg_backend = PDBG_DEFAULT_BACKEND;
static const char *pdbg_backend_option;

static const uint16_t ODYSSEY_CHIP_ID = 0x60C0;
static const uint8_t ATTR_TYPE_OCMB_CHIP = 75;

static struct pdbg_dtb pdbg_dtb = {
.backend = {
.fd = -1,
Expand Down Expand Up @@ -608,6 +612,21 @@ static void close_dtb(struct pdbg_mfile *mfile)
}
}

bool is_ody_ocmb_chip(struct pdbg_target *target)
{
uint8_t type;
pdbg_target_get_attribute(target, "ATTR_TYPE", 1, 1, &type);
if(type != ATTR_TYPE_OCMB_CHIP) {
return false;
}
uint32_t chipId = 0;
pdbg_target_get_attribute(target, "ATTR_CHIP_ID", 4, 1, &chipId);
if(chipId == ODYSSEY_CHIP_ID) {
return true;
}
return false;
}

__attribute__((destructor))
static void pdbg_close_targets(void)
{
Expand Down
7 changes: 7 additions & 0 deletions libpdbg/hwunit.h
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,13 @@ struct chipop {
};
#define target_to_chipop(x) container_of(x, struct chipop, target)

struct chipop_ody {
struct pdbg_target target;
uint32_t (*ffdc_get)(struct pdbg_target *, const uint8_t **, uint32_t *);
int (*dump)(struct chipop_ody *, uint8_t, uint8_t, uint8_t, uint8_t **, uint32_t *);
};
#define target_to_chipop_ody(x) container_of(x, struct chipop_ody, target)

struct sbefifo {
struct pdbg_target target;
struct sbefifo_context *sf_ctx;
Expand Down
29 changes: 29 additions & 0 deletions libpdbg/kernel.c
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,20 @@ static struct fsi kernel_fsi = {
};
DECLARE_HW_UNIT(kernel_fsi);

static struct fsi kernel_fsi_ody = {
.target = {
.name = "Kernel based FSI master for odyssey",
.compatible = "ibm,kernel-fsi-ody",
.class = "fsi-ody",
.probe = kernel_fsi_probe,
.release = kernel_fsi_release,
},
.read = kernel_fsi_getcfam,
.write = kernel_fsi_putcfam,
};
DECLARE_HW_UNIT(kernel_fsi_ody);


static int kernel_pib_getscom(struct pib *pib, uint64_t addr, uint64_t *value)
{
int rc;
Expand Down Expand Up @@ -270,9 +284,24 @@ struct pib kernel_pib = {
};
DECLARE_HW_UNIT(kernel_pib);

struct pib kernel_pib_ody = {
.target = {
.name = "Kernel based FSI SCOM for odyssey",
.compatible = "ibm,kernel-pib-ody",
.class = "pib-ody",
.probe = kernel_pib_probe,
},
.read = kernel_pib_getscom,
.write = kernel_pib_putscom,
};
DECLARE_HW_UNIT(kernel_pib_ody);


__attribute__((constructor))
static void register_kernel(void)
{
pdbg_hwunit_register(PDBG_DEFAULT_BACKEND, &kernel_fsi_hw_unit);
pdbg_hwunit_register(PDBG_DEFAULT_BACKEND, &kernel_fsi_ody_hw_unit);
pdbg_hwunit_register(PDBG_DEFAULT_BACKEND, &kernel_pib_hw_unit);
pdbg_hwunit_register(PDBG_DEFAULT_BACKEND, &kernel_pib_ody_hw_unit);
}
Loading

0 comments on commit 944045b

Please sign in to comment.