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 9, 2023
1 parent c82f1d6 commit dda2484
Show file tree
Hide file tree
Showing 5 changed files with 81 additions and 14 deletions.
7 changes: 7 additions & 0 deletions bmc-sbefifo.dts.m4
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
dnl
dnl COMMENT(TODO:DB: Believe we need to create one more sbefifo because we get the path from here)
dnl
define(`COMMENT',
`
')dnl

dnl
dnl SBEFIFO([index], [path-index])
dnl
Expand Down
3 changes: 3 additions & 0 deletions libpdbg/hwunit.h
Original file line number Diff line number Diff line change
Expand Up @@ -340,6 +340,9 @@ struct ocmb {
struct pdbg_target target;
int (*getscom)(struct ocmb *, uint64_t, uint64_t *);
int (*putscom)(struct ocmb *, uint64_t, uint64_t);
//DB: Would it create an issue to create new method? backward compatability?
int (*ody_getscom)(struct ocmb *, uint64_t, uint64_t *);
int (*ody_putscom)(struct ocmb *, uint64_t, uint64_t);
};
#define target_to_ocmb(x) container_of(x, struct ocmb, target);

Expand Down
48 changes: 48 additions & 0 deletions libpdbg/ocmb.c
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,17 @@ static struct sbefifo *ocmb_to_sbefifo(struct ocmb *ocmb)
return sbefifo;
}

static struct sbefifo *ody_ocmb_to_sbefifo(struct ocmb *ocmb)
{
//struct pdbg_target *target;
struct sbefifo *sbefifo = NULL;

//Find the dev path to this specific sbefifo
//May be modify p10.dts.m4 file?
assert(sbefifo);

return sbefifo;
}
static int sbefifo_ocmb_getscom(struct ocmb *ocmb, uint64_t addr, uint64_t *value)
{
struct sbefifo *sbefifo = ocmb_to_sbefifo(ocmb);
Expand Down Expand Up @@ -67,6 +78,41 @@ static int sbefifo_ocmb_putscom(struct ocmb *ocmb, uint64_t addr, uint64_t value
value);
}

static int sbefifo_ody_ocmb_getscom(struct ocmb *ocmb, uint64_t addr, uint64_t *value)
{
struct sbefifo *sbefifo = ody_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;

//DB: Should we add 1 to instance id?
instance_id = instance_id + 1;

return sbefifo_hw_register_get(sctx,
SBEFIFO_TARGET_TYPE_OCMB,
instance_id,
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);
struct sbefifo_context *sctx = sbefifo->get_sbefifo_context(sbefifo);
uint8_t instance_id;

instance_id = pdbg_target_index(&ocmb->target) & 0xff;

//DB: Should we add 1 to instance id?
instance_id = instance_id + 1;

return sbefifo_hw_register_put(sctx,
SBEFIFO_TARGET_TYPE_OCMB,
instance_id,
addr,
value);
}
static struct ocmb sbefifo_ocmb = {
.target = {
.name = "SBE FIFO Chip-op based OCMB",
Expand All @@ -75,6 +121,8 @@ static struct ocmb sbefifo_ocmb = {
},
.getscom = sbefifo_ocmb_getscom,
.putscom = sbefifo_ocmb_putscom,
.ody_getscom = sbefifo_ody_ocmb_getscom,
.ody_putscom = sbefifo_ody_ocmb_putscom,
};
DECLARE_HW_UNIT(sbefifo_ocmb);

Expand Down
5 changes: 4 additions & 1 deletion libpdbg/sbefifo.c
Original file line number Diff line number Diff line change
Expand Up @@ -788,6 +788,9 @@ static int sbefifo_probe(struct pdbg_target *target)
int rc, proc;

sbefifo_path = pdbg_target_property(target, "device-path", NULL);

printf("deepa: sbefifo_path %s \n", sbefifo_path);

assert(sbefifo_path);

switch (pdbg_get_proc()) {
Expand Down Expand Up @@ -866,7 +869,7 @@ static struct pib sbefifo_pib = {
.compatible = "ibm,sbefifo-pib",
.class = "pib",
},
.read = sbefifo_pib_read,
.read = sbefifo_pib_read, //TODO:DB - this is the function that is invoked by getscom
.write = sbefifo_pib_write,
.thread_start_all = sbefifo_pib_thread_start,
.thread_stop_all = sbefifo_pib_thread_stop,
Expand Down
32 changes: 19 additions & 13 deletions libpdbg/target.c
Original file line number Diff line number Diff line change
Expand Up @@ -429,6 +429,25 @@ int ocmb_getscom(struct pdbg_target *target, uint64_t addr, uint64_t *val)
return ocmb->getscom(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->getscom) {
PR_ERROR("getscom() not implemented for the target\n");
return -1;
}

return ocmb->ody_getscom(ocmb, addr, val);
}

int ocmb_putscom(struct pdbg_target *target, uint64_t addr, uint64_t val)
{
struct ocmb *ocmb;
Expand Down Expand Up @@ -638,16 +657,3 @@ struct pdbg_target *target_to_virtual(struct pdbg_target *target, bool strict)

return target;
}

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;
}
}

0 comments on commit dda2484

Please sign in to comment.