From patchwork Mon Feb 13 16:24:24 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahiro Yamada X-Patchwork-Id: 93903 Delivered-To: patch@linaro.org Received: by 10.140.20.99 with SMTP id 90csp1168596qgi; Mon, 13 Feb 2017 08:25:03 -0800 (PST) X-Received: by 10.223.154.114 with SMTP id z105mr20633178wrb.89.1487003102914; Mon, 13 Feb 2017 08:25:02 -0800 (PST) Return-Path: Received: from theia.denx.de (theia.denx.de. [85.214.87.163]) by mx.google.com with ESMTP id b109si14428248wrd.317.2017.02.13.08.25.02; Mon, 13 Feb 2017 08:25:02 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of u-boot-bounces@lists.denx.de designates 85.214.87.163 as permitted sender) client-ip=85.214.87.163; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@nifty.com; spf=pass (google.com: best guess record for domain of u-boot-bounces@lists.denx.de designates 85.214.87.163 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 3A1C94AAA7; Mon, 13 Feb 2017 17:25: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 d4hEdFpTuJnR; Mon, 13 Feb 2017 17:25:00 +0100 (CET) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 7C01F4A05F; Mon, 13 Feb 2017 17:25:00 +0100 (CET) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id D99B94A99B for ; Mon, 13 Feb 2017 17:24:52 +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 esRpoo3Ut6SM for ; Mon, 13 Feb 2017 17:24:52 +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 conuserg-10.nifty.com (conuserg-10.nifty.com [210.131.2.77]) by theia.denx.de (Postfix) with ESMTPS id 2066D4A068 for ; Mon, 13 Feb 2017 17:24:47 +0100 (CET) Received: from grover.sesame (FL1-111-169-71-157.osk.mesh.ad.jp [111.169.71.157]) (authenticated) by conuserg-10.nifty.com with ESMTP id v1DGORTZ006492; Tue, 14 Feb 2017 01:24:30 +0900 DKIM-Filter: OpenDKIM Filter v2.10.3 conuserg-10.nifty.com v1DGORTZ006492 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nifty.com; s=dec2015msa; t=1487003070; bh=H7rb4uEYIIZxf+gpvz8HLM4F5wayBEMMF6YqA49sjio=; h=From:To:Cc:Subject:Date:From; b=eeI7l/jknImrUMZELrtXFM6mFnQ+DmBQq092pLvfxyb1+FrFlrX7UODlvCkVMWkI8 dPUfGdke0lVZDC1I9GbUAnYqA55Z3dqm130cguNjKf/dWDYw/3W1cyPGktmvoEsqYq E2GfHgPor7tSzZUvHUqNaSqtm5JrpctYzF41LrGIpVJneupJmZrR7qlAEwD1CzWcFE Ql3lrIWuON6A40mmxObRa2tA8iIXEm3mLpRGeY25VzNFMRdV+pnhWEvcRWXtxKv+vf k0LAXWOk7bQSF2noKaWgO56c7jM8ekE5GsC81dMh/4djvW6yqr8wjoVc6Z1mNeydQh ktqlKTxS/DnbQ== X-Nifty-SrcIP: [111.169.71.157] From: Masahiro Yamada To: u-boot@lists.denx.de Date: Tue, 14 Feb 2017 01:24:24 +0900 Message-Id: <1487003066-14387-1-git-send-email-yamada.masahiro@socionext.com> X-Mailer: git-send-email 2.7.4 Cc: Albert Aribaud Subject: [U-Boot] [PATCH 1/3] ARM: uniphier: move MMC code to a separate file 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" Currently, arch/arm/mach-uniphier/boot-mode/boot-mode.c is messed up with unrelated code; there is no reason why the "mmcsetn" command must be placed in this file. Split out the MMC code into arch/arm/mach-uniphier/mmc-first-dev.c. Signed-off-by: Masahiro Yamada --- arch/arm/mach-uniphier/Makefile | 1 + arch/arm/mach-uniphier/boot-mode/boot-mode.c | 38 ----------------------- arch/arm/mach-uniphier/mmc-first-dev.c | 46 ++++++++++++++++++++++++++++ 3 files changed, 47 insertions(+), 38 deletions(-) create mode 100644 arch/arm/mach-uniphier/mmc-first-dev.c -- 2.7.4 _______________________________________________ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot diff --git a/arch/arm/mach-uniphier/Makefile b/arch/arm/mach-uniphier/Makefile index 166b41f..0eb59fb 100644 --- a/arch/arm/mach-uniphier/Makefile +++ b/arch/arm/mach-uniphier/Makefile @@ -19,6 +19,7 @@ obj-y += reset.o obj-$(CONFIG_MICRO_SUPPORT_CARD) += sbc/ micro-support-card.o obj-y += pinctrl-glue.o +obj-$(CONFIG_MMC) += mmc-first-dev.o endif diff --git a/arch/arm/mach-uniphier/boot-mode/boot-mode.c b/arch/arm/mach-uniphier/boot-mode/boot-mode.c index a552770..6ce3273 100644 --- a/arch/arm/mach-uniphier/boot-mode/boot-mode.c +++ b/arch/arm/mach-uniphier/boot-mode/boot-mode.c @@ -100,41 +100,3 @@ u32 spl_boot_mode(const u32 boot_device) return MMCSD_MODE_EMMCBOOT; } - -#if defined(CONFIG_DM_MMC) && !defined(CONFIG_SPL_BUILD) -static int find_first_mmc_device(void) -{ - struct mmc *mmc; - int i; - - for (i = 0; (mmc = find_mmc_device(i)); i++) { - if (!mmc_init(mmc) && IS_MMC(mmc)) - return i; - } - - return -ENODEV; -} - -int mmc_get_env_dev(void) -{ - return find_first_mmc_device(); -} - -static int do_mmcsetn(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) -{ - int dev; - - dev = find_first_mmc_device(); - if (dev < 0) - return CMD_RET_FAILURE; - - setenv_ulong("mmc_first_dev", dev); - return CMD_RET_SUCCESS; -} - -U_BOOT_CMD( - mmcsetn, 1, 1, do_mmcsetn, - "Set the first MMC (not SD) dev number to \"mmc_first_dev\" environment", - "" -); -#endif diff --git a/arch/arm/mach-uniphier/mmc-first-dev.c b/arch/arm/mach-uniphier/mmc-first-dev.c new file mode 100644 index 0000000..8c45229 --- /dev/null +++ b/arch/arm/mach-uniphier/mmc-first-dev.c @@ -0,0 +1,46 @@ +/* + * Copyright (C) 2016 Socionext Inc. + * Author: Masahiro Yamada + * + * SPDX-License-Identifier: GPL-2.0+ + */ + +#include +#include +#include + +static int find_first_mmc_device(void) +{ + struct mmc *mmc; + int i; + + for (i = 0; (mmc = find_mmc_device(i)); i++) { + if (!mmc_init(mmc) && IS_MMC(mmc)) + return i; + } + + return -ENODEV; +} + +int mmc_get_env_dev(void) +{ + return find_first_mmc_device(); +} + +static int do_mmcsetn(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) +{ + int dev; + + dev = find_first_mmc_device(); + if (dev < 0) + return CMD_RET_FAILURE; + + setenv_ulong("mmc_first_dev", dev); + return CMD_RET_SUCCESS; +} + +U_BOOT_CMD( + mmcsetn, 1, 1, do_mmcsetn, + "Set the first MMC (not SD) dev number to \"mmc_first_dev\" environment", + "" +); From patchwork Mon Feb 13 16:24:25 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahiro Yamada X-Patchwork-Id: 93904 Delivered-To: patch@linaro.org Received: by 10.140.20.99 with SMTP id 90csp1168656qgi; Mon, 13 Feb 2017 08:25:11 -0800 (PST) X-Received: by 10.223.171.12 with SMTP id q12mr19899619wrc.74.1487003111833; Mon, 13 Feb 2017 08:25:11 -0800 (PST) Return-Path: Received: from theia.denx.de (theia.denx.de. [85.214.87.163]) by mx.google.com with ESMTP id p64si14421494wrc.262.2017.02.13.08.25.11; Mon, 13 Feb 2017 08:25:11 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of u-boot-bounces@lists.denx.de designates 85.214.87.163 as permitted sender) client-ip=85.214.87.163; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@nifty.com; spf=pass (google.com: best guess record for domain of u-boot-bounces@lists.denx.de designates 85.214.87.163 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 2F8104ACF9; Mon, 13 Feb 2017 17:25:07 +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 Z8nmyUK6ZAsS; Mon, 13 Feb 2017 17:25:07 +0100 (CET) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 496F44AD1F; Mon, 13 Feb 2017 17:25:03 +0100 (CET) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id D623C4A997 for ; Mon, 13 Feb 2017 17:24:52 +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 9ZiCnebs3UA5 for ; Mon, 13 Feb 2017 17:24:52 +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 conuserg-10.nifty.com (conuserg-10.nifty.com [210.131.2.77]) by theia.denx.de (Postfix) with ESMTPS id 17D694A05F for ; Mon, 13 Feb 2017 17:24:47 +0100 (CET) Received: from grover.sesame (FL1-111-169-71-157.osk.mesh.ad.jp [111.169.71.157]) (authenticated) by conuserg-10.nifty.com with ESMTP id v1DGORTa006492; Tue, 14 Feb 2017 01:24:31 +0900 DKIM-Filter: OpenDKIM Filter v2.10.3 conuserg-10.nifty.com v1DGORTa006492 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nifty.com; s=dec2015msa; t=1487003071; bh=acyM0lkeDC/kP2ZrvsGev7EKF+eP+wng6thWacZtrOs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=mKBEb1+ak1MgJ1jZlmAR7oG64XNMjtquWXXIB08bkYEaGD1GfYv79guM1xOZGFkqt xVA9fMSQw46boLBaW056YSUfqvVmHhl/XGEDxZfc/Rk+Ilq6P5ICFYYxX3CBlqfFpr GuHYiXJVXJpKDZMFjvFaBBQNwpbAWOFUkdH8BUYQl+eAW+eqmHX4Z/o/5YtDMjnuRB u+WZ37Ul7fFlEFj6DArorlo050Rmapy8SgC2zrwHKRymG8Z1+iL3Csi1pRe5v3sM1k wX5/m9ksjiGM4EkMIjqzs+AAspqG35Kwug4A2yQ73yVqf4PLXpy66Awik+QUsiNQS+ a+dUCu1ss78Fw== X-Nifty-SrcIP: [111.169.71.157] From: Masahiro Yamada To: u-boot@lists.denx.de Date: Tue, 14 Feb 2017 01:24:25 +0900 Message-Id: <1487003066-14387-2-git-send-email-yamada.masahiro@socionext.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1487003066-14387-1-git-send-email-yamada.masahiro@socionext.com> References: <1487003066-14387-1-git-send-email-yamada.masahiro@socionext.com> Cc: Albert Aribaud Subject: [U-Boot] [PATCH 2/3] ARM: uniphier: move spl_boot_mode() to a separate file 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 spl_boot_mode() is unrelated to the other code in this file. Besides, this function is only called from common/spl/spl_mmc.c, so it is reasonable to guard with CONFIG_SPL_MMC_SUPPORT. Signed-off-by: Masahiro Yamada --- arch/arm/mach-uniphier/Makefile | 1 + arch/arm/mach-uniphier/boot-mode/boot-mode.c | 24 ------------------------ arch/arm/mach-uniphier/mmc-boot-mode.c | 27 +++++++++++++++++++++++++++ 3 files changed, 28 insertions(+), 24 deletions(-) create mode 100644 arch/arm/mach-uniphier/mmc-boot-mode.c -- 2.7.4 _______________________________________________ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot diff --git a/arch/arm/mach-uniphier/Makefile b/arch/arm/mach-uniphier/Makefile index 0eb59fb..7baec73 100644 --- a/arch/arm/mach-uniphier/Makefile +++ b/arch/arm/mach-uniphier/Makefile @@ -8,6 +8,7 @@ obj-y += boards.o obj-y += spl_board_init.o obj-y += memconf.o obj-y += bcu/ +obj-$(CONFIG_SPL_MMC_SUPPORT) += mmc-boot-mode.o else diff --git a/arch/arm/mach-uniphier/boot-mode/boot-mode.c b/arch/arm/mach-uniphier/boot-mode/boot-mode.c index 6ce3273..4e1142b 100644 --- a/arch/arm/mach-uniphier/boot-mode/boot-mode.c +++ b/arch/arm/mach-uniphier/boot-mode/boot-mode.c @@ -76,27 +76,3 @@ u32 spl_boot_device(void) return mode; } - -u32 spl_boot_mode(const u32 boot_device) -{ - struct mmc *mmc; - - /* - * work around a bug in the Boot ROM of PH1-sLD3, LD4, Pro4, and sLD8: - * - * The boot ROM in these SoCs breaks the PARTITION_CONFIG [179] of - * Extended CSD register; when switching to the Boot Partition 1, the - * Boot ROM should issue the SWITCH command (CMD6) with Set Bits for - * the Access Bits, but in fact it uses Write Byte for the Access Bits. - * As a result, the BOOT_PARTITION_ENABLE field of the PARTITION_CONFIG - * is lost. This bug was fixed for PH1-Pro5 and later SoCs. - * - * Fixup mmc->part_config here because it is used to determine the - * partition which the U-Boot image is read from. - */ - mmc = find_mmc_device(0); - mmc->part_config &= ~EXT_CSD_BOOT_PART_NUM(PART_ACCESS_MASK); - mmc->part_config |= EXT_CSD_BOOT_PARTITION_ENABLE; - - return MMCSD_MODE_EMMCBOOT; -} diff --git a/arch/arm/mach-uniphier/mmc-boot-mode.c b/arch/arm/mach-uniphier/mmc-boot-mode.c new file mode 100644 index 0000000..ca13bac --- /dev/null +++ b/arch/arm/mach-uniphier/mmc-boot-mode.c @@ -0,0 +1,27 @@ +#include +#include +#include + +u32 spl_boot_mode(const u32 boot_device) +{ + struct mmc *mmc; + + /* + * work around a bug in the Boot ROM of PH1-sLD3, LD4, Pro4, and sLD8: + * + * The boot ROM in these SoCs breaks the PARTITION_CONFIG [179] of + * Extended CSD register; when switching to the Boot Partition 1, the + * Boot ROM should issue the SWITCH command (CMD6) with Set Bits for + * the Access Bits, but in fact it uses Write Byte for the Access Bits. + * As a result, the BOOT_PARTITION_ENABLE field of the PARTITION_CONFIG + * is lost. This bug was fixed for PH1-Pro5 and later SoCs. + * + * Fixup mmc->part_config here because it is used to determine the + * partition which the U-Boot image is read from. + */ + mmc = find_mmc_device(0); + mmc->part_config &= ~EXT_CSD_BOOT_PART_NUM(PART_ACCESS_MASK); + mmc->part_config |= EXT_CSD_BOOT_PARTITION_ENABLE; + + return MMCSD_MODE_EMMCBOOT; +} From patchwork Mon Feb 13 16:24:26 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahiro Yamada X-Patchwork-Id: 93905 Delivered-To: patch@linaro.org Received: by 10.140.20.99 with SMTP id 90csp1168713qgi; Mon, 13 Feb 2017 08:25:21 -0800 (PST) X-Received: by 10.28.111.75 with SMTP id k72mr19632679wmc.39.1487003121110; Mon, 13 Feb 2017 08:25:21 -0800 (PST) Return-Path: Received: from theia.denx.de (theia.denx.de. [85.214.87.163]) by mx.google.com with ESMTP id f66si6148177wmh.81.2017.02.13.08.25.20; Mon, 13 Feb 2017 08:25:21 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of u-boot-bounces@lists.denx.de designates 85.214.87.163 as permitted sender) client-ip=85.214.87.163; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@nifty.com; spf=pass (google.com: best guess record for domain of u-boot-bounces@lists.denx.de designates 85.214.87.163 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 777D94B1FE; Mon, 13 Feb 2017 17:25:14 +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 9HPt728ubsyq; Mon, 13 Feb 2017 17:25:14 +0100 (CET) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id A36C74B270; Mon, 13 Feb 2017 17:25:07 +0100 (CET) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 16CFE4A05F for ; Mon, 13 Feb 2017 17:24:53 +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 yq-6ZQlWuSbU for ; Mon, 13 Feb 2017 17:24:53 +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 conuserg-10.nifty.com (conuserg-10.nifty.com [210.131.2.77]) by theia.denx.de (Postfix) with ESMTPS id 167ED4A023 for ; Mon, 13 Feb 2017 17:24:47 +0100 (CET) Received: from grover.sesame (FL1-111-169-71-157.osk.mesh.ad.jp [111.169.71.157]) (authenticated) by conuserg-10.nifty.com with ESMTP id v1DGORTb006492; Tue, 14 Feb 2017 01:24:31 +0900 DKIM-Filter: OpenDKIM Filter v2.10.3 conuserg-10.nifty.com v1DGORTb006492 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nifty.com; s=dec2015msa; t=1487003071; bh=GkeZDP4Rp2odxBzT899RSucdxyU7Ax/Glb6Ac5G0V8M=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=F0eTx+j2A9i6eBQzxyJZEIcfLiHa+MMypuynaubZxo8GjXxO1iaI4EbzrV5MBmhv6 ELgK5lQbYooiSaqkRRKma3AzcctXIaoERLsncaUSs3LvRJpsRfdibUFu9q/6RGZND+ hbrRVMjNOfL/LghUIKuOD/Wr/csFD1uyeHrelHLMB389C0FEc/wyEvyKU3adhp2V8u Uxu1Y8P8sPxIOyNXAlHu8zmS6zj671+Whx7Se8NgyAmY+GaLt04Y0ynw39DcBRJ5v/ 983BYbwcCjBlrncqM3TitaLqmWKk10yp82lF03QsxXRvBq3Fl+AiMlkdzREtnUNoa9 8kXGxMD7sEfCg== X-Nifty-SrcIP: [111.169.71.157] From: Masahiro Yamada To: u-boot@lists.denx.de Date: Tue, 14 Feb 2017 01:24:26 +0900 Message-Id: <1487003066-14387-3-git-send-email-yamada.masahiro@socionext.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1487003066-14387-1-git-send-email-yamada.masahiro@socionext.com> References: <1487003066-14387-1-git-send-email-yamada.masahiro@socionext.com> Cc: Albert Aribaud Subject: [U-Boot] [PATCH 3/3] ARM: uniphier: rework spl_boot_device() and related code 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 current implementation has ugly switch statements here and there, and duplicates similar code. Rework it using table lookups for SoC data and reduce code duplication. Signed-off-by: Masahiro Yamada --- arch/arm/mach-uniphier/Makefile | 2 +- arch/arm/mach-uniphier/board_late_init.c | 4 +- arch/arm/mach-uniphier/boot-device/Makefile | 19 ++ .../boot-device-ld11.c} | 52 ++---- .../boot-device-ld4.c} | 32 +--- .../boot-device-pro5.c} | 33 +--- .../boot-device-pxs2.c} | 34 +--- .../boot-device-sld3.c} | 32 +--- arch/arm/mach-uniphier/boot-device/boot-device.c | 203 +++++++++++++++++++++ arch/arm/mach-uniphier/boot-device/boot-device.h | 35 ++++ .../{boot-mode => boot-device}/spl_board.c | 0 arch/arm/mach-uniphier/boot-mode/Makefile | 21 --- arch/arm/mach-uniphier/boot-mode/boot-device.h | 29 --- arch/arm/mach-uniphier/boot-mode/boot-mode.c | 78 -------- arch/arm/mach-uniphier/boot-mode/cmd_pinmon.c | 59 ------ arch/arm/mach-uniphier/clk/clk-ld11.c | 3 +- arch/arm/mach-uniphier/init.h | 3 + 17 files changed, 299 insertions(+), 340 deletions(-) create mode 100644 arch/arm/mach-uniphier/boot-device/Makefile rename arch/arm/mach-uniphier/{boot-mode/boot-mode-ld20.c => boot-device/boot-device-ld11.c} (73%) rename arch/arm/mach-uniphier/{boot-mode/boot-mode-ld4.c => boot-device/boot-device-ld4.c} (80%) rename arch/arm/mach-uniphier/{boot-mode/boot-mode-pro5.c => boot-device/boot-device-pro5.c} (79%) rename arch/arm/mach-uniphier/{boot-mode/boot-mode-pxs2.c => boot-device/boot-device-pxs2.c} (78%) rename arch/arm/mach-uniphier/{boot-mode/boot-mode-sld3.c => boot-device/boot-device-sld3.c} (85%) create mode 100644 arch/arm/mach-uniphier/boot-device/boot-device.c create mode 100644 arch/arm/mach-uniphier/boot-device/boot-device.h rename arch/arm/mach-uniphier/{boot-mode => boot-device}/spl_board.c (100%) delete mode 100644 arch/arm/mach-uniphier/boot-mode/Makefile delete mode 100644 arch/arm/mach-uniphier/boot-mode/boot-device.h delete mode 100644 arch/arm/mach-uniphier/boot-mode/boot-mode.c delete mode 100644 arch/arm/mach-uniphier/boot-mode/cmd_pinmon.c -- 2.7.4 _______________________________________________ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot diff --git a/arch/arm/mach-uniphier/Makefile b/arch/arm/mach-uniphier/Makefile index 7baec73..124a1c6 100644 --- a/arch/arm/mach-uniphier/Makefile +++ b/arch/arm/mach-uniphier/Makefile @@ -25,7 +25,7 @@ obj-$(CONFIG_MMC) += mmc-first-dev.o endif obj-y += soc-info.o -obj-y += boot-mode/ +obj-y += boot-device/ obj-y += clk/ obj-y += dram/ diff --git a/arch/arm/mach-uniphier/board_late_init.c b/arch/arm/mach-uniphier/board_late_init.c index ece761f..92dd610 100644 --- a/arch/arm/mach-uniphier/board_late_init.c +++ b/arch/arm/mach-uniphier/board_late_init.c @@ -13,7 +13,7 @@ #include #include <../drivers/mtd/nand/denali.h> -#include "boot-mode/boot-device.h" +#include "init.h" static void nand_denali_wp_disable(void) { @@ -62,7 +62,7 @@ int board_late_init(void) { puts("MODE: "); - switch (spl_boot_device_raw()) { + switch (uniphier_boot_device_raw()) { case BOOT_DEVICE_MMC1: printf("eMMC Boot\n"); setenv("bootmode", "emmcboot"); diff --git a/arch/arm/mach-uniphier/boot-device/Makefile b/arch/arm/mach-uniphier/boot-device/Makefile new file mode 100644 index 0000000..a54d2ac --- /dev/null +++ b/arch/arm/mach-uniphier/boot-device/Makefile @@ -0,0 +1,19 @@ +# +# SPDX-License-Identifier: GPL-2.0+ +# + +obj-y += boot-device.o + +obj-$(CONFIG_ARCH_UNIPHIER_SLD3) += boot-device-sld3.o +obj-$(CONFIG_ARCH_UNIPHIER_LD4) += boot-device-ld4.o +obj-$(CONFIG_ARCH_UNIPHIER_PRO4) += boot-device-ld4.o +obj-$(CONFIG_ARCH_UNIPHIER_SLD8) += boot-device-ld4.o +obj-$(CONFIG_ARCH_UNIPHIER_PRO5) += boot-device-pro5.o +obj-$(CONFIG_ARCH_UNIPHIER_PXS2) += boot-device-pxs2.o +obj-$(CONFIG_ARCH_UNIPHIER_LD6B) += boot-device-pxs2.o +obj-$(CONFIG_ARCH_UNIPHIER_LD11) += boot-device-ld11.o +obj-$(CONFIG_ARCH_UNIPHIER_LD20) += boot-device-ld11.o + +ifdef CONFIG_SPL_BUILD +obj-$(CONFIG_SPL_BOARD_LOAD_IMAGE) += spl_board.o +endif diff --git a/arch/arm/mach-uniphier/boot-mode/boot-mode-ld20.c b/arch/arm/mach-uniphier/boot-device/boot-device-ld11.c similarity index 73% rename from arch/arm/mach-uniphier/boot-mode/boot-mode-ld20.c rename to arch/arm/mach-uniphier/boot-device/boot-device-ld11.c index 2992fd7..f1a467c 100644 --- a/arch/arm/mach-uniphier/boot-mode/boot-mode-ld20.c +++ b/arch/arm/mach-uniphier/boot-device/boot-device-ld11.c @@ -8,12 +8,11 @@ #include #include #include +#include -#include "../sg-regs.h" -#include "../soc-info.h" #include "boot-device.h" -static struct boot_device_info boot_device_table[] = { +const struct uniphier_boot_device uniphier_ld11_boot_device_table[] = { {BOOT_DEVICE_NAND, "NAND (Mirror 8, ECC 8, EraseSize 128KB, Addr 4)"}, {BOOT_DEVICE_NAND, "NAND (Mirror 8, ECC 16, EraseSize 128KB, Addr 4)"}, {BOOT_DEVICE_NAND, "NAND (Mirror 8, ECC 8, EraseSize 128KB, Addr 5)"}, @@ -48,48 +47,23 @@ static struct boot_device_info boot_device_table[] = { {BOOT_DEVICE_NOR, "NOR (XECS1)"}, }; -static int get_boot_mode_sel(void) +const unsigned uniphier_ld11_boot_device_count = + ARRAY_SIZE(uniphier_ld11_boot_device_table); + +int uniphier_ld11_boot_device_is_usb(u32 pinmon) { - return (readl(SG_PINMON0) >> 1) & 0x1f; + return !!(~pinmon & 0x00000080); } -u32 uniphier_ld20_boot_device(void) +int uniphier_ld20_boot_device_is_usb(u32 pinmon) { - int boot_mode; - u32 usb_boot_mask; - - switch (uniphier_get_soc_id()) { -#if defined(CONFIG_ARCH_UNIPHIER_LD11) - case UNIPHIER_LD11_ID: - usb_boot_mask = 0x00000080; - break; -#endif -#if defined(CONFIG_ARCH_UNIPHIER_LD20) - case UNIPHIER_LD20_ID: - usb_boot_mask = 0x00000780; - break; -#endif - default: - BUG(); - } - - if (~readl(SG_PINMON0) & usb_boot_mask) - return BOOT_DEVICE_USB; - - boot_mode = get_boot_mode_sel(); - - return boot_device_table[boot_mode].type; + return !!(~pinmon & 0x00000780); } -void uniphier_ld20_boot_mode_show(void) +unsigned int uniphier_ld11_boot_device_fixup(unsigned int mode) { - int mode_sel, i; - - mode_sel = get_boot_mode_sel(); - - puts("Boot Mode Pin:\n"); + if (mode == BOOT_DEVICE_MMC1 || mode == BOOT_DEVICE_USB) + mode = BOOT_DEVICE_BOARD; - for (i = 0; i < ARRAY_SIZE(boot_device_table); i++) - printf(" %c %02x %s\n", i == mode_sel ? '*' : ' ', i, - boot_device_table[i].info); + return mode; } diff --git a/arch/arm/mach-uniphier/boot-mode/boot-mode-ld4.c b/arch/arm/mach-uniphier/boot-device/boot-device-ld4.c similarity index 80% rename from arch/arm/mach-uniphier/boot-mode/boot-mode-ld4.c rename to arch/arm/mach-uniphier/boot-device/boot-device-ld4.c index b066ed9..1fe26ef 100644 --- a/arch/arm/mach-uniphier/boot-mode/boot-mode-ld4.c +++ b/arch/arm/mach-uniphier/boot-device/boot-device-ld4.c @@ -7,11 +7,11 @@ #include #include #include +#include -#include "../sg-regs.h" #include "boot-device.h" -struct boot_device_info boot_device_table[] = { +const struct uniphier_boot_device uniphier_ld4_boot_device_table[] = { {BOOT_DEVICE_NAND, "NAND (Mirror 8, ECC 8, EraseSize 128KB, Addr 4)"}, {BOOT_DEVICE_NAND, "NAND (Mirror 8, ECC 8, EraseSize 128KB, Addr 5)"}, {BOOT_DEVICE_NAND, "NAND (Mirror 8, ECC 16, EraseSize 128KB, Addr 5)"}, @@ -46,29 +46,5 @@ struct boot_device_info boot_device_table[] = { {BOOT_DEVICE_NOR, "NOR (XECS0)"}, }; -static int get_boot_mode_sel(void) -{ - return (readl(SG_PINMON0) >> 1) & 0x1f; -} - -u32 uniphier_ld4_boot_device(void) -{ - int boot_mode; - - boot_mode = get_boot_mode_sel(); - - return boot_device_table[boot_mode].type; -} - -void uniphier_ld4_boot_mode_show(void) -{ - int mode_sel, i; - - mode_sel = get_boot_mode_sel(); - - puts("Boot Mode Pin:\n"); - - for (i = 0; i < ARRAY_SIZE(boot_device_table); i++) - printf(" %c %02x %s\n", i == mode_sel ? '*' : ' ', i, - boot_device_table[i].info); -} +const unsigned uniphier_ld4_boot_device_count = + ARRAY_SIZE(uniphier_ld4_boot_device_table); diff --git a/arch/arm/mach-uniphier/boot-mode/boot-mode-pro5.c b/arch/arm/mach-uniphier/boot-device/boot-device-pro5.c similarity index 79% rename from arch/arm/mach-uniphier/boot-mode/boot-mode-pro5.c rename to arch/arm/mach-uniphier/boot-device/boot-device-pro5.c index 450c43b..6ba7d7e 100644 --- a/arch/arm/mach-uniphier/boot-mode/boot-mode-pro5.c +++ b/arch/arm/mach-uniphier/boot-device/boot-device-pro5.c @@ -7,11 +7,11 @@ #include #include #include +#include -#include "../sg-regs.h" #include "boot-device.h" -static struct boot_device_info boot_device_table[] = { +const struct uniphier_boot_device uniphier_pro5_boot_device_table[] = { {BOOT_DEVICE_NAND, "NAND (Mirror 1, ECC 8, EraseSize 128KB, Addr 5)"}, {BOOT_DEVICE_NAND, "NAND (Mirror 1, ECC 16, EraseSize 128KB, Addr 5)"}, {BOOT_DEVICE_NAND, "NAND (Mirror 1, ECC 8, EraseSize 256KB, Addr 5)"}, @@ -44,32 +44,7 @@ static struct boot_device_info boot_device_table[] = { {BOOT_DEVICE_NAND, "NAND (Mirror 8, ECC 16, EraseSize 128KB, Addr 5)"}, {BOOT_DEVICE_NAND, "NAND (Mirror 8, ECC 8, EraseSize 256KB, Addr 5)"}, {BOOT_DEVICE_NAND, "NAND (Mirror 8, ECC 16, EraseSize 256KB, Addr 5)"}, - { /* sentinel */ } }; -static int get_boot_mode_sel(void) -{ - return (readl(SG_PINMON0) >> 1) & 0x1f; -} - -u32 uniphier_pro5_boot_device(void) -{ - int boot_mode; - - boot_mode = get_boot_mode_sel(); - - return boot_device_table[boot_mode].type; -} - -void uniphier_pro5_boot_mode_show(void) -{ - int mode_sel, i; - - mode_sel = get_boot_mode_sel(); - - puts("Boot Mode Pin:\n"); - - for (i = 0; i < ARRAY_SIZE(boot_device_table); i++) - printf(" %c %02x %s\n", i == mode_sel ? '*' : ' ', i, - boot_device_table[i].info); -} +const unsigned uniphier_pro5_boot_device_count = + ARRAY_SIZE(uniphier_pro5_boot_device_table); diff --git a/arch/arm/mach-uniphier/boot-mode/boot-mode-pxs2.c b/arch/arm/mach-uniphier/boot-device/boot-device-pxs2.c similarity index 78% rename from arch/arm/mach-uniphier/boot-mode/boot-mode-pxs2.c rename to arch/arm/mach-uniphier/boot-device/boot-device-pxs2.c index 20ff773..4c98f5c 100644 --- a/arch/arm/mach-uniphier/boot-mode/boot-mode-pxs2.c +++ b/arch/arm/mach-uniphier/boot-device/boot-device-pxs2.c @@ -7,11 +7,11 @@ #include #include #include +#include -#include "../sg-regs.h" #include "boot-device.h" -static struct boot_device_info boot_device_table[] = { +const struct uniphier_boot_device uniphier_pxs2_boot_device_table[] = { {BOOT_DEVICE_NAND, "NAND (Mirror 8, ECC 8, EraseSize 128KB, Addr 4)"}, {BOOT_DEVICE_NAND, "NAND (Mirror 8, ECC 8, EraseSize 128KB, Addr 5)"}, {BOOT_DEVICE_NAND, "NAND (Mirror 8, ECC 16, EraseSize 128KB, Addr 5)"}, @@ -46,32 +46,18 @@ static struct boot_device_info boot_device_table[] = { {BOOT_DEVICE_NONE, "Reserved"}, }; -static int get_boot_mode_sel(void) -{ - return (readl(SG_PINMON0) >> 1) & 0x1f; -} +const unsigned uniphier_pxs2_boot_device_count = + ARRAY_SIZE(uniphier_pxs2_boot_device_table); -u32 uniphier_pxs2_boot_device(void) +int uniphier_pxs2_boot_device_is_usb(u32 pinmon) { - int boot_mode; - - if (readl(SG_PINMON0) & BIT(6)) - return BOOT_DEVICE_USB; - - boot_mode = get_boot_mode_sel(); - - return boot_device_table[boot_mode].type; + return !!(pinmon & 0x00000040); } -void uniphier_pxs2_boot_mode_show(void) +unsigned int uniphier_pxs2_boot_device_fixup(unsigned int mode) { - int mode_sel, i; - - mode_sel = get_boot_mode_sel(); - - puts("Boot Mode Pin:\n"); + if (mode == BOOT_DEVICE_USB) + return BOOT_DEVICE_NOR; - for (i = 0; i < ARRAY_SIZE(boot_device_table); i++) - printf(" %c %02x %s\n", i == mode_sel ? '*' : ' ', i, - boot_device_table[i].info); + return mode; } diff --git a/arch/arm/mach-uniphier/boot-mode/boot-mode-sld3.c b/arch/arm/mach-uniphier/boot-device/boot-device-sld3.c similarity index 85% rename from arch/arm/mach-uniphier/boot-mode/boot-mode-sld3.c rename to arch/arm/mach-uniphier/boot-device/boot-device-sld3.c index ddf8259..de008b5 100644 --- a/arch/arm/mach-uniphier/boot-mode/boot-mode-sld3.c +++ b/arch/arm/mach-uniphier/boot-device/boot-device-sld3.c @@ -7,11 +7,11 @@ #include #include #include +#include -#include "../sg-regs.h" #include "boot-device.h" -static struct boot_device_info boot_device_table[] = { +const struct uniphier_boot_device uniphier_sld3_boot_device_table[] = { {BOOT_DEVICE_NOR, "NOR (XECS0)"}, {BOOT_DEVICE_NONE, "External Master"}, {BOOT_DEVICE_NONE, "Reserved"}, @@ -78,29 +78,5 @@ static struct boot_device_info boot_device_table[] = { {BOOT_DEVICE_NONE, "Reserved"}, }; -static int get_boot_mode_sel(void) -{ - return readl(SG_PINMON0) & 0x3f; -} - -u32 uniphier_sld3_boot_device(void) -{ - int boot_mode; - - boot_mode = get_boot_mode_sel(); - - return boot_device_table[boot_mode].type; -} - -void uniphier_sld3_boot_mode_show(void) -{ - int mode_sel, i; - - mode_sel = get_boot_mode_sel(); - - puts("Boot Mode Pin:\n"); - - for (i = 0; i < ARRAY_SIZE(boot_device_table); i++) - printf(" %c %02x %s\n", i == mode_sel ? '*' : ' ', i, - boot_device_table[i].info); -} +const unsigned uniphier_sld3_boot_device_count = + ARRAY_SIZE(uniphier_sld3_boot_device_table); diff --git a/arch/arm/mach-uniphier/boot-device/boot-device.c b/arch/arm/mach-uniphier/boot-device/boot-device.c new file mode 100644 index 0000000..ec3113b --- /dev/null +++ b/arch/arm/mach-uniphier/boot-device/boot-device.c @@ -0,0 +1,203 @@ +/* + * Copyright (C) 2015-2017 Socionext Inc. + * Author: Masahiro Yamada + * + * SPDX-License-Identifier: GPL-2.0+ + */ + +#include +#include + +#include "../init.h" +#include "../sbc/sbc-regs.h" +#include "../sg-regs.h" +#include "../soc-info.h" +#include "boot-device.h" + +struct uniphier_boot_device_info { + unsigned int soc_id; + unsigned int boot_device_sel_shift; + const struct uniphier_boot_device *boot_device_table; + const unsigned int *boot_device_count; + int (*boot_device_is_usb)(u32 pinmon); + unsigned int (*boot_device_fixup)(unsigned int mode); +}; + +static const struct uniphier_boot_device_info uniphier_boot_device_info[] = { +#if defined(CONFIG_ARCH_UNIPHIER_SLD3) + { + .soc_id = UNIPHIER_SLD3_ID, + .boot_device_sel_shift = 0, + .boot_device_table = uniphier_sld3_boot_device_table, + .boot_device_count = &uniphier_sld3_boot_device_count, + }, +#endif +#if defined(CONFIG_ARCH_UNIPHIER_LD4) + { + .soc_id = UNIPHIER_LD4_ID, + .boot_device_sel_shift = 1, + .boot_device_table = uniphier_ld4_boot_device_table, + .boot_device_count = &uniphier_ld4_boot_device_count, + }, +#endif +#if defined(CONFIG_ARCH_UNIPHIER_PRO4) + { + .soc_id = UNIPHIER_PRO4_ID, + .boot_device_sel_shift = 1, + .boot_device_table = uniphier_ld4_boot_device_table, + .boot_device_count = &uniphier_ld4_boot_device_count, + }, +#endif +#if defined(CONFIG_ARCH_UNIPHIER_SLD8) + { + .soc_id = UNIPHIER_SLD8_ID, + .boot_device_sel_shift = 1, + .boot_device_table = uniphier_ld4_boot_device_table, + .boot_device_count = &uniphier_ld4_boot_device_count, + }, +#endif +#if defined(CONFIG_ARCH_UNIPHIER_PRO5) + { + .soc_id = UNIPHIER_PRO5_ID, + .boot_device_sel_shift = 1, + .boot_device_table = uniphier_pro5_boot_device_table, + .boot_device_count = &uniphier_pro5_boot_device_count, + }, +#endif +#if defined(CONFIG_ARCH_UNIPHIER_PXS2) + { + .soc_id = UNIPHIER_PXS2_ID, + .boot_device_sel_shift = 1, + .boot_device_table = uniphier_pxs2_boot_device_table, + .boot_device_count = &uniphier_pxs2_boot_device_count, + .boot_device_is_usb = uniphier_pxs2_boot_device_is_usb, + .boot_device_fixup = uniphier_pxs2_boot_device_fixup, + }, +#endif +#if defined(CONFIG_ARCH_UNIPHIER_LD6B) + { + .soc_id = UNIPHIER_LD6B_ID, + .boot_device_sel_shift = 1, + .boot_device_table = uniphier_pxs2_boot_device_table, + .boot_device_count = &uniphier_pxs2_boot_device_count, + .boot_device_is_usb = uniphier_pxs2_boot_device_is_usb, + .boot_device_fixup = uniphier_pxs2_boot_device_fixup, + }, +#endif +#if defined(CONFIG_ARCH_UNIPHIER_LD11) + { + .soc_id = UNIPHIER_LD11_ID, + .boot_device_sel_shift = 1, + .boot_device_table = uniphier_ld11_boot_device_table, + .boot_device_count = &uniphier_ld11_boot_device_count, + .boot_device_is_usb = uniphier_ld11_boot_device_is_usb, + .boot_device_fixup = uniphier_ld11_boot_device_fixup, + }, +#endif +#if defined(CONFIG_ARCH_UNIPHIER_LD20) + { + .soc_id = UNIPHIER_LD20_ID, + .boot_device_sel_shift = 1, + .boot_device_table = uniphier_ld11_boot_device_table, + .boot_device_count = &uniphier_ld11_boot_device_count, + .boot_device_is_usb = uniphier_ld20_boot_device_is_usb, + .boot_device_fixup = uniphier_ld11_boot_device_fixup, + }, +#endif +}; +UNIPHIER_DEFINE_SOCDATA_FUNC(uniphier_get_boot_device_info, + uniphier_boot_device_info) + +static unsigned int __uniphier_boot_device_raw( + const struct uniphier_boot_device_info *info) +{ + u32 pinmon; + unsigned int boot_sel; + + if (boot_is_swapped()) + return BOOT_DEVICE_NOR; + + pinmon = readl(SG_PINMON0); + + if (info->boot_device_is_usb && info->boot_device_is_usb(pinmon)) + return BOOT_DEVICE_USB; + + boot_sel = pinmon >> info->boot_device_sel_shift; + boot_sel &= *info->boot_device_count - 1; + + return info->boot_device_table[boot_sel].boot_device; +} + +unsigned int uniphier_boot_device_raw(void) +{ + const struct uniphier_boot_device_info *info; + + info = uniphier_get_boot_device_info(); + if (!info) { + pr_err("unsupported SoC\n"); + return BOOT_DEVICE_NONE; + } + + return __uniphier_boot_device_raw(info); +} + +u32 spl_boot_device(void) +{ + const struct uniphier_boot_device_info *info; + u32 raw_mode; + + info = uniphier_get_boot_device_info(); + if (!info) { + pr_err("unsupported SoC\n"); + return BOOT_DEVICE_NONE; + } + + raw_mode = __uniphier_boot_device_raw(info); + + return info->boot_device_fixup ? + info->boot_device_fixup(raw_mode) : raw_mode; +} + +#ifndef CONFIG_SPL_BUILD + +static int do_pinmon(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) +{ + const struct uniphier_boot_device_info *info; + u32 pinmon; + unsigned int boot_device_count, boot_sel; + int i; + + info = uniphier_get_boot_device_info(); + if (!info) { + pr_err("unsupported SoC\n"); + return CMD_RET_FAILURE; + } + + printf("Boot Swap: %s\n\n", boot_is_swapped() ? "ON" : "OFF"); + + pinmon = readl(SG_PINMON0); + + if (info->boot_device_is_usb) + printf("USB Boot: %s\n\n", + info->boot_device_is_usb(pinmon) ? "ON" : "OFF"); + + boot_device_count = *info->boot_device_count; + + boot_sel = pinmon >> info->boot_device_sel_shift; + boot_sel &= boot_device_count - 1; + + printf("Boot Mode Sel:\n"); + for (i = 0; i < boot_device_count; i++) + printf(" %c %02x %s\n", i == boot_sel ? '*' : ' ', i, + info->boot_device_table[i].desc); + + return CMD_RET_SUCCESS; +} + +U_BOOT_CMD( + pinmon, 1, 1, do_pinmon, + "pin monitor", + "" +); + +#endif /* !CONFIG_SPL_BUILD */ diff --git a/arch/arm/mach-uniphier/boot-device/boot-device.h b/arch/arm/mach-uniphier/boot-device/boot-device.h new file mode 100644 index 0000000..f3fb2f3 --- /dev/null +++ b/arch/arm/mach-uniphier/boot-device/boot-device.h @@ -0,0 +1,35 @@ +/* + * Copyright (C) 2017 Socionext Inc. + * Author: Masahiro Yamada + * + * SPDX-License-Identifier: GPL-2.0+ + */ + +#ifndef _UNIPHIER_BOOT_DEVICE_H_ +#define _UNIPHIER_BOOT_DEVICE_H_ + +struct uniphier_boot_device { + unsigned int boot_device; + const char *desc; +}; + +extern const struct uniphier_boot_device uniphier_sld3_boot_device_table[]; +extern const struct uniphier_boot_device uniphier_ld4_boot_device_table[]; +extern const struct uniphier_boot_device uniphier_pro5_boot_device_table[]; +extern const struct uniphier_boot_device uniphier_pxs2_boot_device_table[]; +extern const struct uniphier_boot_device uniphier_ld11_boot_device_table[]; + +extern const unsigned int uniphier_sld3_boot_device_count; +extern const unsigned int uniphier_ld4_boot_device_count; +extern const unsigned int uniphier_pro5_boot_device_count; +extern const unsigned int uniphier_pxs2_boot_device_count; +extern const unsigned int uniphier_ld11_boot_device_count; + +int uniphier_pxs2_boot_device_is_usb(u32 pinmon); +int uniphier_ld11_boot_device_is_usb(u32 pinmon); +int uniphier_ld20_boot_device_is_usb(u32 pinmon); + +unsigned int uniphier_pxs2_boot_device_fixup(unsigned int mode); +unsigned int uniphier_ld11_boot_device_fixup(unsigned int mode); + +#endif /* _UNIPHIER_BOOT_DEVICE_H_ */ diff --git a/arch/arm/mach-uniphier/boot-mode/spl_board.c b/arch/arm/mach-uniphier/boot-device/spl_board.c similarity index 100% rename from arch/arm/mach-uniphier/boot-mode/spl_board.c rename to arch/arm/mach-uniphier/boot-device/spl_board.c diff --git a/arch/arm/mach-uniphier/boot-mode/Makefile b/arch/arm/mach-uniphier/boot-mode/Makefile deleted file mode 100644 index a898021..0000000 --- a/arch/arm/mach-uniphier/boot-mode/Makefile +++ /dev/null @@ -1,21 +0,0 @@ -# -# SPDX-License-Identifier: GPL-2.0+ -# - -obj-y += boot-mode.o - -obj-$(CONFIG_ARCH_UNIPHIER_SLD3) += boot-mode-sld3.o -obj-$(CONFIG_ARCH_UNIPHIER_LD4) += boot-mode-ld4.o -obj-$(CONFIG_ARCH_UNIPHIER_PRO4) += boot-mode-ld4.o -obj-$(CONFIG_ARCH_UNIPHIER_SLD8) += boot-mode-ld4.o -obj-$(CONFIG_ARCH_UNIPHIER_PRO5) += boot-mode-pro5.o -obj-$(CONFIG_ARCH_UNIPHIER_PXS2) += boot-mode-pxs2.o -obj-$(CONFIG_ARCH_UNIPHIER_LD6B) += boot-mode-pxs2.o -obj-$(CONFIG_ARCH_UNIPHIER_LD11) += boot-mode-ld20.o -obj-$(CONFIG_ARCH_UNIPHIER_LD20) += boot-mode-ld20.o - -ifdef CONFIG_SPL_BUILD -obj-$(CONFIG_SPL_BOARD_LOAD_IMAGE) += spl_board.o -else -obj-$(CONFIG_CMD_PINMON) += cmd_pinmon.o -endif diff --git a/arch/arm/mach-uniphier/boot-mode/boot-device.h b/arch/arm/mach-uniphier/boot-mode/boot-device.h deleted file mode 100644 index bd44d73..0000000 --- a/arch/arm/mach-uniphier/boot-mode/boot-device.h +++ /dev/null @@ -1,29 +0,0 @@ -/* - * Copyright (C) 2011-2015 Masahiro Yamada - * - * SPDX-License-Identifier: GPL-2.0+ - */ - -#ifndef _ASM_BOOT_DEVICE_H_ -#define _ASM_BOOT_DEVICE_H_ - -struct boot_device_info { - u32 type; - char *info; -}; - -u32 uniphier_sld3_boot_device(void); -u32 uniphier_ld4_boot_device(void); -u32 uniphier_pro5_boot_device(void); -u32 uniphier_pxs2_boot_device(void); -u32 uniphier_ld20_boot_device(void); - -void uniphier_sld3_boot_mode_show(void); -void uniphier_ld4_boot_mode_show(void); -void uniphier_pro5_boot_mode_show(void); -void uniphier_pxs2_boot_mode_show(void); -void uniphier_ld20_boot_mode_show(void); - -u32 spl_boot_device_raw(void); - -#endif /* _ASM_BOOT_DEVICE_H_ */ diff --git a/arch/arm/mach-uniphier/boot-mode/boot-mode.c b/arch/arm/mach-uniphier/boot-mode/boot-mode.c deleted file mode 100644 index 4e1142b..0000000 --- a/arch/arm/mach-uniphier/boot-mode/boot-mode.c +++ /dev/null @@ -1,78 +0,0 @@ -/* - * Copyright (C) 2015 Masahiro Yamada - * - * SPDX-License-Identifier: GPL-2.0+ - */ - -#include -#include -#include -#include - -#include "../sbc/sbc-regs.h" -#include "../soc-info.h" -#include "boot-device.h" - -u32 spl_boot_device_raw(void) -{ - if (boot_is_swapped()) - return BOOT_DEVICE_NOR; - - switch (uniphier_get_soc_id()) { -#if defined(CONFIG_ARCH_UNIPHIER_SLD3) - case UNIPHIER_SLD3_ID: - return uniphier_sld3_boot_device(); -#endif -#if defined(CONFIG_ARCH_UNIPHIER_LD4) || defined(CONFIG_ARCH_UNIPHIER_PRO4) || \ - defined(CONFIG_ARCH_UNIPHIER_SLD8) - case UNIPHIER_LD4_ID: - case UNIPHIER_PRO4_ID: - case UNIPHIER_SLD8_ID: - return uniphier_ld4_boot_device(); -#endif -#if defined(CONFIG_ARCH_UNIPHIER_PRO5) - case UNIPHIER_PRO5_ID: - return uniphier_pro5_boot_device(); -#endif -#if defined(CONFIG_ARCH_UNIPHIER_PXS2) || defined(CONFIG_ARCH_UNIPHIER_LD6B) - case UNIPHIER_PXS2_ID: - case UNIPHIER_LD6B_ID: - return uniphier_pxs2_boot_device(); -#endif -#if defined(CONFIG_ARCH_UNIPHIER_LD11) || defined(CONFIG_ARCH_UNIPHIER_LD20) - case UNIPHIER_LD11_ID: - case UNIPHIER_LD20_ID: - return uniphier_ld20_boot_device(); -#endif - default: - return BOOT_DEVICE_NONE; - } -} - -u32 spl_boot_device(void) -{ - u32 mode; - - mode = spl_boot_device_raw(); - - switch (uniphier_get_soc_id()) { -#if defined(CONFIG_ARCH_UNIPHIER_PXS2) || defined(CONFIG_ARCH_UNIPHIER_LD6B) - case UNIPHIER_PXS2_ID: - case UNIPHIER_LD6B_ID: - if (mode == BOOT_DEVICE_USB) - mode = BOOT_DEVICE_NOR; - break; -#endif -#if defined(CONFIG_ARCH_UNIPHIER_LD11) || defined(CONFIG_ARCH_UNIPHIER_LD20) - case UNIPHIER_LD11_ID: - case UNIPHIER_LD20_ID: - if (mode == BOOT_DEVICE_MMC1 || mode == BOOT_DEVICE_USB) - mode = BOOT_DEVICE_BOARD; - break; -#endif - default: - break; - } - - return mode; -} diff --git a/arch/arm/mach-uniphier/boot-mode/cmd_pinmon.c b/arch/arm/mach-uniphier/boot-mode/cmd_pinmon.c deleted file mode 100644 index 670d4f6..0000000 --- a/arch/arm/mach-uniphier/boot-mode/cmd_pinmon.c +++ /dev/null @@ -1,59 +0,0 @@ -/* - * Copyright (C) 2014-2015 Masahiro Yamada - * - * SPDX-License-Identifier: GPL-2.0+ - */ - -#include - -#include "../sbc/sbc-regs.h" -#include "../soc-info.h" -#include "boot-device.h" - -static int do_pinmon(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) -{ - printf("Boot Swap: %s\n\n", boot_is_swapped() ? "ON" : "OFF"); - - switch (uniphier_get_soc_id()) { -#if defined(CONFIG_ARCH_UNIPHIER_SLD3) - case UNIPHIER_SLD3_ID: - uniphier_sld3_boot_mode_show(); - break; -#endif -#if defined(CONFIG_ARCH_UNIPHIER_LD4) || defined(CONFIG_ARCH_UNIPHIER_PRO4) || \ - defined(CONFIG_ARCH_UNIPHIER_SLD8) - case UNIPHIER_LD4_ID: - case UNIPHIER_PRO4_ID: - case UNIPHIER_SLD8_ID: - uniphier_ld4_boot_mode_show(); - break; -#endif -#if defined(CONFIG_ARCH_UNIPHIER_PRO5) - case UNIPHIER_PRO5_ID: - uniphier_pro5_boot_mode_show(); - break; -#endif -#if defined(CONFIG_ARCH_UNIPHIER_PXS2) || defined(CONFIG_ARCH_UNIPHIER_LD6B) - case UNIPHIER_PXS2_ID: - case UNIPHIER_LD6B_ID: - uniphier_pxs2_boot_mode_show(); - break; -#endif -#if defined(CONFIG_ARCH_UNIPHIER_LD11) || defined(CONFIG_ARCH_UNIPHIER_LD20) - case UNIPHIER_LD11_ID: - case UNIPHIER_LD20_ID: - uniphier_ld20_boot_mode_show(); - break; -#endif - default: - break; - } - - return 0; -} - -U_BOOT_CMD( - pinmon, 1, 1, do_pinmon, - "pin monitor", - "" -); diff --git a/arch/arm/mach-uniphier/clk/clk-ld11.c b/arch/arm/mach-uniphier/clk/clk-ld11.c index 58069cb..b1e82a1 100644 --- a/arch/arm/mach-uniphier/clk/clk-ld11.c +++ b/arch/arm/mach-uniphier/clk/clk-ld11.c @@ -9,7 +9,6 @@ #include #include -#include "../boot-mode/boot-device.h" #include "../init.h" #include "../sc64-regs.h" #include "../sg-regs.h" @@ -18,7 +17,7 @@ void uniphier_ld11_clk_init(void) { /* if booted from a device other than USB, without stand-by MPU */ if ((readl(SG_PINMON0) & BIT(27)) && - spl_boot_device_raw() != BOOT_DEVICE_USB) { + uniphier_boot_device_raw() != BOOT_DEVICE_USB) { writel(1, SG_ETPHYPSHUT); writel(1, SG_ETPHYCNT); diff --git a/arch/arm/mach-uniphier/init.h b/arch/arm/mach-uniphier/init.h index c41a5df..6691d44 100644 --- a/arch/arm/mach-uniphier/init.h +++ b/arch/arm/mach-uniphier/init.h @@ -120,11 +120,14 @@ void uniphier_pro5_clk_init(void); void uniphier_pxs2_clk_init(void); void uniphier_ld11_clk_init(void); +unsigned int uniphier_boot_device_raw(void); int uniphier_pin_init(const char *pinconfig_name); void uniphier_smp_kick_all_cpus(void); void cci500_init(int nr_slaves); +#undef pr_warn #define pr_warn(fmt, args...) printf(fmt, ##args) +#undef pr_err #define pr_err(fmt, args...) printf(fmt, ##args) #endif /* __MACH_INIT_H */