Skip to content

Commit

Permalink
For testing: Add the ody_getscom support
Browse files Browse the repository at this point in the history
  • Loading branch information
deepakala-k committed Nov 22, 2023
1 parent c82f1d6 commit dc23f5d
Show file tree
Hide file tree
Showing 7 changed files with 271 additions and 11 deletions.
110 changes: 110 additions & 0 deletions bmc-sbefifo.dts.m4
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ define(`SBEFIFO',
};
')dnl


dnl
dnl FSI_PRE([addr], [index], [path-index])
dnl
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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,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MB(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)
};
2 changes: 2 additions & 0 deletions libpdbg/hwunit.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
22 changes: 22 additions & 0 deletions libpdbg/libpdbg.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
88 changes: 85 additions & 3 deletions libpdbg/ocmb.c
Original file line number Diff line number Diff line change
Expand Up @@ -37,24 +37,85 @@ 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,
addr,
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;

Expand All @@ -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",
Expand All @@ -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);

Expand Down
38 changes: 38 additions & 0 deletions libpdbg/target.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down
5 changes: 3 additions & 2 deletions libsbefifo/cmd_register.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
Loading

0 comments on commit dc23f5d

Please sign in to comment.