{"id":797558,"url":"http://patchwork.ozlabs.org/api/patches/797558/?format=json","web_url":"http://patchwork.ozlabs.org/project/uboot/patch/20170804020403.20996-2-wenyou.yang@microchip.com/","project":{"id":18,"url":"http://patchwork.ozlabs.org/api/projects/18/?format=json","name":"U-Boot","link_name":"uboot","list_id":"u-boot.lists.denx.de","list_email":"u-boot@lists.denx.de","web_url":null,"scm_url":null,"webscm_url":null,"list_archive_url":"","list_archive_url_format":"","commit_url_format":""},"msgid":"<20170804020403.20996-2-wenyou.yang@microchip.com>","list_archive_url":null,"date":"2017-08-04T02:03:58","name":"[U-Boot,v3,1/6] ARM: at91: spl: Adjust switching to oscillator for SAMA5D2","commit_ref":null,"pull_url":null,"state":"superseded","archived":false,"hash":"3364bca57dffd0025444cb3c97e5d4f9e98bef41","submitter":{"id":69532,"url":"http://patchwork.ozlabs.org/api/people/69532/?format=json","name":"Wenyou Yang","email":"Wenyou.Yang@microchip.com"},"delegate":{"id":3651,"url":"http://patchwork.ozlabs.org/api/users/3651/?format=json","username":"trini","first_name":"Tom","last_name":"Rini","email":"trini@ti.com"},"mbox":"http://patchwork.ozlabs.org/project/uboot/patch/20170804020403.20996-2-wenyou.yang@microchip.com/mbox/","series":[],"comments":"http://patchwork.ozlabs.org/api/patches/797558/comments/","check":"pending","checks":"http://patchwork.ozlabs.org/api/patches/797558/checks/","tags":{},"related":[],"headers":{"Return-Path":"<u-boot-bounces@lists.denx.de>","X-Original-To":"incoming@patchwork.ozlabs.org","Delivered-To":"patchwork-incoming@bilbo.ozlabs.org","Authentication-Results":"ozlabs.org;\n\tspf=none (mailfrom) smtp.mailfrom=lists.denx.de\n\t(client-ip=81.169.180.215; helo=lists.denx.de;\n\tenvelope-from=u-boot-bounces@lists.denx.de;\n\treceiver=<UNKNOWN>)","Received":["from lists.denx.de (dione.denx.de [81.169.180.215])\n\tby ozlabs.org (Postfix) with ESMTP id 3xNr4P6jr3z9s8P\n\tfor <incoming@patchwork.ozlabs.org>;\n\tFri,  4 Aug 2017 12:10:45 +1000 (AEST)","by lists.denx.de (Postfix, from userid 105)\n\tid 6ADB5C21DB5; Fri,  4 Aug 2017 02:09:59 +0000 (UTC)","from lists.denx.de (localhost [IPv6:::1])\n\tby lists.denx.de (Postfix) with ESMTP id 63872C21DA3;\n\tFri,  4 Aug 2017 02:09:56 +0000 (UTC)","by lists.denx.de (Postfix, from userid 105)\n\tid 9F66AC21DDF; Fri,  4 Aug 2017 02:09:46 +0000 (UTC)","from eusmtp01.atmel.com (eusmtp01.atmel.com [212.144.249.243])\n\tby lists.denx.de (Postfix) with ESMTPS id 0311DC21DF0\n\tfor <u-boot@lists.denx.de>; Fri,  4 Aug 2017 02:09:43 +0000 (UTC)","from apsmtp01.atmel.com (10.168.254.30) by eusmtp01.atmel.com\n\t(10.145.145.31) with Microsoft SMTP Server id 14.3.235.1;\n\tFri, 4 Aug 2017 04:09:33 +0200","from shaarm01.corp.atmel.com (10.168.254.13) by\n\tapsmtp01.corp.atmel.com (10.168.254.30) with Microsoft SMTP Server id\n\t14.3.235.1; Fri, 4 Aug 2017 10:12:38 +0800"],"X-Spam-Checker-Version":"SpamAssassin 3.4.0 (2014-02-07) on lists.denx.de","X-Spam-Level":"","X-Spam-Status":"No, score=-2.3 required=5.0 tests=RCVD_IN_DNSWL_MED\n\tautolearn=unavailable autolearn_force=no version=3.4.0","From":"Wenyou Yang <wenyou.yang@microchip.com>","To":"U-Boot Mailing List <u-boot@lists.denx.de>","Date":"Fri, 4 Aug 2017 10:03:58 +0800","Message-ID":"<20170804020403.20996-2-wenyou.yang@microchip.com>","X-Mailer":"git-send-email 2.13.0","In-Reply-To":"<20170804020403.20996-1-wenyou.yang@microchip.com>","References":"<20170804020403.20996-1-wenyou.yang@microchip.com>","MIME-Version":"1.0","Cc":"Marek Vasut <marex@denx.de>, Tom Rini <trini@konsulko.com>","Subject":"[U-Boot] [PATCH v3 1/6] ARM: at91: spl: Adjust switching to\n\toscillator for SAMA5D2","X-BeenThere":"u-boot@lists.denx.de","X-Mailman-Version":"2.1.18","Precedence":"list","List-Id":"U-Boot discussion <u-boot.lists.denx.de>","List-Unsubscribe":"<https://lists.denx.de/options/u-boot>,\n\t<mailto:u-boot-request@lists.denx.de?subject=unsubscribe>","List-Archive":"<http://lists.denx.de/pipermail/u-boot/>","List-Post":"<mailto:u-boot@lists.denx.de>","List-Help":"<mailto:u-boot-request@lists.denx.de?subject=help>","List-Subscribe":"<https://lists.denx.de/listinfo/u-boot>,\n\t<mailto:u-boot-request@lists.denx.de?subject=subscribe>","Content-Type":"text/plain; charset=\"utf-8\"","Content-Transfer-Encoding":"base64","Errors-To":"u-boot-bounces@lists.denx.de","Sender":"\"U-Boot\" <u-boot-bounces@lists.denx.de>"},"content":"As said in 29.5.7 section of SAMA5D2 datasheet, before switching to\nthe crystal oscillator, a check must be carried out to ensure that\nthe oscillator is present and that its freqency is valid.\n\nSigned-off-by: Wenyou Yang <wenyou.yang@microchip.com>\nReviewed-by: Simon Glass <sjg@chromium.org>\n---\n\nChanges in v3: None\nChanges in v2: None\n\n arch/arm/mach-at91/include/mach/at91_pmc.h |  2 ++\n arch/arm/mach-at91/spl_atmel.c             | 18 +++++++++++++++++-\n 2 files changed, 19 insertions(+), 1 deletion(-)","diff":"diff --git a/arch/arm/mach-at91/include/mach/at91_pmc.h b/arch/arm/mach-at91/include/mach/at91_pmc.h\nindex 2875ff20b1..08ad1bf2d0 100644\n--- a/arch/arm/mach-at91/include/mach/at91_pmc.h\n+++ b/arch/arm/mach-at91/include/mach/at91_pmc.h\n@@ -87,6 +87,8 @@ typedef struct at91_pmc {\n \n #define AT91_PMC_MCFR_MAINRDY\t\t0x00010000\n #define AT91_PMC_MCFR_MAINF_MASK\t0x0000FFFF\n+#define AT91_PMC_MCFR_RCMEAS\t\t0x00100000\n+#define AT91_PMC_MCFR_CCSS_XTAL_OSC\t0x01000000\n \n #define AT91_PMC_MCKR_CSS_SLOW\t\t0x00000000\n #define AT91_PMC_MCKR_CSS_MAIN\t\t0x00000001\ndiff --git a/arch/arm/mach-at91/spl_atmel.c b/arch/arm/mach-at91/spl_atmel.c\nindex b75c2ccefd..ce16ef3bdb 100644\n--- a/arch/arm/mach-at91/spl_atmel.c\n+++ b/arch/arm/mach-at91/spl_atmel.c\n@@ -32,6 +32,20 @@ static void switch_to_main_crystal_osc(void)\n \twhile (!(readl(&pmc->sr) & AT91_PMC_IXR_MOSCS))\n \t\t;\n \n+#if defined(CONFIG_SAMA5D2)\n+\t/* Enable a measurement of the external oscillator */\n+\ttmp = readl(&pmc->mcfr);\n+\ttmp |= AT91_PMC_MCFR_CCSS_XTAL_OSC;\n+\ttmp |= AT91_PMC_MCFR_RCMEAS;\n+\twritel(tmp, &pmc->mcfr);\n+\n+\twhile (!(readl(&pmc->mcfr) & AT91_PMC_MCFR_MAINRDY))\n+\t\t;\n+\n+\tif (!(readl(&pmc->mcfr) & AT91_PMC_MCFR_MAINF_MASK))\n+\t\thang();\n+#endif\n+\n \ttmp = readl(&pmc->mor);\n \ttmp &= ~AT91_PMC_MOR_OSCBYPASS;\n \ttmp &= ~AT91_PMC_MOR_KEY(0xff);\n@@ -47,11 +61,13 @@ static void switch_to_main_crystal_osc(void)\n \twhile (!(readl(&pmc->sr) & AT91_PMC_IXR_MOSCSELS))\n \t\t;\n \n+#if !defined(CONFIG_SAMA5D2)\n \t/* Wait until MAINRDY field is set to make sure main clock is stable */\n \twhile (!(readl(&pmc->mcfr) & AT91_PMC_MAINRDY))\n \t\t;\n+#endif\n \n-#ifndef CONFIG_SAMA5D4\n+#if !defined(CONFIG_SAMA5D4) && !defined(CONFIG_SAMA5D2)\n \ttmp = readl(&pmc->mor);\n \ttmp &= ~AT91_PMC_MOR_MOSCRCEN;\n \ttmp &= ~AT91_PMC_MOR_KEY(0xff);\n","prefixes":["U-Boot","v3","1/6"]}