Received: by 10.192.165.156 with SMTP id m28csp1668994imm; Tue, 17 Apr 2018 03:31:06 -0700 (PDT) X-Google-Smtp-Source: AIpwx49TjTEXkn6qwAySr8pHuO9uunX56IyAYL5qi1HmFYALjUfF5mSBt3HFjqKd+1/iy95jc8dG X-Received: by 10.99.104.131 with SMTP id d125mr1347039pgc.9.1523961066210; Tue, 17 Apr 2018 03:31:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1523961066; cv=none; d=google.com; s=arc-20160816; b=VSvg3DdUBohjZ5qkQoB8LTf0PdspBcDSINwnd+xTZBZrwvbyikbiQsIgh0rh2gX88J /C9ReX/9cq1CqxepoMW/Tjf4UH095g+w4PX416uK3eSoHl5LF+f+G+kUnnTfpJFj6L62 NPu/TDPe6bEA/lQ5O/p6ZLgUX6nMzAivjpdYfN7rU1ARnLHqVSovfeN3Elh3TXZGxYTE Y8eWokAP3uA0ydPLTF5jxI8UsoY5gWR1CkfRad/yucX/OC9q2M2gi8k9UZE9Xiavw7Rg SHlDzGXmmYXASqnce5XzyH2i+6pnQddxauo8JKvEdFr2a2/vQUv9lom7SniNAvqqPOwK Pdkg== 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=RV1MP/8Wnqhwg5XtUn9tqKsFBBsTkuZhPj5C0gNFUlo=; b=o7PhG5seyzGYuphQFHoljmQt4FjBSvE2hRs3yFnHdIOd2NINWYQqLln9hijeeNs+hu DezQ2I3KW26N8mv2MJikE7ZZKNRafnYwRjYpD+1jxLwUgqRXQdIEcPELkdAkRx9Iyev9 RMKEYVC/jfdFe53ynqS76+C438OWgAgEdnwXdE0xJLi8BiFgL03nScpGCcjIuUhkgruh +sLLnboB/LX5+AQr8NuOcnl38PMidH2zPSJC6E8oQsTCeYxn5hlyrxm6rTcRmv7WuDLS UZXxOxLoSZjCSEX/dHjMGKI9oKwse5d9on6oWmHN9sFFGnXHr7Z95b9mfjaqoZig/Oor ZQLw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bgdev-pl.20150623.gappssmtp.com header.s=20150623 header.b=kXn0GH5k; 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 b126si11591438pgc.579.2018.04.17.03.30.52; Tue, 17 Apr 2018 03:31:06 -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=kXn0GH5k; 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 S1752743AbeDQK3c (ORCPT + 99 others); Tue, 17 Apr 2018 06:29:32 -0400 Received: from mail-wr0-f194.google.com ([209.85.128.194]:44550 "EHLO mail-wr0-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752592AbeDQK32 (ORCPT ); Tue, 17 Apr 2018 06:29:28 -0400 Received: by mail-wr0-f194.google.com with SMTP id o15so3007068wro.11 for ; Tue, 17 Apr 2018 03:29:27 -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=CR0M+P22g1nnfbQfGd5wuqo89QefWbZciX9tHXHNk1va/YP1psjNVrF4LcTMBRPx9D 4qyNZicsdwwHMOXDqKK87cLno1FtYd1M6udvfVFW/vYND3LaAQuElT5VoU+oSyAXy1fq Ldje2ylMZ0NSeXcRxF2ds/HXuu1d1C6ATJUJ5mG9AU0JoVi4V0xssfIFnL9LL33XOAFL vGtMPaPIJMRvRgjz+xR0DEF33wRs78idQvDxYb2fRY5j0PL4HzurZgszuh2jY65r1l1m CX1WrwkFnLnJhXuC1UDG0zcGcbcRrnAGkHswgthE0xovNHWPzeDnC4BH/baNBx8vMFUJ DqQA== X-Gm-Message-State: ALQs6tA4dab1R7ll9G5y6D+ykxstNPQUYkw9OGi4vqw7CxirlyFQOxsC 9dVe8Br96SpNvncM00PvfqYo3g== 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 Cc: linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Bartosz Golaszewski 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> 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.17.0