From patchwork Fri Feb 15 06:34:49 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Amar X-Patchwork-Id: 14822 Return-Path: X-Original-To: patchwork@peony.canonical.com Delivered-To: patchwork@peony.canonical.com Received: from fiordland.canonical.com (fiordland.canonical.com [91.189.94.145]) by peony.canonical.com (Postfix) with ESMTP id 49EC323FC2 for ; Fri, 15 Feb 2013 06:14:14 +0000 (UTC) Received: from mail-ve0-f176.google.com (mail-ve0-f176.google.com [209.85.128.176]) by fiordland.canonical.com (Postfix) with ESMTP id 7C033A18048 for ; Fri, 15 Feb 2013 06:14:13 +0000 (UTC) Received: by mail-ve0-f176.google.com with SMTP id cz10so2789692veb.35 for ; Thu, 14 Feb 2013 22:14:13 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=x-received:x-forwarded-to:x-forwarded-for:delivered-to:x-received :received-spf:x-auditid:from:to:cc:subject:date:message-id:x-mailer :in-reply-to:references:x-brightmail-tracker:x-brightmail-tracker :dlp-filter:x-mtr:x-cfilter-loop:x-gm-message-state; bh=Tkevlp0uF2jz4ZKphwMfmm3ghQJGRZHfVMHR6abz8G4=; b=hYZd2SwHxKJ7k/tnHDrvGZXzAgSju/e1b2eqbhXSSCpJ3CDLFHV/06bpB3Atu32Hd2 9iEyrjb789zTuH5Pzb3k89bFICxxgc5/LMrZKbW1Ybv+MjNOkeIHKiaDP/3gg4wsQrBk B3l6Xz9x5Gi07D1hKwI0yUZks349k1id5hqwxOvRWCv0YKPVoGiNLF4GzevXMYXaBR2M xgM75MYaLwHdqxQu8janfFwFVlpzWTg6yiQ6pB4OKADYngAp9FlCOauciklxwabY7mn6 pvMfmRYL+okaygrWB8iClDDL5sQdPx2U3ojt+HHmA8W7NQ6z4S8gLWUPRk7dfuF69Gsj twAA== X-Received: by 10.220.220.134 with SMTP id hy6mr1808132vcb.2.1360908852989; Thu, 14 Feb 2013 22:14:12 -0800 (PST) X-Forwarded-To: linaro-patchwork@canonical.com X-Forwarded-For: patch@linaro.org linaro-patchwork@canonical.com Delivered-To: patches@linaro.org Received: by 10.221.4.5 with SMTP id oa5csp305014vcb; Thu, 14 Feb 2013 22:14:12 -0800 (PST) X-Received: by 10.68.222.73 with SMTP id qk9mr3297566pbc.115.1360908852007; Thu, 14 Feb 2013 22:14:12 -0800 (PST) Received: from mailout2.samsung.com (mailout2.samsung.com. [203.254.224.25]) by mx.google.com with ESMTP id tm7si1031864pbc.210.2013.02.14.22.14.11; Thu, 14 Feb 2013 22:14:12 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of amarendra.xt@samsung.com designates 203.254.224.25 as permitted sender) client-ip=203.254.224.25; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of amarendra.xt@samsung.com designates 203.254.224.25 as permitted sender) smtp.mail=amarendra.xt@samsung.com Received: from epcpsbgr2.samsung.com (u142.gpu120.samsung.co.kr [203.254.230.142]) by mailout2.samsung.com (Oracle Communications Messaging Server 7u4-24.01 (7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTP id <0MI8008WAZZBVE50@mailout2.samsung.com>; Fri, 15 Feb 2013 15:14:10 +0900 (KST) Received: from epcpsbgm2.samsung.com ( [172.20.52.125]) by epcpsbgr2.samsung.com (EPCPMTA) with SMTP id 14.5D.06456.232DD115; Fri, 15 Feb 2013 15:14:10 +0900 (KST) X-AuditID: cbfee68e-b7fc26d000001938-74-511dd2325c80 Received: from epmmp2 ( [203.254.227.17]) by epcpsbgm2.samsung.com (EPCPMTA) with SMTP id 3F.53.03880.232DD115; Fri, 15 Feb 2013 15:14:10 +0900 (KST) Received: from chrome-ubuntu.sisodomain.com ([107.108.73.106]) by mmp2.samsung.com (Oracle Communications Messaging Server 7u4-24.01(7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTPA id <0MI8005Z0ZYZ7R20@mmp2.samsung.com>; Fri, 15 Feb 2013 15:14:10 +0900 (KST) From: Amar To: u-boot@lists.denx.de Cc: patches@linaro.org, sjg@chromium.org, mk7.kang@samsung.com, chander.kashyap@linaro.org, afleming@gmail.com, jh80.chung@samsung.com Subject: [PATCH V6 08/10] SMDK5250: Enable EMMC booting Date: Fri, 15 Feb 2013 01:34:49 -0500 Message-id: <1360910091-6285-9-git-send-email-amarendra.xt@samsung.com> X-Mailer: git-send-email 1.8.0 In-reply-to: <1360910091-6285-1-git-send-email-amarendra.xt@samsung.com> References: <1360910091-6285-1-git-send-email-amarendra.xt@samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFjrFLMWRmVeSWpSXmKPExsWyRsSkVtfokmygwfb1GhYP199ksZhy+AuL A5PHnWt72AIYo7hsUlJzMstSi/TtErgyfp05ylbQqF2xsL2PpYHxjnIXIyeHhICJxN3Pc1gh bDGJC/fWs3UxcnEICSxllGhZ+4AFpmjNxzUsEInpjBKts85BVfUySfSePwWU4eBgE1CV+LXY HqRBREBC4lf/VUaQGmaBDkaJHRM3M4IkhAXMJTavOwxmswDVP3j7kxGkl1fAXWJ/vxLEMjmJ D3sesYPYnAIeEucmv2YGsYWASnZ+6gCbKSFwm02ib+UkqDkCEt8mHwK7QUJAVmLTAWaIOZIS B1fcYJnAKLyAkWEVo2hqQXJBcVJ6kZFecWJucWleul5yfu4mRmA4nv73rG8H480D1ocYk4HG TWSWEk3OB4ZzXkm8obGJuamxqZmRpaWlKWnCSuK88pdkAoUE0hNLUrNTUwtSi+KLSnNSiw8x MnFwSjUwxhX6XC8Ii53yrU1mW2CgxaycJc/PPSrKt/NTuTA3ML7wMIvT9VdJl56/WtyZFsDd yfVE/cWz4/MyWpaE8H65tKOiR3t66Pu2qwy3vvtJFs26vHPKvkwXno2uFxexR8y/08xdeP34 4njFjxUldldb/R4a3mPIdMnaUOjJO2Pjh4KdC21Drtk8UWIpzkg01GIuKk4EAK5QEzRdAgAA X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFlrOIsWRmVeSWpSXmKPExsVy+t9jQV2jS7KBBm3f5C0err/JYjHl8BcW ByaPO9f2sAUwRjUw2mSkJqakFimk5iXnp2TmpdsqeQfHO8ebmhkY6hpaWpgrKeQl5qbaKrn4 BOi6ZeYAzVZSKEvMKQUKBSQWFyvp22GaEBripmsB0xih6xsSBNdjZIAGEtYwZvw6c5StoFG7 YmF7H0sD4x3lLkZODgkBE4k1H9ewQNhiEhfurWfrYuTiEBKYzijROusclNPLJNF7/hRQFQcH m4CqxK/F9iANIgISEr/6rzKC1DALdDBK7Ji4mREkISxgLrF53WEwmwWo/sHbn4wgvbwC7hL7 +5UglslJfNjziB3E5hTwkDg3+TUziC0EVLLzUwfjBEbeBYwMqxhFUwuSC4qT0nON9IoTc4tL 89L1kvNzNzGCg/2Z9A7GVQ0WhxgFOBiVeHgFJGQDhVgTy4orcw8xSnAwK4nwrgkBCvGmJFZW pRblxxeV5qQWH2JMBjpqIrOUaHI+MBLzSuINjU3MTY1NLU0sTMwsSRNWEudlPPUkQEggPbEk NTs1tSC1CGYLEwenVANjyywVvjthT34alv19dahCvuC25lq7o31Wm+9z6WbqNM5oVHt/4cJD 540b3a86dAS8S6ut/q90tv/dsWLRkPP+U1ROHojYkPw5Iy1x+cEXP5jdVVyXNG76/TlarmH3 vB5Zx0tRPpqlNnvOMvn+bFnPfGoOw+WDKckX3MMuTVvPcuvgrO36D8o/KLEUZyQaajEXFScC ACuXT8G6AgAA DLP-Filter: Pass X-MTR: 20000000000000000@CPGS X-CFilter-Loop: Reflected X-Gm-Message-State: ALoCoQk5pAB2rGMfEDtaiBOy4+aoYGvVmWMBd/AxyL7NbR8xQ44ing9ZScKwz6+xY0fnXvmNq3uE This patch adds support for EMMC booting on SMDK5250. Signed-off-by: Amar Acked-by: Simon Glass --- Changes since V1: 1)Updated spl_boot.c file to maintain irom pointer table instead of using the #define values defined in header file. Changes since V2: 1)Updation of commit message and resubmition of proper patch set. Changes since V3: No change. Changes since V4: 1)The function get_irom_func(int index) has been added to avoid type casting at many places. 2)The changes to file arch/arm/include/asm/arch-exynos/clk.h are included in this patch file. Changes since V5: No change. arch/arm/include/asm/arch-exynos/clk.h | 3 ++ board/samsung/smdk5250/clock_init.c | 15 ++++++++++ board/samsung/smdk5250/clock_init.h | 5 ++++ board/samsung/smdk5250/spl_boot.c | 52 ++++++++++++++++++++++++++++++---- 4 files changed, 69 insertions(+), 6 deletions(-) diff --git a/arch/arm/include/asm/arch-exynos/clk.h b/arch/arm/include/asm/arch-exynos/clk.h index 1935b0b..a4d5b4e 100644 --- a/arch/arm/include/asm/arch-exynos/clk.h +++ b/arch/arm/include/asm/arch-exynos/clk.h @@ -29,6 +29,9 @@ #define VPLL 4 #define BPLL 5 +#define FSYS1_MMC0_DIV_MASK 0xff0f +#define FSYS1_MMC0_DIV_VAL 0x0701 + unsigned long get_pll_clk(int pllreg); unsigned long get_arm_clk(void); unsigned long get_i2c_clk(void); diff --git a/board/samsung/smdk5250/clock_init.c b/board/samsung/smdk5250/clock_init.c index c009ae5..154993c 100644 --- a/board/samsung/smdk5250/clock_init.c +++ b/board/samsung/smdk5250/clock_init.c @@ -28,6 +28,7 @@ #include #include #include +#include #include "clock_init.h" #include "setup.h" @@ -664,3 +665,17 @@ void clock_init_dp_clock(void) /* We run DP at 267 Mhz */ setbits_le32(&clk->div_disp1_0, CLK_DIV_DISP1_0_FIMD1); } + +/* + * Set clock divisor value for booting from EMMC. + * Set DWMMC channel-0 clk div to operate mmc0 device at 50MHz. + */ +void emmc_boot_clk_div_set(void) +{ + struct exynos5_clock *clk = (struct exynos5_clock *)EXYNOS5_CLOCK_BASE; + unsigned int div_mmc; + + div_mmc = readl((unsigned int) &clk->div_fsys1) & ~FSYS1_MMC0_DIV_MASK; + div_mmc |= FSYS1_MMC0_DIV_VAL; + writel(div_mmc, (unsigned int) &clk->div_fsys1); +} diff --git a/board/samsung/smdk5250/clock_init.h b/board/samsung/smdk5250/clock_init.h index f751bcb..20a1d47 100644 --- a/board/samsung/smdk5250/clock_init.h +++ b/board/samsung/smdk5250/clock_init.h @@ -146,4 +146,9 @@ struct mem_timings *clock_get_mem_timings(void); * Initialize clock for the device */ void system_clock_init(void); + +/* + * Set clock divisor value for booting from EMMC. + */ +void emmc_boot_clk_div_set(void); #endif diff --git a/board/samsung/smdk5250/spl_boot.c b/board/samsung/smdk5250/spl_boot.c index d8f3c1e..4ddbd4a 100644 --- a/board/samsung/smdk5250/spl_boot.c +++ b/board/samsung/smdk5250/spl_boot.c @@ -23,15 +23,42 @@ #include #include +#include +#include +#include + +#include "clock_init.h" + +/* Index into irom ptr table */ +enum index { + MMC_INDEX, + EMMC44_INDEX, + EMMC44_END_INDEX, + SPI_INDEX, +}; + +/* IROM Function Pointers Table */ +u32 irom_ptr_table[] = { + [MMC_INDEX] = 0x02020030, /* iROM Function Pointer-SDMMC boot */ + [EMMC44_INDEX] = 0x02020044, /* iROM Function Pointer-EMMC4.4 boot*/ + [EMMC44_END_INDEX] = 0x02020048,/* iROM Function Pointer + -EMMC4.4 end boot operation */ + [SPI_INDEX] = 0x02020058, /* iROM Function Pointer-SPI boot */ + }; + enum boot_mode { BOOT_MODE_MMC = 4, BOOT_MODE_SERIAL = 20, + BOOT_MODE_EMMC = 8, /* EMMC4.4 */ /* Boot based on Operating Mode pin settings */ BOOT_MODE_OM = 32, BOOT_MODE_USB, /* Boot using USB download */ }; - typedef u32 (*spi_copy_func_t)(u32 offset, u32 nblock, u32 dst); +void *get_irom_func(int index) +{ + return (void *) *(u32 *)irom_ptr_table[index]; +} /* * Copy U-boot from mmc to RAM: @@ -40,23 +67,36 @@ enum boot_mode { */ void copy_uboot_to_ram(void) { - spi_copy_func_t spi_copy; enum boot_mode bootmode; - u32 (*copy_bl2)(u32, u32, u32); - + u32 (*spi_copy)(u32 offset, u32 nblock, u32 dst); + u32 (*copy_bl2)(u32 offset, u32 nblock, u32 dst); + u32 (*copy_bl2_from_emmc)(u32 nblock, u32 dst); + void (*end_bootop_from_emmc)(void); + /* read Operation Mode ststus register to find the bootmode */ bootmode = readl(EXYNOS5_POWER_BASE) & OM_STAT; switch (bootmode) { case BOOT_MODE_SERIAL: - spi_copy = *(spi_copy_func_t *)EXYNOS_COPY_SPI_FNPTR_ADDR; + spi_copy = get_irom_func(SPI_INDEX); spi_copy(SPI_FLASH_UBOOT_POS, CONFIG_BL2_SIZE, CONFIG_SYS_TEXT_BASE); break; case BOOT_MODE_MMC: - copy_bl2 = (void *) *(u32 *)COPY_BL2_FNPTR_ADDR; + copy_bl2 = get_irom_func(MMC_INDEX); copy_bl2(BL2_START_OFFSET, BL2_SIZE_BLOC_COUNT, CONFIG_SYS_TEXT_BASE); break; + case BOOT_MODE_EMMC: + /* Set the FSYS1 clock divisor value for EMMC boot */ + emmc_boot_clk_div_set(); + + copy_bl2_from_emmc = get_irom_func(EMMC44_INDEX); + end_bootop_from_emmc = get_irom_func(EMMC44_END_INDEX); + + copy_bl2_from_emmc(BL2_SIZE_BLOC_COUNT, CONFIG_SYS_TEXT_BASE); + end_bootop_from_emmc(); + break; + default: break; }