Return-Path: Received: by yocto-www.yoctoproject.org (Postfix, from userid 118) id 2576DE00901; Fri, 7 Nov 2014 01:57:27 -0800 (PST) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on yocto-www.yoctoproject.org X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00 autolearn=ham version=3.3.1 X-Spam-HAM-Report: * -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% * [score: 0.0000] Received: from mail.ahsoftware.de (h1446028.stratoserver.net [85.214.92.142]) by yocto-www.yoctoproject.org (Postfix) with ESMTP id CCC74E00863 for ; Fri, 7 Nov 2014 01:57:21 -0800 (PST) Received: by mail.ahsoftware.de (Postfix, from userid 65534) id 56E152C9CED9; Fri, 7 Nov 2014 10:47:29 +0100 (CET) Received: from eiche.ahsoftware (p4FC3685E.dip0.t-ipconnect.de [79.195.104.94]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by mail.ahsoftware.de (Postfix) with ESMTPSA id B798C2C9CED7 for ; Fri, 7 Nov 2014 10:47:28 +0100 (CET) Received: by eiche.ahsoftware (Postfix, from userid 65534) id 099AA8C2B0; Fri, 7 Nov 2014 10:47:28 +0100 (CET) Received: from krabat.ahsoftware (unknown [192.168.207.2]) by eiche.ahsoftware (Postfix) with ESMTP id 5D1488E34E; Fri, 7 Nov 2014 09:44:32 +0000 (UTC) From: Alexander Holler To: meta-freescale@yoctoproject.org Date: Fri, 7 Nov 2014 10:43:35 +0100 Message-Id: <1415353415-3805-2-git-send-email-holler@ahsoftware.de> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1415353415-3805-1-git-send-email-holler@ahsoftware.de> References: <1415353415-3805-1-git-send-email-holler@ahsoftware.de> Cc: Jon Nettleton , Otavio Salvador Subject: [PATCH 1/1] arm: imx: fsl_otp: make fuses (OTP memory) read-only X-BeenThere: meta-freescale@yoctoproject.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: Usage and development list for the meta-fsl-* layers List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 07 Nov 2014 09:57:27 -0000 Nothing in userspace should be able to kill the HW. Not even just as root and for sure not that easy. For obvious reason, I haven't tested this patch thoroughly. Reported-by: Jon Nettleton Signed-off-by: Alexander Holler --- drivers/char/fsl_otp.c | 57 +------------------------------------------------- 1 file changed, 1 insertion(+), 56 deletions(-) diff --git a/drivers/char/fsl_otp.c b/drivers/char/fsl_otp.c index face297..d9d1c59 100644 --- a/drivers/char/fsl_otp.c +++ b/drivers/char/fsl_otp.c @@ -151,60 +151,6 @@ out: return ret ? 0 : sprintf(buf, "0x%x\n", value); } -static int otp_write_bits(int addr, u32 data, u32 magic) -{ - u32 c; /* for control register */ - - /* init the control register */ - c = __raw_readl(otp_base + HW_OCOTP_CTRL); - c &= ~BM_OCOTP_CTRL_ADDR; - c |= BF(addr, OCOTP_CTRL_ADDR); - c |= BF(magic, OCOTP_CTRL_WR_UNLOCK); - __raw_writel(c, otp_base + HW_OCOTP_CTRL); - - /* init the data register */ - __raw_writel(data, otp_base + HW_OCOTP_DATA); - otp_wait_busy(0); - - mdelay(2); /* Write Postamble */ - - return 0; -} - -static ssize_t fsl_otp_store(struct kobject *kobj, struct kobj_attribute *attr, - const char *buf, size_t count) -{ - unsigned int index = attr - otp_kattr; - u32 value; - int ret; - - sscanf(buf, "0x%x", &value); - - ret = clk_prepare_enable(otp_clk); - if (ret) - return 0; - - mutex_lock(&otp_mutex); - - set_otp_timing(); - ret = otp_wait_busy(0); - if (ret) - goto out; - - otp_write_bits(index, value, 0x3e77); - - /* Reload all the shadow registers */ - __raw_writel(BM_OCOTP_CTRL_RELOAD_SHADOWS, - otp_base + HW_OCOTP_CTRL_SET); - udelay(1); - otp_wait_busy(BM_OCOTP_CTRL_RELOAD_SHADOWS); - -out: - mutex_unlock(&otp_mutex); - clk_disable_unprepare(otp_clk); - return ret ? 0 : count; -} - static int fsl_otp_probe(struct platform_device *pdev) { struct resource *res; @@ -244,9 +190,8 @@ static int fsl_otp_probe(struct platform_device *pdev) for (i = 0; i < num; i++) { sysfs_attr_init(&otp_kattr[i].attr); otp_kattr[i].attr.name = desc[i]; - otp_kattr[i].attr.mode = 0600; + otp_kattr[i].attr.mode = 0400; otp_kattr[i].show = fsl_otp_show; - otp_kattr[i].store = fsl_otp_store; attrs[i] = &otp_kattr[i].attr; } otp_attr_group->attrs = attrs; -- 1.8.3.1