Skip to content

Commit

Permalink
Merge branch 'master' of git://git.kernel.org/pub/scm/linux/kernel/gi…
Browse files Browse the repository at this point in the history
…t/linville/wireless-next-2.6 into for-davem
  • Loading branch information
linvjw committed Jul 8, 2011
2 parents 31817df + 5f0dd29 commit 204d164
Show file tree
Hide file tree
Showing 124 changed files with 6,268 additions and 1,033 deletions.
128 changes: 128 additions & 0 deletions Documentation/networking/nfc.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,128 @@
Linux NFC subsystem
===================

The Near Field Communication (NFC) subsystem is required to standardize the
NFC device drivers development and to create an unified userspace interface.

This document covers the architecture overview, the device driver interface
description and the userspace interface description.

Architecture overview
---------------------

The NFC subsystem is responsible for:
- NFC adapters management;
- Polling for targets;
- Low-level data exchange;

The subsystem is divided in some parts. The 'core' is responsible for
providing the device driver interface. On the other side, it is also
responsible for providing an interface to control operations and low-level
data exchange.

The control operations are available to userspace via generic netlink.

The low-level data exchange interface is provided by the new socket family
PF_NFC. The NFC_SOCKPROTO_RAW performs raw communication with NFC targets.


+--------------------------------------+
| USER SPACE |
+--------------------------------------+
^ ^
| low-level | control
| data exchange | operations
| |
| v
| +-----------+
| AF_NFC | netlink |
| socket +-----------+
| raw ^
| |
v v
+---------+ +-----------+
| rawsock | <--------> | core |
+---------+ +-----------+
^
|
v
+-----------+
| driver |
+-----------+

Device Driver Interface
-----------------------

When registering on the NFC subsystem, the device driver must inform the core
of the set of supported NFC protocols and the set of ops callbacks. The ops
callbacks that must be implemented are the following:

* start_poll - setup the device to poll for targets
* stop_poll - stop on progress polling operation
* activate_target - select and initialize one of the targets found
* deactivate_target - deselect and deinitialize the selected target
* data_exchange - send data and receive the response (transceive operation)

Userspace interface
--------------------

The userspace interface is divided in control operations and low-level data
exchange operation.

CONTROL OPERATIONS:

Generic netlink is used to implement the interface to the control operations.
The operations are composed by commands and events, all listed below:

* NFC_CMD_GET_DEVICE - get specific device info or dump the device list
* NFC_CMD_START_POLL - setup a specific device to polling for targets
* NFC_CMD_STOP_POLL - stop the polling operation in a specific device
* NFC_CMD_GET_TARGET - dump the list of targets found by a specific device

* NFC_EVENT_DEVICE_ADDED - reports an NFC device addition
* NFC_EVENT_DEVICE_REMOVED - reports an NFC device removal
* NFC_EVENT_TARGETS_FOUND - reports START_POLL results when 1 or more targets
are found

The user must call START_POLL to poll for NFC targets, passing the desired NFC
protocols through NFC_ATTR_PROTOCOLS attribute. The device remains in polling
state until it finds any target. However, the user can stop the polling
operation by calling STOP_POLL command. In this case, it will be checked if
the requester of STOP_POLL is the same of START_POLL.

If the polling operation finds one or more targets, the event TARGETS_FOUND is
sent (including the device id). The user must call GET_TARGET to get the list of
all targets found by such device. Each reply message has target attributes with
relevant information such as the supported NFC protocols.

All polling operations requested through one netlink socket are stopped when
it's closed.

LOW-LEVEL DATA EXCHANGE:

The userspace must use PF_NFC sockets to perform any data communication with
targets. All NFC sockets use AF_NFC:

struct sockaddr_nfc {
sa_family_t sa_family;
__u32 dev_idx;
__u32 target_idx;
__u32 nfc_protocol;
};

To establish a connection with one target, the user must create an
NFC_SOCKPROTO_RAW socket and call the 'connect' syscall with the sockaddr_nfc
struct correctly filled. All information comes from NFC_EVENT_TARGETS_FOUND
netlink event. As a target can support more than one NFC protocol, the user
must inform which protocol it wants to use.

Internally, 'connect' will result in an activate_target call to the driver.
When the socket is closed, the target is deactivated.

The data format exchanged through the sockets is NFC protocol dependent. For
instance, when communicating with MIFARE tags, the data exchanged are MIFARE
commands and their responses.

The first received package is the response to the first sent package and so
on. In order to allow valid "empty" responses, every data received has a NULL
header of 1 byte.
2 changes: 0 additions & 2 deletions drivers/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -94,8 +94,6 @@ source "drivers/memstick/Kconfig"

source "drivers/leds/Kconfig"

source "drivers/nfc/Kconfig"

source "drivers/accessibility/Kconfig"

source "drivers/infiniband/Kconfig"
Expand Down
1 change: 1 addition & 0 deletions drivers/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -122,3 +122,4 @@ obj-y += ieee802154/
obj-y += clk/

obj-$(CONFIG_HWSPINLOCK) += hwspinlock/
obj-$(CONFIG_NFC) += nfc/
6 changes: 6 additions & 0 deletions drivers/bcma/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,12 @@ config BCMA_HOST_PCI
bool "Support for BCMA on PCI-host bus"
depends on BCMA_HOST_PCI_POSSIBLE

config BCMA_DRIVER_PCI_HOSTMODE
bool "Driver for PCI core working in hostmode"
depends on BCMA && MIPS
help
PCI core hostmode operation (external PCI bus).

config BCMA_DEBUG
bool "BCMA debugging"
depends on BCMA
Expand Down
1 change: 1 addition & 0 deletions drivers/bcma/Makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
bcma-y += main.o scan.o core.o sprom.o
bcma-y += driver_chipcommon.o driver_chipcommon_pmu.o
bcma-y += driver_pci.o
bcma-$(CONFIG_BCMA_DRIVER_PCI_HOSTMODE) += driver_pci_host.o
bcma-$(CONFIG_BCMA_HOST_PCI) += host_pci.o
obj-$(CONFIG_BCMA) += bcma.o

Expand Down
4 changes: 4 additions & 0 deletions drivers/bcma/bcma_private.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,8 @@ extern int __init bcma_host_pci_init(void);
extern void __exit bcma_host_pci_exit(void);
#endif /* CONFIG_BCMA_HOST_PCI */

#ifdef CONFIG_BCMA_DRIVER_PCI_HOSTMODE
void bcma_core_pci_hostmode_init(struct bcma_drv_pci *pc);
#endif /* CONFIG_BCMA_DRIVER_PCI_HOSTMODE */

#endif
38 changes: 37 additions & 1 deletion drivers/bcma/driver_pci.c
Original file line number Diff line number Diff line change
Expand Up @@ -157,11 +157,47 @@ static void bcma_pcicore_serdes_workaround(struct bcma_drv_pci *pc)
* Init.
**************************************************/

void bcma_core_pci_init(struct bcma_drv_pci *pc)
static void bcma_core_pci_clientmode_init(struct bcma_drv_pci *pc)
{
bcma_pcicore_serdes_workaround(pc);
}

static bool bcma_core_pci_is_in_hostmode(struct bcma_drv_pci *pc)
{
struct bcma_bus *bus = pc->core->bus;
u16 chipid_top;

chipid_top = (bus->chipinfo.id & 0xFF00);
if (chipid_top != 0x4700 &&
chipid_top != 0x5300)
return false;

if (bus->sprom.boardflags_lo & SSB_PCICORE_BFL_NOPCI)
return false;

#if 0
/* TODO: on BCMA we use address from EROM instead of magic formula */
u32 tmp;
return !mips_busprobe32(tmp, (bus->mmio +
(pc->core->core_index * BCMA_CORE_SIZE)));
#endif

return true;
}

void bcma_core_pci_init(struct bcma_drv_pci *pc)
{
if (bcma_core_pci_is_in_hostmode(pc)) {
#ifdef CONFIG_BCMA_DRIVER_PCI_HOSTMODE
bcma_core_pci_hostmode_init(pc);
#else
pr_err("Driver compiled without support for hostmode PCI\n");
#endif /* CONFIG_BCMA_DRIVER_PCI_HOSTMODE */
} else {
bcma_core_pci_clientmode_init(pc);
}
}

int bcma_core_pci_irq_ctl(struct bcma_drv_pci *pc, struct bcma_device *core,
bool enable)
{
Expand Down
14 changes: 14 additions & 0 deletions drivers/bcma/driver_pci_host.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
/*
* Broadcom specific AMBA
* PCI Core in hostmode
*
* Licensed under the GNU/GPL. See COPYING for details.
*/

#include "bcma_private.h"
#include <linux/bcma/bcma.h>

void bcma_core_pci_hostmode_init(struct bcma_drv_pci *pc)
{
pr_err("No support for PCI core in hostmode yet\n");
}
3 changes: 2 additions & 1 deletion drivers/net/wireless/ath/carl9170/carl9170.h
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,8 @@

#define PAYLOAD_MAX (CARL9170_MAX_CMD_LEN / 4 - 1)

static const u8 ar9170_qmap[__AR9170_NUM_TXQ] = { 3, 2, 1, 0 };

enum carl9170_rf_init_mode {
CARL9170_RFI_NONE,
CARL9170_RFI_WARM,
Expand Down Expand Up @@ -440,7 +442,6 @@ struct ar9170 {
enum carl9170_ps_off_override_reasons {
PS_OFF_VIF = BIT(0),
PS_OFF_BCN = BIT(1),
PS_OFF_5GHZ = BIT(2),
};

struct carl9170_ba_stats {
Expand Down
2 changes: 1 addition & 1 deletion drivers/net/wireless/ath/carl9170/fw.c
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@ static int carl9170_fw(struct ar9170 *ar, const __u8 *data, size_t len)
ar->disable_offload = true;
}

if (SUPP(CARL9170FW_PSM))
if (SUPP(CARL9170FW_PSM) && SUPP(CARL9170FW_FIXED_5GHZ_PSM))
ar->hw->flags |= IEEE80211_HW_SUPPORTS_PS;

if (!SUPP(CARL9170FW_USB_INIT_FIRMWARE)) {
Expand Down
19 changes: 18 additions & 1 deletion drivers/net/wireless/ath/carl9170/fwcmd.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* Firmware command interface definitions
*
* Copyright 2008, Johannes Berg <[email protected]>
* Copyright 2009, 2010, Christian Lamparter <[email protected]>
* Copyright 2009-2011 Christian Lamparter <[email protected]>
*
* 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
Expand Down Expand Up @@ -54,6 +54,7 @@ enum carl9170_cmd_oids {
CARL9170_CMD_BCN_CTRL = 0x05,
CARL9170_CMD_READ_TSF = 0x06,
CARL9170_CMD_RX_FILTER = 0x07,
CARL9170_CMD_WOL = 0x08,

/* CAM */
CARL9170_CMD_EKEY = 0x10,
Expand Down Expand Up @@ -180,6 +181,21 @@ struct carl9170_bcn_ctrl_cmd {
#define CARL9170_BCN_CTRL_DRAIN 0
#define CARL9170_BCN_CTRL_CAB_TRIGGER 1

struct carl9170_wol_cmd {
__le32 flags;
u8 mac[6];
u8 bssid[6];
__le32 null_interval;
__le32 free_for_use2;
__le32 mask;
u8 pattern[32];
} __packed;

#define CARL9170_WOL_CMD_SIZE 60

#define CARL9170_WOL_DISCONNECT 1
#define CARL9170_WOL_MAGIC_PKT 2

struct carl9170_cmd_head {
union {
struct {
Expand All @@ -203,6 +219,7 @@ struct carl9170_cmd {
struct carl9170_write_reg wreg;
struct carl9170_rf_init rf_init;
struct carl9170_psm psm;
struct carl9170_wol_cmd wol;
struct carl9170_bcn_ctrl_cmd bcn_ctrl;
struct carl9170_rx_filter_cmd rx_filter;
u8 data[CARL9170_MAX_CMD_PAYLOAD_LEN];
Expand Down
18 changes: 16 additions & 2 deletions drivers/net/wireless/ath/carl9170/fwdesc.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
*
* Firmware descriptor format
*
* Copyright 2009, 2010, Christian Lamparter <[email protected]>
* Copyright 2009-2011 Christian Lamparter <[email protected]>
*
* 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
Expand Down Expand Up @@ -72,6 +72,9 @@ enum carl9170fw_feature_list {
/* Wake up on WLAN */
CARL9170FW_WOL,

/* Firmware supports PSM in the 5GHZ Band */
CARL9170FW_FIXED_5GHZ_PSM,

/* KEEP LAST */
__CARL9170FW_FEATURE_NUM
};
Expand All @@ -82,6 +85,7 @@ enum carl9170fw_feature_list {
#define DBG_MAGIC "DBG\0"
#define CHK_MAGIC "CHK\0"
#define TXSQ_MAGIC "TXSQ"
#define WOL_MAGIC "WOL\0"
#define LAST_MAGIC "LAST"

#define CARL9170FW_SET_DAY(d) (((d) - 1) % 31)
Expand All @@ -104,7 +108,7 @@ struct carl9170fw_desc_head {
(sizeof(struct carl9170fw_desc_head))

#define CARL9170FW_OTUS_DESC_MIN_VER 6
#define CARL9170FW_OTUS_DESC_CUR_VER 6
#define CARL9170FW_OTUS_DESC_CUR_VER 7
struct carl9170fw_otus_desc {
struct carl9170fw_desc_head head;
__le32 feature_set;
Expand Down Expand Up @@ -186,6 +190,16 @@ struct carl9170fw_txsq_desc {
#define CARL9170FW_TXSQ_DESC_SIZE \
(sizeof(struct carl9170fw_txsq_desc))

#define CARL9170FW_WOL_DESC_MIN_VER 1
#define CARL9170FW_WOL_DESC_CUR_VER 1
struct carl9170fw_wol_desc {
struct carl9170fw_desc_head head;

__le32 supported_triggers; /* CARL9170_WOL_ */
} __packed;
#define CARL9170FW_WOL_DESC_SIZE \
(sizeof(struct carl9170fw_wol_desc))

#define CARL9170FW_LAST_DESC_MIN_VER 1
#define CARL9170FW_LAST_DESC_CUR_VER 2
struct carl9170fw_last_desc {
Expand Down
15 changes: 13 additions & 2 deletions drivers/net/wireless/ath/carl9170/hw.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* Register map, hardware-specific definitions
*
* Copyright 2008, Johannes Berg <[email protected]>
* Copyright 2009, 2010, Christian Lamparter <[email protected]>
* Copyright 2009-2011 Christian Lamparter <[email protected]>
*
* 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
Expand Down Expand Up @@ -357,7 +357,18 @@

#define AR9170_MAC_REG_DMA_WLAN_STATUS (AR9170_MAC_REG_BASE + 0xd38)
#define AR9170_MAC_REG_DMA_STATUS (AR9170_MAC_REG_BASE + 0xd3c)

#define AR9170_MAC_REG_DMA_TXQ_LAST_ADDR (AR9170_MAC_REG_BASE + 0xd40)
#define AR9170_MAC_REG_DMA_TXQ0_LAST_ADDR (AR9170_MAC_REG_BASE + 0xd40)
#define AR9170_MAC_REG_DMA_TXQ1_LAST_ADDR (AR9170_MAC_REG_BASE + 0xd44)
#define AR9170_MAC_REG_DMA_TXQ2_LAST_ADDR (AR9170_MAC_REG_BASE + 0xd48)
#define AR9170_MAC_REG_DMA_TXQ3_LAST_ADDR (AR9170_MAC_REG_BASE + 0xd4c)
#define AR9170_MAC_REG_DMA_TXQ4_LAST_ADDR (AR9170_MAC_REG_BASE + 0xd50)
#define AR9170_MAC_REG_DMA_TXQ0Q1_LEN (AR9170_MAC_REG_BASE + 0xd54)
#define AR9170_MAC_REG_DMA_TXQ2Q3_LEN (AR9170_MAC_REG_BASE + 0xd58)
#define AR9170_MAC_REG_DMA_TXQ4_LEN (AR9170_MAC_REG_BASE + 0xd5c)

#define AR9170_MAC_REG_DMA_TXQX_LAST_ADDR (AR9170_MAC_REG_BASE + 0xd74)
#define AR9170_MAC_REG_DMA_TXQX_FAIL_ADDR (AR9170_MAC_REG_BASE + 0xd78)
#define AR9170_MAC_REG_TXRX_MPI (AR9170_MAC_REG_BASE + 0xd7c)
#define AR9170_MAC_TXRX_MPI_TX_MPI_MASK 0x0000000f
#define AR9170_MAC_TXRX_MPI_TX_TO_MASK 0x0000fff0
Expand Down
Loading

0 comments on commit 204d164

Please sign in to comment.