From patchwork Sat Feb 11 01:15:34 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dalon Westergreen X-Patchwork-Id: 726797 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 3vKv5h5c7bz9s7n for ; Sat, 11 Feb 2017 12:16:08 +1100 (AEDT) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="tc9CzcgU"; dkim-atps=neutral Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id E91C64B660; Sat, 11 Feb 2017 02:16:01 +0100 (CET) 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 k7MxB0Qr5VIb; Sat, 11 Feb 2017 02:16:01 +0100 (CET) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id A60804B642; Sat, 11 Feb 2017 02:15:52 +0100 (CET) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 8BE0E4B55F for ; Sat, 11 Feb 2017 02:15:46 +0100 (CET) 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 behIZotzB6sC for ; Sat, 11 Feb 2017 02:15:46 +0100 (CET) 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-pg0-f68.google.com (mail-pg0-f68.google.com [74.125.83.68]) by theia.denx.de (Postfix) with ESMTPS id 1D4DB4B58A for ; Sat, 11 Feb 2017 02:15:43 +0100 (CET) Received: by mail-pg0-f68.google.com with SMTP id 204so4230143pge.2 for ; Fri, 10 Feb 2017 17:15:43 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=Z1n/bgnVjwocqyDNoVKYqHq9B6zfRKVCUiWNffm99pg=; b=tc9CzcgUL5USby4Wf0dZikqnZcQuL6iKK8PSoTZ/EzKW3K1b/+HpElJRfZ9RLOl/ty deW8HziNXGHX2I+UA/bMwCnFMo04bT0R35dY3KTyLHtUAkot3woHVCYLuJDU/zwOQUTG UXHS/1kzKHLPxXMPAR/KMMYDFgShAUfA/2bSX5C+SPKA/mpT47fqTcD9WFZIpt+xrkKZ XRwdI8EdIqtTyzrNfIx+x2ClNGmxBT0lBHtA5x7aohOfzTl7MUGfZ9ri4hMHdiv7Xxrw WZQ6vLPLsL1v59sIBINutTcJhPU4gYy788ERyHgPU2lFwyur4/GxpC6iaia+NRd2UVmv NfsQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=Z1n/bgnVjwocqyDNoVKYqHq9B6zfRKVCUiWNffm99pg=; b=FhqgPwRGD7sBxGBF9JTjXWRWf4kDBUA83sJSlv48iNTHdvEauEvYVC5cSAeGN7nAAQ yoQoEQgHrI1RzePq8i+HHghBvgqhO6RRIxeIDGwHg0i1DNNsF3AEuqI8scLzthAr2WpK yIvpikQANPi6zE64MHgS17x5/7dTECMvcb0tkD7h24uf8BPFnh2YLfPINGl6F6cql+L6 4qLb85fP03hZFaLkoIWhg3WI0OHJGO4fBPV0cXEEt/Vn3mbIcxIXlm3f3cips74BZ/pN lvjKG2f0QX2OWnZ/L1bbFetDBtebN2DjZNu97Mw91+NwmmIhk2tfuYvuIl4mYwP8aSfU sIqw== X-Gm-Message-State: AMke39lJ0BSoFqh3v+CZ/Ii75JLUb8YIHWLos+PcsBng+GA7mtyfHA0TXXLt8L/sI2nZTg== X-Received: by 10.98.31.136 with SMTP id l8mr13628107pfj.184.1486775741708; Fri, 10 Feb 2017 17:15:41 -0800 (PST) Received: from dwesterg-mobl1.amr.corp.intel.com ([192.55.54.44]) by smtp.gmail.com with ESMTPSA id w16sm7756293pgc.15.2017.02.10.17.15.40 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 10 Feb 2017 17:15:41 -0800 (PST) From: Dalon Westergreen To: u-boot@lists.denx.de, trini@konsulko.com, marex@denx.de, chin.liang.see@intel.com, dinguyen@kernel.org, agraf@suse.de, sr@denx.de Date: Fri, 10 Feb 2017 17:15:34 -0800 Message-Id: <1486775735-14676-2-git-send-email-dwesterg@gmail.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1486775735-14676-1-git-send-email-dwesterg@gmail.com> References: <1486775735-14676-1-git-send-email-dwesterg@gmail.com> Subject: [U-Boot] [PATCH v9 1/2] SPL: add support to boot from a partition type 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" the socfpga bootrom supports mmc booting from either a raw image starting at 0x0, or from a partition of type 0xa2. This patch adds support for locating the boot image in the first type 0xa2 partition found. Assigned a partition number of -1 will cause a search for a partition of type CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_PARTITION_TYPE and use it to find the u-boot image Signed-off-by: Dalon Westergreen --- Changes in v9: - Missed moving use partition type to socfpga/Kconfig Changes in v8: - Move partition type default to arch/arm/mach-socfpga/Kconfig Changes in v7: - set part type to 0xa2 only if socfpga selected Changes in V6: - Remove unneeded backslash Changes in V5: - fix styling in if (..) per Tom's request Changes in V4: - Try search for partition type and failover to the defined partition number Changes in V3: - Add depends on DOS_PARTITION - Ensure that PARTTION_TYPE defaults to non-zero - Add ifdef around sys_ind in disk_partition structure Changes in V2: - Merge partition search into single partition function --- arch/arm/mach-socfpga/Kconfig | 6 ++++++ common/spl/Kconfig | 16 ++++++++++++++++ common/spl/spl_mmc.c | 15 +++++++++++++++ disk/part_dos.c | 1 + include/part.h | 3 +++ 5 files changed, 41 insertions(+) diff --git a/arch/arm/mach-socfpga/Kconfig b/arch/arm/mach-socfpga/Kconfig index df9e8d4..e56b3db 100644 --- a/arch/arm/mach-socfpga/Kconfig +++ b/arch/arm/mach-socfpga/Kconfig @@ -27,6 +27,12 @@ config SPL_SPI_SUPPORT config SPL_WATCHDOG_SUPPORT default y +config SYS_MMCSD_RAW_MODE_U_BOOT_USE_PARTITION_TYPE + default y + +config SYS_MMCSD_RAW_MODE_U_BOOT_PARTITION_TYPE + default 0xa2 + config TARGET_SOCFPGA_ARRIA5 bool select TARGET_SOCFPGA_GEN5 diff --git a/common/spl/Kconfig b/common/spl/Kconfig index cf714c2..baff7b6 100644 --- a/common/spl/Kconfig +++ b/common/spl/Kconfig @@ -96,6 +96,22 @@ config SYS_MMCSD_RAW_MODE_U_BOOT_SECTOR Address on the MMC to load U-Boot from, when the MMC is being used in raw mode. Units: MMC sectors (1 sector = 512 bytes). +config SYS_MMCSD_RAW_MODE_U_BOOT_USE_PARTITION_TYPE + bool "MMC raw mode: by partition type" + depends on SPL && DOS_PARTITION && \ + SYS_MMCSD_RAW_MODE_U_BOOT_USE_PARTITION + help + Use partition type for specifying U-Boot partition on MMC/SD in + raw mode. U-Boot will be loaded from the first partition of this + type to be found. + +config SYS_MMCSD_RAW_MODE_U_BOOT_PARTITION_TYPE + hex "Partition Type on the MMC to load U-Boot from" + depends on SPL && SYS_MMCSD_RAW_MODE_U_BOOT_USE_PARTITION_TYPE + help + Partition Type on the MMC to load U-Boot from, when the MMC is being + used in raw mode. + config TPL bool depends on SPL && SUPPORT_TPL diff --git a/common/spl/spl_mmc.c b/common/spl/spl_mmc.c index 0cd355c..fb51fd5 100644 --- a/common/spl/spl_mmc.c +++ b/common/spl/spl_mmc.c @@ -157,6 +157,21 @@ static int mmc_load_image_raw_partition(struct spl_image_info *spl_image, disk_partition_t info; int err; +#ifdef CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_USE_PARTITION_TYPE + int type_part; + /* Only support MBR so DOS_ENTRY_NUMBERS */ + for (type_part = 1; type_part <= DOS_ENTRY_NUMBERS; type_part++) { + err = part_get_info(mmc_get_blk_desc(mmc), type_part, &info); + if (err) + continue; + if (info.sys_ind == + CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_PARTITION_TYPE) { + partition = type_part; + break; + } + } +#endif + err = part_get_info(mmc_get_blk_desc(mmc), partition, &info); if (err) { #ifdef CONFIG_SPL_LIBCOMMON_SUPPORT diff --git a/disk/part_dos.c b/disk/part_dos.c index c77d881..7ede15e 100644 --- a/disk/part_dos.c +++ b/disk/part_dos.c @@ -217,6 +217,7 @@ static int part_get_info_extended(struct blk_desc *dev_desc, #if CONFIG_IS_ENABLED(PARTITION_UUIDS) sprintf(info->uuid, "%08x-%02x", disksig, part_num); #endif + info->sys_ind = pt->sys_ind; return 0; } diff --git a/include/part.h b/include/part.h index 9d0e20d..b6d1b33 100644 --- a/include/part.h +++ b/include/part.h @@ -59,6 +59,9 @@ typedef struct disk_partition { #ifdef CONFIG_PARTITION_TYPE_GUID char type_guid[37]; /* type GUID as string, if exists */ #endif +#ifdef CONFIG_DOS_PARTITION + uchar sys_ind; /* partition type */ +#endif } disk_partition_t; /* Misc _get_dev functions */