From patchwork Mon Jan 26 10:04:24 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wenyou Yang X-Patchwork-Id: 5707651 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 1B6A29F2ED for ; Mon, 26 Jan 2015 10:07:31 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 823F92011E for ; Mon, 26 Jan 2015 10:07:29 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 9F20D20123 for ; Mon, 26 Jan 2015 10:07:28 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1YFgY8-0005Dl-6G; Mon, 26 Jan 2015 10:05:40 +0000 Received: from nasmtp01.atmel.com ([192.199.1.245] helo=DVREDG01.corp.atmel.com) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1YFgY3-00055m-Sr for linux-arm-kernel@lists.infradead.org; Mon, 26 Jan 2015 10:05:36 +0000 Received: from apsmtp01.atmel.com (10.168.254.31) by DVREDG01.corp.atmel.com (10.42.103.30) with Microsoft SMTP Server (TLS) id 14.2.347.0; Mon, 26 Jan 2015 03:05:11 -0700 Received: from shaarm01.corp.atmel.com (10.168.254.13) by apsmtp01.atmel.com (10.168.254.31) with Microsoft SMTP Server id 14.2.347.0; Mon, 26 Jan 2015 18:08:52 +0800 From: Wenyou Yang To: , Subject: [PATCH 1/7] pm: at91: achieve the memory controller's type from the dts file. Date: Mon, 26 Jan 2015 18:04:24 +0800 Message-ID: <1422266664-24416-1-git-send-email-wenyou.yang@atmel.com> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1422266617-24381-1-git-send-email-wenyou.yang@atmel.com> References: <1422266617-24381-1-git-send-email-wenyou.yang@atmel.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20150126_020536_043682_0935E2FD X-CRM114-Status: GOOD ( 12.40 ) X-Spam-Score: -0.0 (/) Cc: sylvain.rochet@finsecur.com, linux-kernel@vger.kernel.org, wenyou.yang@atmel.com, alexandre.belloni@free-electrons.com, peda@axentia.se, linux-arm-kernel@lists.infradead.org X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Instead of achieve the ram controller's tpye through the SoC, through the sram controller configuration, it is more sensible. Signed-off-by: Wenyou Yang --- arch/arm/mach-at91/generic.h | 5 +++++ arch/arm/mach-at91/pm.c | 9 +-------- arch/arm/mach-at91/setup.c | 28 ++++++++++++++++++++++++---- 3 files changed, 30 insertions(+), 12 deletions(-) diff --git a/arch/arm/mach-at91/generic.h b/arch/arm/mach-at91/generic.h index a8ee83e..41796bf 100644 --- a/arch/arm/mach-at91/generic.h +++ b/arch/arm/mach-at91/generic.h @@ -44,4 +44,9 @@ void __init at91_sam9g45_pm_init(void) { } void __init at91_sam9x5_pm_init(void) { } #endif +struct at91_pm_struct { + unsigned long uhp_udp_mask; + int memctrl; +}; + #endif /* _AT91_GENERIC_H */ diff --git a/arch/arm/mach-at91/pm.c b/arch/arm/mach-at91/pm.c index 7473978..f75dc32 100644 --- a/arch/arm/mach-at91/pm.c +++ b/arch/arm/mach-at91/pm.c @@ -35,10 +35,7 @@ #include "generic.h" #include "pm.h" -static struct { - unsigned long uhp_udp_mask; - int memctrl; -} at91_pm_data; +struct at91_pm_struct at91_pm_data; static int at91_pm_valid_state(suspend_state_t state) { @@ -287,14 +284,12 @@ void __init at91_rm9200_pm_init(void) at91_ramc_write(0, AT91RM9200_SDRAMC_LPR, 0); at91_pm_data.uhp_udp_mask = AT91RM9200_PMC_UHP | AT91RM9200_PMC_UDP; - at91_pm_data.memctrl = AT91_MEMCTRL_MC; at91_pm_init(); } void __init at91_sam9260_pm_init(void) { - at91_pm_data.memctrl = AT91_MEMCTRL_SDRAMC; at91_pm_data.uhp_udp_mask = AT91SAM926x_PMC_UHP | AT91SAM926x_PMC_UDP; return at91_pm_init(); } @@ -302,13 +297,11 @@ void __init at91_sam9260_pm_init(void) void __init at91_sam9g45_pm_init(void) { at91_pm_data.uhp_udp_mask = AT91SAM926x_PMC_UHP; - at91_pm_data.memctrl = AT91_MEMCTRL_DDRSDR; return at91_pm_init(); } void __init at91_sam9x5_pm_init(void) { at91_pm_data.uhp_udp_mask = AT91SAM926x_PMC_UHP | AT91SAM926x_PMC_UDP; - at91_pm_data.memctrl = AT91_MEMCTRL_DDRSDR; return at91_pm_init(); } diff --git a/arch/arm/mach-at91/setup.c b/arch/arm/mach-at91/setup.c index b8dba9f..7924663 100644 --- a/arch/arm/mach-at91/setup.c +++ b/arch/arm/mach-at91/setup.c @@ -26,6 +26,8 @@ #include "generic.h" #include "pm.h" +extern struct at91_pm_struct at91_pm_data; + struct at91_init_soc __initdata at91_boot_soc; struct at91_socinfo at91_soc_initdata; @@ -361,11 +363,25 @@ void __init at91_ioremap_matrix(u32 base_addr) panic(pr_fmt("Impossible to ioremap at91_matrix_base\n")); } +struct at91_ramc_of_data { + u8 ramc_type; +}; + +static const struct at91_ramc_of_data at91rm9200_ramc_of_data = { + .ramc_type = AT91_MEMCTRL_MC, +}; +static const struct at91_ramc_of_data at91sam9260_ramc_of_data = { + .ramc_type = AT91_MEMCTRL_SDRAMC, +}; +static const struct at91_ramc_of_data at91sam9g45_ramc_of_data = { + .ramc_type = AT91_MEMCTRL_DDRSDR, +}; + static struct of_device_id ramc_ids[] = { - { .compatible = "atmel,at91rm9200-sdramc" }, - { .compatible = "atmel,at91sam9260-sdramc" }, - { .compatible = "atmel,at91sam9g45-ddramc" }, - { .compatible = "atmel,sama5d3-ddramc" }, + { .compatible = "atmel,at91rm9200-sdramc", .data = &at91rm9200_ramc_of_data }, + { .compatible = "atmel,at91sam9260-sdramc", .data = &at91sam9260_ramc_of_data }, + { .compatible = "atmel,at91sam9g45-ddramc", .data = &at91sam9g45_ramc_of_data }, + { .compatible = "atmel,sama5d3-ddramc", .data = &at91sam9g45_ramc_of_data }, { /*sentinel*/ } }; @@ -374,12 +390,16 @@ static void at91_dt_ramc(void) struct device_node *np; const struct of_device_id *of_id; int idx = 0; + const struct at91_ramc_of_data *of_data; for_each_matching_node_and_match(np, ramc_ids, &of_id) { at91_ramc_base[idx] = of_iomap(np, 0); if (!at91_ramc_base[idx]) panic(pr_fmt("unable to map ramc[%d] cpu registers\n"), idx); + of_data = of_id->data; + at91_pm_data.memctrl = of_data->ramc_type; + idx++; }