Commit 70b4b49b91e2bfb148307dc4e35594740ba00514

Authored by Anatolij Gustschin
Committed by Stefano Babic
1 parent 1ef20a3d81

imx8: cpu: add function for reading FEC MAC from fuse

FEC driver requires imx_get_mac_from_fuse(). Add it in preparation
for ENETx support.

Signed-off-by: Anatolij Gustschin <agust@denx.de>
Cc: Stefano Babic <sbabic@denx.de>
Reviewed-by: Peng Fan <peng.fan@nxp.com>

Showing 1 changed file with 38 additions and 0 deletions Side-by-side Diff

arch/arm/mach-imx/imx8/cpu.c
... ... @@ -543,4 +543,42 @@
543 543 return size;
544 544 }
545 545 #endif
  546 +
  547 +#define FUSE_MAC0_WORD0 708
  548 +#define FUSE_MAC0_WORD1 709
  549 +#define FUSE_MAC1_WORD0 710
  550 +#define FUSE_MAC1_WORD1 711
  551 +
  552 +void imx_get_mac_from_fuse(int dev_id, unsigned char *mac)
  553 +{
  554 + u32 word[2], val[2] = {};
  555 + int i, ret;
  556 +
  557 + if (dev_id == 0) {
  558 + word[0] = FUSE_MAC0_WORD0;
  559 + word[1] = FUSE_MAC0_WORD1;
  560 + } else {
  561 + word[0] = FUSE_MAC1_WORD0;
  562 + word[1] = FUSE_MAC1_WORD1;
  563 + }
  564 +
  565 + for (i = 0; i < 2; i++) {
  566 + ret = sc_misc_otp_fuse_read(-1, word[i], &val[i]);
  567 + if (ret < 0)
  568 + goto err;
  569 + }
  570 +
  571 + mac[0] = val[0];
  572 + mac[1] = val[0] >> 8;
  573 + mac[2] = val[0] >> 16;
  574 + mac[3] = val[0] >> 24;
  575 + mac[4] = val[1];
  576 + mac[5] = val[1] >> 8;
  577 +
  578 + debug("%s: MAC%d: %02x.%02x.%02x.%02x.%02x.%02x\n",
  579 + __func__, dev_id, mac[0], mac[1], mac[2], mac[3], mac[4], mac[5]);
  580 + return;
  581 +err:
  582 + printf("%s: fuse %d, err: %d\n", __func__, word[i], ret);
  583 +}