diff --git a/bmc-sbefifo.dts.m4 b/bmc-sbefifo.dts.m4 index 462a25050..0d52b6fb4 100644 --- a/bmc-sbefifo.dts.m4 +++ b/bmc-sbefifo.dts.m4 @@ -36,6 +36,7 @@ define(`SBEFIFO', }; ')dnl + dnl dnl FSI_PRE([addr], [index], [path-index]) dnl @@ -81,6 +82,42 @@ define(`HMFSI', }; ')dnl +dnl +dnl SBEFIFO_OCMB([index], [proc], [proc], [proc+1], [port] []) +dnl +define(`SBEFIFO_OCMB', +` + sbefifo-ocmb@$3$4{ /* Bogus address */ + #address-cells = <0x1>; + #size-cells = <0x1>; + compatible = "ibm,kernel-sbefifo"; + reg = <0x0 0x1>; /*dummy to fix dts warning*/ + index = <0x$1>; + proc = <0x$2>; + port = <0x$3>; + device-path = "/dev/sbefifo$3$4"; + }; +')dnl + +dnl +dnl HMFSI_OCMB([index], [proc], [proc+1], [port]) +dnl +define(`HMFSI_OCMB', +` + hmfsi-ocmb@$3$4 { + #address-cells = <0x1>; + #size-cells = <0x1>; + compatible = "ibm,kernel-fsi"; + device-path = "/i2cr$3$4/slave@00:00/raw"; + reg = <0x0 0x1>; /*dummy to fix dts warning*/ + index = <0x$1>; + proc = <0x$2>; + port = <0x$3>; + + SBEFIFO_OCMB($1, $2, $3, $4) + }; +')dnl + dnl dnl BMC_I2CBUS([index]) dnl @@ -131,4 +168,77 @@ define(`BMC_I2CBUS', HMFSI(400000, 7, 7, 8) FSI_POST() + + HMFSI_OCMB(0, 0, 1, 00) + HMFSI_OCMB(1, 0, 1, 01) + HMFSI_OCMB(2, 0, 1, 10) + HMFSI_OCMB(3, 0, 1, 11) + HMFSI_OCMB(4, 0, 1, 12) + HMFSI_OCMB(5, 0, 1, 13) + HMFSI_OCMB(6, 0, 1, 14) + HMFSI_OCMB(7, 0, 1, 15) + + HMFSI_OCMB(0, 1, 2, 02) + HMFSI_OCMB(1, 1, 2, 03) + HMFSI_OCMB(2, 1, 2, 10) + HMFSI_OCMB(3, 1, 2, 11) + HMFSI_OCMB(4, 1, 2, 14) + HMFSI_OCMB(5, 1, 2, 15) + HMFSI_OCMB(6, 1, 2, 16) + HMFSI_OCMB(7, 1, 2, 17) + + + HMFSI_OCMB(0, 2, 3, 00) + HMFSI_OCMB(1, 2, 3, 01) + HMFSI_OCMB(2, 2, 3, 10) + HMFSI_OCMB(3, 2, 3, 11) + HMFSI_OCMB(4, 2, 3, 12) + HMFSI_OCMB(5, 2, 3, 13) + HMFSI_OCMB(6, 2, 3, 14) + HMFSI_OCMB(7, 2, 3, 15) + + HMFSI_OCMB(0, 3, 4, 02) + HMFSI_OCMB(1, 3, 4, 03) + HMFSI_OCMB(2, 3, 4, 10) + HMFSI_OCMB(3, 3, 4, 11) + HMFSI_OCMB(4, 3, 4, 14) + HMFSI_OCMB(5, 3, 4, 15) + HMFSI_OCMB(6, 3, 4, 16) + HMFSI_OCMB(7, 3, 4, 17) + + HMFSI_OCMB(0, 4, 5, 00) + HMFSI_OCMB(1, 4, 5, 01) + HMFSI_OCMB(2, 4, 5, 10) + HMFSI_OCMB(3, 4, 5, 11) + HMFSI_OCMB(4, 4, 5, 12) + HMFSI_OCMB(5, 4, 5, 13) + HMFSI_OCMB(6, 4, 5, 14) + HMFSI_OCMB(7, 4, 5, 15) + + HMFSI_OCMB(0, 5, 6, 02) + HMFSI_OCMB(1, 5, 6, 03) + HMFSI_OCMB(2, 5, 6, 10) + HMFSI_OCMB(3, 5, 6, 11) + HMFSI_OCMB(4, 5, 6, 14) + HMFSI_OCMB(5, 5, 6, 15) + HMFSI_OCMB(6, 5, 6, 16) + HMFSI_OCMB(7, 5, 6, 17) + + HMFSI_OCMB(0, 6, 7, 00) + HMFSI_OCMB(1, 6, 7, 01) + HMFSI_OCMB(2, 6, 7, 10) + HMFSI_OCMB(3, 6, 7, 11) + HMFSI_OCMB(4, 6, 7, 12) + HMFSI_OCMB(5, 6, 7, 13) + HMFSI_OCMB(6, 6, 7, 14) + HMFSI_OCMB(7, 6, 7, 15) + + HMFSI_OCMB(0, 7, 8, 02) + HMFSI_OCMB(1, 7, 8, 03) + HMFSI_OCMB(2, 7, 8, 10) + HMFSI_OCMB(3, 7, 8, 11) + HMFSI_OCMB(4, 7, 8, 14) + HMFSI_OCMB(5, 7, 8, 15) + HMFSI_OCMB(6, 7, 8, 16) + HMFSI_OCMB(7, 7, 8, 17) }; diff --git a/libpdbg/hwunit.h b/libpdbg/hwunit.h index 563b58124..097b1c2d8 100644 --- a/libpdbg/hwunit.h +++ b/libpdbg/hwunit.h @@ -340,6 +340,8 @@ struct ocmb { struct pdbg_target target; int (*getscom)(struct ocmb *, uint64_t, uint64_t *); int (*putscom)(struct ocmb *, uint64_t, uint64_t); + int (*odygetscom)(struct ocmb *, uint64_t, uint64_t *); + int (*odyputscom)(struct ocmb *, uint64_t, uint64_t); }; #define target_to_ocmb(x) container_of(x, struct ocmb, target); diff --git a/libpdbg/libpdbg.h b/libpdbg/libpdbg.h index b2a36b5c6..78601c669 100644 --- a/libpdbg/libpdbg.h +++ b/libpdbg/libpdbg.h @@ -1372,6 +1372,28 @@ int ocmb_getscom(struct pdbg_target *target, uint64_t addr, uint64_t *val); */ int ocmb_putscom(struct pdbg_target *target, uint64_t addr, uint64_t val); +/** + * @brief Read a Odyssey OCMB SCOM register + * + * @param[in] target odyssey ocmb target + * @param[in] addr the address offset relative to target + * @param[out] val the read data + * + * @return 0 on success, -1 on failure + */ +int ody_ocmb_getscom(struct pdbg_target *target, uint64_t addr, uint64_t *val); + +/** + * @brief Write a Odyssey OCMB SCOM register + * + * @param[in] target odyssey ocmb target + * @param[in] addr the address offset relative to target + * @param[in] val the write data + * + * @return 0 on success, -1 on failure + */ +int ody_ocmb_putscom(struct pdbg_target *target, uint64_t addr, uint64_t val); + /** * @brief Type for specifying a progress callback for long running * operations diff --git a/libpdbg/ocmb.c b/libpdbg/ocmb.c index ef929f9b7..b3fda9d62 100644 --- a/libpdbg/ocmb.c +++ b/libpdbg/ocmb.c @@ -37,14 +37,70 @@ static struct sbefifo *ocmb_to_sbefifo(struct ocmb *ocmb) return sbefifo; } -static int sbefifo_ocmb_getscom(struct ocmb *ocmb, uint64_t addr, uint64_t *value) +static struct sbefifo *ody_ocmb_to_sbefifo(struct ocmb *ocmb) +{ + /*uint32_t proc_index = pdbg_target_index(pdbg_target_parent("proc", &ocmb->target)); + uint32_t ocmb_index = pdbg_target_index(&ocmb->target) % 0x8; + printf("ody_ocmb_to_sbefifo ocmb index %d proc index %d \n", ocmb_index, proc_index); + + size_t len = 0; + uint32_t port = 0; + struct pdbg_target *target; + struct sbefifo *sbefifo = NULL; + pdbg_for_each_class_target("sbefifo", target) { + if(ocmb_index != pdbg_target_index(target)) { + printf("ody_ocmb_to_sbefifo ocmb index %d != fifoindex %d \n", ocmb_index, pdbg_target_index(target)); + continue; + } + if (pdbg_target_u32_property(target, "port", &port)) + { + char ocmb_devpath[512]; + sprintf(ocmb_devpath, "/dev/sbefifo%d%02d", proc_index+1, port); + const char* sbefifo_devpath = (const char*)pdbg_target_property(target, "device-path", &len); + printf("ody_ocmb_to_sbefifo computed ocmb devpath %s and sbefifo devpath %s \n", ocmb_devpath, sbefifo_devpath); + if(strcmp(ocmb_devpath, sbefifo_devpath) == 0) { + sbefifo = target_to_sbefifo(target); + break; + } + } + }*/ + struct pdbg_target *target; + struct sbefifo *sbefifo = NULL; + int my_index = 0; + pdbg_for_each_class_target("sbefifo", target) { + if(my_index == 9) + { + if (PDBG_TARGET_ENABLED == pdbg_target_probe(target)) + { + printf(" deepa: sbefifo probed\n"); + const char* sbefifo_devpath = (const char*)pdbg_target_property(target, "device-path", NULL); + printf("deepa: sbefifo devpath %s \n", sbefifo_devpath); + break; + } + else + { + printf(" deepa: NOOOOOOOOOOOOO sbefifo probed\n"); + } + } + + my_index++; + + } + sbefifo = target_to_sbefifo(target); + assert(sbefifo); + + return sbefifo; +} + +static int getscom(struct sbefifo *sbefifo, struct ocmb *ocmb, uint64_t addr, uint64_t *value) { - 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; + printf("deepa instance_id: %d\n", instance_id); + return sbefifo_hw_register_get(sctx, SBEFIFO_TARGET_TYPE_OCMB, instance_id, @@ -52,9 +108,14 @@ static int sbefifo_ocmb_getscom(struct ocmb *ocmb, uint64_t addr, uint64_t *valu value); } -static int sbefifo_ocmb_putscom(struct ocmb *ocmb, uint64_t addr, uint64_t value) +static int sbefifo_ocmb_getscom(struct ocmb *ocmb, uint64_t addr, uint64_t *value) { struct sbefifo *sbefifo = ocmb_to_sbefifo(ocmb); + return getscom(sbefifo, ocmb, addr, value); +} + +static int putscom(struct sbefifo *sbefifo, struct ocmb *ocmb, uint64_t addr, uint64_t value) +{ struct sbefifo_context *sctx = sbefifo->get_sbefifo_context(sbefifo); uint8_t instance_id; @@ -67,6 +128,25 @@ static int sbefifo_ocmb_putscom(struct ocmb *ocmb, uint64_t addr, uint64_t value value); } +static int sbefifo_ocmb_putscom(struct ocmb *ocmb, uint64_t addr, uint64_t value) +{ + struct sbefifo *sbefifo = ocmb_to_sbefifo(ocmb); + return putscom(sbefifo, ocmb, addr, value); +} + +static int sbefifo_ody_ocmb_getscom(struct ocmb *ocmb, uint64_t addr, uint64_t *value) +{ + struct sbefifo *sbefifo = ody_ocmb_to_sbefifo(ocmb); + return getscom(sbefifo, ocmb, addr, value); +} + +static int sbefifo_ody_ocmb_putscom(struct ocmb *ocmb, uint64_t addr, uint64_t value) +{ + struct sbefifo *sbefifo = ody_ocmb_to_sbefifo(ocmb); + return putscom(sbefifo, ocmb, addr, value); +} + + static struct ocmb sbefifo_ocmb = { .target = { .name = "SBE FIFO Chip-op based OCMB", @@ -75,6 +155,8 @@ static struct ocmb sbefifo_ocmb = { }, .getscom = sbefifo_ocmb_getscom, .putscom = sbefifo_ocmb_putscom, + .odygetscom = sbefifo_ody_ocmb_getscom, + .odyputscom = sbefifo_ody_ocmb_putscom, }; DECLARE_HW_UNIT(sbefifo_ocmb); diff --git a/libpdbg/target.c b/libpdbg/target.c index 5b517ca56..7aa4eef36 100644 --- a/libpdbg/target.c +++ b/libpdbg/target.c @@ -448,6 +448,44 @@ int ocmb_putscom(struct pdbg_target *target, uint64_t addr, uint64_t val) return ocmb->putscom(ocmb, addr, val); } +int ody_ocmb_getscom(struct pdbg_target *target, uint64_t addr, uint64_t *val) +{ + struct ocmb *ocmb; + + assert(pdbg_target_is_class(target, "ocmb")); + + if (pdbg_target_status(target) != PDBG_TARGET_ENABLED) + return -1; + + ocmb = target_to_ocmb(target); + + if (!ocmb->odygetscom) { + PR_ERROR("odygetscom() not implemented for the target\n"); + return -1; + } + + return ocmb->odygetscom(ocmb, addr, val); +} + +int ody_ocmb_putscom(struct pdbg_target *target, uint64_t addr, uint64_t val) +{ + struct ocmb *ocmb; + + assert(pdbg_target_is_class(target, "ocmb")); + + if (pdbg_target_status(target) != PDBG_TARGET_ENABLED) + return -1; + + ocmb = target_to_ocmb(target); + + if (!ocmb->odyputscom) { + PR_ERROR("odyputscom() not implemented for the target\n"); + return -1; + } + + return ocmb->odyputscom(ocmb, addr, val); +} + /* Finds the given class. Returns NULL if not found. */ struct pdbg_target_class *find_target_class(const char *name) { diff --git a/libsbefifo/cmd_register.c b/libsbefifo/cmd_register.c index 076b774cb..c714a78b2 100644 --- a/libsbefifo/cmd_register.c +++ b/libsbefifo/cmd_register.c @@ -231,16 +231,17 @@ int sbefifo_hw_register_get(struct sbefifo_context *sctx, uint8_t target_type, u return ENOSYS; rc = sbefifo_hw_register_get_push(target_type, instance_id, reg_id, &msg, &msg_len); + printf("deepa sbefifo_hw_register_get_push rc: %d\n", rc); if (rc) return rc; - out_len = 8; rc = sbefifo_operation(sctx, msg, msg_len, &out, &out_len); free(msg); + printf("deepa sbefifo_operation rc: %d", rc); if (rc) return rc; - rc = sbefifo_hw_register_get_pull(out, out_len, value); + printf("deepa sbefifo_hw_register_get_pull rc: %d", rc); if (out) free(out); diff --git a/libsbefifo/operation.c b/libsbefifo/operation.c index 37507d03b..b29ae8e5c 100644 --- a/libsbefifo/operation.c +++ b/libsbefifo/operation.c @@ -60,9 +60,10 @@ static int sbefifo_transport(struct sbefifo_context *sctx, uint8_t *msg, uint32_ int rc; size_t buflen; - +printf("deepa: sbefifo_transport %d", msg_len); buflen = msg_len; rc = sbefifo_write(sctx, msg, buflen); + printf("deepa: sbefifo_write rc %d\n", rc); if (rc) { LOG("write: cmd=%08x, rc=%d\n", be32toh(*(uint32_t *)(msg+4)), rc); return rc; @@ -70,6 +71,8 @@ static int sbefifo_transport(struct sbefifo_context *sctx, uint8_t *msg, uint32_ buflen = *out_len; rc = sbefifo_read(sctx, out, &buflen); + printf("deepa: sbefifo_read rc %d\n", rc); + if (rc) { LOG("read: cmd=%08x, buflen=%zu, rc=%d\n", be32toh(*(uint32_t *)(msg+4)), buflen, rc); return rc; @@ -147,10 +150,10 @@ int sbefifo_operation(struct sbefifo_context *sctx, assert(msg); assert(msg_len > 0); - +printf("deepa: Before connection\n"); if (!sctx->transport && sctx->fd == -1) return ENOTCONN; - +printf("deepa: after connection\n"); /* * Allocate extra memory for FFDC (SBEFIFO_MAX_FFDC_SIZE = 0x2000) * Use *out_len as a hint to expected reply length @@ -159,16 +162,17 @@ int sbefifo_operation(struct sbefifo_context *sctx, buf = malloc(buflen); if (!buf) return ENOMEM; - +printf("deepa: after allocation\n"); cmd = be32toh(*(uint32_t *)(msg + 4)); LOG("request: cmd=%08x, len=%u\n", cmd, msg_len); + printf("request: cmd=%08x, len=%u\n", cmd, msg_len); if (sctx->transport) rc = sctx->transport(msg, msg_len, buf, &buflen, sctx->priv); else rc = sbefifo_transport(sctx, msg, msg_len, buf, &buflen); - +printf("deepa: after transport rc::::%d\n", rc); if (rc) { free(buf); @@ -181,8 +185,9 @@ int sbefifo_operation(struct sbefifo_context *sctx, return rc; } - +printf("deepa: before sbefifo_parse_output\n"); rc = sbefifo_parse_output(sctx, cmd, buf, buflen, out, out_len); +printf("deepa: after sbefifo_parse_output\n"); free(buf); return rc; }