Skip to content

Commit

Permalink
add get/put scom cfam support for ody ocmb with kernel backend
Browse files Browse the repository at this point in the history
1) Uses the device path configured in the kernel backend device
tree to perform get and put scom on odyssey ddr5 chip

2) Checks attribute chip-id of the ocmb target to differentiate
between ddr4 and ddr5 ocmb chips for get/put scom

4) For ddr5 ocmb targets its corresponding scom device path is
used for get/put scom

4) For cfam i2c target path configured in the backend device tree
is used.

Tested:
test get/putscom
1) At present noticing kernel panic at kernel_pib_getscom method
   need to debug further.

test - getcfam
get_ody_fsi_target ocmb_proc 2 ocmb_index 3
kernel_fsi_probe fsi_path set is /i2cr311/slave@00:00/raw
get_ody_fsi_target ocmb_proc 2 ocmb_index 3
kernel_fsi_getcfam address 02804
kernel_fsi_getcfam value 010000010
PDBG:fsi_ody_read[383]: rc = 0, addr = 0x02804, data = 0x10000010, target =
/hmfsi-ody@311
ody kernel pib read address 0x2804 value 0x10000010

Change-Id: Ia768e375e4a190c328b6fa71ba7bff6a195c26e5
Signed-off-by: Marri Devender Rao <devenrao@in.ibm.com>
  • Loading branch information
devenrao committed Dec 14, 2023
1 parent 447f32b commit 216740b
Show file tree
Hide file tree
Showing 4 changed files with 345 additions and 14 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

/dts-v1/;

Expand Down Expand Up @@ -141,4 +193,77 @@ define(`HMFSI',
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)
};
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);
}
49 changes: 49 additions & 0 deletions libpdbg/libpdbg.h
Original file line number Diff line number Diff line change
Expand Up @@ -760,6 +760,24 @@ int fsi_write(struct pdbg_target *target, uint32_t addr, uint32_t val);
*/
int fsi_write_mask(struct pdbg_target *target, uint32_t addr, uint32_t val, uint32_t mask);

/**
* @brief Read a CFAM FSI register
* @param[in] target the pdbg_target
* @param[in] addr the CFAM address offset
* @param[out] val the read data
* @return int 0 if successful, -1 otherwise
*/
int fsi_ody_read(struct pdbg_target *target, uint32_t addr, uint32_t *val);

/**
* @brief Write a CFAM FSI register
* @param[in] target the pdbg_target
* @param[in] addr the address offset relative to target
* @param[in] val the write data
* @return int 0 if successful, -1 otherwise
*/
int fsi_ody_write(struct pdbg_target *target, uint32_t addr, uint32_t val);

/**
* @brief Read a PIB SCOM register
* @param[in] target the pdbg_target
Expand All @@ -778,6 +796,24 @@ int pib_read(struct pdbg_target *target, uint64_t addr, uint64_t *val);
*/
int pib_write(struct pdbg_target *target, uint64_t addr, uint64_t val);

/**
* @brief Read a PIB odyssey ocmb SCOM register
* @param[in] target the pdbg_target
* @param[in] addr the address offset relative to target
* @param[out] val the read data
* @return int 0 if successful, -1 otherwise
*/
int pib_ody_read(struct pdbg_target *target, uint64_t addr, uint64_t *val);

/**
* @brief Write a PIB odyssey ocmb SCOM register
* @param[in] target the pdbg_target
* @param[in] addr the address offset relative to target
* @param[out] val the write data
* @return int 0 if successful, -1 otherwise
*/
int pib_ody_write(struct pdbg_target *target, uint64_t addr, uint64_t val);

/**
* @brief Write a PIB SCOM register with a mask
* @param[in] target the pdbg_target
Expand All @@ -798,6 +834,19 @@ int pib_write_mask(struct pdbg_target *target, uint64_t addr, uint64_t val, uint
*/
int pib_wait(struct pdbg_target *pib_dt, uint64_t addr, uint64_t mask, uint64_t data);

/**
* @brief Get the PIB pdbg target for the matching odyssey ocmb chip target
* @param[in] target the ocmb pdbg_target
* @return pib target
*/
struct pdbg_target* get_ody_pib_target(struct pdbg_target* target);

/**
* @brief Get the fsi pdbg target for the matching odyssey ocmb chip target
* @param[in] target ocmb pdbg_target
* @return fsi target
*/
struct pdbg_target* get_ody_fsi_target(struct pdbg_target* target);
/**
* @brief Read data from i2c device
*
Expand Down
Loading

0 comments on commit 216740b

Please sign in to comment.