From patchwork Mon Jun 30 16:19:27 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrea Merello X-Patchwork-Id: 4452911 Return-Path: X-Original-To: patchwork-linux-wireless@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 7DF4CBEEAA for ; Mon, 30 Jun 2014 16:19:43 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 844B4202FE for ; Mon, 30 Jun 2014 16:19:42 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 9EC92202DD for ; Mon, 30 Jun 2014 16:19:41 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932176AbaF3QTj (ORCPT ); Mon, 30 Jun 2014 12:19:39 -0400 Received: from mail-we0-f182.google.com ([74.125.82.182]:63086 "EHLO mail-we0-f182.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754411AbaF3QTi (ORCPT ); Mon, 30 Jun 2014 12:19:38 -0400 Received: by mail-we0-f182.google.com with SMTP id q59so8311070wes.41 for ; Mon, 30 Jun 2014 09:19:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id; bh=2GUJLaIkU9PNoPv8YK1plKWjoNYbwWS5mq3jPPkcjsA=; b=Ja8Le9cYBOOCeygKF292E9HKxEwVeAkaDta0XyB46UTw6g8cJPs28H9mLBIrnvStaf v8QVi4wX8yC0l/7gmKBelGqMGGJ3LC815fSnmpriHMRENQOcc2z2sqGtIl1xA0T9QgxM u70/8N8TU9belCDHnGhU5lg/9BdlA8HzPAmjIEVeZ+o3DeDjy4kYTJ+djqNggRY+TcqA zI/uSNXeFdxNsVuMxZ/Fm946b8E1WNfhjXoCRB5TVOo+DFgUvX1Pa21j8I6uhdtooxmf imVOD00cot2C/Tl+qaBpVSnu6KfczDW9K7aNFqmsmz/oI+58Mqyw8He0HO3+k5aw6szc yNQQ== X-Received: by 10.180.221.108 with SMTP id qd12mr30523827wic.83.1404145177624; Mon, 30 Jun 2014 09:19:37 -0700 (PDT) Received: from localhost.localdomain (host174-123-dynamic.6-79-r.retail.telecomitalia.it. [79.6.123.174]) by mx.google.com with ESMTPSA id di7sm42231180wjb.34.2014.06.30.09.19.36 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 30 Jun 2014 09:19:37 -0700 (PDT) From: Andrea Merello To: linville@tuxdriver.com Cc: linux-wireless@vger.kernel.org, Larry.Finger@lwfinger.net, bernhard@schiffner-limbach.de, dan.carpenter@oracle.com, Andrea Merello Subject: [PATCH 6/7] rtl818x_pci: handle broken PIO mapping Date: Mon, 30 Jun 2014 18:19:27 +0200 Message-Id: <1404145167-16207-1-git-send-email-andrea.merello@gmail.com> X-Mailer: git-send-email 1.9.1 Sender: linux-wireless-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org X-Spam-Status: No, score=-6.8 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, T_DKIM_INVALID, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=ham 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 All boards supported by this driver could work using PIO or MMIO for accessing registers. This driver tries to access HW by using MMIO, and, if this fails for somewhat reason, the driver tries to fall back to PIO mode. MMIO-mode is straightforward on all boards. PIO-mode is straightforward on rtl8180 only. On rtl8185 and rtl8187se boards not all registers are directly available in PIO mode (they are paged). On rtl8185 there are two pages and it is known how to switch page. PIO mode works, except for only one access to a register out of default page, recently added by me in the initialization code with patch: rtl818x_pci: Fix rtl8185 excessive IFS after CTS-to-self This can be easily fixed to work in both cases (MMIO and PIO). On rtl8187se, for a number of reasons, there is much more work to do to fix PIO access. PIO access is currently broken on rtl8187se, and it never worked. This patch fixes the said register write for rtl8185 and makes the driver to fail cleanly if PIO mode is attempted with rtl8187se boards. While doing this, I converted also a couple of printk(KERN_ERR) to dev_err(), in order to make checkpatch happy. Signed-off-by: Andrea Merello --- drivers/net/wireless/rtl818x/rtl8180/dev.c | 24 ++++++++++++++++++++---- drivers/net/wireless/rtl818x/rtl8180/rtl8180.h | 1 + 2 files changed, 21 insertions(+), 4 deletions(-) diff --git a/drivers/net/wireless/rtl818x/rtl8180/dev.c b/drivers/net/wireless/rtl818x/rtl8180/dev.c index 5303b8f..68304a9 100644 --- a/drivers/net/wireless/rtl818x/rtl8180/dev.c +++ b/drivers/net/wireless/rtl818x/rtl8180/dev.c @@ -878,7 +878,15 @@ static int rtl8180_init_hw(struct ieee80211_hw *dev) rtl818x_iowrite8(priv, &priv->map->CONFIG3, reg | (1 << 2)); rtl818x_iowrite8(priv, &priv->map->EEPROM_CMD, RTL818X_EEPROM_CMD_NORMAL); /* fix eccessive IFS after CTS-to-self */ - rtl818x_iowrite8(priv, REG_ADDR1(0x1ff), 0x35); + if (priv->map_pio) { + u8 reg; + + reg = rtl818x_ioread8(priv, &priv->map->PGSELECT); + rtl818x_iowrite8(priv, &priv->map->PGSELECT, reg | 1); + rtl818x_iowrite8(priv, REG_ADDR1(0xff), 0x35); + rtl818x_iowrite8(priv, &priv->map->PGSELECT, reg); + } else + rtl818x_iowrite8(priv, REG_ADDR1(0x1ff), 0x35); } if (priv->chip_family == RTL818X_CHIP_FAMILY_RTL8187SE) { @@ -1739,13 +1747,15 @@ static int rtl8180_probe(struct pci_dev *pdev, SET_IEEE80211_DEV(dev, &pdev->dev); pci_set_drvdata(pdev, dev); + priv->map_pio = false; priv->map = pci_iomap(pdev, 1, mem_len); - if (!priv->map) + if (!priv->map) { priv->map = pci_iomap(pdev, 0, io_len); + priv->map_pio = true; + } if (!priv->map) { - printk(KERN_ERR "%s (rtl8180): Cannot map device memory\n", - pci_name(pdev)); + dev_err(&pdev->dev, "Cannot map device memory/PIO\n"); goto err_free_dev; } @@ -1794,6 +1804,12 @@ static int rtl8180_probe(struct pci_dev *pdev, case RTL818X_TX_CONF_RTL8187SE: chip_name = "RTL8187SE"; + if (priv->map_pio) { + dev_err(&pdev->dev, + "MMIO failed. PIO not supported on RTL8187SE\n"); + err = -ENOMEM; + goto err_iounmap; + } priv->chip_family = RTL818X_CHIP_FAMILY_RTL8187SE; break; diff --git a/drivers/net/wireless/rtl818x/rtl8180/rtl8180.h b/drivers/net/wireless/rtl818x/rtl8180/rtl8180.h index 291a559..e8243a4 100644 --- a/drivers/net/wireless/rtl818x/rtl8180/rtl8180.h +++ b/drivers/net/wireless/rtl818x/rtl8180/rtl8180.h @@ -107,6 +107,7 @@ struct rtl8180_priv { struct ieee80211_vif *vif; /* rtl8180 driver specific */ + bool map_pio; spinlock_t lock; void *rx_ring; u8 rx_ring_sz;