aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Vrabel <david.vrabel@csr.com>2009-10-12 11:45:18 -0400
committerGreg Kroah-Hartman <gregkh@suse.de>2009-12-11 14:55:16 -0500
commitc3f22d92a1249665d4cd87a68a4078a56002c3ab (patch)
tree40aab1a3bd032835551bf6c97c21921294536960
parentd19fc291929aae528a40dd17c71a81f26254715d (diff)
USB: wusb: add wusb_phy_rate sysfs file to host controllers
Add the wusb_phy_rate sysfs file to Wireless USB host controllers. This sets the maximum PHY rate that will be used for all connected devices. Signed-off-by: David Vrabel <david.vrabel@csr.com> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
-rw-r--r--Documentation/ABI/testing/sysfs-class-uwb_rc-wusbhc13
-rw-r--r--drivers/usb/host/whci/qset.c24
-rw-r--r--drivers/usb/host/whci/whci-hc.h9
-rw-r--r--drivers/usb/wusbcore/wusbhc.c32
-rw-r--r--drivers/usb/wusbcore/wusbhc.h1
5 files changed, 68 insertions, 11 deletions
diff --git a/Documentation/ABI/testing/sysfs-class-uwb_rc-wusbhc b/Documentation/ABI/testing/sysfs-class-uwb_rc-wusbhc
index 4e8106f7cfd9..25b1e751b777 100644
--- a/Documentation/ABI/testing/sysfs-class-uwb_rc-wusbhc
+++ b/Documentation/ABI/testing/sysfs-class-uwb_rc-wusbhc
@@ -23,3 +23,16 @@ Description:
23 Since this relates to security (specifically, the 23 Since this relates to security (specifically, the
24 lifetime of PTKs and GTKs) it should not be changed 24 lifetime of PTKs and GTKs) it should not be changed
25 from the default. 25 from the default.
26
27What: /sys/class/uwb_rc/uwbN/wusbhc/wusb_phy_rate
28Date: August 2009
29KernelVersion: 2.6.32
30Contact: David Vrabel <david.vrabel@csr.com>
31Description:
32 The maximum PHY rate to use for all connected devices.
33 This is only of limited use for testing and
34 development as the hardware's automatic rate
35 adaptation is better then this simple control.
36
37 Refer to [ECMA-368] section 10.3.1.1 for the value to
38 use.
diff --git a/drivers/usb/host/whci/qset.c b/drivers/usb/host/whci/qset.c
index 08280869ed1c..39e855a55c63 100644
--- a/drivers/usb/host/whci/qset.c
+++ b/drivers/usb/host/whci/qset.c
@@ -49,11 +49,13 @@ struct whc_qset *qset_alloc(struct whc *whc, gfp_t mem_flags)
49 * state 49 * state
50 * @urb: an urb for a transfer to this endpoint 50 * @urb: an urb for a transfer to this endpoint
51 */ 51 */
52static void qset_fill_qh(struct whc_qset *qset, struct urb *urb) 52static void qset_fill_qh(struct whc *whc, struct whc_qset *qset, struct urb *urb)
53{ 53{
54 struct usb_device *usb_dev = urb->dev; 54 struct usb_device *usb_dev = urb->dev;
55 struct wusb_dev *wusb_dev = usb_dev->wusb_dev;
55 struct usb_wireless_ep_comp_descriptor *epcd; 56 struct usb_wireless_ep_comp_descriptor *epcd;
56 bool is_out; 57 bool is_out;
58 uint8_t phy_rate;
57 59
58 is_out = usb_pipeout(urb->pipe); 60 is_out = usb_pipeout(urb->pipe);
59 61
@@ -68,6 +70,22 @@ static void qset_fill_qh(struct whc_qset *qset, struct urb *urb)
68 qset->max_burst = 1; 70 qset->max_burst = 1;
69 } 71 }
70 72
73 /*
74 * Initial PHY rate is 53.3 Mbit/s for control endpoints or
75 * the maximum supported by the device for other endpoints
76 * (unless limited by the user).
77 */
78 if (usb_pipecontrol(urb->pipe))
79 phy_rate = UWB_PHY_RATE_53;
80 else {
81 uint16_t phy_rates;
82
83 phy_rates = le16_to_cpu(wusb_dev->wusb_cap_descr->wPHYRates);
84 phy_rate = fls(phy_rates) - 1;
85 if (phy_rate > whc->wusbhc.phy_rate)
86 phy_rate = whc->wusbhc.phy_rate;
87 }
88
71 qset->qh.info1 = cpu_to_le32( 89 qset->qh.info1 = cpu_to_le32(
72 QH_INFO1_EP(usb_pipeendpoint(urb->pipe)) 90 QH_INFO1_EP(usb_pipeendpoint(urb->pipe))
73 | (is_out ? QH_INFO1_DIR_OUT : QH_INFO1_DIR_IN) 91 | (is_out ? QH_INFO1_DIR_OUT : QH_INFO1_DIR_IN)
@@ -87,7 +105,7 @@ static void qset_fill_qh(struct whc_qset *qset, struct urb *urb)
87 * strength and can presumably guess the Tx power required 105 * strength and can presumably guess the Tx power required
88 * from that? */ 106 * from that? */
89 qset->qh.info3 = cpu_to_le32( 107 qset->qh.info3 = cpu_to_le32(
90 QH_INFO3_TX_RATE_53_3 108 QH_INFO3_TX_RATE(phy_rate)
91 | QH_INFO3_TX_PWR(0) /* 0 == max power */ 109 | QH_INFO3_TX_PWR(0) /* 0 == max power */
92 ); 110 );
93 111
@@ -149,7 +167,7 @@ struct whc_qset *get_qset(struct whc *whc, struct urb *urb,
149 167
150 qset->ep = urb->ep; 168 qset->ep = urb->ep;
151 urb->ep->hcpriv = qset; 169 urb->ep->hcpriv = qset;
152 qset_fill_qh(qset, urb); 170 qset_fill_qh(whc, qset, urb);
153 } 171 }
154 return qset; 172 return qset;
155} 173}
diff --git a/drivers/usb/host/whci/whci-hc.h b/drivers/usb/host/whci/whci-hc.h
index d5e5c3aacced..4d4cbc0730bf 100644
--- a/drivers/usb/host/whci/whci-hc.h
+++ b/drivers/usb/host/whci/whci-hc.h
@@ -172,14 +172,7 @@ struct whc_qhead {
172#define QH_INFO3_MAX_DELAY(d) ((d) << 0) /* maximum stream delay in 125 us units (isoc only) */ 172#define QH_INFO3_MAX_DELAY(d) ((d) << 0) /* maximum stream delay in 125 us units (isoc only) */
173#define QH_INFO3_INTERVAL(i) ((i) << 16) /* segment interval in 125 us units (isoc only) */ 173#define QH_INFO3_INTERVAL(i) ((i) << 16) /* segment interval in 125 us units (isoc only) */
174 174
175#define QH_INFO3_TX_RATE_53_3 (0 << 24) 175#define QH_INFO3_TX_RATE(r) ((r) << 24) /* PHY rate (see [ECMA-368] section 10.3.1.1) */
176#define QH_INFO3_TX_RATE_80 (1 << 24)
177#define QH_INFO3_TX_RATE_106_7 (2 << 24)
178#define QH_INFO3_TX_RATE_160 (3 << 24)
179#define QH_INFO3_TX_RATE_200 (4 << 24)
180#define QH_INFO3_TX_RATE_320 (5 << 24)
181#define QH_INFO3_TX_RATE_400 (6 << 24)
182#define QH_INFO3_TX_RATE_480 (7 << 24)
183#define QH_INFO3_TX_PWR(p) ((p) << 29) /* transmit power (see [WUSB] section 5.2.1.2) */ 176#define QH_INFO3_TX_PWR(p) ((p) << 29) /* transmit power (see [WUSB] section 5.2.1.2) */
184 177
185#define QH_STATUS_FLOW_CTRL (1 << 15) 178#define QH_STATUS_FLOW_CTRL (1 << 15)
diff --git a/drivers/usb/wusbcore/wusbhc.c b/drivers/usb/wusbcore/wusbhc.c
index ee6256f23636..eab86e4bc770 100644
--- a/drivers/usb/wusbcore/wusbhc.c
+++ b/drivers/usb/wusbcore/wusbhc.c
@@ -147,10 +147,40 @@ static ssize_t wusb_chid_store(struct device *dev,
147} 147}
148static DEVICE_ATTR(wusb_chid, 0644, wusb_chid_show, wusb_chid_store); 148static DEVICE_ATTR(wusb_chid, 0644, wusb_chid_show, wusb_chid_store);
149 149
150
151static ssize_t wusb_phy_rate_show(struct device *dev,
152 struct device_attribute *attr,
153 char *buf)
154{
155 struct wusbhc *wusbhc = usbhc_dev_to_wusbhc(dev);
156
157 return sprintf(buf, "%d\n", wusbhc->phy_rate);
158}
159
160static ssize_t wusb_phy_rate_store(struct device *dev,
161 struct device_attribute *attr,
162 const char *buf, size_t size)
163{
164 struct wusbhc *wusbhc = usbhc_dev_to_wusbhc(dev);
165 uint8_t phy_rate;
166 ssize_t result;
167
168 result = sscanf(buf, "%hhu", &phy_rate);
169 if (result != 1)
170 return -EINVAL;
171 if (phy_rate >= UWB_PHY_RATE_INVALID)
172 return -EINVAL;
173
174 wusbhc->phy_rate = phy_rate;
175 return size;
176}
177static DEVICE_ATTR(wusb_phy_rate, 0644, wusb_phy_rate_show, wusb_phy_rate_store);
178
150/* Group all the WUSBHC attributes */ 179/* Group all the WUSBHC attributes */
151static struct attribute *wusbhc_attrs[] = { 180static struct attribute *wusbhc_attrs[] = {
152 &dev_attr_wusb_trust_timeout.attr, 181 &dev_attr_wusb_trust_timeout.attr,
153 &dev_attr_wusb_chid.attr, 182 &dev_attr_wusb_chid.attr,
183 &dev_attr_wusb_phy_rate.attr,
154 NULL, 184 NULL,
155}; 185};
156 186
@@ -177,6 +207,8 @@ int wusbhc_create(struct wusbhc *wusbhc)
177 int result = 0; 207 int result = 0;
178 208
179 wusbhc->trust_timeout = WUSB_TRUST_TIMEOUT_MS; 209 wusbhc->trust_timeout = WUSB_TRUST_TIMEOUT_MS;
210 wusbhc->phy_rate = UWB_PHY_RATE_INVALID - 1;
211
180 mutex_init(&wusbhc->mutex); 212 mutex_init(&wusbhc->mutex);
181 result = wusbhc_mmcie_create(wusbhc); 213 result = wusbhc_mmcie_create(wusbhc);
182 if (result < 0) 214 if (result < 0)
diff --git a/drivers/usb/wusbcore/wusbhc.h b/drivers/usb/wusbcore/wusbhc.h
index 797c2453a35b..fd2fd4e277e1 100644
--- a/drivers/usb/wusbcore/wusbhc.h
+++ b/drivers/usb/wusbcore/wusbhc.h
@@ -253,6 +253,7 @@ struct wusbhc {
253 253
254 unsigned trust_timeout; /* in jiffies */ 254 unsigned trust_timeout; /* in jiffies */
255 struct wusb_ckhdid chid; 255 struct wusb_ckhdid chid;
256 uint8_t phy_rate;
256 struct wuie_host_info *wuie_host_info; 257 struct wuie_host_info *wuie_host_info;
257 258
258 struct mutex mutex; /* locks everything else */ 259 struct mutex mutex; /* locks everything else */