From patchwork Sun Aug 24 21:24:44 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hauke Mehrtens X-Patchwork-Id: 4771301 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 4D1D8C0338 for ; Sun, 24 Aug 2014 21:28:37 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 1453920138 for ; Sun, 24 Aug 2014 21:28:36 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 454C9200E9 for ; Sun, 24 Aug 2014 21:28:35 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1XLfJJ-0000vS-O6; Sun, 24 Aug 2014 21:26:49 +0000 Received: from test.hauke-m.de ([2001:41d0:8:b27b::1]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1XLfId-0000KS-OL for linux-arm-kernel@lists.infradead.org; Sun, 24 Aug 2014 21:26:08 +0000 Received: from hauke-desktop.lan (spit-414.wohnheim.uni-bremen.de [134.102.133.158]) by test.hauke-m.de (Postfix) with ESMTPSA id 7FF702097B; Sun, 24 Aug 2014 23:25:20 +0200 (CEST) From: Hauke Mehrtens To: linux-wireless@vger.kernel.org, devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-mips@linux-mips.org Subject: [RFC 6/7] bcma: get sprom from devicetree Date: Sun, 24 Aug 2014 23:24:44 +0200 Message-Id: <1408915485-8078-8-git-send-email-hauke@hauke-m.de> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1408915485-8078-1-git-send-email-hauke@hauke-m.de> References: <1408915485-8078-1-git-send-email-hauke@hauke-m.de> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20140824_142607_961210_642B5E93 X-CRM114-Status: GOOD ( 12.75 ) X-Spam-Score: -0.0 (/) Cc: Hauke Mehrtens , zajec5@gmail.com X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_NONE, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP This patch make it possible to device an sprom provider in device tree and get the sprom from this driver. Every time there is such a provider it gets asked for a sprom. Signed-off-by: Hauke Mehrtens --- drivers/bcma/sprom.c | 51 ++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 50 insertions(+), 1 deletion(-) diff --git a/drivers/bcma/sprom.c b/drivers/bcma/sprom.c index efb037f..ebe495d 100644 --- a/drivers/bcma/sprom.c +++ b/drivers/bcma/sprom.c @@ -15,6 +15,8 @@ #include #include #include +#include +#include static int(*get_fallback_sprom)(struct bcma_bus *dev, struct ssb_sprom *out); @@ -46,6 +48,46 @@ int bcma_arch_register_fallback_sprom(int (*sprom_callback)(struct bcma_bus *bus return 0; } +#ifdef CONFIG_OF +static int bcma_fill_sprom_with_dt(struct bcma_bus *bus, + struct ssb_sprom *out) +{ + const __be32 *handle; + struct device_node *sprom_node; + struct platform_device *sprom_dev; + struct ssb_sprom *sprom; + + if (!bus->host_pdev || !bus->host_pdev->dev.of_node) + return -ENOENT; + + handle = of_get_property(bus->host_pdev->dev.of_node, "sprom", NULL); + if (!handle) + return -ENOENT; + + sprom_node = of_find_node_by_phandle(be32_to_cpup(handle)); + if (!sprom_node) + return -ENOENT; + + sprom_dev = of_find_device_by_node(sprom_node); + if (!sprom_dev) + return -ENOENT; + + sprom = platform_get_drvdata(sprom_dev); + if (!sprom) + return -ENOENT; + + memcpy(out, sprom, sizeof(*out)); + + return 0; +} +#else +static int bcma_fill_sprom_with_dt(struct bcma_bus *bus, + struct ssb_sprom *out) +{ + return -ENOENT; +} +#endif + static int bcma_fill_sprom_with_fallback(struct bcma_bus *bus, struct ssb_sprom *out) { @@ -580,7 +622,14 @@ int bcma_sprom_get(struct bcma_bus *bus) u16 *sprom; size_t sprom_sizes[] = { SSB_SPROMSIZE_WORDS_R4, SSB_SPROMSIZE_WORDS_R10, }; - int i, err = 0; + int i, err; + + err = bcma_fill_sprom_with_dt(bus, &bus->sprom); + if (err == 0) { + bcma_info(bus, "Found sprom from device tree provider\n"); + return 0; + } + err = 0; if (!bus->drv_cc.core) return -EOPNOTSUPP;