diff --git a/bmc-kernel.dts.m4 b/bmc-kernel.dts.m4 index e07a98d9c..600141bcd 100644 --- a/bmc-kernel.dts.m4 +++ b/bmc-kernel.dts.m4 @@ -203,67 +203,68 @@ define(`HMFSI_ODY', 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) + HMFSI_ODY(8, 1, 2, 02) + HMFSI_ODY(9, 1, 2, 03) + HMFSI_ODY(a, 1, 2, 10) + HMFSI_ODY(b, 1, 2, 11) + HMFSI_ODY(c, 1, 2, 14) + HMFSI_ODY(d, 1, 2, 15) + HMFSI_ODY(e, 1, 2, 16) + HMFSI_ODY(f, 1, 2, 17) + + + HMFSI_ODY(10, 2, 3, 00) + HMFSI_ODY(11, 2, 3, 01) + HMFSI_ODY(12, 2, 3, 10) + HMFSI_ODY(13, 2, 3, 11) + HMFSI_ODY(14, 2, 3, 12) + HMFSI_ODY(15, 2, 3, 13) + HMFSI_ODY(16, 2, 3, 14) + HMFSI_ODY(17, 2, 3, 15) + + HMFSI_ODY(18, 3, 4, 02) + HMFSI_ODY(19, 3, 4, 03) + HMFSI_ODY(1a, 3, 4, 10) + HMFSI_ODY(1b, 3, 4, 11) + HMFSI_ODY(1c, 3, 4, 14) + HMFSI_ODY(1d, 3, 4, 15) + HMFSI_ODY(1e, 3, 4, 16) + HMFSI_ODY(1f, 3, 4, 17) + + HMFSI_ODY(20, 4, 5, 00) + HMFSI_ODY(21, 4, 5, 01) + HMFSI_ODY(22, 4, 5, 10) + HMFSI_ODY(23, 4, 5, 11) + HMFSI_ODY(24, 4, 5, 12) + HMFSI_ODY(25, 4, 5, 13) + HMFSI_ODY(26, 4, 5, 14) + HMFSI_ODY(27, 4, 5, 15) + + HMFSI_ODY(28, 5, 6, 02) + HMFSI_ODY(29, 5, 6, 03) + HMFSI_ODY(2a, 5, 6, 10) + HMFSI_ODY(2b, 5, 6, 11) + HMFSI_ODY(2c, 5, 6, 14) + HMFSI_ODY(2d, 5, 6, 15) + HMFSI_ODY(2e, 5, 6, 16) + HMFSI_ODY(2f, 5, 6, 17) + + HMFSI_ODY(30, 6, 7, 00) + HMFSI_ODY(31, 6, 7, 01) + HMFSI_ODY(32, 6, 7, 10) + HMFSI_ODY(33, 6, 7, 11) + HMFSI_ODY(34, 6, 7, 12) + HMFSI_ODY(35, 6, 7, 13) + HMFSI_ODY(36, 6, 7, 14) + HMFSI_ODY(37, 6, 7, 15) + + HMFSI_ODY(38, 7, 8, 02) + HMFSI_ODY(39, 7, 8, 03) + HMFSI_ODY(3a, 7, 8, 10) + HMFSI_ODY(3b, 7, 8, 11) + HMFSI_ODY(3c, 7, 8, 14) + HMFSI_ODY(3d, 7, 8, 15) + HMFSI_ODY(3e, 7, 8, 16) + HMFSI_ODY(3f, 7, 8, 17) + }; diff --git a/bmc-sbefifo.dts.m4 b/bmc-sbefifo.dts.m4 index 1541cdfa4..08dd70c61 100644 --- a/bmc-sbefifo.dts.m4 +++ b/bmc-sbefifo.dts.m4 @@ -96,18 +96,18 @@ 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) - }; + 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 @@ -115,7 +115,7 @@ dnl SBEFIFO_ODY([index], [proc], [path-index], [port] []) dnl define(`SBEFIFO_ODY', ` - sbefifo-ody@$3$4{ /* Bogus address */ + sbefifo@2400{ /* Bogus address */ #address-cells = <0x2>; #size-cells = <0x1>; compatible = "ibm,kernel-sbefifo-ody"; @@ -125,7 +125,15 @@ define(`SBEFIFO_ODY', port = <$4>; device-path = "/dev/sbefifo$3$4"; - sbefifo-chipop-ody { + sbefifo-pib { + #address-cells = <0x2>; + #size-cells = <0x1>; + compatible = "ibm,sbefifo-pib-ody"; + index = <0x$1>; + system-path = "/proc$2/ocmb$1/pib"; + }; + + sbefifo-chipop { compatible = "ibm,sbefifo-chipop-ody"; index = <0x$1>; proc = <0x$2>; @@ -195,67 +203,67 @@ define(`BMC_I2CBUS', 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) + HMFSI_ODY(8, 1, 2, 02) + HMFSI_ODY(9, 1, 2, 03) + HMFSI_ODY(a, 1, 2, 10) + HMFSI_ODY(b, 1, 2, 11) + HMFSI_ODY(c, 1, 2, 14) + HMFSI_ODY(d, 1, 2, 15) + HMFSI_ODY(e, 1, 2, 16) + HMFSI_ODY(f, 1, 2, 17) + + + HMFSI_ODY(10, 2, 3, 00) + HMFSI_ODY(11, 2, 3, 01) + HMFSI_ODY(12, 2, 3, 10) + HMFSI_ODY(13, 2, 3, 11) + HMFSI_ODY(14, 2, 3, 12) + HMFSI_ODY(15, 2, 3, 13) + HMFSI_ODY(16, 2, 3, 14) + HMFSI_ODY(17, 2, 3, 15) + + HMFSI_ODY(18, 3, 4, 02) + HMFSI_ODY(19, 3, 4, 03) + HMFSI_ODY(1a, 3, 4, 10) + HMFSI_ODY(1b, 3, 4, 11) + HMFSI_ODY(1c, 3, 4, 14) + HMFSI_ODY(1d, 3, 4, 15) + HMFSI_ODY(1e, 3, 4, 16) + HMFSI_ODY(1f, 3, 4, 17) + + HMFSI_ODY(20, 4, 5, 00) + HMFSI_ODY(21, 4, 5, 01) + HMFSI_ODY(22, 4, 5, 10) + HMFSI_ODY(23, 4, 5, 11) + HMFSI_ODY(24, 4, 5, 12) + HMFSI_ODY(25, 4, 5, 13) + HMFSI_ODY(26, 4, 5, 14) + HMFSI_ODY(27, 4, 5, 15) + + HMFSI_ODY(28, 5, 6, 02) + HMFSI_ODY(29, 5, 6, 03) + HMFSI_ODY(2a, 5, 6, 10) + HMFSI_ODY(2b, 5, 6, 11) + HMFSI_ODY(2c, 5, 6, 14) + HMFSI_ODY(2d, 5, 6, 15) + HMFSI_ODY(2e, 5, 6, 16) + HMFSI_ODY(2f, 5, 6, 17) + + HMFSI_ODY(30, 6, 7, 00) + HMFSI_ODY(31, 6, 7, 01) + HMFSI_ODY(32, 6, 7, 10) + HMFSI_ODY(33, 6, 7, 11) + HMFSI_ODY(34, 6, 7, 12) + HMFSI_ODY(35, 6, 7, 13) + HMFSI_ODY(36, 6, 7, 14) + HMFSI_ODY(37, 6, 7, 15) + + HMFSI_ODY(38, 7, 8, 02) + HMFSI_ODY(39, 7, 8, 03) + HMFSI_ODY(3a, 7, 8, 10) + HMFSI_ODY(3b, 7, 8, 11) + HMFSI_ODY(3c, 7, 8, 14) + HMFSI_ODY(3d, 7, 8, 15) + HMFSI_ODY(3e, 7, 8, 16) + HMFSI_ODY(3f, 7, 8, 17) }; diff --git a/libpdbg/dtb.c b/libpdbg/dtb.c index 2ca99f3df..b4e2084d2 100644 --- a/libpdbg/dtb.c +++ b/libpdbg/dtb.c @@ -627,20 +627,6 @@ bool is_ody_ocmb_chip(struct pdbg_target *target) return false; } -bool is_child_of_ody_chip(struct pdbg_target *target) -{ - struct pdbg_target *ocmb = NULL; - assert(target); - - ocmb = pdbg_target_parent("ocmb", target); - /*If it has a parent and the parent is of odyssey ocmb chip - return true */ - if( (ocmb) && (is_ody_ocmb_chip(ocmb)) ) - return true; - - return false; -} - __attribute__((destructor)) static void pdbg_close_targets(void) { diff --git a/libpdbg/hwunit.h b/libpdbg/hwunit.h index c3edce938..563b58124 100644 --- a/libpdbg/hwunit.h +++ b/libpdbg/hwunit.h @@ -86,13 +86,6 @@ 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; diff --git a/libpdbg/libpdbg.h b/libpdbg/libpdbg.h index ab4525963..376805b53 100644 --- a/libpdbg/libpdbg.h +++ b/libpdbg/libpdbg.h @@ -849,9 +849,9 @@ struct pdbg_target* get_ody_pib_target(struct pdbg_target* target); struct pdbg_target* get_ody_fsi_target(struct pdbg_target* target); /** - * @brief Get the fsi pdbg target for the matching odyssey ocmb chip target + * @brief Get the sbeffifo chipop pdbg target for the matching odyssey ocmb chip target * @param[in] target ocmb pdbg_target - * @return fsi target + * @return co target */ struct pdbg_target* get_ody_chipop_target(struct pdbg_target* target); diff --git a/libpdbg/ocmb.c b/libpdbg/ocmb.c index a341577d2..aade77a0f 100644 --- a/libpdbg/ocmb.c +++ b/libpdbg/ocmb.c @@ -19,14 +19,17 @@ #include "hwunit.h" +const int MAX_OCMB_PER_PROC = 8; static struct sbefifo *ocmb_to_sbefifo(struct ocmb *ocmb) { - struct pdbg_target *pib = pdbg_target_require_parent("pib", &ocmb->target); + // for ddr4 systems need to use proc sbefifo target to access ocmb struct pdbg_target *target; struct sbefifo *sbefifo = NULL; + //TODO: Need to get proc index number based on AFFINITY_PATH when done + uint32_t proc_index = pdbg_target_index(&ocmb->target) / MAX_OCMB_PER_PROC; pdbg_for_each_class_target("sbefifo", target) { - if (pdbg_target_index(target) == pdbg_target_index(pib)) { + if (pdbg_target_index(target) == proc_index) { sbefifo = target_to_sbefifo(target); break; } @@ -39,17 +42,24 @@ static struct sbefifo *ocmb_to_sbefifo(struct ocmb *ocmb) static int sbefifo_ocmb_getscom(struct ocmb *ocmb, uint64_t addr, uint64_t *value) { + if(pdbg_target_probe(&ocmb->target) != PDBG_TARGET_ENABLED) + return -1; + if(is_ody_ocmb_chip(&ocmb->target)) { - struct sbefifo *sbefifo = ody_ocmb_to_sbefifo(&ocmb->target); + struct pdbg_target *target = get_ody_sbefifo_target(&ocmb->target); + if(pdbg_target_probe(target) != PDBG_TARGET_ENABLED) + return -1; + + struct sbefifo *sbefifo = target_to_sbefifo(target); struct sbefifo_context *sctx = sbefifo->get_sbefifo_context(sbefifo); return sbefifo_scom_get(sctx, addr, value); } else { struct sbefifo *sbefifo = ocmb_to_sbefifo(ocmb); - struct sbefifo_context *sctx = sbefifo->get_sbefifo_context(sbefifo); - uint8_t instance_id; - - instance_id = pdbg_target_index(&ocmb->target) & 0xff; + if(pdbg_target_probe(&sbefifo->target) != PDBG_TARGET_ENABLED) + return -1; + struct sbefifo_context *sctx = sbefifo->get_sbefifo_context(sbefifo); + uint8_t instance_id = pdbg_target_index(&ocmb->target) & 0xff; return sbefifo_hw_register_get(sctx, SBEFIFO_TARGET_TYPE_OCMB, instance_id, @@ -60,17 +70,25 @@ static int sbefifo_ocmb_getscom(struct ocmb *ocmb, uint64_t addr, uint64_t *valu static int sbefifo_ocmb_putscom(struct ocmb *ocmb, uint64_t addr, uint64_t value) { + if(pdbg_target_probe(&ocmb->target) != PDBG_TARGET_ENABLED) + return -1; + if(is_ody_ocmb_chip(&ocmb->target)) { - struct sbefifo *sbefifo = ody_ocmb_to_sbefifo(&ocmb->target); + struct pdbg_target *target = get_ody_sbefifo_target(&ocmb->target); + if(pdbg_target_probe(target) != PDBG_TARGET_ENABLED) + return -1; + + struct sbefifo *sbefifo = target_to_sbefifo(target); struct sbefifo_context *sctx = sbefifo->get_sbefifo_context(sbefifo); return sbefifo_scom_put(sctx, addr, value); + } else { struct sbefifo *sbefifo = ocmb_to_sbefifo(ocmb); - struct sbefifo_context *sctx = sbefifo->get_sbefifo_context(sbefifo); - uint8_t instance_id; - - instance_id = pdbg_target_index(&ocmb->target) & 0xff; + if(pdbg_target_probe(&sbefifo->target) != PDBG_TARGET_ENABLED) + return -1; + struct sbefifo_context *sctx = sbefifo->get_sbefifo_context(sbefifo); + uint8_t instance_id = pdbg_target_index(&ocmb->target) & 0xff; return sbefifo_hw_register_put(sctx, SBEFIFO_TARGET_TYPE_OCMB, instance_id, diff --git a/libpdbg/sbe_api.c b/libpdbg/sbe_api.c index 21e1d5be2..b20be5333 100644 --- a/libpdbg/sbe_api.c +++ b/libpdbg/sbe_api.c @@ -78,6 +78,28 @@ static struct chipop *pib_to_chipop(struct pdbg_target *pib) return NULL; } +static struct chipop *pib_ody_to_chipop_ody(struct pdbg_target *pib) +{ + struct pdbg_target *chipop; + uint32_t index; + + assert(pdbg_target_is_class(pib, "pib-ody")); + + if (pdbg_target_status(pib) != PDBG_TARGET_ENABLED) + return NULL; + + index = pdbg_target_index(pib); + + pdbg_for_each_class_target("chipop-ody", chipop) { + if (pdbg_target_index(chipop) != index) + continue; + + if (pdbg_target_probe(chipop) == PDBG_TARGET_ENABLED) + return target_to_chipop(chipop); + } + + return NULL; +} int sbe_istep(struct pdbg_target *target, uint32_t major, uint32_t minor) { struct chipop *chipop; @@ -173,41 +195,33 @@ int sbe_mpipl_get_ti_info(struct pdbg_target *target, uint8_t **data, uint32_t * int sbe_dump(struct pdbg_target *target, uint8_t type, uint8_t clock, uint8_t fa_collect, uint8_t **data, uint32_t *data_len) { - if(!is_ody_ocmb_chip(target)) { - struct chipop *chipop; - int rc; + struct chipop *chipop; + int rc; + + if (pdbg_target_probe(target) != PDBG_TARGET_ENABLED) + return -1; + const char* name = pdbg_target_class_name(target); + if(strcmp(name, "pib-ody") == 0) { + chipop = pib_ody_to_chipop_ody(target); + } else { chipop = pib_to_chipop(target); - if (!chipop) - return -1; + } + if (!chipop) + return -1; - if (!chipop->dump) { - PR_ERROR("dump() not implemented for the target\n"); - return -1; - } + if (pdbg_target_probe(&chipop->target) != PDBG_TARGET_ENABLED) + return -1; - rc = chipop->dump(chipop, type, clock, fa_collect, data, data_len); - if (rc) { - PR_ERROR("sbe dump() returned rc=%d\n", rc); - return -1; - } - } else { - struct chipop_ody *chipop; - int rc; - struct pdbg_target *co_target = get_ody_chipop_target(target); - chipop = target_to_chipop_ody(co_target); - if (!chipop) - return -1; + if (!chipop->dump) { + PR_ERROR("dump() not implemented for the target\n"); + return -1; + } - if (!chipop->dump) { - PR_ERROR("dump() not implemented for the target\n"); - return -1; - } - rc = chipop->dump(chipop, type, clock, fa_collect, data, data_len); - if (rc) { - PR_ERROR("sbe dump() returned rc=%d\n", rc); - return -1; - } + rc = chipop->dump(chipop, type, clock, fa_collect, data, data_len); + if (rc) { + PR_ERROR("sbe dump() returned rc=%d\n", rc); + return -1; } return 0; } @@ -215,55 +229,40 @@ int sbe_dump(struct pdbg_target *target, uint8_t type, uint8_t clock, int sbe_ffdc_get(struct pdbg_target *target, uint32_t *status, uint8_t **ffdc, uint32_t *ffdc_len) { - if(!is_ody_ocmb_chip(target)) { - struct chipop *chipop; - const uint8_t *data = NULL; - uint32_t len = 0; + struct chipop *chipop; + const uint8_t *data = NULL; + uint32_t len = 0; - chipop = pib_to_chipop(target); - if (!chipop) - return -1; + if (pdbg_target_probe(target) != PDBG_TARGET_ENABLED) + return -1; - if (!chipop->ffdc_get) { - PR_ERROR("ffdc_get() not implemented for the target\n"); - return -1; - } - - *status = chipop->ffdc_get(chipop, &data, &len); - if (data && len > 0) { - *ffdc = malloc(len); - assert(*ffdc); - memcpy(*ffdc, data, len); - *ffdc_len = len; - } else { - *ffdc = NULL; - *ffdc_len = 0; - } + const char* name = pdbg_target_class_name(target); + if(strcmp(name, "pib-ody") == 0) { + chipop = pib_ody_to_chipop_ody(target); } else { - struct chipop_ody *chipop; - const uint8_t *data = NULL; - uint32_t len = 0; + chipop = pib_to_chipop(target); + } + if (!chipop) + return -1; - struct pdbg_target *co_target = get_ody_chipop_target(target); - chipop = target_to_chipop_ody(co_target); - if (!chipop) - return -1; + if (pdbg_target_probe(&chipop->target) != PDBG_TARGET_ENABLED) { + return -1; + } - if (!chipop->ffdc_get) { - PR_ERROR("ffdc_get() not implemented for the target\n"); - return -1; - } - - *status = chipop->ffdc_get(target, &data, &len); - if (data && len > 0) { - *ffdc = malloc(len); - assert(*ffdc); - memcpy(*ffdc, data, len); - *ffdc_len = len; - } else { - *ffdc = NULL; - *ffdc_len = 0; - } + if (!chipop->ffdc_get) { + PR_ERROR("ffdc_get() not implemented for the target\n"); + return -1; + } + + *status = chipop->ffdc_get(chipop, &data, &len); + if (data && len > 0) { + *ffdc = malloc(len); + assert(*ffdc); + memcpy(*ffdc, data, len); + *ffdc_len = len; + } else { + *ffdc = NULL; + *ffdc_len = 0; } return 0; } @@ -288,39 +287,39 @@ static int sbe_read_msg_register(struct pdbg_target *pib, uint32_t *value) return 0; } -static int sbe_read_state_register(struct pdbg_target *pib, uint32_t *value) +static int sbe_ody_read_msg_register(struct pdbg_target *fsi, uint32_t *value) { - struct pdbg_target *fsi = pdbg_target_parent_virtual("fsi", pib); int rc; - assert(pdbg_target_is_class(pib, "pib")); assert(fsi); + assert(pdbg_target_is_class(fsi, "fsi-ody")); - if (pdbg_target_status(pib) != PDBG_TARGET_ENABLED) + if (pdbg_target_status(fsi) != PDBG_TARGET_ENABLED) return -1; - rc = fsi_read(fsi, SBE_STATE_REG, value); + rc = fsi_ody_read(fsi, SBE_MSG_REG, value); if (rc) { - PR_NOTICE("Failed to read sbe state register\n"); + PR_NOTICE("Failed to read ody sbe mailbox register\n"); return rc; } return 0; } -static int sbe_ody_read_msg_register(struct pdbg_target *fsi, uint32_t *value) +static int sbe_read_state_register(struct pdbg_target *pib, uint32_t *value) { + struct pdbg_target *fsi = pdbg_target_parent_virtual("fsi", pib); int rc; + assert(pdbg_target_is_class(pib, "pib")); assert(fsi); - assert(pdbg_target_is_class(fsi, "fsi-ody")); - if (pdbg_target_status(fsi) != PDBG_TARGET_ENABLED) + if (pdbg_target_status(pib) != PDBG_TARGET_ENABLED) return -1; - rc = fsi_ody_read(fsi, SBE_MSG_REG, value); + rc = fsi_read(fsi, SBE_STATE_REG, value); if (rc) { - PR_NOTICE("Failed to read ody sbe mailbox register\n"); + PR_NOTICE("Failed to read sbe state register\n"); return rc; } diff --git a/libpdbg/sbefifo.c b/libpdbg/sbefifo.c index b2d42958e..dccc9277f 100644 --- a/libpdbg/sbefifo.c +++ b/libpdbg/sbefifo.c @@ -168,39 +168,7 @@ static int sbefifo_op_putmem_pba(struct mem *sbefifo_mem, static uint32_t sbefifo_op_ffdc_get(struct chipop *chipop, const uint8_t **ffdc, uint32_t *ffdc_len) { - struct pdbg_target *fsi = pdbg_target_require_parent("fsi", &chipop->target); struct sbefifo *sbefifo = target_to_sbefifo(chipop->target.parent); - struct sbefifo_context *sctx = sbefifo->get_sbefifo_context(sbefifo); - uint32_t status, value = 0; - int rc; - - status = sbefifo_ffdc_get(sctx, ffdc, ffdc_len); - if (status) - return status; - - /* Check if async FFDC is set */ - rc = fsi_read(fsi, SBE_MSG_REG, &value); - if (rc) { - PR_NOTICE("Failed to read sbe mailbox register\n"); - goto end; - } - - if ((value & SBE_MSG_ASYNC_FFDC) == SBE_MSG_ASYNC_FFDC) { - sbefifo_get_ffdc(sbefifo->sf_ctx); - return sbefifo_ffdc_get(sctx, ffdc, ffdc_len); - } - -end: - *ffdc = NULL; - *ffdc_len = 0; - return 0; - -} - -static uint32_t sbefifo_op_ody_ffdc_get(struct pdbg_target *ocmb, const uint8_t **ffdc, uint32_t *ffdc_len) -{ - struct pdbg_target *fsi = get_ody_fsi_target(ocmb); - struct sbefifo *sbefifo = target_to_sbefifo(ocmb); struct sbefifo_context *sctx = sbefifo->get_sbefifo_context(sbefifo); uint32_t status, value = 0; @@ -210,11 +178,26 @@ static uint32_t sbefifo_op_ody_ffdc_get(struct pdbg_target *ocmb, const uint8_t if (status) return status; - /* Check if async FFDC is set */ - rc = fsi_ody_read(fsi, SBE_MSG_REG, &value); - if (rc) { - PR_NOTICE("Failed to read sbe mailbox register\n"); - goto end; + const char* co_class = pdbg_target_class_name(&chipop->target); + if (strcmp(co_class, "chipop-ody") == 0) + { + struct pdbg_target *fsi = pdbg_target_require_parent("fsi-ody", &chipop->target); + /* Check if async FFDC is set */ + rc = fsi_ody_read(fsi, SBE_MSG_REG, &value); + if (rc) { + PR_NOTICE("Failed to read sbe mailbox register\n"); + goto end; + } + } + else + { + struct pdbg_target *fsi = pdbg_target_require_parent("fsi", &chipop->target); + /* Check if async FFDC is set */ + rc = fsi_read(fsi, SBE_MSG_REG, &value); + if (rc) { + PR_NOTICE("Failed to read sbe mailbox register\n"); + goto end; + } } if ((value & SBE_MSG_ASYNC_FFDC) == SBE_MSG_ASYNC_FFDC) { @@ -226,8 +209,8 @@ static uint32_t sbefifo_op_ody_ffdc_get(struct pdbg_target *ocmb, const uint8_t *ffdc = NULL; *ffdc_len = 0; return 0; - } + static int sbefifo_op_istep(struct chipop *chipop, uint32_t major, uint32_t minor) { @@ -263,14 +246,8 @@ static int sbefifo_op_mpipl_get_ti_info(struct chipop *chipop, uint8_t **data, u return sbefifo_mpipl_get_ti_info(sctx, data, data_len); } -static int sbefifo_op_dump(struct chipop *chipop, uint8_t type, uint8_t clock, uint8_t fa_collect, uint8_t **data, uint32_t *data_len) -{ - struct sbefifo *sbefifo = target_to_sbefifo(chipop->target.parent); - struct sbefifo_context *sctx = sbefifo->get_sbefifo_context(sbefifo); - - return sbefifo_get_dump(sctx, type, clock, fa_collect, data, data_len); -} -static int sbefifo_op_ody_dump(struct chipop_ody *chipop, uint8_t type, uint8_t clock, uint8_t fa_collect, uint8_t **data, uint32_t *data_len) +static int sbefifo_op_dump(struct chipop *chipop, uint8_t type, uint8_t clock, + uint8_t fa_collect, uint8_t **data, uint32_t *data_len) { struct sbefifo *sbefifo = target_to_sbefifo(chipop->target.parent); struct sbefifo_context *sctx = sbefifo->get_sbefifo_context(sbefifo); @@ -898,14 +875,14 @@ static struct chipop sbefifo_chipop = { }; DECLARE_HW_UNIT(sbefifo_chipop); -static struct chipop_ody sbefifo_chipop_ody = { +static struct chipop sbefifo_chipop_ody = { .target = { .name = "SBE FIFO Chip-op engine odyssey", .compatible = "ibm,sbefifo-chipop-ody", .class = "chipop-ody", }, - .dump = sbefifo_op_ody_dump, - .ffdc_get = sbefifo_op_ody_ffdc_get, + .dump = sbefifo_op_dump, + .ffdc_get = sbefifo_op_ffdc_get, }; DECLARE_HW_UNIT(sbefifo_chipop_ody); @@ -925,6 +902,16 @@ static struct pib sbefifo_pib = { }; DECLARE_HW_UNIT(sbefifo_pib); +static struct pib sbefifo_pib_ody = { + .target = { + .name = "SBE FIFO Chip-op based PIB", + .compatible = "ibm,sbefifo-pib-ody", + .class = "pib-ody", + }, + .fd = -1, +}; +DECLARE_HW_UNIT(sbefifo_pib_ody); + static struct thread sbefifo_thread = { .target = { .name = "SBE FIFO Chip-op based Thread", @@ -988,6 +975,7 @@ static void register_sbefifo(void) pdbg_hwunit_register(PDBG_DEFAULT_BACKEND, &sbefifo_chipop_hw_unit); pdbg_hwunit_register(PDBG_DEFAULT_BACKEND, &sbefifo_chipop_ody_hw_unit); pdbg_hwunit_register(PDBG_DEFAULT_BACKEND, &sbefifo_pib_hw_unit); + pdbg_hwunit_register(PDBG_DEFAULT_BACKEND, &sbefifo_pib_ody_hw_unit); pdbg_hwunit_register(PDBG_BACKEND_SBEFIFO, &sbefifo_thread_hw_unit); pdbg_hwunit_register(PDBG_DEFAULT_BACKEND, &sbefifo_mem_hw_unit); pdbg_hwunit_register(PDBG_DEFAULT_BACKEND, &sbefifo_pba_hw_unit); diff --git a/libpdbg/target.c b/libpdbg/target.c index 6961f8649..300b7dd79 100644 --- a/libpdbg/target.c +++ b/libpdbg/target.c @@ -19,18 +19,19 @@ struct list_head target_classes = LIST_HEAD_INIT(target_classes); static struct pdbg_target *get_class_target_addr(struct pdbg_target *target, const char *name, uint64_t *addr) { uint64_t old_addr = *addr; - /* Check class */ while (strcmp(target->class, name)) { if (target->translate) { *addr = target->translate(target, *addr); target = target_parent(name, target, false); + assert(target); break; } else { *addr += pdbg_target_address(target, NULL); } + /* Keep walking the tree translating addresses */ target = get_parent(target, false); @@ -125,16 +126,14 @@ static int pib_indirect_write(struct pib *pib, uint64_t addr, uint64_t data) return 0; } - -int pib_read(struct pdbg_target *pib_dt, uint64_t addr, uint64_t *data) +int _pib_read(struct pdbg_target *pib_dt, const char* class, uint64_t addr, uint64_t *data) { struct pib *pib; uint64_t target_addr = addr; int rc; + pib_dt = get_class_target_addr(pib_dt, class, &target_addr); - pib_dt = get_class_target_addr(pib_dt, "pib", &target_addr); - - if (pdbg_target_status(pib_dt) != PDBG_TARGET_ENABLED) + if (pdbg_target_probe(pib_dt) != PDBG_TARGET_ENABLED) return -1; pib = target_to_pib(pib_dt); @@ -149,47 +148,31 @@ int pib_read(struct pdbg_target *pib_dt, uint64_t addr, uint64_t *data) else rc = pib->read(pib, target_addr, data); - PR_DEBUG("rc = %d, addr = 0x%016" PRIx64 ", data = 0x%016" PRIx64 ", target = %s\n", + PR_NOTICE("rc = %d, addr = 0x%016" PRIx64 ", data = 0x%016" PRIx64 ", target = %s\n", rc, target_addr, *data, pdbg_target_path(&pib->target)); return rc; } -int pib_ody_read(struct pdbg_target *pib_dt, uint64_t addr, uint64_t *data) +int pib_read(struct pdbg_target *pib_dt, uint64_t addr, uint64_t *data) { - struct pib *pib; - uint64_t target_addr = addr; - int rc; - if (pdbg_target_status(pib_dt) != PDBG_TARGET_ENABLED) - return -1; - - pib = target_to_pib(pib_dt); - - if (!pib->read) { - PR_ERROR("read() not implemented for the target\n"); - return -1; - } - - if (target_addr & PPC_BIT(0)) - rc = pib_indirect_read(pib, target_addr, data); - else - rc = pib->read(pib, target_addr, data); - - PR_DEBUG("rc = %d, addr = 0x%016" PRIx64 ", data = 0x%016" PRIx64 ", target = %s\n", - rc, target_addr, *data, pdbg_target_path(&pib->target)); + return _pib_read(pib_dt, "pib", addr, data); +} - return rc; +int pib_ody_read(struct pdbg_target *pib_dt, uint64_t addr, uint64_t *data) +{ + return _pib_read(pib_dt, "pib-ody", addr, data); } -int pib_write(struct pdbg_target *pib_dt, uint64_t addr, uint64_t data) +int _pib_write(struct pdbg_target *pib_dt, const char* class, uint64_t addr, uint64_t data) { struct pib *pib; uint64_t target_addr = addr; int rc; - pib_dt = get_class_target_addr(pib_dt, "pib", &target_addr); + pib_dt = get_class_target_addr(pib_dt, class, &target_addr); - if (pdbg_target_status(pib_dt) != PDBG_TARGET_ENABLED) + if (pdbg_target_probe(pib_dt) != PDBG_TARGET_ENABLED) return -1; pib = target_to_pib(pib_dt); @@ -206,39 +189,20 @@ int pib_write(struct pdbg_target *pib_dt, uint64_t addr, uint64_t data) else rc = pib->write(pib, target_addr, data); - PR_DEBUG("rc = %d, addr = 0x%016" PRIx64 ", data = 0x%016" PRIx64 ", target = %s\n", + PR_NOTICE("rc = %d, addr = 0x%016" PRIx64 ", data = 0x%016" PRIx64 ", target = %s\n", rc, target_addr, data, pdbg_target_path(&pib->target)); return rc; } -int pib_ody_write(struct pdbg_target *pib_dt, uint64_t addr, uint64_t data) +int pib_write(struct pdbg_target *pib_dt, uint64_t addr, uint64_t data) { - struct pib *pib; - uint64_t target_addr = addr; - int rc; - - if (pdbg_target_status(pib_dt) != PDBG_TARGET_ENABLED) - return -1; - - pib = target_to_pib(pib_dt); - - if (!pib->write) { - PR_ERROR("write() not implemented for the target\n"); - return -1; - } - - PR_DEBUG("addr:0x%08" PRIx64 " data:0x%016" PRIx64 "\n", - target_addr, data); - if (target_addr & PPC_BIT(0)) - rc = pib_indirect_write(pib, target_addr, data); - else - rc = pib->write(pib, target_addr, data); - - PR_DEBUG("rc = %d, addr = 0x%016" PRIx64 ", data = 0x%016" PRIx64 ", target = %s\n", - rc, target_addr, data, pdbg_target_path(&pib->target)); + return _pib_write(pib_dt, "pib", addr, data); +} - return rc; +int pib_ody_write(struct pdbg_target *pib_dt, uint64_t addr, uint64_t data) +{ + return _pib_write(pib_dt, "pib-ody", addr, data); } int pib_write_mask(struct pdbg_target *pib_dt, uint64_t addr, uint64_t data, uint64_t mask) @@ -325,13 +289,17 @@ int opb_write(struct pdbg_target *opb_dt, uint32_t addr, uint32_t data) return opb->write(opb, addr64, data); } -int fsi_read(struct pdbg_target *fsi_dt, uint32_t addr, uint32_t *data) +static int _fsi_read(struct pdbg_target *fsi_dt, const char* class, uint32_t addr, uint32_t *data) { struct fsi *fsi; int rc; uint64_t addr64 = addr; - fsi_dt = get_class_target_addr(fsi_dt, "fsi", &addr64); + fsi_dt = get_class_target_addr(fsi_dt, class, &addr64); + + if (pdbg_target_probe(fsi_dt) != PDBG_TARGET_ENABLED) + return -1; + fsi = target_to_fsi(fsi_dt); if (!fsi->read) { @@ -340,56 +308,33 @@ int fsi_read(struct pdbg_target *fsi_dt, uint32_t addr, uint32_t *data) } rc = fsi->read(fsi, addr64, data); - PR_DEBUG("rc = %d, addr = 0x%05" PRIx64 ", data = 0x%08" PRIx32 ", target = %s\n", + PR_NOTICE("rc = %d, addr = 0x%05" PRIx64 ", data = 0x%08" PRIx32 ", target = %s\n", rc, addr64, *data, pdbg_target_path(&fsi->target)); + return rc; } -int fsi_write(struct pdbg_target *fsi_dt, uint32_t addr, uint32_t data) -{ - struct fsi *fsi; - int rc; - uint64_t addr64 = addr; - - fsi_dt = get_class_target_addr(fsi_dt, "fsi", &addr64); - fsi = target_to_fsi(fsi_dt); - - if (!fsi->write) { - PR_ERROR("write() not implemented for the target\n"); - return -1; - } - rc = fsi->write(fsi, addr64, data); - PR_DEBUG("rc = %d, addr = 0x%05" PRIx64 ", data = 0x%08" PRIx32 ", target = %s\n", - rc, addr64, data, pdbg_target_path(&fsi->target)); - return rc; +int fsi_read(struct pdbg_target *fsi_dt, uint32_t addr, uint32_t *data) +{ + return _fsi_read(fsi_dt, "fsi", addr, data); } int fsi_ody_read(struct pdbg_target *fsi_dt, uint32_t addr, uint32_t *data) { - struct fsi *fsi; - int rc; - uint64_t addr64 = addr; - - fsi = target_to_fsi(fsi_dt); - - if (!fsi->read) { - PR_ERROR("read() not implemented for the target\n"); - return -1; - } - - rc = fsi->read(fsi, addr64, data); - PR_DEBUG("rc = %d, addr = 0x%05" PRIx64 ", data = 0x%08" PRIx32 ", target = %s\n", - rc, addr64, *data, pdbg_target_path(&fsi->target)); - return rc; + return _fsi_read(fsi_dt, "fsi-ody", addr, data); } -int fsi_ody_write(struct pdbg_target *fsi_dt, uint32_t addr, uint32_t data) +static int _fsi_write(struct pdbg_target *fsi_dt, const char* class, uint32_t addr, uint32_t data) { struct fsi *fsi; int rc; uint64_t addr64 = addr; + fsi_dt = get_class_target_addr(fsi_dt, class, &addr64); + if (pdbg_target_probe(fsi_dt) != PDBG_TARGET_ENABLED) + return -1; + fsi = target_to_fsi(fsi_dt); if (!fsi->write) { @@ -398,11 +343,21 @@ int fsi_ody_write(struct pdbg_target *fsi_dt, uint32_t addr, uint32_t data) } rc = fsi->write(fsi, addr64, data); - PR_DEBUG("rc = %d, addr = 0x%05" PRIx64 ", data = 0x%08" PRIx32 ", target = %s\n", + PR_NOTICE("rc = %d, addr = 0x%05" PRIx64 ", data = 0x%08" PRIx32 ", target = %s\n", rc, addr64, data, pdbg_target_path(&fsi->target)); return rc; } +int fsi_write(struct pdbg_target *fsi_dt, uint32_t addr, uint32_t data) +{ + return _fsi_write(fsi_dt, "fsi", addr, data); +} + +int fsi_ody_write(struct pdbg_target *fsi_dt, uint32_t addr, uint32_t data) +{ + return _fsi_write(fsi_dt, "fsi-ody", addr, data); +} + int fsi_write_mask(struct pdbg_target *fsi_dt, uint32_t addr, uint32_t data, uint32_t mask) { uint32_t value; @@ -507,17 +462,7 @@ int ocmb_getscom(struct pdbg_target *target, uint64_t addr, uint64_t *val) { struct ocmb *ocmb; - assert(pdbg_target_is_class(target, "ocmb") || is_child_of_ody_chip(target)); - - /*TODO: https://jsw.ibm.com/browse/PFEBMC-1931 - Handling Odyssey as a special case can be removed, - once device tree hierarchy for ocmb is fixed */ - /*It is memport or perv under odyssey ocmb, - so we need to translate before calling getscom */ - if(is_child_of_ody_chip(target)) - { - target = get_class_target_addr(target, "ocmb", &addr); - } + target = get_class_target_addr(target, "ocmb", &addr); if (pdbg_target_status(target) != PDBG_TARGET_ENABLED) return -1; @@ -536,17 +481,7 @@ int ocmb_putscom(struct pdbg_target *target, uint64_t addr, uint64_t val) { struct ocmb *ocmb; - assert(pdbg_target_is_class(target, "ocmb") || is_child_of_ody_chip(target)); - - /*TODO: https://jsw.ibm.com/browse/PFEBMC-1931 - Handling Odyssey as a special case can be removed, - once device tree hierarchy for ocmb is fixed */ - /*It is memport or perv under odyssey ocmb, - so we need to translate before calling getscom */ - if(is_child_of_ody_chip(target)) - { - target = get_class_target_addr(target, "ocmb", &addr); - } + target = get_class_target_addr(target, "ocmb", &addr); if (pdbg_target_status(target) != PDBG_TARGET_ENABLED) return -1; @@ -605,81 +540,6 @@ struct pdbg_target_class *get_target_class(struct pdbg_target *target) return target_class; } -/*ddr5 ocmb is itself a chip but in device tree as it is kept under - perv, mc, mcc, omi so probing ocmb will probe its parent chips which - are failing, for now treating ody ocmb as special case*/ -enum pdbg_target_status pdbg_target_probe_ody_ocmb(struct pdbg_target *target) -{ - assert(is_ody_ocmb_chip(target) || is_child_of_ody_chip(target)); - - if(is_child_of_ody_chip(target)) - { - if (target && target->probe && target->probe(target)) { - target->status = PDBG_TARGET_NONEXISTENT; - return PDBG_TARGET_NONEXISTENT; - } - target->status = PDBG_TARGET_ENABLED; - - //point to the ocmb target and continue, it will not be NULL for sure - struct pdbg_target *parent_target = pdbg_target_parent("ocmb", target); - return pdbg_target_probe_ody_ocmb(parent_target); - } - - if(pdbg_get_backend() == PDBG_BACKEND_KERNEL) - { - struct pdbg_target *pibtarget = get_ody_pib_target(target); - if (pibtarget && pibtarget->probe && pibtarget->probe(pibtarget)) { - pibtarget->status = PDBG_TARGET_NONEXISTENT; - return PDBG_TARGET_NONEXISTENT; - } - - struct pdbg_target *fsitarget = get_ody_fsi_target(target); - if (fsitarget && fsitarget->probe && fsitarget->probe(fsitarget)) { - fsitarget->status = PDBG_TARGET_NONEXISTENT; - return PDBG_TARGET_NONEXISTENT; - } - - if (target && target->probe && target->probe(target)) { - target->status = PDBG_TARGET_NONEXISTENT; - return PDBG_TARGET_NONEXISTENT; - } - - fsitarget->status = PDBG_TARGET_ENABLED; - target->status = PDBG_TARGET_ENABLED; - pibtarget->status = PDBG_TARGET_ENABLED; - } - else - { - struct sbefifo *sbefifo = ody_ocmb_to_sbefifo(target); - if (sbefifo && sbefifo->target.probe && sbefifo->target.probe(&sbefifo->target)) { - sbefifo->target.status = PDBG_TARGET_NONEXISTENT; - return PDBG_TARGET_NONEXISTENT; - } - if (target && target->probe && target->probe(target)) { - target->status = PDBG_TARGET_NONEXISTENT; - return PDBG_TARGET_NONEXISTENT; - } - - //probe the chip-op target - struct pdbg_target *co_target = get_ody_chipop_target(target); - if (co_target && co_target->probe && co_target->probe(co_target)) { - co_target->status = PDBG_TARGET_NONEXISTENT; - return PDBG_TARGET_NONEXISTENT; - } - - struct pdbg_target *fsi_target = get_ody_fsi_target(target); - if (fsi_target && fsi_target->probe && fsi_target->probe(fsi_target)) { - fsi_target->status = PDBG_TARGET_NONEXISTENT; - return PDBG_TARGET_NONEXISTENT; - } - - target->status = PDBG_TARGET_ENABLED; - sbefifo->target.status = PDBG_TARGET_ENABLED; - co_target->status = PDBG_TARGET_ENABLED; - fsi_target->status = PDBG_TARGET_ENABLED; - } - return PDBG_TARGET_ENABLED; -} /* We walk the tree root down disabling targets which might/should * exist but don't */ @@ -689,22 +549,14 @@ enum pdbg_target_status pdbg_target_probe(struct pdbg_target *target) enum pdbg_target_status status; assert(target); - status = pdbg_target_status(target); assert(status != PDBG_TARGET_RELEASED); - if (status == PDBG_TARGET_DISABLED || status == PDBG_TARGET_NONEXISTENT || status == PDBG_TARGET_ENABLED) /* We've already tried probing this target and by assumption * it's status won't have changed */ return status; - /* odyssey ddr5 ocmb is a chip itself but in device tree it is placed - under chiplet, mc, mcc, omi so do not probe parent targets. - */ - if(is_ody_ocmb_chip(target) || is_child_of_ody_chip(target)) - return pdbg_target_probe_ody_ocmb(target); - parent = get_parent(target, false); if (parent) { /* Recurse up the tree to probe and set parent target status */ @@ -836,15 +688,15 @@ struct pdbg_target *target_to_virtual(struct pdbg_target *target, bool strict) void clear_target_classes() { - struct pdbg_target_class *child = NULL; - struct pdbg_target_class *next = NULL; - list_for_each_safe(&target_classes, child, next, class_head_link) - { - list_del_from(&target_classes, &child->class_head_link); - if (child) - free(child); - child = NULL; - } + struct pdbg_target_class *child = NULL; + struct pdbg_target_class *next = NULL; + list_for_each_safe(&target_classes, child, next, class_head_link) + { + list_del_from(&target_classes, &child->class_head_link); + if (child) + free(child); + child = NULL; + } } struct pdbg_target *get_backend_target(const char* class, @@ -863,21 +715,13 @@ struct pdbg_target *get_backend_target(const char* class, //ody ocmb system device tree targets need to be mapped to backend //ody sbefifo device tree targets for communication with the SBE instance. - //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 device - //tree - - uint32_t ocmb_proc = pdbg_target_index(pdbg_target_parent("proc", - ocmb)); - uint32_t ocmb_index = pdbg_target_index(ocmb) % 0x8; + + //map the ody backend target index to that of the ocmb index + uint32_t ocmb_index = pdbg_target_index(ocmb); struct pdbg_target *target; pdbg_for_each_class_target(class, target) { - uint32_t index = pdbg_target_index(target); - uint32_t proc = 0; - if(!pdbg_target_u32_property(target, "proc", &proc)) { - if(index == ocmb_index && proc == ocmb_proc) { - return target; - } + if(pdbg_target_index(target) == ocmb_index) { + return target; } } @@ -886,16 +730,9 @@ struct pdbg_target *get_backend_target(const char* class, return NULL; } -struct sbefifo *ody_ocmb_to_sbefifo(struct pdbg_target *target) -{ - struct pdbg_target *sbefifo_target = get_backend_target("sbefifo-ody", target); - return target_to_sbefifo(sbefifo_target); -} - -struct chipop_ody *ody_ocmb_to_chipop(struct pdbg_target *target) +struct pdbg_target* get_ody_sbefifo_target(struct pdbg_target *target) { - struct pdbg_target *co_target = get_backend_target("sbefifo-chipop-ody", target); - return target_to_chipop_ody(co_target); + return get_backend_target("sbefifo-ody", target); } struct pdbg_target* get_ody_pib_target(struct pdbg_target *target) diff --git a/libpdbg/target.h b/libpdbg/target.h index a0bd744e0..03bd0fdeb 100644 --- a/libpdbg/target.h +++ b/libpdbg/target.h @@ -117,26 +117,10 @@ void clear_target_classes(); bool is_ody_ocmb_chip(struct pdbg_target *target); /** - * @brief Return true if given target is child of odyssey chip - * @param[in] target - pdbg target - * - * @return true if target is of child of odyssey ocmb chip + * @brief Get the SBEFIFO pdbg target for the matching odyssey ocmb chip target + * @param[in] target the ocmb pdbg_target + * @return sbefifo target */ -bool is_child_of_ody_chip(struct pdbg_target *target); +struct pdbg_target* get_ody_sbefifo_target(struct pdbg_target* target); -/** - * @brief Return matching backend sbefifo target for ocmb target - * @param[in] target - pdbg target - * - * @return backend sbefifo odyssey target - */ -struct sbefifo *ody_ocmb_to_sbefifo(struct pdbg_target *target); - -/** - * @brief Return matching backend sbefifo chipop target for ocmb target - * @param[in] target - pdbg target - * - * @return backend sbefifo odyssey chipop target - */ -struct chipop_ody *ody_ocmb_to_chipop(struct pdbg_target *target); #endif