From patchwork Tue Apr 17 10:29:15 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bartosz Golaszewski X-Patchwork-Id: 10344757 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 748D460216 for ; Tue, 17 Apr 2018 10:45:17 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7450E28A29 for ; Tue, 17 Apr 2018 10:45:17 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 688BC28A4F; Tue, 17 Apr 2018 10:45:17 +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=-2.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI 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 D2C6928A29 for ; Tue, 17 Apr 2018 10:45:16 +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=jC107KIUfL17s2v6Bb0thk7cpPa2bxY7F9Yzkbc069k=; b=QtexEjQRJkmUkxwQT+cJSJqHej Wlunk439EB9spMH4v5vRwgYzFwFLIpO0kWQZo4Hrj1et0bB7kht+evWNoGFZwUUnY5dLHgySPyZw3 lzukpbaQAGO71FwVAaHGXgrfvYIOW6JAchNRPQDaGyi+FpdQRcKnKXFUBFhj8dRCwJHilxvL7hkEH QigpARaKY8/UPPSZHqnZ22CPziCgqZ04QpXl8h3AkA9Ya2TCUB6zoZLp0F9E9ijjGy9unTapaVqdG Yn+W7slIGCHpcbxDjGt7MrbOHgr81fDWeoswbVC+WL1bYB3GA7ZrWDDWQTC+7gJpR8hpXFzCtR7E/ ZfnvFuXQ==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1f8O6e-0002VA-UX; Tue, 17 Apr 2018 10:45:00 +0000 Received: from casper.infradead.org ([2001:8b0:10b:1236::1]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1f8O6A-0001Ju-6z for linux-arm-kernel@bombadil.infradead.org; Tue, 17 Apr 2018 10:44:30 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=References:In-Reply-To:Message-Id:Date: Subject:Cc:To:From:Sender:Reply-To:MIME-Version:Content-Type: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=RV1MP/8Wnqhwg5XtUn9tqKsFBBsTkuZhPj5C0gNFUlo=; b=ExI5mBv6Sv1aMKYrsAZmyAHXA qVseWSRZ6R9FlGJcG1HChmoFzSfqC2TDOI9oRMWbcpGb7uHznCrcILGSS11b/GMWBtBj8SQujJVvb CaRa+BvQLZVUb9qbzEGXm3qIBmQGGLebkIIDUcu9ui8nVk1YaRBZEfvI0VA0EWu2zcR7cDoLqM6bV +EE2ZEcH7TKEd89ouzRMmWsej5tZFND80rwyTkceggjLfQkaZ9GDEi3oWRkU3s2qEVadRH8TPujol l34Mwsi/eOtzJddegmCnomUqXAvJmg4QJXlcj2pxy+dr43l6sNmNbqFr802dPY4Mbls3h2TH7qJOi S2ojBAXLQ==; Received: from mail-wr0-x241.google.com ([2a00:1450:400c:c0c::241]) by casper.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1f8Nrn-0000x1-Es for linux-arm-kernel@lists.infradead.org; Tue, 17 Apr 2018 10:29:41 +0000 Received: by mail-wr0-x241.google.com with SMTP id h3so21384603wrh.5 for ; Tue, 17 Apr 2018 03:29:28 -0700 (PDT) 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=RV1MP/8Wnqhwg5XtUn9tqKsFBBsTkuZhPj5C0gNFUlo=; b=kXn0GH5k+eL+SW3tjc62FtkoRl3bJMgtk4YzyhKpO9aPLVmg2+T/Z/Fbt2ZvZdb6mN loPYnRxCbdfGYDx0Xorm5uSL/bDIsMsFV4WOFR4Sv16xkUwyvImc2mzgspy8MHrBvpWF Zp/dy8vJterjyLt2gd24Q0a9wnLMOuQd33uGOEIQc2X2nHuo9Z9PevzFCEybBtG98t7K eh5LSsRpbm5wUSLhInRPI9weJisGuQuDl2IruxDnBlgpt5vsBViVGGAAfQ4m22cyropo 9JEBQ9buZigrOZOQ7KdbpKI6qql3gCC5wkwZxNTcZ8RrVe1IZzF0JY2IhPEOhe1t3niR 3ffg== 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=RV1MP/8Wnqhwg5XtUn9tqKsFBBsTkuZhPj5C0gNFUlo=; b=TQC/qqQgZYuo4yQhcrUZS6gl7QaxJVqMmjuyWb8DxShpslTCvT6ur2fsAdXcBNmxL4 nw5V9PdW8vrHQ1Pf2OQF9TQjsDdT6r/oJ1Bimq0WE0whoi7sVM+YcJ5hvTYogsqHSf5l G6JxmvgJLnMcwrJqacIFyW3SmourgEEgxvqW2CcIMaaBtXgTFMo1EH808isErAsVp61Q QQb2A+jzu+1qBvk+vKf6EuGb9FK+9x1t/FZoosUASt06OO6OL+mdfurVU+bweL+5LmWz 7OBvb8QThdl3U7WXvow6TrHqAdmeEfVbXjo2xmqmFRhMF2QLSb1hXUcnzoj0ivZiOstj MJUg== X-Gm-Message-State: ALQs6tA8WziqXtVac022F2duAldLig1js5GmsuSoUb7sJp7dMEcgbyUq QwlRCPWRLCkEogb5j8lOXpkycA== X-Google-Smtp-Source: AIpwx49E4fUyLYYyINZ7mfjOwyBUy6wCshaR5qcpdjCOoJZ7UQxtb5ZsoLxSeoFGERKgtaKTugVsDw== X-Received: by 10.28.133.82 with SMTP id h79mr594845wmd.56.1523960966758; Tue, 17 Apr 2018 03:29:26 -0700 (PDT) Received: from brgl-bgdev.home ([2a01:cb1d:af:5b00:e837:b8d5:48c1:571b]) by smtp.gmail.com with ESMTPSA id r75sm8842252wmf.34.2018.04.17.03.29.25 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 17 Apr 2018 03:29:26 -0700 (PDT) From: Bartosz Golaszewski To: Sekhar Nori , Kevin Hilman , Russell King , Santosh Shilimkar Subject: [RESEND PATCH v2 2/4] memory: aemif: add support for board files Date: Tue, 17 Apr 2018 12:29:15 +0200 Message-Id: <20180417102917.7794-3-brgl@bgdev.pl> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180417102917.7794-1-brgl@bgdev.pl> References: <20180417102917.7794-1-brgl@bgdev.pl> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20180417_112939_499472_3B6A8249 X-CRM114-Status: GOOD ( 26.96 ) 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-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org 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__ */