From patchwork Mon Mar 19 15:33:12 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bartosz Golaszewski X-Patchwork-Id: 10292577 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 9FDDD600F6 for ; Mon, 19 Mar 2018 15:34:49 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8C7CF29484 for ; Mon, 19 Mar 2018 15:34:49 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 8047E29486; Mon, 19 Mar 2018 15:34:49 +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 1D6AA29484 for ; Mon, 19 Mar 2018 15:34:48 +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=Pxt3jxLRxx0bsXy/dSVhZYtDpn e6usLcd+I2wUaMmqLfZ9W7r4yY1W9LiUJzrzXkGN4Q9504USq56DCoNo1e3MA4XgFtBJkMcLzFZ0+ q25cURGF8KM6GdRdW2zbm3hlKPUoC09WoProa2ANGG91mnViiPZVOi5GltrDq++1F7nGBK76xVHP9 KjSw6UWk/ox2+SStxJItUALFWu0gUW9xNgbDGhK8WzTsEXeUPRrD8Y1YU+bRf7ydbPJbxmTdhV4g3 aSWtIm6MdS+9G0BTPZ82QFoFxjru//Ji1umqgsewHPRTzqCVHW1HBMLFXBfFve9F+1EGoSpffOuNl Q7Va8wQg==; 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 1exwo4-00038T-TH; Mon, 19 Mar 2018 15:34:40 +0000 Received: from mail-wm0-x241.google.com ([2a00:1450:400c:c09::241]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1exwnA-0002TN-5N for linux-arm-kernel@lists.infradead.org; Mon, 19 Mar 2018 15:33:51 +0000 Received: by mail-wm0-x241.google.com with SMTP id l16so7194955wmh.3 for ; Mon, 19 Mar 2018 08:33:33 -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=ugLGO1urX68nC92gZx8vWM9SDgsR/iJoL1afvvH2xtk=; b=XXqanESaC4lUBXAGySQBjeS3UdQ6NhrcH2yyhjgmfa2XH1sPkQ2X0GnydBf0RGIVF2 VdtxbzhZTqd/nipQY+vJ5iEyWg9GRhAmYRhfM4CcjNupz4tB4Zowd17KMvqu4A73bx47 PX+3+zsHj2g5WUdFPEYERBcztlU1Jk3UW5s62eD8ho+GxPS9FRrosKoAR8h8EUeoIHMg a+gDA4YzpNPdBFhZ+zA8QgtEYOp/XhBSCRU5Ai6hPVKYwwfmpRK9mo7fq5w3Ft+la1Vk 5d5lyUmTrAr4ju9z5LHhXAPCWHwT8IP+MqrQ1hclKIr2iBCpOh3x6Cyp/CYrJ4mku4Fe 0N8g== 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=S7+3sxlTyqMlCnxWVCQ3nppPMmKksu6wMd6ZFwDymo/pb3Aj2sdSJWZtpy75eFY7FV xLXDm7ILyIqc0QL4sMFyNLLg53hYrtKL6ZcF/XDjw1Qb69tIf8hAjK2JF8/XcHQj2gEm EwCcjgfEVuULky0OUs7sfVywox4VSyOLVXAeqZVTfvSCvHHBYH61wBOF0tO+ueP/dAEN 5hN9JNoyJ+w0lyl28cQyJ3JHF/PG+4YQNEvl8N+ZiVBdi0ToM657YMuMCkbJXbVjd6Ri PREuo2ZAJebdTQafDqquu32bMIPBSIuqXVEdNBH7NMDTo6bB+aD8rlmxBdtnFnr+3iy6 HXDw== X-Gm-Message-State: AElRT7GyubbmTA1jJhV8tQ4Fz8raanoG6jnODT4Jt5jrRpaywl16InZx 2eIBoqXDD3CmuX8fOy9wPYW+cA== X-Google-Smtp-Source: AG47ELsMBbSOSWxvYmoJzFFZ7YOoPeRyqqi9r0BzxKV1Fqjo/rUUAKpmCD+RkV6127Uksx8X9iaaXw== X-Received: by 10.28.239.8 with SMTP id n8mr9619900wmh.120.1521473612406; Mon, 19 Mar 2018 08:33:32 -0700 (PDT) Received: from brgl-bgdev.baylibre.local ([90.63.244.31]) by smtp.gmail.com with ESMTPSA id w73sm695489wmw.42.2018.03.19.08.33.29 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 19 Mar 2018 08:33:31 -0700 (PDT) From: Bartosz Golaszewski To: Sekhar Nori , Kevin Hilman , Russell King , Santosh Shilimkar Subject: [PATCH v2 2/4] memory: aemif: add support for board files Date: Mon, 19 Mar 2018 16:33:12 +0100 Message-Id: <20180319153314.26120-3-brgl@bgdev.pl> X-Mailer: git-send-email 2.16.1 In-Reply-To: <20180319153314.26120-1-brgl@bgdev.pl> References: <20180319153314.26120-1-brgl@bgdev.pl> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20180319_083344_855866_7DF85730 X-CRM114-Status: GOOD ( 23.56 ) 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__ */