From patchwork Mon Oct 27 23:09:31 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexandre Belloni X-Patchwork-Id: 5166781 Return-Path: X-Original-To: patchwork-linux-pm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id DAB24C11AC for ; Mon, 27 Oct 2014 23:12:58 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id A7A96201DD for ; Mon, 27 Oct 2014 23:12:57 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id CF25B20155 for ; Mon, 27 Oct 2014 23:12:56 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752654AbaJ0XMm (ORCPT ); Mon, 27 Oct 2014 19:12:42 -0400 Received: from down.free-electrons.com ([37.187.137.238]:55583 "EHLO mail.free-electrons.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1752806AbaJ0XJ5 (ORCPT ); Mon, 27 Oct 2014 19:09:57 -0400 Received: by mail.free-electrons.com (Postfix, from userid 106) id 648994732; Tue, 28 Oct 2014 00:10:03 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Spam-Level: X-Spam-Status: No, score=-7.5 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 Received: from localhost (128-79-216-6.hfc.dyn.abo.bbox.fr [128.79.216.6]) by mail.free-electrons.com (Postfix) with ESMTPSA id ECCDA46E4; Tue, 28 Oct 2014 00:10:02 +0100 (CET) From: Alexandre Belloni To: Nicolas Ferre , Sebastian Reichel Cc: Jean-Christophe Plagniol-Villard , Dmitry Eremin-Solenikov , David Woodhouse , Maxime Ripard , Boris Brezillon , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-pm@vger.kernel.org, Alexandre Belloni Subject: [PATCH v2 2/8] memory: atmel-sdramc: allow probing from pdata Date: Tue, 28 Oct 2014 00:09:31 +0100 Message-Id: <1414451377-11053-3-git-send-email-alexandre.belloni@free-electrons.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1414451377-11053-1-git-send-email-alexandre.belloni@free-electrons.com> References: <1414451377-11053-1-git-send-email-alexandre.belloni@free-electrons.com> Sender: linux-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Allow probing the atmel-sdramc from platform_data. Signed-off-by: Alexandre Belloni --- drivers/memory/atmel-sdramc.c | 45 ++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 44 insertions(+), 1 deletion(-) diff --git a/drivers/memory/atmel-sdramc.c b/drivers/memory/atmel-sdramc.c index d89ed0af44d9..c4a7ba0f291f 100644 --- a/drivers/memory/atmel-sdramc.c +++ b/drivers/memory/atmel-sdramc.c @@ -19,6 +19,7 @@ #include #include +#include #include #include #include @@ -140,7 +141,7 @@ static const struct of_device_id atmel_ramc_of_match[] = { }; MODULE_DEVICE_TABLE(of, atmel_ramc_of_match); -static int atmel_ramc_probe(struct platform_device *pdev) +static int atmel_ramc_of_probe(struct platform_device *pdev) { const struct of_device_id *match; const struct at91_ramc_caps *caps; @@ -181,6 +182,47 @@ static int atmel_ramc_probe(struct platform_device *pdev) return 0; } +static int atmel_ramc_platform_probe(struct platform_device *pdev) +{ + struct resource *res; + const struct platform_device_id *match; + int idx = 0; + + for (idx = 0; idx < 2; idx++) { + res = platform_get_resource(pdev, IORESOURCE_MEM, idx + 1); + at91_ramc_base[idx] = devm_ioremap(&pdev->dev, res->start, + resource_size(res)); + if (IS_ERR(at91_ramc_base[idx])) { + dev_err(&pdev->dev, "Could not map ram controller address\n"); + return PTR_ERR(at91_ramc_base[idx]); + } + } + + match = platform_get_device_id(pdev); + at91_ramc_shutdown = + (void (*)(void __iomem *rstc_cr, u32 value))match->driver_data; + + return 0; +}; + +static int atmel_ramc_probe(struct platform_device *pdev) +{ + int ret; + + if (pdev->dev.of_node) + ret = atmel_ramc_of_probe(pdev); + else + ret = atmel_ramc_platform_probe(pdev); + + return ret; +} + +static struct platform_device_id atmel_ramc_plat_match[] = { + { "at91sam9260-sdramc", (unsigned long)at91sam9260_shutdown, }, + { "at91sam9g45-ddramc", (unsigned long)at91sam9g45_shutdown, }, + { /* sentinel */ } +}; + static struct platform_driver atmel_ramc_driver = { .probe = atmel_ramc_probe, .driver = { @@ -188,6 +230,7 @@ static struct platform_driver atmel_ramc_driver = { .owner = THIS_MODULE, .of_match_table = atmel_ramc_of_match, }, + .id_table = atmel_ramc_plat_match, }; static int __init atmel_ramc_init(void)