soc/qc/spmi: Add API to read byte array
Introduce a new API, spmi_read_bytes(), to allow reading a sequence of registers from a Qualcomm PMIC using the SPMI bus. While the existing spmi_read8() is suitable for single-byte access, reading large log areas (like the PON history log) requires iterating over a contiguous block of addresses. This new function encapsulates the required loop, calling spmi_read8() sequentially for each address in the range. This abstraction improves code cleanliness and makes high-level PMIC log parsing much simpler. Key changes: - Define spmi_read_bytes() prototype in qcom_spmi.h. - Implement spmi_read_bytes() in spmi.c to perform sequential reads using spmi_read8(). BUG=b:439819922 TEST=Verify off-mode charging behavior on Google/Quenbi. Change-Id: I6017336a882a8fa8d771b0127e78dd4f0fdbdd0e Signed-off-by: Kapil Porwal <kapilporwal@google.com> Reviewed-on: https://review.coreboot.org/c/coreboot/+/90191 Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Subrata Banik <subratabanik@google.com>
This commit is contained in:
parent
9f675eb96b
commit
293f3a7f5c
2 changed files with 17 additions and 0 deletions
|
|
@ -11,5 +11,6 @@
|
|||
|
||||
int spmi_read8(uint32_t addr);
|
||||
int spmi_write8(uint32_t addr, uint8_t data);
|
||||
int spmi_read_bytes(uint32_t addr, uint8_t *data, uint32_t num_bytes);
|
||||
|
||||
#endif // __SOC_QCOM_SPMI_H__
|
||||
|
|
|
|||
|
|
@ -125,3 +125,19 @@ int spmi_write8(uint32_t addr, uint8_t data)
|
|||
|
||||
return ret;
|
||||
}
|
||||
|
||||
int spmi_read_bytes(uint32_t addr, uint8_t *data, uint32_t num_bytes)
|
||||
{
|
||||
int spmi_result;
|
||||
if (!data)
|
||||
return -1;
|
||||
|
||||
for (uint32_t i = 0; i < num_bytes; i++) {
|
||||
spmi_result = spmi_read8(addr + i);
|
||||
if (spmi_result < 0)
|
||||
return -1;
|
||||
*data = spmi_result & 0xff;
|
||||
data++;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue