From patchwork Sun Jan 18 05:16:52 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: warmcat X-Patchwork-Id: 43279 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-wg0-f69.google.com (mail-wg0-f69.google.com [74.125.82.69]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id DD188240BA for ; Sun, 18 Jan 2015 05:17:08 +0000 (UTC) Received: by mail-wg0-f69.google.com with SMTP id x13sf2118732wgg.0 for ; Sat, 17 Jan 2015 21:17:08 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:delivered-to:subject:from:to:cc:date:message-id :in-reply-to:references:user-agent:mime-version:content-type :content-transfer-encoding:sender:precedence:list-id :x-original-sender:x-original-authentication-results:mailing-list :list-post:list-help:list-archive:list-unsubscribe; bh=HwPgwTRAoWzQZEnzlIKrcwNfW47AoKP4MMOFndx42K8=; b=MS0yTtxMK9VkLBvjVfOpxoJqhdN4sAlHnB8WgA+nv2uowBvnWs9m09NVqiCnvH4Si+ MTThckeIWOHGVZJ5rM1U8vq1gYHrDYN3v7govLk5u/jgN8rXtVB3igyXaa2AV16u9RpU hKLYtkmOgVF1clml+dcX7Dk/O83R2VUjX1MEMSNi0DImXD0YmMPr/QgNFjR8yx4C+EYF u3lMgIxW3YhZo6oAu2Y6vfBLoue768uO4wQ/4FAApAHcOFA09eaa+EtTJqP5z0TTRCLB AjMXFa5jO9M/kNXyJDH9uvvAn7kKRBAxIoFCNKn94aj+5a5urdhL8904sJfQKtGZSkh0 vnpw== X-Gm-Message-State: ALoCoQmQrnaie6ZJ4ubnAxMIGlJ2X2vorAKgClUQyzIv5xuT8tKnZjRW484yOWYZKdupbwdou6oj X-Received: by 10.180.19.42 with SMTP id b10mr1340282wie.0.1421558228223; Sat, 17 Jan 2015 21:17:08 -0800 (PST) X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.26.200 with SMTP id n8ls453967lag.15.gmail; Sat, 17 Jan 2015 21:17:07 -0800 (PST) X-Received: by 10.112.129.228 with SMTP id nz4mr23232842lbb.8.1421558227897; Sat, 17 Jan 2015 21:17:07 -0800 (PST) Received: from mail-la0-x232.google.com (mail-la0-x232.google.com. [2a00:1450:4010:c03::232]) by mx.google.com with ESMTPS id k1si8616488lah.94.2015.01.17.21.17.07 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Sat, 17 Jan 2015 21:17:07 -0800 (PST) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 2a00:1450:4010:c03::232 as permitted sender) client-ip=2a00:1450:4010:c03::232; Received: by mail-la0-f50.google.com with SMTP id pn19so24278488lab.9 for ; Sat, 17 Jan 2015 21:17:07 -0800 (PST) X-Received: by 10.152.23.38 with SMTP id j6mr23481561laf.81.1421558227787; Sat, 17 Jan 2015 21:17:07 -0800 (PST) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.112.9.200 with SMTP id c8csp741288lbb; Sat, 17 Jan 2015 21:17:07 -0800 (PST) X-Received: by 10.68.240.233 with SMTP id wd9mr34925634pbc.69.1421558226727; Sat, 17 Jan 2015 21:17:06 -0800 (PST) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id qn10si10372301pdb.256.2015.01.17.21.17.05; Sat, 17 Jan 2015 21:17:06 -0800 (PST) Received-SPF: none (google.com: netdev-owner@vger.kernel.org does not designate permitted sender hosts) client-ip=209.132.180.67; Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751459AbbARFRA (ORCPT + 3 others); Sun, 18 Jan 2015 00:17:00 -0500 Received: from mail-pa0-f48.google.com ([209.85.220.48]:60749 "EHLO mail-pa0-f48.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751104AbbARFQ5 (ORCPT ); Sun, 18 Jan 2015 00:16:57 -0500 Received: by mail-pa0-f48.google.com with SMTP id rd3so32106095pab.7; Sat, 17 Jan 2015 21:16:56 -0800 (PST) X-Received: by 10.66.251.200 with SMTP id zm8mr7669561pac.72.1421558216835; Sat, 17 Jan 2015 21:16:56 -0800 (PST) Received: from warmcat.com (114-36-241-182.dynamic.hinet.net. [114.36.241.182]) by mx.google.com with ESMTPSA id uk5sm8074138pbc.17.2015.01.17.21.16.55 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 17 Jan 2015 21:16:55 -0800 (PST) Subject: [PATCH 2/2] net wireless wcn36xx adapt wcnss platform to select module by DT From: Andy Green To: Kalle Valo , Eugene Krasnikov Cc: wcn36xx@lists.infradead.org, linux-wireless@vger.kernel.org, netdev@vger.kernel.org Date: Sun, 18 Jan 2015 13:16:52 +0800 Message-ID: <20150118051650.32019.49483.stgit@114-36-241-182.dynamic.hinet.net> In-Reply-To: <20150118051222.32019.32719.stgit@114-36-241-182.dynamic.hinet.net> References: <20150118051222.32019.32719.stgit@114-36-241-182.dynamic.hinet.net> User-Agent: StGit/0.17-dirty MIME-Version: 1.0 Sender: netdev-owner@vger.kernel.org Precedence: list List-ID: X-Mailing-List: netdev@vger.kernel.org X-Original-Sender: andy.green@linaro.org X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 2a00:1450:4010:c03::232 as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org; dkim=neutral (body hash did not verify) header.i=@ Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , Simplify the resource handling and use DT to indicate which chip type we are dealing with Signed-off-by: Andy Green --- drivers/net/wireless/ath/wcn36xx/wcn36xx-msm.c | 101 ++++++++++++------------ 1 file changed, 52 insertions(+), 49 deletions(-) -- To unsubscribe from this list: send the line "unsubscribe netdev" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/drivers/net/wireless/ath/wcn36xx/wcn36xx-msm.c b/drivers/net/wireless/ath/wcn36xx/wcn36xx-msm.c index f6f6c83..c9250e0 100644 --- a/drivers/net/wireless/ath/wcn36xx/wcn36xx-msm.c +++ b/drivers/net/wireless/ath/wcn36xx/wcn36xx-msm.c @@ -42,7 +42,10 @@ struct wcn36xx_msm { struct completion smd_compl; smd_channel_t *smd_ch; struct pinctrl *pinctrl; -} wmsm; + enum wcn36xx_chip_type chip_type; +}; + +static struct wcn36xx_msm wmsm; static int wcn36xx_msm_smsm_change_state(u32 clear_mask, u32 set_mask) { @@ -217,14 +220,47 @@ int wcn36xx_msm_powerup(const struct subsys_desc *desc) return 0; } +static const struct of_device_id wcn36xx_msm_match_table[] = { + { .compatible = "qcom,wcn3660", .data = (void *)WCN36XX_CHIP_3660 }, + { .compatible = "qcom,wcn3680", .data = (void *)WCN36XX_CHIP_3680 }, + { .compatible = "qcom,wcn3620", .data = (void *)WCN36XX_CHIP_3620 }, + { } +}; + +static int wcn36xx_msm_get_chip_type(void) +{ + return wmsm.chip_type; +} + +static struct wcn36xx_msm wmsm = { + .ctrl_ops = { + .open = wcn36xx_msm_smd_open, + .close = wcn36xx_msm_smd_close, + .tx = wcn36xx_msm_smd_send_and_wait, + .get_hw_mac = wcn36xx_msm_get_hw_mac, + .smsm_change_state = wcn36xx_msm_smsm_change_state, + .get_chip_type = wcn36xx_msm_get_chip_type, + }, +}; + static int wcn36xx_msm_probe(struct platform_device *pdev) { int ret; - struct resource *wcnss_memory; - struct resource *tx_irq; - struct resource *rx_irq; + const struct of_device_id *of_id; + struct resource *r; struct resource res[3]; struct pinctrl_state *ps; + static const char const *rnames[] = { + "wcnss_mmio", "wcnss_wlantx_irq", "wcnss_wlanrx_irq" }; + static const int rtype[] = { + IORESOURCE_MEM, IORESOURCE_IRQ, IORESOURCE_IRQ }; + int n; + + of_id = of_match_node(wcn36xx_msm_match_table, pdev->dev.of_node); + if (!of_id) + return -EINVAL; + + wmsm.chip_type = (enum wcn36xx_chip_type)of_id->data; wmsm.pinctrl = devm_pinctrl_get(&pdev->dev); if (IS_ERR_OR_NULL(wmsm.pinctrl)) @@ -240,52 +276,23 @@ static int wcn36xx_msm_probe(struct platform_device *pdev) if (IS_ERR_OR_NULL(pil)) pil = subsystem_get("wcnss"); - if (IS_ERR_OR_NULL(pil)) - return PTR_ERR(pil); + if (IS_ERR_OR_NULL(pil)) + return PTR_ERR(pil); wmsm.core = platform_device_alloc("wcn36xx", -1); - //dev_err(&pdev->dev, "%s starting\n", __func__); - - memset(res, 0x00, sizeof(res)); - wmsm.ctrl_ops.open = wcn36xx_msm_smd_open; - wmsm.ctrl_ops.close = wcn36xx_msm_smd_close; - wmsm.ctrl_ops.tx = wcn36xx_msm_smd_send_and_wait; - wmsm.ctrl_ops.get_hw_mac = wcn36xx_msm_get_hw_mac; - wmsm.ctrl_ops.smsm_change_state = wcn36xx_msm_smsm_change_state; - wcnss_memory = - platform_get_resource_byname(pdev, - IORESOURCE_MEM, - "wcnss_mmio"); - if (wcnss_memory == NULL) { - dev_err(&wmsm.core->dev, - "Failed to get wcnss wlan memory map.\n"); - ret = -ENOMEM; - return ret; - } - memcpy(&res[0], wcnss_memory, sizeof(*wcnss_memory)); - - tx_irq = platform_get_resource_byname(pdev, - IORESOURCE_IRQ, - "wcnss_wlantx_irq"); - if (tx_irq == NULL) { - dev_err(&wmsm.core->dev, "Failed to get wcnss tx_irq"); - ret = -ENOMEM; - return ret; - } - memcpy(&res[1], tx_irq, sizeof(*tx_irq)); - - rx_irq = platform_get_resource_byname(pdev, - IORESOURCE_IRQ, - "wcnss_wlanrx_irq"); - if (rx_irq == NULL) { - dev_err(&wmsm.core->dev, "Failed to get wcnss rx_irq"); - ret = -ENOMEM; - return ret; + for (n = 0; n < ARRAY_SIZE(rnames); n++) { + r = platform_get_resource_byname(pdev, rtype[n], rnames[n]); + if (!r) { + dev_err(&wmsm.core->dev, + "Missing resource %s'\n", rnames[n]); + ret = -ENOMEM; + return ret; + } + res[n] = *r; } - memcpy(&res[2], rx_irq, sizeof(*rx_irq)); - platform_device_add_resources(wmsm.core, res, ARRAY_SIZE(res)); + platform_device_add_resources(wmsm.core, res, n); ret = platform_device_add_data(wmsm.core, &wmsm.ctrl_ops, sizeof(wmsm.ctrl_ops)); @@ -319,10 +326,6 @@ static int wcn36xx_msm_remove(struct platform_device *pdev) return 0; } -static const struct of_device_id wcn36xx_msm_match_table[] = { - { .compatible = "qcom,wcn36xx" }, - { } -}; MODULE_DEVICE_TABLE(of, wcn36xx_msm_match_table); static struct platform_driver wcn36xx_msm_driver = {