diff options
author | Alistair Popple <alistair@popple.id.au> | 2016-12-02 17:33:32 +1100 |
---|---|---|
committer | Alistair Popple <alistair@popple.id.au> | 2016-12-02 17:40:10 +1100 |
commit | 3172dd9a17dc9aabb8dc6438b849db148728fb0c (patch) | |
tree | e5ae2870566338439835e42614e23018592af83a /libpdbg | |
parent | 23410a93cc70009094cbab22fda4063fa6879962 (diff) | |
download | pdbg-3172dd9a17dc9aabb8dc6438b849db148728fb0c.tar.gz pdbg-3172dd9a17dc9aabb8dc6438b849db148728fb0c.zip |
Add detection of chip types
Support detecting different chip types so we enable chip type
dependent behaviour.
Signed-off-by: Alistair Popple <alistair@popple.id.au>
Diffstat (limited to 'libpdbg')
-rw-r--r-- | libpdbg/adu.c | 8 | ||||
-rw-r--r-- | libpdbg/bmcfsi.c | 4 | ||||
-rw-r--r-- | libpdbg/cfam.c | 21 | ||||
-rw-r--r-- | libpdbg/chip.c | 4 | ||||
-rw-r--r-- | libpdbg/i2c.c | 1 | ||||
-rw-r--r-- | libpdbg/operations.h | 1 | ||||
-rw-r--r-- | libpdbg/target.c | 4 | ||||
-rw-r--r-- | libpdbg/target.h | 3 |
8 files changed, 41 insertions, 5 deletions
diff --git a/libpdbg/adu.c b/libpdbg/adu.c index 4e7211e..466924d 100644 --- a/libpdbg/adu.c +++ b/libpdbg/adu.c @@ -113,6 +113,10 @@ int adu_getmem(struct target *target, uint64_t start_addr, uint8_t *output, uint int rc = 0; uint64_t addr, cmd_reg, ctrl_reg, val; + /* P9 ADU is not currently supported */ + if (target->chip_type == CHIP_P9) + return -1; + CHECK_ERR(adu_lock(target)); ctrl_reg = TTYPE_TREAD; @@ -184,6 +188,10 @@ int adu_putmem(struct target *target, uint64_t start_addr, uint8_t *input, uint6 int rc = 0, tsize; uint64_t addr, cmd_reg, ctrl_reg, val, data, end_addr; + /* P9 ADU is not currently supported */ + if (target->chip_type == CHIP_P9) + return -1; + CHECK_ERR(adu_lock(target)); ctrl_reg = TTYPE_TWRITE; diff --git a/libpdbg/bmcfsi.c b/libpdbg/bmcfsi.c index 35a3407..93c18f6 100644 --- a/libpdbg/bmcfsi.c +++ b/libpdbg/bmcfsi.c @@ -524,5 +524,9 @@ int fsi_target_init(struct target *target, const char *name, enum fsi_system_typ target_init(target, name, 0, fsi_getcfam, fsi_putcfam, fsi_destroy, next); + /* Read chip id */ + CHECK_ERR(read_target(target, 0xc09, &value)); + target->chip_type = get_chip_type(value); + return 0; } diff --git a/libpdbg/cfam.c b/libpdbg/cfam.c index 51d0b84..15000b8 100644 --- a/libpdbg/cfam.c +++ b/libpdbg/cfam.c @@ -225,6 +225,20 @@ int opb_target_init(struct target *target, const char *name, uint64_t base, stru return 0; } +enum chip_type get_chip_type(uint64_t chip_id) +{ + switch(GETFIELD(PPC_BITMASK32(12, 19), chip_id)) { + case 0xea: + return CHIP_P8; + case 0xd3: + return CHIP_P8NV; + case 0xd1: + return CHIP_P9; + default: + return CHIP_UNKNOWN; + } +} + int mfsi_target_init(struct target *target, const char *name, uint64_t base, struct target *next) { target_init(target, name, base, NULL, NULL, NULL, next); @@ -236,7 +250,7 @@ int mfsi_target_init(struct target *target, const char *name, uint64_t base, str int hmfsi_target_probe(struct target *cfam, struct target *targets, int max_target_count) { struct target *target = targets; - uint64_t value, chip_id; + uint64_t value; int target_count = 0, i; for (i = 0; i < 8 && i < max_target_count; i++) { @@ -246,9 +260,8 @@ int hmfsi_target_probe(struct target *cfam, struct target *targets, int max_targ continue; } - /* Ignore unknown chip ids */ - chip_id = GETFIELD(PPC_BITMASK32(12, 19), value); - if (chip_id != 0xea && chip_id != 0xd3) { + target->chip_type = get_chip_type(value); + if (target->chip_type == CHIP_UNKNOWN) { target_del(target); continue; } diff --git a/libpdbg/chip.c b/libpdbg/chip.c index 14c92b3..aededba 100644 --- a/libpdbg/chip.c +++ b/libpdbg/chip.c @@ -514,6 +514,10 @@ int chiplet_target_probe(struct target *processor, struct target *targets, int m struct target *target = targets; int i, count = 0, rc = 0; + /* P9 chiplets are not currently supported */ + if (target->chip_type == CHIP_P9) + return 0; + for (i = 0; i <= 0xf && i < max_target_count; i++) { if (i == 0 || i == 7 || i == 8 || i == 0xf) /* 0, 7, 8 & 0xf are reserved */ diff --git a/libpdbg/i2c.c b/libpdbg/i2c.c index d551658..a75056c 100644 --- a/libpdbg/i2c.c +++ b/libpdbg/i2c.c @@ -139,6 +139,7 @@ int i2c_target_init(struct target *target, const char *name, struct target *next target_init(target, name, addr, i2c_getscom, i2c_putscom, i2c_destroy, next); target->priv = i2c_data; + target->chip_type = CHIP_P8; return 0; } diff --git a/libpdbg/operations.h b/libpdbg/operations.h index 553001c..f698d40 100644 --- a/libpdbg/operations.h +++ b/libpdbg/operations.h @@ -76,6 +76,7 @@ int i2c_target_init(struct target *target, const char *name, struct target *next const char *bus, int addr); int fsi2pib_target_init(struct target *target, const char *name, uint64_t base, struct target *next); int opb_target_init(struct target *target, const char *name, uint64_t base, struct target *next); +enum chip_type get_chip_type(uint64_t chip_id); int thread_target_init(struct target *thread, const char *name, uint64_t thread_id, struct target *next); int thread_target_probe(struct target *chiplet, struct target *targets, int max_target_count); int chiplet_target_init(struct target *target, const char *name, uint64_t chip_id, struct target *next); diff --git a/libpdbg/target.c b/libpdbg/target.c index 228e778..a006f49 100644 --- a/libpdbg/target.c +++ b/libpdbg/target.c @@ -20,8 +20,10 @@ void target_init(struct target *target, const char *name, uint64_t base, list_head_init(&target->children); - if (next) + if (next) { + target->chip_type = target->next->chip_type; list_add_tail(&next->children, &target->link); + } } void target_del(struct target *target) diff --git a/libpdbg/target.h b/libpdbg/target.h index 250bc1b..9e73e3b 100644 --- a/libpdbg/target.h +++ b/libpdbg/target.h @@ -24,6 +24,8 @@ typedef int (*target_read)(struct target *target, uint64_t addr, uint64_t *value typedef int (*target_write)(struct target *target, uint64_t addr, uint64_t value); typedef void (*target_destroy)(struct target *target); +enum chip_type {CHIP_UNKNOWN, CHIP_P8, CHIP_P8NV, CHIP_P9}; + struct target { const char *name; int index; @@ -31,6 +33,7 @@ struct target { target_read read; target_write write; target_destroy destroy; + enum chip_type chip_type; struct target *next; struct list_node link; struct list_head children; |