Received: by 10.223.185.116 with SMTP id b49csp1041361wrg; Fri, 16 Feb 2018 11:19:20 -0800 (PST) X-Google-Smtp-Source: AH8x225VrouoeLOAc4uBm9ZsfDceRKINmo8fYaYN1xRmfxQY700isAaxfK960XcU5J5MJhw2+l2m X-Received: by 2002:a17:902:43e4:: with SMTP id j91-v6mr6632364pld.153.1518808760862; Fri, 16 Feb 2018 11:19:20 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1518808760; cv=none; d=google.com; s=arc-20160816; b=ahTHhczXIukM3EZxOC9n4sxqH/MeIpDGuddpNXoJ5xGFIbYnyDGoAz0LQ/RoD/orE9 X84yCVKxmDvGzhdx7vAu5knHcyWS3Ngp3AmPm+qcLtBjFq7QYGYg+2On9rdMTpe08ooo N76VivZ/DIVgWYxIreeomLJRc3p+oui+PH1OPvcEMSmlAbvD0UNZIXbgmvcFYIIfEE/i Ot/8m/ZJIbTHnz9ep9HAfIZgRS3RCDpvVjIFcceArniXfGqqhN/lkSNgZrF2I0I8+IKq Q5QjlpFg3pe5iLXz4HyKVrdov8nqk1F7AfIQNQawZmWFyeZPeCzzChtWVYNO1Q0cXtBe JXrg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:arc-authentication-results; bh=ugLGO1urX68nC92gZx8vWM9SDgsR/iJoL1afvvH2xtk=; b=DD8RqEIhm/wuNAU85Cb8iV7ZBlSx4rr/YdHdazmnMbkwkFdfDTK0kqoLKLg07yER9P Q9wHAFp8f1saMLEIqYC9yEjZakwHLpFYrIgTC1vnmWa75MVP9+x9UPil/REzqdDyX3l9 D6cTye46MI7uOYcH7DM3nFJioXJaVd1ZOlPnPA9p/KuEIUAZMsE7thKgzWdkMCIk/P3R K45wTxZmrX/cfEz4L6NP+9MWkjDG+8VEidNvCR682SPkQYLeUzjTDmgHqhL8DCO0hQEV vAPok4gHS64weUnI9dE+psTunQlXN0TuOQ/3UEAZnlxVMR2SN/+kklPBQTqbGsn+yC/y mJMQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bgdev-pl.20150623.gappssmtp.com header.s=20150623 header.b=THnXQtcv; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id o15si4671423pgc.48.2018.02.16.11.19.06; Fri, 16 Feb 2018 11:19:20 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@bgdev-pl.20150623.gappssmtp.com header.s=20150623 header.b=THnXQtcv; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1161166AbeBPQra (ORCPT + 99 others); Fri, 16 Feb 2018 11:47:30 -0500 Received: from mail-wr0-f195.google.com ([209.85.128.195]:43861 "EHLO mail-wr0-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1161071AbeBPQr0 (ORCPT ); Fri, 16 Feb 2018 11:47:26 -0500 Received: by mail-wr0-f195.google.com with SMTP id b52so3502901wrd.10 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=Vki5Coom7sSl1JtEdVvtxwOcf5g5p8am42y6PkxbJ3/dqFgrbHZOqT/K6yGT8EqXp+ JX5/JbrSPk3brzg6HssKHwkjJHN+3h/ygN/SmFs12pqJNdrl0eNj+7NzzGohp4ViKuxP O1KWQ71yDrTGaHKnjhxJhNXfAgJsZ7SwYIz50mHw0F+Tc8xuZRx0lj8BLtrDdOFJm/+H /8Jz3RagWTSmqhCPcQhLHh/ENvS5ttOI5P/rT539HwkRQCP/w97IM5Lbjsj07RKL738Y bqCBMeIDSifYdMX/xEkRFN2aS/AyF1szK17PHuv/c8NcrzoWkeo2s4qnB0abtAvWVvG9 ClMw== X-Gm-Message-State: APf1xPA3nrSqy5kT+/3ETKDmSqTn7rtdEjTl7qqZaBumQ0AOTzstWOTD xSTPLuwv9OJPcBe61SyhxPd8Cw== 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 Cc: linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-mtd@lists.infradead.org, David Lechner , Bartosz Golaszewski 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> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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__ */ -- 2.16.1