From patchwork Wed Apr 18 15:35:52 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bartosz Golaszewski X-Patchwork-Id: 10348505 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 D94A560365 for ; Wed, 18 Apr 2018 15:39:44 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C8BEA286BE for ; Wed, 18 Apr 2018 15:39:44 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id BAF08286C5; Wed, 18 Apr 2018 15:39:44 +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 28720286BE for ; Wed, 18 Apr 2018 15:39:44 +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=zpULQdjXXkrVL7JR4iqLZ73LSHvnCZjuGZ13jea9aeA=; b=eVlie3y+G1RHMVuZAonq07AIe/ 4sZDWZDskIGeEBnXvcHuwZLFRBcv/0AFHI1VdpwftaCEODd6AJN/hwDvgeTd8NEvJ1S/JP0CRaus7 Eqyz7bT8VigBjuMcQTaj5yD2I0qptOuKYSPenDYtSZTulMIP553mOFzSwYZf6Aotf/8+WB+lOQRtj TSfvAGEyOBx2iQ9pAdIVIU4Gfu1K52Ds72Klrgu8uCaZYppOanylVRdDCTgNRPgfRghbGNQrpc8Pb tDqj8H0m7uy+3sqLXrp4Wl/WAN9Cwqbat6eU1kcvrN94TbXYORS7QHSQN6/ztFOE82HW0RTv+0Lja xlWPW68g==; 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 1f8pBC-0000sL-Mr; Wed, 18 Apr 2018 15:39:30 +0000 Received: from mail-wr0-x242.google.com ([2a00:1450:400c:c0c::242]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1f8p7w-0007zH-8t for linux-arm-kernel@lists.infradead.org; Wed, 18 Apr 2018 15:36:13 +0000 Received: by mail-wr0-x242.google.com with SMTP id v24-v6so6032378wra.8 for ; Wed, 18 Apr 2018 08:36:00 -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=ZPXk8oNI3pixH51i6kiqwaCPvVNDzhx6uCeE0B0ZrwE=; b=1ZdgPSY70vj/IF2dvVpYtAKTBfjLM3x2T8mbG6kU1uXvSiWLVe9gXG9B9z8kal9YNd qrWC5aTUev01USw/FdUcTCMpb6MdLtWeq3QSNLvXIOKQzJmMGznjwQtsgmzEtgxkIfs3 OIoGjpb9ZjT4I1Kp2n/z6TMFamARx1AyFxJjn7QQB2l2KdovUhl0hz7uVXu8iYtk7iuJ JxD57DVJB5zzI+231TXe9THIPpuiC5xtv3JePRC5wGQjIjgpaujx0pxBBDBlO6SZCknL iMDHJ176ecPw5cOCV7v2iyK7TnvFbLpvwE+Ysc125WYun2oSpxRlfPBaeX6i5x3yH79t tIIg== 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=ZPXk8oNI3pixH51i6kiqwaCPvVNDzhx6uCeE0B0ZrwE=; b=t3eZs4WKB7ObJNUQQMI3ian4cQtJ8iJ0vRaxJ7SSI7O5q8IxfqVOLZPmxvRDBAQkMY tXZzOiWjQuGijr/RfkMQnUZVUqDh7UakilRFiGJLh4c/q95Bph5gPqY9ow3J8sUpYRLb IFZcSHCh4cUCJqVuyWPqZcPrcSusnGgKbX5GqQiLWOFxxKpAwQulBXmzHBQ8j7T9U5RG pddGMYTUFsuXmx6f1/a1X6i2PxEaliDIUcluJchq6WpHsQE3koH0oWmPZ+lAbRCbKV+P lrTbJYmpmraelqyXYb8EzHlkrEmLusiM1B+xnAkNa9QEHhm7dbg7EsK6Zk5CgWD9WS43 CZYw== X-Gm-Message-State: ALQs6tCYhrUGyicAAx6mlED9hrUVwajuqGasdkXU89shhr+hXJbMa8Ze mf9PEefET/tjEin1I+zkf0Scvw== X-Google-Smtp-Source: AIpwx4+tfA+u3V7Nas6EMUxe3VlJYHwwSzkdUIkPsi088HVZqXyy0pZL2BWIG/4f1meqZyBrXPjCUQ== X-Received: by 10.28.238.19 with SMTP id m19mr2269669wmh.126.1524065758764; Wed, 18 Apr 2018 08:35:58 -0700 (PDT) Received: from brgl-bgdev.baylibre.local ([90.63.244.31]) by smtp.gmail.com with ESMTPSA id v5sm1289706wmh.19.2018.04.18.08.35.57 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 18 Apr 2018 08:35:58 -0700 (PDT) From: Bartosz Golaszewski To: Sekhar Nori , Kevin Hilman , Santosh Shilimkar Subject: [PATCH 2/2] memory: aemif: add support for board files Date: Wed, 18 Apr 2018 17:35:52 +0200 Message-Id: <20180418153552.14632-3-brgl@bgdev.pl> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180418153552.14632-1-brgl@bgdev.pl> References: <20180418153552.14632-1-brgl@bgdev.pl> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20180418_083608_355477_966945AE X-CRM114-Status: GOOD ( 22.48 ) 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. While extending the platform data struct, add kernel docs describing its members. Signed-off-by: Bartosz Golaszewski --- drivers/memory/ti-aemif.c | 58 +++++++++++++++++--------- include/linux/platform_data/ti-aemif.h | 25 +++++++++++ 2 files changed, 63 insertions(+), 20 deletions(-) diff --git a/drivers/memory/ti-aemif.c b/drivers/memory/ti-aemif.c index 588e58d40d1b..c9577fda967c 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,25 @@ 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++) { + pdata->sub_devices[i].dev.parent = dev; + 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..e6407bafcbf8 100644 --- a/include/linux/platform_data/ti-aemif.h +++ b/include/linux/platform_data/ti-aemif.h @@ -16,8 +16,33 @@ #include +/** + * struct aemif_abus_data - Async bus configuration parameters. + * + * @cs - Chip-select number. + */ +struct aemif_abus_data { + u32 cs; +}; + +/** + * struct aemif_platform_data - Data to set up the TI aemif driver. + * + * @dev_lookup: of_dev_auxdata passed to of_platform_populate() for aemif + * subdevices. + * @cs_offset: Lowest allowed chip-select number. + * @abus_data: Array of async bus configuration entries. + * @num_abus_data: Number of abus entries. + * @sub_devices: Array of platform subdevices. + * @num_sub_devices: Number of subdevices. + */ 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__ */