From patchwork Fri Feb 16 16:47:10 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bartosz Golaszewski X-Patchwork-Id: 10225097 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 829E9602CB for ; Fri, 16 Feb 2018 16:54:27 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7036021EEB for ; Fri, 16 Feb 2018 16:54:27 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 62B582879C; Fri, 16 Feb 2018 16:54:27 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-1.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID autolearn=unavailable version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id F0DB121EEB for ; Fri, 16 Feb 2018 16:54:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=UJQ6t7mJOnbfVFQGbra9vmP9SLsp0wVJSQRLGJi5tZs=; b=uXVESL9RfO3zzCfomgn9+JryLc xyB+OElD9HS11SMMAin6QXEDBVQ5Pg+YbhjXSNzSeZvyoDNii9/7h7yAIdkgZlpGygfzc3zBxzJH6 4aGCHYU5efA0H4oq29kCmPTe81yUPE3FNHngOt+lB4KOzx+tlpX46AFyuAs2RFwvYmgctolIdG1RV 9Sqn2Q+8ycJ+DC7dHjy8X/sI/KIrkKOdboW8nS4feHd/S8k1AwHSAJvMqki0b/1xCmAd0+xwQsV7C SqbuiiO2BLMqFyd7Mc+IOK4EsL6y9QrYmM47sxKcxggnOjkNuAVsb3K+n/ys+Xr6DftRj9bZgNu/6 zgczbTng==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.89 #1 (Red Hat Linux)) id 1emjH4-0004Ok-Nd; Fri, 16 Feb 2018 16:54:14 +0000 Received: from mail-wr0-x241.google.com ([2a00:1450:400c:c0c::241]) by bombadil.infradead.org with esmtps (Exim 4.89 #1 (Red Hat Linux)) id 1emjAe-0007OE-MP for linux-arm-kernel@lists.infradead.org; Fri, 16 Feb 2018 16:47:48 +0000 Received: by mail-wr0-x241.google.com with SMTP id w77so3520428wrc.6 for ; Fri, 16 Feb 2018 08:47:25 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bgdev-pl.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=ugLGO1urX68nC92gZx8vWM9SDgsR/iJoL1afvvH2xtk=; b=THnXQtcvxCpYNcmM/5B+M3uIBn6PWlV0LmTPEUemoVm3Z7dWZsyMsz5ax6hpLypwuh 2Ff6Fh/PU9EHqVzFRNgcyilEbxVbtvnjP3t8K+bZADnNFNd/y237RVyJjs0Gm3kaUdaR laIVEysRx1xbwe5L6nocJJbBN7KyE4+Lr7lGPtJ/KlY7+DgWT0XjbmjqzoXAiHfwbOTr Q2vx0m4Uw7mC6ykeIoDcvSbJ4ddwYXrpxWJiVptq/ElXyBddWFPMl/aUbCXv/wBX3/tw zNDKz5UIUJdlbxTRAtx9F9d0jTjdgDDhkbpf4+KH/3HVdYqmJfmY+9Bvnot6Sgil9BSV UqpQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=ugLGO1urX68nC92gZx8vWM9SDgsR/iJoL1afvvH2xtk=; b=WDtMCfiNRAKqnLB3xt4UBDDglPer69VMmtnzXzDW1XM9s31R3Ojv8gCvPEbiLPbGwF KpbgweZth1LBpCbjucrHkRe20Iub8aq/wx1jWoDcrdiIfY0oB4jcGqQRqxRmQ6HhduLh 0yt/vz0vPLaHXvEs25CRNqKOrumzYedGlwQjfOHEuRAOpoRFL4h7qvpa+jTm6vFND4E+ r0URLH4LYaPFmkuOV9V+PiiaYaZWLP3xi110qkrKTPnq1R7YSCn9yB1XIox62sU3n6Bl buyb3iqYDOlpDnEru1Leedzy+Odf1uvvTxW79cvz9SOqnYqFHPGpaYMm2/Y3vn0T28Ug 8toQ== X-Gm-Message-State: APf1xPCBELYzP2j+Ah+VSrahZf5dS2PbfdivkW/io2c/WaJDj8U7VXCK K+10Ld3MPlWjdDzHQOiZk6d7Zw== X-Google-Smtp-Source: AH8x226Jf3zE2HpcU3r+k7acB2vKyqz42sauMIZ4ucbgFNoRz0RIDv9i1iUfXCw82CwbqE4Xk1YLXA== X-Received: by 10.223.189.8 with SMTP id j8mr6726860wrh.20.1518799644506; Fri, 16 Feb 2018 08:47:24 -0800 (PST) Received: from brgl-bgdev.baylibre.local ([90.63.244.31]) by smtp.gmail.com with ESMTPSA id 90sm7832826wrp.2.2018.02.16.08.47.22 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 16 Feb 2018 08:47:23 -0800 (PST) From: Bartosz Golaszewski To: Sekhar Nori , Kevin Hilman , Russell King , Santosh Shilimkar , Boris Brezillon , Richard Weinberger , David Woodhouse , Brian Norris , Marek Vasut , Cyrille Pitchen Subject: [PATCH 4/6] memory: aemif: add support for board files Date: Fri, 16 Feb 2018 17:47:10 +0100 Message-Id: <20180216164712.25898-5-brgl@bgdev.pl> X-Mailer: git-send-email 2.16.1 In-Reply-To: <20180216164712.25898-1-brgl@bgdev.pl> References: <20180216164712.25898-1-brgl@bgdev.pl> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20180216_084736_778389_B776F998 X-CRM114-Status: GOOD ( 20.66 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Bartosz Golaszewski , linux-mtd@lists.infradead.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, David Lechner MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP From: Bartosz Golaszewski Currently aemif is supported in two places separately. By the platform driver in drivers/memory and by a hand crafted driver in mach-davinci. We want to drop the latter but also keep the legacy mode. Add support for board files to the aemif driver. The new structure in platform data currently only contains the chip select number, since currently existing users don't require anything else, but it can be extended in the future. Signed-off-by: Bartosz Golaszewski --- drivers/memory/ti-aemif.c | 57 ++++++++++++++++++++++------------ include/linux/platform_data/ti-aemif.h | 9 ++++++ 2 files changed, 46 insertions(+), 20 deletions(-) diff --git a/drivers/memory/ti-aemif.c b/drivers/memory/ti-aemif.c index 588e58d40d1b..27d2b076f465 100644 --- a/drivers/memory/ti-aemif.c +++ b/drivers/memory/ti-aemif.c @@ -339,9 +339,6 @@ static int aemif_probe(struct platform_device *pdev) struct aemif_platform_data *pdata; struct of_dev_auxdata *dev_lookup; - if (np == NULL) - return 0; - aemif = devm_kzalloc(dev, sizeof(*aemif), GFP_KERNEL); if (!aemif) return -ENOMEM; @@ -363,8 +360,10 @@ static int aemif_probe(struct platform_device *pdev) aemif->clk_rate = clk_get_rate(aemif->clk) / MSEC_PER_SEC; - if (of_device_is_compatible(np, "ti,da850-aemif")) + if (np && of_device_is_compatible(np, "ti,da850-aemif")) aemif->cs_offset = 2; + else if (pdata) + aemif->cs_offset = pdata->cs_offset; res = platform_get_resource(pdev, IORESOURCE_MEM, 0); aemif->base = devm_ioremap_resource(dev, res); @@ -373,15 +372,23 @@ static int aemif_probe(struct platform_device *pdev) goto error; } - /* - * For every controller device node, there is a cs device node that - * describe the bus configuration parameters. This functions iterate - * over these nodes and update the cs data array. - */ - for_each_available_child_of_node(np, child_np) { - ret = of_aemif_parse_abus_config(pdev, child_np); - if (ret < 0) - goto error; + if (np) { + /* + * For every controller device node, there is a cs device node + * that describe the bus configuration parameters. This + * functions iterate over these nodes and update the cs data + * array. + */ + for_each_available_child_of_node(np, child_np) { + ret = of_aemif_parse_abus_config(pdev, child_np); + if (ret < 0) + goto error; + } + } else if (pdata && pdata->num_abus_data > 0) { + for (i = 0; i < pdata->num_abus_data; i++, aemif->num_cs++) { + aemif->cs_data[i].cs = pdata->abus_data->cs; + aemif_get_hw_params(pdev, i); + } } for (i = 0; i < aemif->num_cs; i++) { @@ -394,14 +401,24 @@ static int aemif_probe(struct platform_device *pdev) } /* - * Create a child devices explicitly from here to - * guarantee that the child will be probed after the AEMIF timing - * parameters are set. + * Create a child devices explicitly from here to guarantee that the + * child will be probed after the AEMIF timing parameters are set. */ - for_each_available_child_of_node(np, child_np) { - ret = of_platform_populate(child_np, NULL, dev_lookup, dev); - if (ret < 0) - goto error; + if (np) { + for_each_available_child_of_node(np, child_np) { + ret = of_platform_populate(child_np, NULL, + dev_lookup, dev); + if (ret < 0) + goto error; + } + } else { + for (i = 0; i < pdata->num_sub_devices; i++) { + ret = platform_device_register(&pdata->sub_devices[i]); + if (ret) { + dev_warn(dev, "Error register sub device %s\n", + pdata->sub_devices[i].name); + } + } } return 0; diff --git a/include/linux/platform_data/ti-aemif.h b/include/linux/platform_data/ti-aemif.h index ac72e115093c..dfe8901128c9 100644 --- a/include/linux/platform_data/ti-aemif.h +++ b/include/linux/platform_data/ti-aemif.h @@ -16,8 +16,17 @@ #include +struct aemif_abus_data { + u32 cs; +}; + struct aemif_platform_data { struct of_dev_auxdata *dev_lookup; + u32 cs_offset; + struct aemif_abus_data *abus_data; + size_t num_abus_data; + struct platform_device *sub_devices; + size_t num_sub_devices; }; #endif /* __TI_DAVINCI_AEMIF_DATA_H__ */