From patchwork Sun Jul 19 14:19:46 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Antonio Borneo X-Patchwork-Id: 497463 X-Patchwork-Delegate: trini@ti.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from theia.denx.de (theia.denx.de [85.214.87.163]) by ozlabs.org (Postfix) with ESMTP id 19562140B0E for ; Mon, 20 Jul 2015 00:21:12 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b=Oo12OpHb; dkim-atps=neutral Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id F0F314B61D; Sun, 19 Jul 2015 16:21:07 +0200 (CEST) Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 2sgpRmK_EFIM; Sun, 19 Jul 2015 16:21:07 +0200 (CEST) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 866A94B615; Sun, 19 Jul 2015 16:21:07 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id C0AD64B615 for ; Sun, 19 Jul 2015 16:21:03 +0200 (CEST) Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id Zaxe9VxzY4ea for ; Sun, 19 Jul 2015 16:21:03 +0200 (CEST) X-policyd-weight: NOT_IN_SBL_XBL_SPAMHAUS=-1.5 NOT_IN_SPAMCOP=-1.5 NOT_IN_BL_NJABL=-1.5 (only DNSBL check requested) Received: from mail-wi0-f172.google.com (mail-wi0-f172.google.com [209.85.212.172]) by theia.denx.de (Postfix) with ESMTPS id 90B974A039 for ; Sun, 19 Jul 2015 16:20:59 +0200 (CEST) Received: by wicgb10 with SMTP id gb10so7372233wic.1 for ; Sun, 19 Jul 2015 07:20:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id; bh=FYdlkXUKwYU7EZqbWw6kSITEtYMOGneaOHwd1ChlZvg=; b=Oo12OpHbUGaW+9f9RwyMVk8p+Nhj4ViNupUe+0p8Zb7HOJ4TLix/sujTg05wIqIJp5 7EcW48M1g292SSakqspprk/g7M7o6EsshBKjcu+LfEytI7RsO9zI9xb+H3iutkwqVETl 5Y4PUg0kTPaEsafI4JmT5Zq/MEoYxiPv6uprapmuwktk0aaEv1LhALHx8hWts2fwTcUb aM6tfAEhbcwy1zyIGKPrP05DAsLeTU5yUgVMDePL+n9PucvvPobpvnef3bPur9DYkl9T hFvIUvVgTz5Co8kBE6uqSkl2WMRQQi8IRRt55oYRpwugYI3vs+VmmwSkPKsLUZYWeIcF 8CAg== X-Received: by 10.180.198.178 with SMTP id jd18mr13092898wic.14.1437315658928; Sun, 19 Jul 2015 07:20:58 -0700 (PDT) Received: from localhost ([158.110.27.95]) by smtp.gmail.com with ESMTPSA id l6sm7163957wib.18.2015.07.19.07.20.54 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 19 Jul 2015 07:20:58 -0700 (PDT) From: Antonio Borneo To: Albert Aribaud , Tom Rini , Kamil Lulko Date: Sun, 19 Jul 2015 22:19:46 +0800 Message-Id: <1437315588-20060-1-git-send-email-borneo.antonio@gmail.com> X-Mailer: git-send-email 2.4.6 Cc: u-boot@lists.denx.de Subject: [U-Boot] [PATCH 1/3] stm32f429: pass the device unique ID in DTB X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.15 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" Read device unique ID and set environment variable "serial#". Value would then be passed to kernel through DTB. To read ID from DTB, kernel is required to have commit: 3f599875e5202986b350618a617527ab441bf206 (ARM: 8355/1: arch: Show the serial number from devicetree in cpuinfo) This commit is already mainline since v4.1-rc1. Signed-off-by: Antonio Borneo To: Albert Aribaud To: Tom Rini To: Kamil Lulko Cc: u-boot@lists.denx.de --- arch/arm/include/asm/arch-stm32f4/stm32.h | 10 ++++++++++ board/st/stm32f429-discovery/stm32f429-discovery.c | 19 +++++++++++++++++++ include/configs/stm32f429-discovery.h | 1 + 3 files changed, 30 insertions(+) diff --git a/arch/arm/include/asm/arch-stm32f4/stm32.h b/arch/arm/include/asm/arch-stm32f4/stm32.h index a9f88db..3ed3801 100644 --- a/arch/arm/include/asm/arch-stm32f4/stm32.h +++ b/arch/arm/include/asm/arch-stm32f4/stm32.h @@ -14,6 +14,7 @@ /* * Peripheral memory map */ +#define STM32_SYSMEM_BASE 0x1FFF0000 #define STM32_PERIPH_BASE 0x40000000 #define STM32_APB1PERIPH_BASE (STM32_PERIPH_BASE + 0x00000000) #define STM32_APB2PERIPH_BASE (STM32_PERIPH_BASE + 0x00010000) @@ -25,6 +26,12 @@ /* * Register maps */ +struct stm32_u_id_regs { + u32 u_id_low; + u32 u_id_mid; + u32 u_id_high; +}; + struct stm32_rcc_regs { u32 cr; /* RCC clock control */ u32 pllcfgr; /* RCC PLL configuration */ @@ -78,6 +85,9 @@ struct stm32_flash_regs { /* * Registers access macros */ +#define STM32_U_ID_BASE (STM32_SYSMEM_BASE + 0x7A10) +#define STM32_U_ID ((struct stm32_u_id_regs *)STM32_U_ID_BASE) + #define STM32_RCC_BASE (STM32_AHB1PERIPH_BASE + 0x3800) #define STM32_RCC ((struct stm32_rcc_regs *)STM32_RCC_BASE) diff --git a/board/st/stm32f429-discovery/stm32f429-discovery.c b/board/st/stm32f429-discovery/stm32f429-discovery.c index 2dd5d93..f418186 100644 --- a/board/st/stm32f429-discovery/stm32f429-discovery.c +++ b/board/st/stm32f429-discovery/stm32f429-discovery.c @@ -285,3 +285,22 @@ int board_init(void) return 0; } + +#ifdef CONFIG_MISC_INIT_R +int misc_init_r(void) +{ + char serialno[25]; + uint32_t u_id_low, u_id_mid, u_id_high; + + if (!getenv("serial#")) { + u_id_low = readl(&STM32_U_ID->u_id_low); + u_id_mid = readl(&STM32_U_ID->u_id_mid); + u_id_high = readl(&STM32_U_ID->u_id_high); + sprintf(serialno, "%08x%08x%08x", + u_id_high, u_id_mid, u_id_low); + setenv("serial#", serialno); + } + + return 0; +} +#endif diff --git a/include/configs/stm32f429-discovery.h b/include/configs/stm32f429-discovery.h index 1b4fd21..4cc7324 100644 --- a/include/configs/stm32f429-discovery.h +++ b/include/configs/stm32f429-discovery.h @@ -15,6 +15,7 @@ #define CONFIG_OF_LIBFDT #define CONFIG_BOARD_EARLY_INIT_F +#define CONFIG_MISC_INIT_R #define CONFIG_SYS_FLASH_BASE 0x08000000