Merge branch 'for-upstream' of git://git.kernel.org/pub/scm/linux/kernel/git/dvrabel/uwb

* 'for-upstream' of git://git.kernel.org/pub/scm/linux/kernel/git/dvrabel/uwb: (47 commits)
  uwb: wrong sizeof argument in mac address compare
  uwb: don't use printk_ratelimit() so often
  uwb: use kcalloc where appropriate
  uwb: use time_after() when purging stale beacons
  uwb: add credits for the original developers of the UWB/WUSB/WLP subsystems
  uwb: add entries in the MAINTAINERS file
  uwb: depend on EXPERIMENTAL
  wusb: wusb-cbaf (CBA driver) sysfs ABI simplification
  uwb: document UWB and WUSB sysfs files
  uwb: add symlinks in sysfs between radio controllers and PALs
  uwb: dont tranmit identification IEs
  uwb: i1480/GUWA100U: fix firmware download issues
  uwb: i1480: remove MAC/PHY information checking function
  uwb: add Intel i1480 HWA to the UWB RC quirk table
  uwb: disable command/event filtering for D-Link DUB-1210
  uwb: initialize the debug sub-system
  uwb: Fix handling IEs with empty IE data in uwb_est_get_size()
  wusb: fix bmRequestType for Abort RPipe request
  wusb: fix error path for wusb_set_dev_addr()
  wusb: add HWA host controller driver
  ...
This commit is contained in:
Linus Torvalds
2008-10-23 08:20:34 -07:00
110 changed files with 35819 additions and 0 deletions
+1
View File
@@ -129,6 +129,7 @@ extern void bitmap_fold(unsigned long *dst, const unsigned long *orig,
extern int bitmap_find_free_region(unsigned long *bitmap, int bits, int order);
extern void bitmap_release_region(unsigned long *bitmap, int pos, int order);
extern int bitmap_allocate_region(unsigned long *bitmap, int pos, int order);
extern void bitmap_copy_le(void *dst, const unsigned long *src, int nbits);
#define BITMAP_LAST_WORD_MASK(nbits) \
( \
+271
View File
@@ -0,0 +1,271 @@
/*
* Wireless USB Wire Adapter constants and structures.
*
* Copyright (C) 2005-2006 Intel Corporation.
* Inaky Perez-Gonzalez <inaky.perez-gonzalez@intel.com>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License version
* 2 as published by the Free Software Foundation.
*
* 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, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301, USA.
*
*
* FIXME: docs
* FIXME: organize properly, group logically
*
* All the event structures are defined in uwb/spec.h, as they are
* common to the WHCI and WUSB radio control interfaces.
*
* References:
* [WUSB] Wireless Universal Serial Bus Specification, revision 1.0, ch8
*/
#ifndef __LINUX_USB_WUSB_WA_H
#define __LINUX_USB_WUSB_WA_H
/**
* Radio Command Request for the Radio Control Interface
*
* Radio Control Interface command and event codes are the same as
* WHCI, and listed in include/linux/uwb.h:UWB_RC_{CMD,EVT}_*
*/
enum {
WA_EXEC_RC_CMD = 40, /* Radio Control command Request */
};
/* Wireless Adapter Requests ([WUSB] table 8-51) */
enum {
WUSB_REQ_ADD_MMC_IE = 20,
WUSB_REQ_REMOVE_MMC_IE = 21,
WUSB_REQ_SET_NUM_DNTS = 22,
WUSB_REQ_SET_CLUSTER_ID = 23,
WUSB_REQ_SET_DEV_INFO = 24,
WUSB_REQ_GET_TIME = 25,
WUSB_REQ_SET_STREAM_IDX = 26,
WUSB_REQ_SET_WUSB_MAS = 27,
};
/* Wireless Adapter WUSB Channel Time types ([WUSB] table 8-52) */
enum {
WUSB_TIME_ADJ = 0,
WUSB_TIME_BPST = 1,
WUSB_TIME_WUSB = 2,
};
enum {
WA_ENABLE = 0x01,
WA_RESET = 0x02,
RPIPE_PAUSE = 0x1,
};
/* Responses from Get Status request ([WUSB] section 8.3.1.6) */
enum {
WA_STATUS_ENABLED = 0x01,
WA_STATUS_RESETTING = 0x02
};
enum rpipe_crs {
RPIPE_CRS_CTL = 0x01,
RPIPE_CRS_ISO = 0x02,
RPIPE_CRS_BULK = 0x04,
RPIPE_CRS_INTR = 0x08
};
/**
* RPipe descriptor ([WUSB] section 8.5.2.11)
*
* FIXME: explain rpipes
*/
struct usb_rpipe_descriptor {
u8 bLength;
u8 bDescriptorType;
__le16 wRPipeIndex;
__le16 wRequests;
__le16 wBlocks; /* rw if 0 */
__le16 wMaxPacketSize; /* rw? */
u8 bHSHubAddress; /* reserved: 0 */
u8 bHSHubPort; /* ??? FIXME ??? */
u8 bSpeed; /* rw: xfer rate 'enum uwb_phy_rate' */
u8 bDeviceAddress; /* rw: Target device address */
u8 bEndpointAddress; /* rw: Target EP address */
u8 bDataSequence; /* ro: Current Data sequence */
__le32 dwCurrentWindow; /* ro */
u8 bMaxDataSequence; /* ro?: max supported seq */
u8 bInterval; /* rw: */
u8 bOverTheAirInterval; /* rw: */
u8 bmAttribute; /* ro? */
u8 bmCharacteristics; /* ro? enum rpipe_attr, supported xsactions */
u8 bmRetryOptions; /* rw? */
__le16 wNumTransactionErrors; /* rw */
} __attribute__ ((packed));
/**
* Wire Adapter Notification types ([WUSB] sections 8.4.5 & 8.5.4)
*
* These are the notifications coming on the notification endpoint of
* an HWA and a DWA.
*/
enum wa_notif_type {
DWA_NOTIF_RWAKE = 0x91,
DWA_NOTIF_PORTSTATUS = 0x92,
WA_NOTIF_TRANSFER = 0x93,
HWA_NOTIF_BPST_ADJ = 0x94,
HWA_NOTIF_DN = 0x95,
};
/**
* Wire Adapter notification header
*
* Notifications coming from a wire adapter use a common header
* defined in [WUSB] sections 8.4.5 & 8.5.4.
*/
struct wa_notif_hdr {
u8 bLength;
u8 bNotifyType; /* enum wa_notif_type */
} __attribute__((packed));
/**
* HWA DN Received notification [(WUSB] section 8.5.4.2)
*
* The DNData is specified in WUSB1.0[7.6]. For each device
* notification we received, we just need to dispatch it.
*
* @dndata: this is really an array of notifications, but all start
* with the same header.
*/
struct hwa_notif_dn {
struct wa_notif_hdr hdr;
u8 bSourceDeviceAddr; /* from errata 2005/07 */
u8 bmAttributes;
struct wusb_dn_hdr dndata[];
} __attribute__((packed));
/* [WUSB] section 8.3.3 */
enum wa_xfer_type {
WA_XFER_TYPE_CTL = 0x80,
WA_XFER_TYPE_BI = 0x81, /* bulk/interrupt */
WA_XFER_TYPE_ISO = 0x82,
WA_XFER_RESULT = 0x83,
WA_XFER_ABORT = 0x84,
};
/* [WUSB] section 8.3.3 */
struct wa_xfer_hdr {
u8 bLength; /* 0x18 */
u8 bRequestType; /* 0x80 WA_REQUEST_TYPE_CTL */
__le16 wRPipe; /* RPipe index */
__le32 dwTransferID; /* Host-assigned ID */
__le32 dwTransferLength; /* Length of data to xfer */
u8 bTransferSegment;
} __attribute__((packed));
struct wa_xfer_ctl {
struct wa_xfer_hdr hdr;
u8 bmAttribute;
__le16 wReserved;
struct usb_ctrlrequest baSetupData;
} __attribute__((packed));
struct wa_xfer_bi {
struct wa_xfer_hdr hdr;
u8 bReserved;
__le16 wReserved;
} __attribute__((packed));
struct wa_xfer_hwaiso {
struct wa_xfer_hdr hdr;
u8 bReserved;
__le16 wPresentationTime;
__le32 dwNumOfPackets;
/* FIXME: u8 pktdata[]? */
} __attribute__((packed));
/* [WUSB] section 8.3.3.5 */
struct wa_xfer_abort {
u8 bLength;
u8 bRequestType;
__le16 wRPipe; /* RPipe index */
__le32 dwTransferID; /* Host-assigned ID */
} __attribute__((packed));
/**
* WA Transfer Complete notification ([WUSB] section 8.3.3.3)
*
*/
struct wa_notif_xfer {
struct wa_notif_hdr hdr;
u8 bEndpoint;
u8 Reserved;
} __attribute__((packed));
/** Transfer result basic codes [WUSB] table 8-15 */
enum {
WA_XFER_STATUS_SUCCESS,
WA_XFER_STATUS_HALTED,
WA_XFER_STATUS_DATA_BUFFER_ERROR,
WA_XFER_STATUS_BABBLE,
WA_XFER_RESERVED,
WA_XFER_STATUS_NOT_FOUND,
WA_XFER_STATUS_INSUFFICIENT_RESOURCE,
WA_XFER_STATUS_TRANSACTION_ERROR,
WA_XFER_STATUS_ABORTED,
WA_XFER_STATUS_RPIPE_NOT_READY,
WA_XFER_INVALID_FORMAT,
WA_XFER_UNEXPECTED_SEGMENT_NUMBER,
WA_XFER_STATUS_RPIPE_TYPE_MISMATCH,
};
/** [WUSB] section 8.3.3.4 */
struct wa_xfer_result {
struct wa_notif_hdr hdr;
__le32 dwTransferID;
__le32 dwTransferLength;
u8 bTransferSegment;
u8 bTransferStatus;
__le32 dwNumOfPackets;
} __attribute__((packed));
/**
* Wire Adapter Class Descriptor ([WUSB] section 8.5.2.7).
*
* NOTE: u16 fields are read Little Endian from the hardware.
*
* @bNumPorts is the original max number of devices that the host can
* connect; we might chop this so the stack can handle
* it. In case you need to access it, use wusbhc->ports_max
* if it is a Wireless USB WA.
*/
struct usb_wa_descriptor {
u8 bLength;
u8 bDescriptorType;
u16 bcdWAVersion;
u8 bNumPorts; /* don't use!! */
u8 bmAttributes; /* Reserved == 0 */
u16 wNumRPipes;
u16 wRPipeMaxBlock;
u8 bRPipeBlockSize;
u8 bPwrOn2PwrGood;
u8 bNumMMCIEs;
u8 DeviceRemovable; /* FIXME: in DWA this is up to 16 bytes */
} __attribute__((packed));
/**
* HWA Device Information Buffer (WUSB1.0[T8.54])
*/
struct hwa_dev_info {
u8 bmDeviceAvailability[32]; /* FIXME: ignored for now */
u8 bDeviceAddress;
__le16 wPHYRates;
u8 bmDeviceAttribute;
} __attribute__((packed));
#endif /* #ifndef __LINUX_USB_WUSB_WA_H */
+376
View File
@@ -0,0 +1,376 @@
/*
* Wireless USB Standard Definitions
* Event Size Tables
*
* Copyright (C) 2005-2006 Intel Corporation
* Inaky Perez-Gonzalez <inaky.perez-gonzalez@intel.com>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License version
* 2 as published by the Free Software Foundation.
*
* 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, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301, USA.
*
*
* FIXME: docs
* FIXME: organize properly, group logically
*
* All the event structures are defined in uwb/spec.h, as they are
* common to the WHCI and WUSB radio control interfaces.
*/
#ifndef __WUSB_H__
#define __WUSB_H__
#include <linux/types.h>
#include <linux/kernel.h>
#include <linux/uwb/spec.h>
#include <linux/usb/ch9.h>
#include <linux/param.h>
/**
* WUSB Information Element header
*
* I don't know why, they decided to make it different to the MBOA MAC
* IE Header; beats me.
*/
struct wuie_hdr {
u8 bLength;
u8 bIEIdentifier;
} __attribute__((packed));
enum {
WUIE_ID_WCTA = 0x80,
WUIE_ID_CONNECTACK,
WUIE_ID_HOST_INFO,
WUIE_ID_CHANGE_ANNOUNCE,
WUIE_ID_DEVICE_DISCONNECT,
WUIE_ID_HOST_DISCONNECT,
WUIE_ID_KEEP_ALIVE = 0x89,
WUIE_ID_ISOCH_DISCARD,
WUIE_ID_RESET_DEVICE,
};
/**
* Maximum number of array elements in a WUSB IE.
*
* WUSB1.0[7.5 before table 7-38] says that in WUSB IEs that
* are "arrays" have to limited to 4 elements. So we define it
* like that to ease up and submit only the neeed size.
*/
#define WUIE_ELT_MAX 4
/**
* Wrapper for the data that defines a CHID, a CDID or a CK
*
* WUSB defines that CHIDs, CDIDs and CKs are a 16 byte string of
* data. In order to avoid confusion and enforce types, we wrap it.
*
* Make it packed, as we use it in some hw defintions.
*/
struct wusb_ckhdid {
u8 data[16];
} __attribute__((packed));
const static
struct wusb_ckhdid wusb_ckhdid_zero = { .data = { 0 } };
#define WUSB_CKHDID_STRSIZE (3 * sizeof(struct wusb_ckhdid) + 1)
/**
* WUSB IE: Host Information (WUSB1.0[7.5.2])
*
* Used to provide information about the host to the Wireless USB
* devices in range (CHID can be used as an ASCII string).
*/
struct wuie_host_info {
struct wuie_hdr hdr;
__le16 attributes;
struct wusb_ckhdid CHID;
} __attribute__((packed));
/**
* WUSB IE: Connect Ack (WUSB1.0[7.5.1])
*
* Used to acknowledge device connect requests. See note for
* WUIE_ELT_MAX.
*/
struct wuie_connect_ack {
struct wuie_hdr hdr;
struct {
struct wusb_ckhdid CDID;
u8 bDeviceAddress; /* 0 means unused */
u8 bReserved;
} blk[WUIE_ELT_MAX];
} __attribute__((packed));
/**
* WUSB IE Host Information Element, Connect Availability
*
* WUSB1.0[7.5.2], bmAttributes description
*/
enum {
WUIE_HI_CAP_RECONNECT = 0,
WUIE_HI_CAP_LIMITED,
WUIE_HI_CAP_RESERVED,
WUIE_HI_CAP_ALL,
};
/**
* WUSB IE: Channel Stop (WUSB1.0[7.5.8])
*
* Tells devices the host is going to stop sending MMCs and will dissapear.
*/
struct wuie_channel_stop {
struct wuie_hdr hdr;
u8 attributes;
u8 timestamp[3];
} __attribute__((packed));
/**
* WUSB IE: Keepalive (WUSB1.0[7.5.9])
*
* Ask device(s) to send keepalives.
*/
struct wuie_keep_alive {
struct wuie_hdr hdr;
u8 bDeviceAddress[WUIE_ELT_MAX];
} __attribute__((packed));
/**
* WUSB IE: Reset device (WUSB1.0[7.5.11])
*
* Tell device to reset; in all truth, we can fit 4 CDIDs, but we only
* use it for one at the time...
*
* In any case, this request is a wee bit silly: why don't they target
* by address??
*/
struct wuie_reset {
struct wuie_hdr hdr;
struct wusb_ckhdid CDID;
} __attribute__((packed));
/**
* WUSB IE: Disconnect device (WUSB1.0[7.5.11])
*
* Tell device to disconnect; we can fit 4 addresses, but we only use
* it for one at the time...
*/
struct wuie_disconnect {
struct wuie_hdr hdr;
u8 bDeviceAddress;
u8 padding;
} __attribute__((packed));
/**
* WUSB IE: Host disconnect ([WUSB] section 7.5.5)
*
* Tells all connected devices to disconnect.
*/
struct wuie_host_disconnect {
struct wuie_hdr hdr;
} __attribute__((packed));
/**
* WUSB Device Notification header (WUSB1.0[7.6])
*/
struct wusb_dn_hdr {
u8 bType;
u8 notifdata[];
} __attribute__((packed));
/** Device Notification codes (WUSB1.0[Table 7-54]) */
enum WUSB_DN {
WUSB_DN_CONNECT = 0x01,
WUSB_DN_DISCONNECT = 0x02,
WUSB_DN_EPRDY = 0x03,
WUSB_DN_MASAVAILCHANGED = 0x04,
WUSB_DN_RWAKE = 0x05,
WUSB_DN_SLEEP = 0x06,
WUSB_DN_ALIVE = 0x07,
};
/** WUSB Device Notification Connect */
struct wusb_dn_connect {
struct wusb_dn_hdr hdr;
__le16 attributes;
struct wusb_ckhdid CDID;
} __attribute__((packed));
static inline int wusb_dn_connect_prev_dev_addr(const struct wusb_dn_connect *dn)
{
return le16_to_cpu(dn->attributes) & 0xff;
}
static inline int wusb_dn_connect_new_connection(const struct wusb_dn_connect *dn)
{
return (le16_to_cpu(dn->attributes) >> 8) & 0x1;
}
static inline int wusb_dn_connect_beacon_behavior(const struct wusb_dn_connect *dn)
{
return (le16_to_cpu(dn->attributes) >> 9) & 0x03;
}
/** Device is alive (aka: pong) (WUSB1.0[7.6.7]) */
struct wusb_dn_alive {
struct wusb_dn_hdr hdr;
} __attribute__((packed));
/** Device is disconnecting (WUSB1.0[7.6.2]) */
struct wusb_dn_disconnect {
struct wusb_dn_hdr hdr;
} __attribute__((packed));
/* General constants */
enum {
WUSB_TRUST_TIMEOUT_MS = 4000, /* [WUSB] section 4.15.1 */
};
static inline size_t ckhdid_printf(char *pr_ckhdid, size_t size,
const struct wusb_ckhdid *ckhdid)
{
return scnprintf(pr_ckhdid, size,
"%02hx %02hx %02hx %02hx %02hx %02hx %02hx %02hx "
"%02hx %02hx %02hx %02hx %02hx %02hx %02hx %02hx",
ckhdid->data[0], ckhdid->data[1],
ckhdid->data[2], ckhdid->data[3],
ckhdid->data[4], ckhdid->data[5],
ckhdid->data[6], ckhdid->data[7],
ckhdid->data[8], ckhdid->data[9],
ckhdid->data[10], ckhdid->data[11],
ckhdid->data[12], ckhdid->data[13],
ckhdid->data[14], ckhdid->data[15]);
}
/*
* WUSB Crypto stuff (WUSB1.0[6])
*/
extern const char *wusb_et_name(u8);
/**
* WUSB key index WUSB1.0[7.3.2.4], for usage when setting keys for
* the host or the device.
*/
static inline u8 wusb_key_index(int index, int type, int originator)
{
return (originator << 6) | (type << 4) | index;
}
#define WUSB_KEY_INDEX_TYPE_PTK 0 /* for HWA only */
#define WUSB_KEY_INDEX_TYPE_ASSOC 1
#define WUSB_KEY_INDEX_TYPE_GTK 2
#define WUSB_KEY_INDEX_ORIGINATOR_HOST 0
#define WUSB_KEY_INDEX_ORIGINATOR_DEVICE 1
/* A CCM Nonce, defined in WUSB1.0[6.4.1] */
struct aes_ccm_nonce {
u8 sfn[6]; /* Little Endian */
u8 tkid[3]; /* LE */
struct uwb_dev_addr dest_addr;
struct uwb_dev_addr src_addr;
} __attribute__((packed));
/* A CCM operation label, defined on WUSB1.0[6.5.x] */
struct aes_ccm_label {
u8 data[14];
} __attribute__((packed));
/*
* Input to the key derivation sequence defined in
* WUSB1.0[6.5.1]. Rest of the data is in the CCM Nonce passed to the
* PRF function.
*/
struct wusb_keydvt_in {
u8 hnonce[16];
u8 dnonce[16];
} __attribute__((packed));
/*
* Output from the key derivation sequence defined in
* WUSB1.0[6.5.1].
*/
struct wusb_keydvt_out {
u8 kck[16];
u8 ptk[16];
} __attribute__((packed));
/* Pseudo Random Function WUSB1.0[6.5] */
extern int wusb_crypto_init(void);
extern void wusb_crypto_exit(void);
extern ssize_t wusb_prf(void *out, size_t out_size,
const u8 key[16], const struct aes_ccm_nonce *_n,
const struct aes_ccm_label *a,
const void *b, size_t blen, size_t len);
static inline int wusb_prf_64(void *out, size_t out_size, const u8 key[16],
const struct aes_ccm_nonce *n,
const struct aes_ccm_label *a,
const void *b, size_t blen)
{
return wusb_prf(out, out_size, key, n, a, b, blen, 64);
}
static inline int wusb_prf_128(void *out, size_t out_size, const u8 key[16],
const struct aes_ccm_nonce *n,
const struct aes_ccm_label *a,
const void *b, size_t blen)
{
return wusb_prf(out, out_size, key, n, a, b, blen, 128);
}
static inline int wusb_prf_256(void *out, size_t out_size, const u8 key[16],
const struct aes_ccm_nonce *n,
const struct aes_ccm_label *a,
const void *b, size_t blen)
{
return wusb_prf(out, out_size, key, n, a, b, blen, 256);
}
/* Key derivation WUSB1.0[6.5.1] */
static inline int wusb_key_derive(struct wusb_keydvt_out *keydvt_out,
const u8 key[16],
const struct aes_ccm_nonce *n,
const struct wusb_keydvt_in *keydvt_in)
{
const struct aes_ccm_label a = { .data = "Pair-wise keys" };
return wusb_prf_256(keydvt_out, sizeof(*keydvt_out), key, n, &a,
keydvt_in, sizeof(*keydvt_in));
}
/*
* Out-of-band MIC Generation WUSB1.0[6.5.2]
*
* Compute the MIC over @key, @n and @hs and place it in @mic_out.
*
* @mic_out: Where to place the 8 byte MIC tag
* @key: KCK from the derivation process
* @n: CCM nonce, n->sfn == 0, TKID as established in the
* process.
* @hs: Handshake struct for phase 2 of the 4-way.
* hs->bStatus and hs->bReserved are zero.
* hs->bMessageNumber is 2 (WUSB1.0[7.3.2.5.2]
* hs->dest_addr is the device's USB address padded with 0
* hs->src_addr is the hosts's UWB device address
* hs->mic is ignored (as we compute that value).
*/
static inline int wusb_oob_mic(u8 mic_out[8], const u8 key[16],
const struct aes_ccm_nonce *n,
const struct usb_handshake *hs)
{
const struct aes_ccm_label a = { .data = "out-of-bandMIC" };
return wusb_prf_64(mic_out, 8, key, n, &a,
hs, sizeof(*hs) - sizeof(hs->MIC));
}
#endif /* #ifndef __WUSB_H__ */
+765
View File
File diff suppressed because it is too large Load Diff
+57
View File
@@ -0,0 +1,57 @@
/*
* Ultra Wide Band
* Debug interface commands
*
* Copyright (C) 2008 Cambridge Silicon Radio Ltd.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License version
* 2 as published by the Free Software Foundation.
*
* 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/>.
*/
#ifndef __LINUX__UWB__DEBUG_CMD_H__
#define __LINUX__UWB__DEBUG_CMD_H__
#include <linux/types.h>
/*
* Debug interface commands
*
* UWB_DBG_CMD_RSV_ESTABLISH: Establish a new unicast reservation.
*
* UWB_DBG_CMD_RSV_TERMINATE: Terminate the Nth reservation.
*/
enum uwb_dbg_cmd_type {
UWB_DBG_CMD_RSV_ESTABLISH = 1,
UWB_DBG_CMD_RSV_TERMINATE = 2,
};
struct uwb_dbg_cmd_rsv_establish {
__u8 target[6];
__u8 type;
__u16 max_mas;
__u16 min_mas;
__u8 sparsity;
};
struct uwb_dbg_cmd_rsv_terminate {
int index;
};
struct uwb_dbg_cmd {
__u32 type;
union {
struct uwb_dbg_cmd_rsv_establish rsv_establish;
struct uwb_dbg_cmd_rsv_terminate rsv_terminate;
};
};
#endif /* #ifndef __LINUX__UWB__DEBUG_CMD_H__ */
+82
View File
@@ -0,0 +1,82 @@
/*
* Ultra Wide Band
* Debug Support
*
* Copyright (C) 2005-2006 Intel Corporation
* Inaky Perez-Gonzalez <inaky.perez-gonzalez@intel.com>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License version
* 2 as published by the Free Software Foundation.
*
* 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, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301, USA.
*
*
* FIXME: doc
* Invoke like:
*
* #define D_LOCAL 4
* #include <linux/uwb/debug.h>
*
* At the end of your include files.
*/
#include <linux/types.h>
struct device;
extern void dump_bytes(struct device *dev, const void *_buf, size_t rsize);
/* Master debug switch; !0 enables, 0 disables */
#define D_MASTER (!0)
/* Local (per-file) debug switch; #define before #including */
#ifndef D_LOCAL
#define D_LOCAL 0
#endif
#undef __d_printf
#undef d_fnstart
#undef d_fnend
#undef d_printf
#undef d_dump
#define __d_printf(l, _tag, _dev, f, a...) \
do { \
struct device *__dev = (_dev); \
if (D_MASTER && D_LOCAL >= (l)) { \
char __head[64] = ""; \
if (_dev != NULL) { \
if ((unsigned long)__dev < 4096) \
printk(KERN_ERR "E: Corrupt dev %p\n", \
__dev); \
else \
snprintf(__head, sizeof(__head), \
"%s %s: ", \
dev_driver_string(__dev), \
__dev->bus_id); \
} \
printk(KERN_ERR "%s%s" _tag ": " f, __head, \
__func__, ## a); \
} \
} while (0 && _dev)
#define d_fnstart(l, _dev, f, a...) \
__d_printf(l, " FNSTART", _dev, f, ## a)
#define d_fnend(l, _dev, f, a...) \
__d_printf(l, " FNEND", _dev, f, ## a)
#define d_printf(l, _dev, f, a...) \
__d_printf(l, "", _dev, f, ## a)
#define d_dump(l, _dev, ptr, size) \
do { \
struct device *__dev = _dev; \
if (D_MASTER && D_LOCAL >= (l)) \
dump_bytes(__dev, ptr, size); \
} while (0 && _dev)
#define d_test(l) (D_MASTER && D_LOCAL >= (l))
File diff suppressed because it is too large Load Diff
+194
View File
@@ -0,0 +1,194 @@
/*
* UWB Multi-interface Controller support.
*
* Copyright (C) 2007 Cambridge Silicon Radio Ltd.
*
* This file is released under the GPLv2
*
* UMC (UWB Multi-interface Controller) capabilities (e.g., radio
* controller, host controller) are presented as devices on the "umc"
* bus.
*
* The radio controller is not strictly a UMC capability but it's
* useful to present it as such.
*
* References:
*
* [WHCI] Wireless Host Controller Interface Specification for
* Certified Wireless Universal Serial Bus, revision 0.95.
*
* How this works is kind of convoluted but simple. The whci.ko driver
* loads when WHCI devices are detected. These WHCI devices expose
* many devices in the same PCI function (they couldn't have reused
* functions, no), so for each PCI function that exposes these many
* devices, whci ceates a umc_dev [whci_probe() -> whci_add_cap()]
* with umc_device_create() and adds it to the bus with
* umc_device_register().
*
* umc_device_register() calls device_register() which will push the
* bus management code to load your UMC driver's somehting_probe()
* that you have registered for that capability code.
*
* Now when the WHCI device is removed, whci_remove() will go over
* each umc_dev assigned to each of the PCI function's capabilities
* and through whci_del_cap() call umc_device_unregister() each
* created umc_dev. Of course, if you are bound to the device, your
* driver's something_remove() will be called.
*/
#ifndef _LINUX_UWB_UMC_H_
#define _LINUX_UWB_UMC_H_
#include <linux/device.h>
#include <linux/pci.h>
/*
* UMC capability IDs.
*
* 0x00 is reserved so use it for the radio controller device.
*
* [WHCI] table 2-8
*/
#define UMC_CAP_ID_WHCI_RC 0x00 /* radio controller */
#define UMC_CAP_ID_WHCI_WUSB_HC 0x01 /* WUSB host controller */
/**
* struct umc_dev - UMC capability device
*
* @version: version of the specification this capability conforms to.
* @cap_id: capability ID.
* @bar: PCI Bar (64 bit) where the resource lies
* @resource: register space resource.
* @irq: interrupt line.
*/
struct umc_dev {
u16 version;
u8 cap_id;
u8 bar;
struct resource resource;
unsigned irq;
struct device dev;
};
#define to_umc_dev(d) container_of(d, struct umc_dev, dev)
/**
* struct umc_driver - UMC capability driver
* @cap_id: supported capability ID.
* @match: driver specific capability matching function.
* @match_data: driver specific data for match() (e.g., a
* table of pci_device_id's if umc_match_pci_id() is used).
*/
struct umc_driver {
char *name;
u8 cap_id;
int (*match)(struct umc_driver *, struct umc_dev *);
const void *match_data;
int (*probe)(struct umc_dev *);
void (*remove)(struct umc_dev *);
int (*suspend)(struct umc_dev *, pm_message_t state);
int (*resume)(struct umc_dev *);
struct device_driver driver;
};
#define to_umc_driver(d) container_of(d, struct umc_driver, driver)
extern struct bus_type umc_bus_type;
struct umc_dev *umc_device_create(struct device *parent, int n);
int __must_check umc_device_register(struct umc_dev *umc);
void umc_device_unregister(struct umc_dev *umc);
int __must_check __umc_driver_register(struct umc_driver *umc_drv,
struct module *mod,
const char *mod_name);
/**
* umc_driver_register - register a UMC capabiltity driver.
* @umc_drv: pointer to the driver.
*/
static inline int __must_check umc_driver_register(struct umc_driver *umc_drv)
{
return __umc_driver_register(umc_drv, THIS_MODULE, KBUILD_MODNAME);
}
void umc_driver_unregister(struct umc_driver *umc_drv);
/*
* Utility function you can use to match (umc_driver->match) against a
* null-terminated array of 'struct pci_device_id' in
* umc_driver->match_data.
*/
int umc_match_pci_id(struct umc_driver *umc_drv, struct umc_dev *umc);
/**
* umc_parent_pci_dev - return the UMC's parent PCI device or NULL if none
* @umc_dev: UMC device whose parent PCI device we are looking for
*
* DIRTY!!! DON'T RELY ON THIS
*
* FIXME: This is as dirty as it gets, but we need some way to check
* the correct type of umc_dev->parent (so that for example, we can
* cast to pci_dev). Casting to pci_dev is necesary because at some
* point we need to request resources from the device. Mapping is
* easily over come (ioremap and stuff are bus agnostic), but hooking
* up to some error handlers (such as pci error handlers) might need
* this.
*
* THIS might (probably will) be removed in the future, so don't count
* on it.
*/
static inline struct pci_dev *umc_parent_pci_dev(struct umc_dev *umc_dev)
{
struct pci_dev *pci_dev = NULL;
if (umc_dev->dev.parent->bus == &pci_bus_type)
pci_dev = to_pci_dev(umc_dev->dev.parent);
return pci_dev;
}
/**
* umc_dev_get() - reference a UMC device.
* @umc_dev: Pointer to UMC device.
*
* NOTE: we are assuming in this whole scheme that the parent device
* is referenced at _probe() time and unreferenced at _remove()
* time by the parent's subsystem.
*/
static inline struct umc_dev *umc_dev_get(struct umc_dev *umc_dev)
{
get_device(&umc_dev->dev);
return umc_dev;
}
/**
* umc_dev_put() - unreference a UMC device.
* @umc_dev: Pointer to UMC device.
*/
static inline void umc_dev_put(struct umc_dev *umc_dev)
{
put_device(&umc_dev->dev);
}
/**
* umc_set_drvdata - set UMC device's driver data.
* @umc_dev: Pointer to UMC device.
* @data: Data to set.
*/
static inline void umc_set_drvdata(struct umc_dev *umc_dev, void *data)
{
dev_set_drvdata(&umc_dev->dev, data);
}
/**
* umc_get_drvdata - recover UMC device's driver data.
* @umc_dev: Pointer to UMC device.
*/
static inline void *umc_get_drvdata(struct umc_dev *umc_dev)
{
return dev_get_drvdata(&umc_dev->dev);
}
int umc_controller_reset(struct umc_dev *umc);
#endif /* #ifndef _LINUX_UWB_UMC_H_ */
+117
View File
@@ -0,0 +1,117 @@
/*
* Wireless Host Controller Interface for Ultra-Wide-Band and Wireless USB
*
* Copyright (C) 2005-2006 Intel Corporation
* Inaky Perez-Gonzalez <inaky.perez-gonzalez@intel.com>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License version
* 2 as published by the Free Software Foundation.
*
* 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, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301, USA.
*
*
*
* References:
* [WHCI] Wireless Host Controller Interface Specification for
* Certified Wireless Universal Serial Bus, revision 0.95.
*/
#ifndef _LINUX_UWB_WHCI_H_
#define _LINUX_UWB_WHCI_H_
#include <linux/pci.h>
/*
* UWB interface capability registers (offsets from UWBBASE)
*
* [WHCI] section 2.2
*/
#define UWBCAPINFO 0x00 /* == UWBCAPDATA(0) */
# define UWBCAPINFO_TO_N_CAPS(c) (((c) >> 0) & 0xFull)
#define UWBCAPDATA(n) (8*(n))
# define UWBCAPDATA_TO_VERSION(c) (((c) >> 32) & 0xFFFFull)
# define UWBCAPDATA_TO_OFFSET(c) (((c) >> 18) & 0x3FFFull)
# define UWBCAPDATA_TO_BAR(c) (((c) >> 16) & 0x3ull)
# define UWBCAPDATA_TO_SIZE(c) ((((c) >> 8) & 0xFFull) * sizeof(u32))
# define UWBCAPDATA_TO_CAP_ID(c) (((c) >> 0) & 0xFFull)
/* Size of the WHCI capability data (including the RC capability) for
a device with n capabilities. */
#define UWBCAPDATA_SIZE(n) (8 + 8*(n))
/*
* URC registers (offsets from URCBASE)
*
* [WHCI] section 2.3
*/
#define URCCMD 0x00
# define URCCMD_RESET (1 << 31) /* UMC Hardware reset */
# define URCCMD_RS (1 << 30) /* Run/Stop */
# define URCCMD_EARV (1 << 29) /* Event Address Register Valid */
# define URCCMD_ACTIVE (1 << 15) /* Command is active */
# define URCCMD_IWR (1 << 14) /* Interrupt When Ready */
# define URCCMD_SIZE_MASK 0x00000fff /* Command size mask */
#define URCSTS 0x04
# define URCSTS_EPS (1 << 17) /* Event Processing Status */
# define URCSTS_HALTED (1 << 16) /* RC halted */
# define URCSTS_HSE (1 << 10) /* Host System Error...fried */
# define URCSTS_ER (1 << 9) /* Event Ready */
# define URCSTS_RCI (1 << 8) /* Ready for Command Interrupt */
# define URCSTS_INT_MASK 0x00000700 /* URC interrupt sources */
# define URCSTS_ISI 0x000000ff /* Interrupt Source Identification */
#define URCINTR 0x08
# define URCINTR_EN_ALL 0x000007ff /* Enable all interrupt sources */
#define URCCMDADDR 0x10
#define URCEVTADDR 0x18
# define URCEVTADDR_OFFSET_MASK 0xfff /* Event pointer offset mask */
/** Write 32 bit @value to little endian register at @addr */
static inline
void le_writel(u32 value, void __iomem *addr)
{
iowrite32(value, addr);
}
/** Read from 32 bit little endian register at @addr */
static inline
u32 le_readl(void __iomem *addr)
{
return ioread32(addr);
}
/** Write 64 bit @value to little endian register at @addr */
static inline
void le_writeq(u64 value, void __iomem *addr)
{
iowrite32(value, addr);
iowrite32(value >> 32, addr + 4);
}
/** Read from 64 bit little endian register at @addr */
static inline
u64 le_readq(void __iomem *addr)
{
u64 value;
value = ioread32(addr);
value |= (u64)ioread32(addr + 4) << 32;
return value;
}
extern int whci_wait_for(struct device *dev, u32 __iomem *reg,
u32 mask, u32 result,
unsigned long max_ms, const char *tag);
#endif /* #ifndef _LINUX_UWB_WHCI_H_ */
+735
View File
File diff suppressed because it is too large Load Diff