adiv5: More checks for a sensible DPIDR.

This commit is contained in:
Uwe Bonnes 2020-11-29 20:18:05 +01:00 committed by UweBonnes
parent 752bc26536
commit 48a79ff9da
1 changed files with 4 additions and 2 deletions

View File

@ -614,8 +614,10 @@ ADIv5_AP_t *adiv5_new_ap(ADIv5_DP_t *dp, uint8_t apsel)
void adiv5_dp_init(ADIv5_DP_t *dp)
{
/* Check IDCODE for a valid designer*/
if ((dp->idcode & 0xfff) == 0) {
#define DPIDR_PARTNO_MASK 0x0ff00000
/* Check IDCODE for a valid designer and sensible PARTNO*/
if (((dp->idcode & 0xfff) == 0) ||
((dp->idcode & DPIDR_PARTNO_MASK)) == DPIDR_PARTNO_MASK) {
DEBUG_WARN("Invalid DP idcode %08" PRIx32 "\n", dp->idcode);
free(dp);
return;