summaryrefslogtreecommitdiff
path: root/drivers/net/wireless/intersil/prism54/isl_38xx.c
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2016-01-12 18:57:02 -0800
committerLinus Torvalds <torvalds@linux-foundation.org>2016-01-12 18:57:02 -0800
commitaee3bfa3307cd0da2126bdc0ea359dabea5ee8f7 (patch)
tree3d35c69e8fa835098bb90f77f30abed120681651 /drivers/net/wireless/intersil/prism54/isl_38xx.c
parentc597b6bcd5c624534afc3df65cdc42bb05173bca (diff)
parent415b6f19e87e350b13585591859d4fdf50772229 (diff)
Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/net-next
Pull networking updates from Davic Miller: 1) Support busy polling generically, for all NAPI drivers. From Eric Dumazet. 2) Add byte/packet counter support to nft_ct, from Floriani Westphal. 3) Add RSS/XPS support to mvneta driver, from Gregory Clement. 4) Implement IPV6_HDRINCL socket option for raw sockets, from Hannes Frederic Sowa. 5) Add support for T6 adapter to cxgb4 driver, from Hariprasad Shenai. 6) Add support for VLAN device bridging to mlxsw switch driver, from Ido Schimmel. 7) Add driver for Netronome NFP4000/NFP6000, from Jakub Kicinski. 8) Provide hwmon interface to mlxsw switch driver, from Jiri Pirko. 9) Reorganize wireless drivers into per-vendor directories just like we do for ethernet drivers. From Kalle Valo. 10) Provide a way for administrators "destroy" connected sockets via the SOCK_DESTROY socket netlink diag operation. From Lorenzo Colitti. 11) Add support to add/remove multicast routes via netlink, from Nikolay Aleksandrov. 12) Make TCP keepalive settings per-namespace, from Nikolay Borisov. 13) Add forwarding and packet duplication facilities to nf_tables, from Pablo Neira Ayuso. 14) Dead route support in MPLS, from Roopa Prabhu. 15) TSO support for thunderx chips, from Sunil Goutham. 16) Add driver for IBM's System i/p VNIC protocol, from Thomas Falcon. 17) Rationalize, consolidate, and more completely document the checksum offloading facilities in the networking stack. From Tom Herbert. 18) Support aborting an ongoing scan in mac80211/cfg80211, from Vidyullatha Kanchanapally. 19) Use per-bucket spinlock for bpf hash facility, from Tom Leiming. * git://git.kernel.org/pub/scm/linux/kernel/git/davem/net-next: (1375 commits) net: bnxt: always return values from _bnxt_get_max_rings net: bpf: reject invalid shifts phonet: properly unshare skbs in phonet_rcv() dwc_eth_qos: Fix dma address for multi-fragment skbs phy: remove an unneeded condition mdio: remove an unneed condition mdio_bus: NULL dereference on allocation error net: Fix typo in netdev_intersect_features net: freescale: mac-fec: Fix build error from phy_device API change net: freescale: ucc_geth: Fix build error from phy_device API change bonding: Prevent IPv6 link local address on enslaved devices IB/mlx5: Add flow steering support net/mlx5_core: Export flow steering API net/mlx5_core: Make ipv4/ipv6 location more clear net/mlx5_core: Enable flow steering support for the IB driver net/mlx5_core: Initialize namespaces only when supported by device net/mlx5_core: Set priority attributes net/mlx5_core: Connect flow tables net/mlx5_core: Introduce modify flow table command net/mlx5_core: Managing root flow table ...
Diffstat (limited to 'drivers/net/wireless/intersil/prism54/isl_38xx.c')
-rw-r--r--drivers/net/wireless/intersil/prism54/isl_38xx.c255
1 files changed, 255 insertions, 0 deletions
diff --git a/drivers/net/wireless/intersil/prism54/isl_38xx.c b/drivers/net/wireless/intersil/prism54/isl_38xx.c
new file mode 100644
index 000000000000..333c1a2f882e
--- /dev/null
+++ b/drivers/net/wireless/intersil/prism54/isl_38xx.c
@@ -0,0 +1,255 @@
+/*
+ * Copyright (C) 2002 Intersil Americas Inc.
+ * Copyright (C) 2003-2004 Luis R. Rodriguez <mcgrof@ruslug.rutgers.edu>_
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+#include <linux/module.h>
+#include <linux/types.h>
+#include <linux/delay.h>
+
+#include <asm/uaccess.h>
+#include <asm/io.h>
+
+#include "prismcompat.h"
+#include "isl_38xx.h"
+#include "islpci_dev.h"
+#include "islpci_mgt.h"
+
+/******************************************************************************
+ Device Interface & Control functions
+******************************************************************************/
+
+/**
+ * isl38xx_disable_interrupts - disable all interrupts
+ * @device: pci memory base address
+ *
+ * Instructs the device to disable all interrupt reporting by asserting
+ * the IRQ line. New events may still show up in the interrupt identification
+ * register located at offset %ISL38XX_INT_IDENT_REG.
+ */
+void
+isl38xx_disable_interrupts(void __iomem *device)
+{
+ isl38xx_w32_flush(device, 0x00000000, ISL38XX_INT_EN_REG);
+ udelay(ISL38XX_WRITEIO_DELAY);
+}
+
+void
+isl38xx_handle_sleep_request(isl38xx_control_block *control_block,
+ int *powerstate, void __iomem *device_base)
+{
+ /* device requests to go into sleep mode
+ * check whether the transmit queues for data and management are empty */
+ if (isl38xx_in_queue(control_block, ISL38XX_CB_TX_DATA_LQ))
+ /* data tx queue not empty */
+ return;
+
+ if (isl38xx_in_queue(control_block, ISL38XX_CB_TX_MGMTQ))
+ /* management tx queue not empty */
+ return;
+
+ /* check also whether received frames are pending */
+ if (isl38xx_in_queue(control_block, ISL38XX_CB_RX_DATA_LQ))
+ /* data rx queue not empty */
+ return;
+
+ if (isl38xx_in_queue(control_block, ISL38XX_CB_RX_MGMTQ))
+ /* management rx queue not empty */
+ return;
+
+#if VERBOSE > SHOW_ERROR_MESSAGES
+ DEBUG(SHOW_TRACING, "Device going to sleep mode\n");
+#endif
+
+ /* all queues are empty, allow the device to go into sleep mode */
+ *powerstate = ISL38XX_PSM_POWERSAVE_STATE;
+
+ /* assert the Sleep interrupt in the Device Interrupt Register */
+ isl38xx_w32_flush(device_base, ISL38XX_DEV_INT_SLEEP,
+ ISL38XX_DEV_INT_REG);
+ udelay(ISL38XX_WRITEIO_DELAY);
+}
+
+void
+isl38xx_handle_wakeup(isl38xx_control_block *control_block,
+ int *powerstate, void __iomem *device_base)
+{
+ /* device is in active state, update the powerstate flag */
+ *powerstate = ISL38XX_PSM_ACTIVE_STATE;
+
+ /* now check whether there are frames pending for the card */
+ if (!isl38xx_in_queue(control_block, ISL38XX_CB_TX_DATA_LQ)
+ && !isl38xx_in_queue(control_block, ISL38XX_CB_TX_MGMTQ))
+ return;
+
+#if VERBOSE > SHOW_ERROR_MESSAGES
+ DEBUG(SHOW_ANYTHING, "Wake up handler trigger the device\n");
+#endif
+
+ /* either data or management transmit queue has a frame pending
+ * trigger the device by setting the Update bit in the Device Int reg */
+ isl38xx_w32_flush(device_base, ISL38XX_DEV_INT_UPDATE,
+ ISL38XX_DEV_INT_REG);
+ udelay(ISL38XX_WRITEIO_DELAY);
+}
+
+void
+isl38xx_trigger_device(int asleep, void __iomem *device_base)
+{
+ u32 reg;
+
+#if VERBOSE > SHOW_ERROR_MESSAGES
+ u32 counter = 0;
+ struct timeval current_time;
+ DEBUG(SHOW_FUNCTION_CALLS, "isl38xx trigger device\n");
+#endif
+
+ /* check whether the device is in power save mode */
+ if (asleep) {
+ /* device is in powersave, trigger the device for wakeup */
+#if VERBOSE > SHOW_ERROR_MESSAGES
+ do_gettimeofday(&current_time);
+ DEBUG(SHOW_TRACING, "%08li.%08li Device wakeup triggered\n",
+ current_time.tv_sec, (long)current_time.tv_usec);
+
+ DEBUG(SHOW_TRACING, "%08li.%08li Device register read %08x\n",
+ current_time.tv_sec, (long)current_time.tv_usec,
+ readl(device_base + ISL38XX_CTRL_STAT_REG));
+#endif
+
+ reg = readl(device_base + ISL38XX_INT_IDENT_REG);
+ if (reg == 0xabadface) {
+#if VERBOSE > SHOW_ERROR_MESSAGES
+ do_gettimeofday(&current_time);
+ DEBUG(SHOW_TRACING,
+ "%08li.%08li Device register abadface\n",
+ current_time.tv_sec, (long)current_time.tv_usec);
+#endif
+ /* read the Device Status Register until Sleepmode bit is set */
+ while (reg = readl(device_base + ISL38XX_CTRL_STAT_REG),
+ (reg & ISL38XX_CTRL_STAT_SLEEPMODE) == 0) {
+ udelay(ISL38XX_WRITEIO_DELAY);
+#if VERBOSE > SHOW_ERROR_MESSAGES
+ counter++;
+#endif
+ }
+
+#if VERBOSE > SHOW_ERROR_MESSAGES
+ DEBUG(SHOW_TRACING,
+ "%08li.%08li Device register read %08x\n",
+ current_time.tv_sec, (long)current_time.tv_usec,
+ readl(device_base + ISL38XX_CTRL_STAT_REG));
+ do_gettimeofday(&current_time);
+ DEBUG(SHOW_TRACING,
+ "%08li.%08li Device asleep counter %i\n",
+ current_time.tv_sec, (long)current_time.tv_usec,
+ counter);
+#endif
+ }
+ /* assert the Wakeup interrupt in the Device Interrupt Register */
+ isl38xx_w32_flush(device_base, ISL38XX_DEV_INT_WAKEUP,
+ ISL38XX_DEV_INT_REG);
+
+#if VERBOSE > SHOW_ERROR_MESSAGES
+ udelay(ISL38XX_WRITEIO_DELAY);
+
+ /* perform another read on the Device Status Register */
+ reg = readl(device_base + ISL38XX_CTRL_STAT_REG);
+ do_gettimeofday(&current_time);
+ DEBUG(SHOW_TRACING, "%08li.%08li Device register read %08x\n",
+ current_time.tv_sec, (long)current_time.tv_usec, reg);
+#endif
+ } else {
+ /* device is (still) awake */
+#if VERBOSE > SHOW_ERROR_MESSAGES
+ DEBUG(SHOW_TRACING, "Device is in active state\n");
+#endif
+ /* trigger the device by setting the Update bit in the Device Int reg */
+
+ isl38xx_w32_flush(device_base, ISL38XX_DEV_INT_UPDATE,
+ ISL38XX_DEV_INT_REG);
+ }
+}
+
+void
+isl38xx_interface_reset(void __iomem *device_base, dma_addr_t host_address)
+{
+#if VERBOSE > SHOW_ERROR_MESSAGES
+ DEBUG(SHOW_FUNCTION_CALLS, "isl38xx_interface_reset\n");
+#endif
+
+ /* load the address of the control block in the device */
+ isl38xx_w32_flush(device_base, host_address, ISL38XX_CTRL_BLK_BASE_REG);
+ udelay(ISL38XX_WRITEIO_DELAY);
+
+ /* set the reset bit in the Device Interrupt Register */
+ isl38xx_w32_flush(device_base, ISL38XX_DEV_INT_RESET, ISL38XX_DEV_INT_REG);
+ udelay(ISL38XX_WRITEIO_DELAY);
+
+ /* enable the interrupt for detecting initialization */
+
+ /* Note: Do not enable other interrupts here. We want the
+ * device to have come up first 100% before allowing any other
+ * interrupts. */
+ isl38xx_w32_flush(device_base, ISL38XX_INT_IDENT_INIT, ISL38XX_INT_EN_REG);
+ udelay(ISL38XX_WRITEIO_DELAY); /* allow complete full reset */
+}
+
+void
+isl38xx_enable_common_interrupts(void __iomem *device_base)
+{
+ u32 reg;
+
+ reg = ISL38XX_INT_IDENT_UPDATE | ISL38XX_INT_IDENT_SLEEP |
+ ISL38XX_INT_IDENT_WAKEUP;
+ isl38xx_w32_flush(device_base, reg, ISL38XX_INT_EN_REG);
+ udelay(ISL38XX_WRITEIO_DELAY);
+}
+
+int
+isl38xx_in_queue(isl38xx_control_block *cb, int queue)
+{
+ const s32 delta = (le32_to_cpu(cb->driver_curr_frag[queue]) -
+ le32_to_cpu(cb->device_curr_frag[queue]));
+
+ /* determine the amount of fragments in the queue depending on the type
+ * of the queue, either transmit or receive */
+
+ BUG_ON(delta < 0); /* driver ptr must be ahead of device ptr */
+
+ switch (queue) {
+ /* send queues */
+ case ISL38XX_CB_TX_MGMTQ:
+ BUG_ON(delta > ISL38XX_CB_MGMT_QSIZE);
+
+ case ISL38XX_CB_TX_DATA_LQ:
+ case ISL38XX_CB_TX_DATA_HQ:
+ BUG_ON(delta > ISL38XX_CB_TX_QSIZE);
+ return delta;
+
+ /* receive queues */
+ case ISL38XX_CB_RX_MGMTQ:
+ BUG_ON(delta > ISL38XX_CB_MGMT_QSIZE);
+ return ISL38XX_CB_MGMT_QSIZE - delta;
+
+ case ISL38XX_CB_RX_DATA_LQ:
+ case ISL38XX_CB_RX_DATA_HQ:
+ BUG_ON(delta > ISL38XX_CB_RX_QSIZE);
+ return ISL38XX_CB_RX_QSIZE - delta;
+ }
+ BUG();
+ return 0;
+}