From 76aefe208e6a16f4c37e9fcd8d67ec6da392fece Mon Sep 17 00:00:00 2001 From: Max Krummenacher Date: Mon, 10 Mar 2014 18:48:36 +0100 Subject: imx6_fuse: add helpers for OTP fusing during module production --- board/toradex/apalis_imx6/Makefile | 2 +- board/toradex/apalis_imx6/do_fuse.c | 70 +++++++++++++++++++++++++++++++++++++ include/configs/apalis-imx6.h | 3 +- 3 files changed, 72 insertions(+), 3 deletions(-) create mode 100644 board/toradex/apalis_imx6/do_fuse.c diff --git a/board/toradex/apalis_imx6/Makefile b/board/toradex/apalis_imx6/Makefile index 0fe2c608e7..40ee4d6fc9 100644 --- a/board/toradex/apalis_imx6/Makefile +++ b/board/toradex/apalis_imx6/Makefile @@ -9,7 +9,7 @@ include $(TOPDIR)/config.mk LIB = $(obj)lib$(BOARD).o -COBJS := apalis_imx6.o pf0100.o +COBJS := apalis_imx6.o pf0100.o do_fuse.o SRCS := $(COBJS:.o=.c) OBJS := $(addprefix $(obj),$(COBJS)) diff --git a/board/toradex/apalis_imx6/do_fuse.c b/board/toradex/apalis_imx6/do_fuse.c new file mode 100644 index 0000000000..55ac7af18e --- /dev/null +++ b/board/toradex/apalis_imx6/do_fuse.c @@ -0,0 +1,70 @@ +/* + * Copyright (C) 2014, Toradex AG + * + * SPDX-License-Identifier: GPL-2.0+ + */ + +/* + * Helpers for i.MX OTP fusing during module production +*/ + +#include +#include + +static unsigned mfgr_fuse(void); +unsigned mfgr_fuse(void) +{ + unsigned val, val6; + unsigned mac_hi, mac_lo; + uchar mac_id[6]; + + fuse_sense(0, 5, &val); + printf("Fuse 0, 5: %8x\n", val); + fuse_sense(0, 6, &val6); + printf("Fuse 0, 6: %8x\n", val6); + fuse_sense(4, 3, &val); + printf("Fuse 4, 3: %8x\n", val); + fuse_sense(4, 2, &val); + printf("Fuse 4, 2: %8x\n", val); + if(val6 & 0x10) + { + puts("BT_FUSE_SEL already fused, will do nothing\n"); + return 1; + } + + if (!eth_getenv_enetaddr("ethaddr", mac_id)) + { + puts("ethaddr not set or not valid in environment, will do nothing\n"); + return 1; + } + mac_hi = (mac_id[0] << 8) + mac_id[1]; + mac_lo = (mac_id[2] << 24) + (mac_id[3] << 16) + (mac_id[4] << 8) + mac_id[5]; + + /* boot cfg */ + fuse_prog(0, 5, 0x00005062); + /* BT_FUSE_SEL */ + fuse_prog(0, 6, 0x00000010); + /* MAC addr */ + fuse_prog(4, 3, mac_hi); + fuse_prog(4, 2, mac_lo); + + return 0; +} + +int do_mfgr_fuse(cmd_tbl_t *cmdtp, int flag, int argc, + char * const argv[]) +{ + puts("Fusing...\n"); + if(!mfgr_fuse()) + puts("done.\n"); + else + puts("failed.\n"); + return 0; +} + +U_BOOT_CMD( + mfgr_fuse, 1, 0, do_mfgr_fuse, + "OTP fusing during module production\n" + "requires the environment variable ethaddr to be set\n", + "" +); diff --git a/include/configs/apalis-imx6.h b/include/configs/apalis-imx6.h index 9291de0ea2..6e60d50ac4 100644 --- a/include/configs/apalis-imx6.h +++ b/include/configs/apalis-imx6.h @@ -197,12 +197,11 @@ "bootcmd=run emmcboot ; "\ "setenv stdout serial,vga ; " \ "echo ; echo emmcboot failed ; " \ - "usb start; setenv stdin serial,usbkbd\0" \ + "run nfsboot\0" \ "bootscript=fatload mmc 1:1 10008000 6x_bootscript && source 10008000\0" \ "console=ttymxc0\0" \ "defargs=enable_wait_mode=off vmalloc=400M\0" \ "emmcboot=" EMMC_BOOTCMD "\0" \ - "ethaddr=00:14:2D:00:00:00\0" \ "mmcargs=ip=off root=/dev/mmcblk0p2 rw,noatime rootfstype=ext3 " \ "rootwait\0" \ "mmc_kernel_size=0x4000\0" \ -- cgit v1.2.3