From patchwork Thu Jan 28 10:00:19 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Purna Chandra Mandal X-Patchwork-Id: 574618 X-Patchwork-Delegate: daniel.schwierzeck@googlemail.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 8CC1D140BB3 for ; Thu, 28 Jan 2016 21:05:10 +1100 (AEDT) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 3068FA7595; Thu, 28 Jan 2016 11:04: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 cuRMo8-g8Fqb; Thu, 28 Jan 2016 11:04:53 +0100 (CET) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 48B0DA75B6; Thu, 28 Jan 2016 11:04:06 +0100 (CET) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id BD33DA7537 for ; Thu, 28 Jan 2016 11:02: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 9o6O-usaXzDZ for ; Thu, 28 Jan 2016 11:02: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 email.microchip.com (exsmtp03.microchip.com [198.175.253.49]) by theia.denx.de (Postfix) with ESMTPS id EFA92A74D0 for ; Thu, 28 Jan 2016 11:02:51 +0100 (CET) Received: from mx.microchip.com (10.10.76.4) by chn-sv-exch03.mchp-main.com (10.10.76.49) with Microsoft SMTP Server id 14.3.181.6; Thu, 28 Jan 2016 03:02:48 -0700 Received: by mx.microchip.com (sSMTP sendmail emulation); Thu, 28 Jan 2016 15:31:29 +0530 From: Purna Chandra Mandal To: Date: Thu, 28 Jan 2016 15:30:19 +0530 Message-ID: <1453975222-11787-11-git-send-email-purna.mandal@microchip.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1453975222-11787-1-git-send-email-purna.mandal@microchip.com> References: <1453975222-11787-1-git-send-email-purna.mandal@microchip.com> MIME-Version: 1.0 Cc: Purna Chandra Mandal Subject: [U-Boot] [PATCH v4 10/13] board: add SDHCI support for PIC32MZDASK board. 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: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" Enable MMC, SDHCI, FAT_FS support for PIC32MZ[DA] StarterKit. Also add custom scripts, rules to boot Linux from microSD card. Signed-off-by: Purna Chandra Mandal --- Changes in v4: None Changes in v3: - use distro boot commands from config_distro_bootcmd.h - separate old booting logic as legacy_bootcmd Changes in v2: - drop shared bus (shared pin selection) configuration. arch/mips/dts/pic32mzda.dtsi | 11 ++++++++ arch/mips/dts/pic32mzda_sk.dts | 7 +++++ configs/pic32mzdask_defconfig | 3 ++- include/configs/pic32mzdask.h | 59 ++++++++++++++++++++++++++++++++++++++++-- 4 files changed, 77 insertions(+), 3 deletions(-) diff --git a/arch/mips/dts/pic32mzda.dtsi b/arch/mips/dts/pic32mzda.dtsi index c67cfa9..f1894ec 100644 --- a/arch/mips/dts/pic32mzda.dtsi +++ b/arch/mips/dts/pic32mzda.dtsi @@ -150,4 +150,15 @@ #gpio-cells = <2>; }; }; + + sdhci: sdhci@1f8ec000 { + compatible = "microchip,pic32mzda-sdhci"; + reg = <0x1f8ec000 0x100>; + interrupts = <191 IRQ_TYPE_LEVEL_HIGH>; + clocks = <&clock REF4CLK>, <&clock PB5CLK>; + clock-names = "base_clk", "sys_clk"; + clock-freq-min-max = <25000000>,<25000000>; + bus-width = <4>; + status = "disabled"; + }; }; diff --git a/arch/mips/dts/pic32mzda_sk.dts b/arch/mips/dts/pic32mzda_sk.dts index 99e7f64..f886a0f 100644 --- a/arch/mips/dts/pic32mzda_sk.dts +++ b/arch/mips/dts/pic32mzda_sk.dts @@ -23,6 +23,9 @@ }; &clock { + microchip,refo2-frequency = <50000000>; + microchip,refo4-frequency = <25000000>; + microchip,refo5-frequency = <40000000>; status = "okay"; u-boot,dm-pre-reloc; }; @@ -36,3 +39,7 @@ status = "okay"; u-boot,dm-pre-reloc; }; + +&sdhci { + status = "okay"; +}; \ No newline at end of file diff --git a/configs/pic32mzdask_defconfig b/configs/pic32mzdask_defconfig index 1c968fc..55ba3f8 100644 --- a/configs/pic32mzdask_defconfig +++ b/configs/pic32mzdask_defconfig @@ -9,7 +9,6 @@ CONFIG_DEFAULT_DEVICE_TREE="pic32mzda_sk" CONFIG_HUSH_PARSER=y CONFIG_SYS_PROMPT="dask # " # CONFIG_CMD_IMLS is not set -# CONFIG_CMD_EXPORTENV is not set # CONFIG_CMD_SAVEENV is not set CONFIG_LOOPW=y CONFIG_CMD_MEMTEST=y @@ -22,6 +21,8 @@ CONFIG_CMD_GPIO=y CONFIG_CMD_TIME=y CONFIG_OF_EMBED=y CONFIG_CLK=y +CONFIG_DM_MMC=y +CONFIG_PIC32_SDHCI=y CONFIG_PINCTRL=y # CONFIG_PINCTRL_FULL is not set CONFIG_SYS_VSNPRINTF=y diff --git a/include/configs/pic32mzdask.h b/include/configs/pic32mzdask.h index 5ba2a19..b258038 100644 --- a/include/configs/pic32mzdask.h +++ b/include/configs/pic32mzdask.h @@ -46,6 +46,7 @@ #define CONFIG_SYS_LOAD_ADDR 0x88500000 /* default load address */ #define CONFIG_SYS_ENV_ADDR 0x88300000 +#define CONFIG_SYS_FDT_ADDR 0x89d00000 /* Memory Test */ #define CONFIG_SYS_MEMTEST_START 0x88000000 @@ -77,6 +78,33 @@ */ #define CONFIG_OF_LIBFDT 1 +/*----------------------------------------------------------------------- + * SDHC Configuration + */ +#define CONFIG_SDHCI +#define CONFIG_MMC +#define CONFIG_GENERIC_MMC +#define CONFIG_CMD_MMC + +/*----------------------------------------------------------------------- + * File System Configuration + */ +/* FAT FS */ +#define CONFIG_DOS_PARTITION +#define CONFIG_PARTITION_UUIDS +#define CONFIG_SUPPORT_VFAT +#define CONFIG_FS_FAT +#define CONFIG_FAT_WRITE +#define CONFIG_CMD_FS_GENERIC +#define CONFIG_CMD_PART +#define CONFIG_CMD_FAT + +/* EXT4 FS */ +#define CONFIG_FS_EXT4 +#define CONFIG_CMD_EXT2 +#define CONFIG_CMD_EXT4 +#define CONFIG_CMD_EXT4_WRITE + /* ------------------------------------------------- * Environment */ @@ -87,7 +115,34 @@ * Board boot configuration */ #define CONFIG_TIMESTAMP /* Print image info with timestamp */ -#define CONFIG_BOOTDELAY 5 /* autoboot after X seconds */ -#undef CONFIG_BOOTARGS +#define CONFIG_BOOTDELAY 5 + +#define MEM_LAYOUT_ENV_SETTINGS \ + "kernel_addr_r="__stringify(CONFIG_SYS_LOAD_ADDR)"\0" \ + "fdt_addr_r="__stringify(CONFIG_SYS_FDT_ADDR)"\0" \ + "scriptaddr="__stringify(CONFIG_SYS_ENV_ADDR)"\0" + +#define CONFIG_LEGACY_BOOTCMD_ENV \ + "legacy_bootcmd= " \ + "if load mmc 0 ${scriptaddr} uEnv.txt; then " \ + "env import -tr ${scriptaddr} ${filesize}; " \ + "if test -n \"${bootcmd_uenv}\" ; then " \ + "echo Running bootcmd_uenv ...; " \ + "run bootcmd_uenv; " \ + "fi; " \ + "fi; \0" + +#define BOOT_TARGET_DEVICES(func) \ + func(MMC, mmc, 0) + +#include + +#define CONFIG_EXTRA_ENV_SETTINGS \ + MEM_LAYOUT_ENV_SETTINGS \ + CONFIG_LEGACY_BOOTCMD_ENV \ + BOOTENV + +#undef CONFIG_BOOTCOMMAND +#define CONFIG_BOOTCOMMAND "run distro_bootcmd || run legacy_bootcmd" #endif /* __PIC32MZDASK_CONFIG_H */