Received: by 10.192.165.156 with SMTP id m28csp1378588imm; Wed, 18 Apr 2018 08:45:00 -0700 (PDT) X-Google-Smtp-Source: AIpwx48Soj0g6l9PBphQVT+83iPLkkPyqs9UH/na1TSnfNTBjEGFn6HMYin3hixDfpCQ/dxjXFHP X-Received: by 10.101.71.193 with SMTP id f1mr2197602pgs.216.1524066300749; Wed, 18 Apr 2018 08:45:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1524066300; cv=none; d=google.com; s=arc-20160816; b=aPi0p4bYu8mQI/d/vfQr38dEmwmI70CCQwM1JCLOD9iGB3z6FlbxVR4FgB0yq6s78+ 3FkRBci/OZMgix2IPF2ST+3m5aHrnfAufWGTvd1q9UjlILEyWolXmPJTxaG9kjWcUVYE 5EM+iemCPiE8Xlsi54axr3suOhmLSxdxJefvwMG/eglmFa4EmjpBDMVx1q3urmEcbL2R mSGDVwQd4JMibGnhQiiKeOJcsLlg8EJJlLl9NYWlpf/AmaFT8nMUjGm+GFhCuP9B+x/5 WbAyC9vNpg8KfEzxMYvwtPJS96YNfmaUuG9pfbxPE4h7iL2H28TN04KgNhZYVbyNU996 yEhw== 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=ZPXk8oNI3pixH51i6kiqwaCPvVNDzhx6uCeE0B0ZrwE=; b=nnm3r0MKAJdR7P0RLEqY6DMmBSE+LbE+1tjxfQZHbhQ1wk/Bt5xEA3yFfJ8e2h8HoS +b4DD8u3+JmWPkK8XV/W+qI14FFdnL2aBXgFDzx14It+UVszuVrlYHpbwXg2niUjQZiI 1L/KyG3MAJFBgvSg3fK+C5cl+uxXL4NPfoiUj+wCVdJnuc7wulmD/dGV5isMX9HDPliQ IuCXrlC1Gq6XT/z1nM2KGBw6G3V16H6a0zrD99onoxhrU6r2xmx4jo4YMpuX2qZTyK0F 9m/TxtukGZGQirX5xQjmD+bu8KoGeZfmqM7ii3eX8MdaP5GKeF7fCdUtW62u7BbNoT/9 z0rg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bgdev-pl.20150623.gappssmtp.com header.s=20150623 header.b=1ZdgPSY7; 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 f1si780074pfg.137.2018.04.18.08.44.46; Wed, 18 Apr 2018 08:45:00 -0700 (PDT) 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=1ZdgPSY7; 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 S1753352AbeDRPgF (ORCPT + 99 others); Wed, 18 Apr 2018 11:36:05 -0400 Received: from mail-wr0-f196.google.com ([209.85.128.196]:40183 "EHLO mail-wr0-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752699AbeDRPgA (ORCPT ); Wed, 18 Apr 2018 11:36:00 -0400 Received: by mail-wr0-f196.google.com with SMTP id v60-v6so6039551wrc.7 for ; Wed, 18 Apr 2018 08:35:59 -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=oezpC8hXd8bkA1NKJ1Zeae5p8gmuYw6JsEdAdqH5x15emt4IWwztvuMaYrgkJVXbxW gHUQZyNX4iiUKcyNS8RXB+twSoppgfbeppzxCiWB4nHsGeb2XMN1s7Cr4pYpcPdlKs29 E9XvMWZr76BQhAuV46fj1rdjdLMu5SrTs2q/YZ3YDYu6SNlfdgq0ZiDcvoSoGKFi2Abs NPN33hcdJyboAMD7z6h4cVpO0NyjNjtubiHmulGszAsJBbZyN8D4IDdQMB3Zj2FG495V TVzX4sGDlSzr3Vhle8d1OwkdsQBZaQnWAEdwrtYi8viBgKWYv9pC2o4xVLIsc6nbIXxN hFpA== X-Gm-Message-State: ALQs6tBnH7DBzZvJaqTqb4Od3FOQvopYOn6gE9ab+nyXauQm5zxnq+Go US0WimAPTJ0k3jtzhe+hs0b97A== 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 Cc: linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Bartosz Golaszewski 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> 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. 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__ */ -- 2.17.0