Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 256419
b: refs/heads/master
c: 4b42c54
h: refs/heads/master
i:
  256417: 06a6dd3
  256415: 6ed3509
v: v3
  • Loading branch information
John W. Linville committed Jul 11, 2011
1 parent 43c61a1 commit 70eb657
Show file tree
Hide file tree
Showing 245 changed files with 24,799 additions and 2,008 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: e2fd318e3a9208245ee1041f6d413c8593fba29d
refs/heads/master: 4b42c542afbc119c4012324ea80e0c5a89afea4f
128 changes: 128 additions & 0 deletions trunk/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 trunk/drivers/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -92,8 +92,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 trunk/drivers/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -120,3 +120,4 @@ obj-y += ieee802154/
obj-y += clk/

obj-$(CONFIG_HWSPINLOCK) += hwspinlock/
obj-$(CONFIG_NFC) += nfc/
6 changes: 6 additions & 0 deletions trunk/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 trunk/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 trunk/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 trunk/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 trunk/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");
}
1 change: 1 addition & 0 deletions trunk/drivers/bcma/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

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

MODULE_DESCRIPTION("Broadcom's specific AMBA driver");
MODULE_LICENSE("GPL");
Expand Down
4 changes: 2 additions & 2 deletions trunk/drivers/net/wireless/ath/ath5k/ahb.c
Original file line number Diff line number Diff line change
Expand Up @@ -167,8 +167,8 @@ static int ath_ahb_probe(struct platform_device *pdev)
* driver for it
*/
if (to_platform_device(sc->dev)->id == 0 &&
(bcfg->config->flags & (BD_WLAN0|BD_WLAN1)) ==
(BD_WLAN1|BD_WLAN0))
(bcfg->config->flags & (BD_WLAN0 | BD_WLAN1)) ==
(BD_WLAN1 | BD_WLAN0))
__set_bit(ATH_STAT_2G_DISABLED, sc->status);
}

Expand Down
2 changes: 1 addition & 1 deletion trunk/drivers/net/wireless/ath/ath5k/ani.c
Original file line number Diff line number Diff line change
Expand Up @@ -642,7 +642,7 @@ ath5k_ani_init(struct ath5k_hw *ah, enum ath5k_ani_mode mode)
/* initial values for our ani parameters */
if (mode == ATH5K_ANI_MODE_OFF) {
ATH5K_DBG_UNLIMIT(ah->ah_sc, ATH5K_DEBUG_ANI, "ANI off\n");
} else if (mode == ATH5K_ANI_MODE_MANUAL_LOW) {
} else if (mode == ATH5K_ANI_MODE_MANUAL_LOW) {
ATH5K_DBG_UNLIMIT(ah->ah_sc, ATH5K_DEBUG_ANI,
"ANI manual low -> high sensitivity\n");
ath5k_ani_set_noise_immunity_level(ah, 0);
Expand Down
Loading

0 comments on commit 70eb657

Please sign in to comment.