From: PrasannaKumar Muralidharan <prasannatsmkumar@xxxxxxxxx>
This patch brings support for the JZ4780 efuse. Currently it only expose
a read only access to the entire 8K bits efuse memory.
Tested-by: Mathieu Malaterre <malat@xxxxxxxxxx>
Signed-off-by: PrasannaKumar Muralidharan <prasannatsmkumar@xxxxxxxxx>
---
+
+/* main entry point */
+static int jz4780_efuse_read(void *context, unsigned int offset,
+ void *val, size_t bytes)
+{
+ static const int nsegments = sizeof(segments) / sizeof(*segments);
+ struct jz4780_efuse *efuse = context;
+ char buf[32];
+ char *cur = val;
+ int i;
+ /* PM recommends read/write each segment separately */
+ for (i = 0; i < nsegments; ++i) {
+ unsigned int *segment = segments[i];
+ unsigned int lpos = segment[0];
+ unsigned int buflen = segment[1] / 8;
+ unsigned int ncount = buflen / 32;
+ unsigned int remain = buflen % 32;
+ int j;
+ /* EFUSE can read or write maximum 256bit in each time */
+ for (j = 0; j < ncount ; ++j) {
+ jz4780_efuse_read_32bytes(efuse, buf, lpos);
+ memcpy(cur, buf, sizeof(buf));
+ cur += sizeof(buf);
+ lpos += sizeof(buf);
+ }
+ if (remain) {
+ jz4780_efuse_read_32bytes(efuse, buf, lpos);
+ memcpy(cur, buf, remain);
+ cur += remain;
+ }
+ }
+
+ return 0;
+}