From patchwork Thu Sep 19 10:52:37 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?SsOpcsO0bWUgUG91aWxsZXI=?= X-Patchwork-Id: 11152165 X-Patchwork-Delegate: johannes@sipsolutions.net Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 5BB7516B1 for ; Thu, 19 Sep 2019 10:54:56 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 1DAB321924 for ; Thu, 19 Sep 2019 10:54:56 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=silabs.onmicrosoft.com header.i=@silabs.onmicrosoft.com header.b="azlZK24m" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2389755AbfISKyu (ORCPT ); Thu, 19 Sep 2019 06:54:50 -0400 Received: from mail-eopbgr700049.outbound.protection.outlook.com ([40.107.70.49]:8577 "EHLO NAM04-SN1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S2389438AbfISKwu (ORCPT ); Thu, 19 Sep 2019 06:52:50 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=MZPXAMGU3WrOcePGtY4dvZdhnS3eU1SjIKuDXjPd6OBpITTTWa6qGtY/vGzlSEWUNDrbrzlyerO+o4Ix+672csg2FhZz78rwDKq/e5DBwhpWmVQIl8JlOcrZxktlZ9SrhhVS5H2LAdQU4VKkxLlW5EJEkcozgKkRgx8S5biv7+5yvcXv8n+Xeu3LaZSzdJM8QxzyDnR8lCNrCsrsbWbJxGV2H/LVLN12rR6v+3Da6CyYsSJafR5wK8WYcswRiMoXLa/7zVm7xCQYHjN3gU7PZoQMG9tCwOWmNwFi5yHaGQ6G/+mh+GmPdRJFMZV3J28zz5F0Vp6bYGCAxfT8y5ELTg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=FNetZ1+im1b4m13t59Ec9MWVOz7kGu89CmnRsIgi600=; b=ZjcUbLGNSf27bIURJ4lmjhdC1oHRPucRH5b0+EErozBfIzbCIWGgaz4NBjRveBk+kx6MAFTu7bk58+Cw3TfuLha9M9x70pp5EgG5jhHAd+ZFiBMyqhJOFyY3Cf37zQgO8Fv4bUa0ZBQ3gYVgxLUbsAAdDMk1Yi539OToEVcuHLM+duPD6ox4LXteA0NK4w9JekHx+xRp6qT33WHOAylvZ5Q0wpxL2eexaKvLNZ5kFd+fvQsBGaLZX2WKlCrRqMd5jMb9K7Qv2N5TyMjRup5OSQZ9M5vtimQhthKh2g717cVHmF1an9HCKdzP89YUHpBHbSmezLF74//wmY4tKRK5eg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=silabs.com; dmarc=pass action=none header.from=silabs.com; dkim=pass header.d=silabs.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=silabs.onmicrosoft.com; s=selector2-silabs-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=FNetZ1+im1b4m13t59Ec9MWVOz7kGu89CmnRsIgi600=; b=azlZK24med+NenlspmnLIhnbJBxas/gsEJwQmCfE8mHtUud7gxDtQIkFVkxZHH0Ds+h7N7veyRfAvLCy5BpVzhK+sRekUi2cfFKC2sfOCnHJGFQEDyXT318u6weMbDhJiSxEdszDBuNOTcR9fix+sjxZ+sbsjzueqkFZ2uv9u9s= Received: from MN2PR11MB4063.namprd11.prod.outlook.com (20.179.149.217) by MN2PR11MB3775.namprd11.prod.outlook.com (20.178.253.202) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2263.17; Thu, 19 Sep 2019 10:52:38 +0000 Received: from MN2PR11MB4063.namprd11.prod.outlook.com ([fe80::45dc:e073:4446:4bf8]) by MN2PR11MB4063.namprd11.prod.outlook.com ([fe80::45dc:e073:4446:4bf8%3]) with mapi id 15.20.2263.023; Thu, 19 Sep 2019 10:52:38 +0000 From: Jerome Pouiller To: "devel@driverdev.osuosl.org" , "linux-wireless@vger.kernel.org" CC: "netdev@vger.kernel.org" , "linux-kernel@vger.kernel.org" , Greg Kroah-Hartman , Kalle Valo , "David S . Miller" , David Le Goff , Jerome Pouiller Subject: [PATCH 07/20] staging: wfx: add IRQ handling Thread-Topic: [PATCH 07/20] staging: wfx: add IRQ handling Thread-Index: AQHVbthZSqAgZ+UjRkKZkCdHQwf+3Q== Date: Thu, 19 Sep 2019 10:52:37 +0000 Message-ID: <20190919105153.15285-8-Jerome.Pouiller@silabs.com> References: <20190919105153.15285-1-Jerome.Pouiller@silabs.com> In-Reply-To: <20190919105153.15285-1-Jerome.Pouiller@silabs.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: authentication-results: spf=none (sender IP is ) smtp.mailfrom=Jerome.Pouiller@silabs.com; x-originating-ip: [37.71.187.125] x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: 39e1c97d-04f4-4b51-eb9c-08d73cef7cce x-microsoft-antispam: BCL:0;PCL:0;RULEID:(2390118)(7020095)(4652040)(8989299)(5600167)(711020)(4605104)(1401327)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(2017052603328)(7193020);SRVR:MN2PR11MB3775; x-ms-traffictypediagnostic: MN2PR11MB3775: x-ms-exchange-transport-forked: True x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:8273; x-forefront-prvs: 016572D96D x-forefront-antispam-report: SFV:NSPM;SFS:(10009020)(1496009)(366004)(376002)(346002)(39850400004)(136003)(396003)(199004)(189003)(86362001)(256004)(14444005)(8936002)(4326008)(66066001)(36756003)(14454004)(305945005)(64756008)(5660300002)(66476007)(66556008)(66446008)(316002)(476003)(446003)(11346002)(110136005)(2616005)(66946007)(478600001)(91956017)(25786009)(76116006)(7736002)(71190400001)(81166006)(1076003)(30864003)(2501003)(6506007)(186003)(6436002)(486006)(81156014)(3846002)(6116002)(8676002)(102836004)(107886003)(54906003)(76176011)(2906002)(26005)(66574012)(99286004)(6486002)(71200400001)(6512007);DIR:OUT;SFP:1101;SCL:1;SRVR:MN2PR11MB3775;H:MN2PR11MB4063.namprd11.prod.outlook.com;FPR:;SPF:None;LANG:en;PTR:InfoNoRecords;A:1;MX:1; received-spf: None (protection.outlook.com: silabs.com does not designate permitted sender hosts) x-ms-exchange-senderadcheck: 1 x-microsoft-antispam-message-info: uxnj9qqAs3HQ0PyQn4sY+UfY/G71eQngeVL3OA+JcVMYeyH/4zS58GE5GKJGSWpRcuFtrgDjVALsNfaNZN9c+4MQdFIx0yrQiVc0HgWtapnGDE1K5wmUmAz2cPX+ioh2My83poMtXKbLt/YMnvd2/keBBG0L0Op9QJv11YeYsvX2QFp/BiPorqqxA8UEO1Pjro82IyKlstKJKj6faTY2c/okUcxgJo6WbkJfwtlXTJ4Lt1t5moa9o5cLcZ0r7JGU0DorkoT1yM/1ftaJ4J0tiYeAC/2s73+4QwntMaED/GqxzM1v5v7lgw2YcQx6SITQz+f11b6dBGWC85FhETKO/+kZ271IAXeJMHTNg4k7sLR5pVMimSccEkM9Bi+o14nf11gLOzrzzgklBG7iVhc8hzZY/KuUc+C60a7/f1zDP7Q= Content-ID: <036F09717650BC439F89A1F23AB1BF82@namprd11.prod.outlook.com> MIME-Version: 1.0 X-OriginatorOrg: silabs.com X-MS-Exchange-CrossTenant-Network-Message-Id: 39e1c97d-04f4-4b51-eb9c-08d73cef7cce X-MS-Exchange-CrossTenant-originalarrivaltime: 19 Sep 2019 10:52:37.7664 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 54dbd822-5231-4b20-944d-6f4abcd541fb X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: iqQBIPDrflc29tKbq8GUdIKowrgQDG6VSz9PLBVanM2+E/K028jrVNm/lPy3WD81W+cly8FD1BxZ/5OxZtNM4w== X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN2PR11MB3775 Sender: linux-wireless-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org From: Jérôme Pouiller bh_work() is in charge to schedule all HIF message from/to chip. On normal operation, when an IRQ is received, driver can get size of next message in control register. In order to save control register access, when chip send a message, it also appends a copy of control register after the message (this register is not accounted in message length declared in message header, but must accounted in bus request). This copy of control register is called "piggyback". It also handles a power saving mechanism specific to WFxxx series. This mechanism is based on a GPIO called "wakeup" GPIO. Obviously, this gpio is not part of SPI/SDIO standard buses and must be declared independently (this is the main reason for why SDIO mode try to get parameters from DT). When wakeup is enabled, host can communicate with chip only if it is awake. To wake up chip, there are two cases: - host receive an IRQ from chip (chip initiate communication): host just have to set wakeup GPIO before reading data - host want to send data to chip: host set wakeup GPIO, then wait for an IRQ (in fact, wait for an empty message) and finally send data bh_work() is also in charge to track usage of chip buffers. Normally each request expect a confirmation. However, you can notice that special "multi tx" confirmation can acknowledge multiple requests at time. Finally, note that wfx_bh_request_rx() is not atomic (because of control_reg_read()). So, in SPI mode, hard-irq handler only postpone all processing to wfx_spi_request_rx(). Signed-off-by: Jérôme Pouiller --- drivers/staging/wfx/Makefile | 1 + drivers/staging/wfx/bh.c | 277 +++++++++++++++++++++++++++++++++ drivers/staging/wfx/bh.h | 32 ++++ drivers/staging/wfx/bus_sdio.c | 4 +- drivers/staging/wfx/bus_spi.c | 5 + drivers/staging/wfx/main.c | 21 +++ drivers/staging/wfx/main.h | 2 + drivers/staging/wfx/wfx.h | 4 + 8 files changed, 345 insertions(+), 1 deletion(-) create mode 100644 drivers/staging/wfx/bh.c create mode 100644 drivers/staging/wfx/bh.h diff --git a/drivers/staging/wfx/Makefile b/drivers/staging/wfx/Makefile index e568d7a6fb06..1abd3115f11d 100644 --- a/drivers/staging/wfx/Makefile +++ b/drivers/staging/wfx/Makefile @@ -4,6 +4,7 @@ CFLAGS_debug.o = -I$(src) wfx-y := \ + bh.o \ hwio.o \ fwio.o \ main.o \ diff --git a/drivers/staging/wfx/bh.c b/drivers/staging/wfx/bh.c new file mode 100644 index 000000000000..02a42e5c1e10 --- /dev/null +++ b/drivers/staging/wfx/bh.c @@ -0,0 +1,277 @@ +// SPDX-License-Identifier: GPL-2.0-only +/* + * Interrupt bottom half (BH). + * + * Copyright (c) 2017-2019, Silicon Laboratories, Inc. + * Copyright (c) 2010, ST-Ericsson + */ +#include +#include + +#include "bh.h" +#include "wfx.h" +#include "hwio.h" +#include "hif_api_cmd.h" + +static void device_wakeup(struct wfx_dev *wdev) +{ + if (!wdev->pdata.gpio_wakeup) + return; + if (gpiod_get_value(wdev->pdata.gpio_wakeup)) + return; + + gpiod_set_value(wdev->pdata.gpio_wakeup, 1); + if (wfx_api_older_than(wdev, 1, 4)) { + if (!completion_done(&wdev->hif.ctrl_ready)) + udelay(2000); + } else { + // completion.h does not provide any function to wait + // completion without consume it (a kind of + // wait_for_completion_done_timeout()). So we have to emulate + // it. + if (wait_for_completion_timeout(&wdev->hif.ctrl_ready, msecs_to_jiffies(2) + 1)) + complete(&wdev->hif.ctrl_ready); + else + dev_err(wdev->dev, "timeout while wake up chip\n"); + } +} + +static void device_release(struct wfx_dev *wdev) +{ + if (!wdev->pdata.gpio_wakeup) + return; + + gpiod_set_value(wdev->pdata.gpio_wakeup, 0); +} + +static int rx_helper(struct wfx_dev *wdev, size_t read_len, int *is_cnf) +{ + struct sk_buff *skb; + struct hif_msg *hif; + size_t alloc_len; + size_t computed_len; + int release_count; + int piggyback = 0; + + WARN_ON(read_len < 4); + WARN(read_len > round_down(0xFFF, 2) * sizeof(u16), + "%s: request exceed WFx capability", __func__); + + // Add 2 to take into account piggyback size + alloc_len = wdev->hwbus_ops->align_size(wdev->hwbus_priv, read_len + 2); + skb = dev_alloc_skb(alloc_len); + if (!skb) + return -ENOMEM; + + if (wfx_data_read(wdev, skb->data, alloc_len)) + goto err; + + piggyback = le16_to_cpup((u16 *) (skb->data + alloc_len - 2)); + + hif = (struct hif_msg *) skb->data; + WARN(hif->encrypted & 0x1, "unsupported encryption type"); + if (hif->encrypted == 0x2) { + BUG(); // Not yet implemented + } else { + le16_to_cpus(hif->len); + computed_len = round_up(hif->len, 2); + } + if (computed_len != read_len) { + dev_err(wdev->dev, "inconsistent message length: %zu != %zu\n", + computed_len, read_len); + print_hex_dump(KERN_INFO, "hif: ", DUMP_PREFIX_OFFSET, 16, 1, + hif, read_len, true); + goto err; + } + + if (!(hif->id & HIF_ID_IS_INDICATION)) { + (*is_cnf)++; + if (hif->id == HIF_CNF_ID_MULTI_TRANSMIT) + release_count = le32_to_cpu(((struct hif_cnf_multi_transmit *) hif->body)->num_tx_confs); + else + release_count = 1; + WARN(wdev->hif.tx_buffers_used < release_count, "corrupted buffer counter"); + wdev->hif.tx_buffers_used -= release_count; + if (!wdev->hif.tx_buffers_used) + wake_up(&wdev->hif.tx_buffers_empty); + } + + if (hif->id != HIF_IND_ID_EXCEPTION && hif->id != HIF_IND_ID_ERROR) { + if (hif->seqnum != wdev->hif.rx_seqnum) + dev_warn(wdev->dev, "wrong message sequence: %d != %d\n", + hif->seqnum, wdev->hif.rx_seqnum); + wdev->hif.rx_seqnum = (hif->seqnum + 1) % (HIF_COUNTER_MAX + 1); + } + + skb_put(skb, hif->len); + dev_kfree_skb(skb); /* FIXME: handle received data */ + + return piggyback; + +err: + if (skb) + dev_kfree_skb(skb); + return -EIO; +} + +static int bh_work_rx(struct wfx_dev *wdev, int max_msg, int *num_cnf) +{ + size_t len; + int i; + int ctrl_reg, piggyback; + + piggyback = 0; + for (i = 0; i < max_msg; i++) { + if (piggyback & CTRL_NEXT_LEN_MASK) + ctrl_reg = piggyback; + else if (try_wait_for_completion(&wdev->hif.ctrl_ready)) + ctrl_reg = atomic_xchg(&wdev->hif.ctrl_reg, 0); + else + ctrl_reg = 0; + if (!(ctrl_reg & CTRL_NEXT_LEN_MASK)) + return i; + // ctrl_reg units are 16bits words + len = (ctrl_reg & CTRL_NEXT_LEN_MASK) * 2; + piggyback = rx_helper(wdev, len, num_cnf); + if (piggyback < 0) + return i; + if (!(piggyback & CTRL_WLAN_READY)) + dev_err(wdev->dev, "unexpected piggyback value: ready bit not set: %04x\n", + piggyback); + } + if (piggyback & CTRL_NEXT_LEN_MASK) { + ctrl_reg = atomic_xchg(&wdev->hif.ctrl_reg, piggyback); + complete(&wdev->hif.ctrl_ready); + if (ctrl_reg) + dev_err(wdev->dev, "unexpected IRQ happened: %04x/%04x\n", + ctrl_reg, piggyback); + } + return i; +} + +static void tx_helper(struct wfx_dev *wdev, struct hif_msg *hif) +{ + int ret; + void *data; + bool is_encrypted = false; + size_t len = le16_to_cpu(hif->len); + + BUG_ON(len < sizeof(*hif)); + + hif->seqnum = wdev->hif.tx_seqnum; + wdev->hif.tx_seqnum = (wdev->hif.tx_seqnum + 1) % (HIF_COUNTER_MAX + 1); + + data = hif; + WARN(len > wdev->hw_caps.size_inp_ch_buf, + "%s: request exceed WFx capability: %zu > %d\n", __func__, + len, wdev->hw_caps.size_inp_ch_buf); + len = wdev->hwbus_ops->align_size(wdev->hwbus_priv, len); + ret = wfx_data_write(wdev, data, len); + if (ret) + goto end; + + wdev->hif.tx_buffers_used++; +end: + if (is_encrypted) + kfree(data); +} + +static int bh_work_tx(struct wfx_dev *wdev, int max_msg) +{ + struct hif_msg *hif; + int i; + + for (i = 0; i < max_msg; i++) { + hif = NULL; + if (wdev->hif.tx_buffers_used < wdev->hw_caps.num_inp_ch_bufs) { + /* FIXME: get queued data */ + } + if (!hif) + return i; + tx_helper(wdev, hif); + } + return i; +} + +/* In SDIO mode, it is necessary to make an access to a register to acknowledge + * last received message. It could be possible to restrict this acknowledge to + * SDIO mode and only if last operation was rx. + */ +static void ack_sdio_data(struct wfx_dev *wdev) +{ + uint32_t cfg_reg; + + config_reg_read(wdev, &cfg_reg); + if (cfg_reg & 0xFF) { + dev_warn(wdev->dev, "chip reports errors: %02x\n", cfg_reg & 0xFF); + config_reg_write_bits(wdev, 0xFF, 0x00); + } +} + +static void bh_work(struct work_struct *work) +{ + struct wfx_dev *wdev = container_of(work, struct wfx_dev, hif.bh); + int stats_req = 0, stats_cnf = 0, stats_ind = 0; + bool release_chip = false, last_op_is_rx = false; + int num_tx, num_rx; + + device_wakeup(wdev); + do { + num_tx = bh_work_tx(wdev, 32); + stats_req += num_tx; + if (num_tx) + last_op_is_rx = false; + num_rx = bh_work_rx(wdev, 32, &stats_cnf); + stats_ind += num_rx; + if (num_rx) + last_op_is_rx = true; + } while (num_rx || num_tx); + stats_ind -= stats_cnf; + + if (last_op_is_rx) + ack_sdio_data(wdev); + if (!wdev->hif.tx_buffers_used && !work_pending(work)) { + device_release(wdev); + release_chip = true; + } +} + +/* + * An IRQ from chip did occur + */ +void wfx_bh_request_rx(struct wfx_dev *wdev) +{ + u32 cur, prev; + + control_reg_read(wdev, &cur); + prev = atomic_xchg(&wdev->hif.ctrl_reg, cur); + complete(&wdev->hif.ctrl_ready); + queue_work(system_highpri_wq, &wdev->hif.bh); + + if (!(cur & CTRL_NEXT_LEN_MASK)) + dev_err(wdev->dev, "unexpected control register value: length field is 0: %04x\n", + cur); + if (prev != 0) + dev_err(wdev->dev, "received IRQ but previous data was not (yet) read: %04x/%04x\n", + prev, cur); +} + +/* + * Driver want to send data + */ +void wfx_bh_request_tx(struct wfx_dev *wdev) +{ + queue_work(system_highpri_wq, &wdev->hif.bh); +} + +void wfx_bh_register(struct wfx_dev *wdev) +{ + INIT_WORK(&wdev->hif.bh, bh_work); + init_completion(&wdev->hif.ctrl_ready); + init_waitqueue_head(&wdev->hif.tx_buffers_empty); +} + +void wfx_bh_unregister(struct wfx_dev *wdev) +{ + flush_work(&wdev->hif.bh); +} diff --git a/drivers/staging/wfx/bh.h b/drivers/staging/wfx/bh.h new file mode 100644 index 000000000000..93ca98424e0b --- /dev/null +++ b/drivers/staging/wfx/bh.h @@ -0,0 +1,32 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ +/* + * Interrupt bottom half. + * + * Copyright (c) 2017-2019, Silicon Laboratories, Inc. + * Copyright (c) 2010, ST-Ericsson + */ +#ifndef WFX_BH_H +#define WFX_BH_H + +#include +#include +#include + +struct wfx_dev; + +struct wfx_hif { + struct work_struct bh; + struct completion ctrl_ready; + wait_queue_head_t tx_buffers_empty; + atomic_t ctrl_reg; + int rx_seqnum; + int tx_seqnum; + int tx_buffers_used; +}; + +void wfx_bh_register(struct wfx_dev *wdev); +void wfx_bh_unregister(struct wfx_dev *wdev); +void wfx_bh_request_rx(struct wfx_dev *wdev); +void wfx_bh_request_tx(struct wfx_dev *wdev); + +#endif /* WFX_BH_H */ diff --git a/drivers/staging/wfx/bus_sdio.c b/drivers/staging/wfx/bus_sdio.c index 25c587fe2141..c0c063c3cfc9 100644 --- a/drivers/staging/wfx/bus_sdio.c +++ b/drivers/staging/wfx/bus_sdio.c @@ -15,6 +15,7 @@ #include "wfx.h" #include "hwio.h" #include "main.h" +#include "bh.h" static const struct wfx_platform_data wfx_sdio_pdata = { .file_fw = "wfm_wf200", @@ -90,7 +91,7 @@ static void wfx_sdio_irq_handler(struct sdio_func *func) struct wfx_sdio_priv *bus = sdio_get_drvdata(func); if (bus->core) - /* empty */; + wfx_bh_request_rx(bus->core); else WARN(!bus->core, "race condition in driver init/deinit"); } @@ -104,6 +105,7 @@ static irqreturn_t wfx_sdio_irq_handler_ext(int irq, void *priv) return IRQ_NONE; } sdio_claim_host(bus->func); + wfx_bh_request_rx(bus->core); sdio_release_host(bus->func); return IRQ_HANDLED; } diff --git a/drivers/staging/wfx/bus_spi.c b/drivers/staging/wfx/bus_spi.c index c474949a32dd..8a9aab3e7384 100644 --- a/drivers/staging/wfx/bus_spi.c +++ b/drivers/staging/wfx/bus_spi.c @@ -19,6 +19,7 @@ #include "wfx.h" #include "hwio.h" #include "main.h" +#include "bh.h" #define DETECT_INVALID_CTRL_ACCESS @@ -215,6 +216,10 @@ static irqreturn_t wfx_spi_irq_handler(int irq, void *priv) static void wfx_spi_request_rx(struct work_struct *work) { + struct wfx_spi_priv *bus = + container_of(work, struct wfx_spi_priv, request_rx); + + wfx_bh_request_rx(bus->core); } static size_t wfx_spi_align_size(void *priv, size_t size) diff --git a/drivers/staging/wfx/main.c b/drivers/staging/wfx/main.c index a8ef29174232..f0bea053a0d9 100644 --- a/drivers/staging/wfx/main.c +++ b/drivers/staging/wfx/main.c @@ -23,6 +23,7 @@ #include "fwio.h" #include "hwio.h" #include "bus.h" +#include "bh.h" #include "wfx_version.h" MODULE_DESCRIPTION("Silicon Labs 802.11 Wireless LAN driver for WFx"); @@ -30,6 +31,21 @@ MODULE_AUTHOR("Jérôme Pouiller "); MODULE_LICENSE("GPL"); MODULE_VERSION(WFX_LABEL); +static int gpio_wakeup = -2; +module_param(gpio_wakeup, int, 0644); +MODULE_PARM_DESC(gpio_wakeup, "gpio number for wakeup. -1 for none."); + +bool wfx_api_older_than(struct wfx_dev *wdev, int major, int minor) +{ + if (wdev->hw_caps.api_version_major < major) + return true; + if (wdev->hw_caps.api_version_major > major) + return false; + if (wdev->hw_caps.api_version_minor < minor) + return true; + return false; +} + struct gpio_desc *wfx_get_gpio(struct device *dev, int override, const char *label) { struct gpio_desc *ret; @@ -82,18 +98,23 @@ int wfx_probe(struct wfx_dev *wdev) { int err; + wfx_bh_register(wdev); + err = wfx_init_device(wdev); if (err) goto err1; + return 0; err1: + wfx_bh_unregister(wdev); return err; } void wfx_release(struct wfx_dev *wdev) { + wfx_bh_unregister(wdev); } static int __init wfx_core_init(void) diff --git a/drivers/staging/wfx/main.h b/drivers/staging/wfx/main.h index 8b2526d81984..f7c65999a493 100644 --- a/drivers/staging/wfx/main.h +++ b/drivers/staging/wfx/main.h @@ -20,6 +20,7 @@ struct wfx_dev; struct wfx_platform_data { /* Keyset and ".sec" extention will appended to this string */ const char *file_fw; + struct gpio_desc *gpio_wakeup; /* * if true HIF D_out is sampled on the rising edge of the clock * (intended to be used in 50Mhz SDIO) @@ -38,5 +39,6 @@ void wfx_release(struct wfx_dev *wdev); struct gpio_desc *wfx_get_gpio(struct device *dev, int override, const char *label); +bool wfx_api_older_than(struct wfx_dev *wdev, int major, int minor); #endif diff --git a/drivers/staging/wfx/wfx.h b/drivers/staging/wfx/wfx.h index 56aed33291ae..4f28938fa3a6 100644 --- a/drivers/staging/wfx/wfx.h +++ b/drivers/staging/wfx/wfx.h @@ -10,7 +10,9 @@ #ifndef WFX_H #define WFX_H +#include "bh.h" #include "main.h" +#include "hif_api_general.h" struct hwbus_ops; @@ -21,6 +23,8 @@ struct wfx_dev { void *hwbus_priv; u8 keyset; + struct hif_ind_startup hw_caps; + struct wfx_hif hif; }; #endif /* WFX_H */