aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/usb
diff options
context:
space:
mode:
authorRicardo Ribalda Delgado <ricardo.ribalda@gmail.com>2014-05-20 12:30:05 -0400
committerFelipe Balbi <balbi@ti.com>2014-06-30 13:33:32 -0400
commit3e76fdcba6b2e30921d280704ea10764f150ec9c (patch)
tree13cb1a4510c332b825fb62a4017616a610b25b37 /drivers/usb
parentc2db8a8a01978a1ffad735f31268a1c9c81b413e (diff)
usb: gadget: net2280: Use BIT() macro
Improves readability of the code Signed-off-by: Ricardo Ribalda Delgado <ricardo.ribalda@gmail.com> Signed-off-by: Felipe Balbi <balbi@ti.com>
Diffstat (limited to 'drivers/usb')
-rw-r--r--drivers/usb/gadget/net2280.c572
-rw-r--r--drivers/usb/gadget/net2280.h65
2 files changed, 318 insertions, 319 deletions
diff --git a/drivers/usb/gadget/net2280.c b/drivers/usb/gadget/net2280.c
index ba1fdd8f675d..5b9368d73b48 100644
--- a/drivers/usb/gadget/net2280.c
+++ b/drivers/usb/gadget/net2280.c
@@ -144,8 +144,8 @@ static char *type_string (u8 bmAttributes)
144 144
145#include "net2280.h" 145#include "net2280.h"
146 146
147#define valid_bit cpu_to_le32 (1 << VALID_BIT) 147#define valid_bit cpu_to_le32(BIT(VALID_BIT))
148#define dma_done_ie cpu_to_le32 (1 << DMA_DONE_INTERRUPT_ENABLE) 148#define dma_done_ie cpu_to_le32(BIT(DMA_DONE_INTERRUPT_ENABLE))
149 149
150/*-------------------------------------------------------------------------*/ 150/*-------------------------------------------------------------------------*/
151static inline void enable_pciirqenb(struct net2280_ep *ep) 151static inline void enable_pciirqenb(struct net2280_ep *ep)
@@ -153,9 +153,9 @@ static inline void enable_pciirqenb(struct net2280_ep *ep)
153 u32 tmp = readl(&ep->dev->regs->pciirqenb0); 153 u32 tmp = readl(&ep->dev->regs->pciirqenb0);
154 154
155 if (ep->dev->pdev->vendor == PCI_VENDOR_ID_PLX_LEGACY) 155 if (ep->dev->pdev->vendor == PCI_VENDOR_ID_PLX_LEGACY)
156 tmp |= 1 << ep->num; 156 tmp |= BIT(ep->num);
157 else 157 else
158 tmp |= 1 << ep_bit[ep->num]; 158 tmp |= BIT(ep_bit[ep->num]);
159 writel(tmp, &ep->dev->regs->pciirqenb0); 159 writel(tmp, &ep->dev->regs->pciirqenb0);
160 160
161 return; 161 return;
@@ -218,14 +218,14 @@ net2280_enable (struct usb_ep *_ep, const struct usb_endpoint_descriptor *desc)
218 } 218 }
219 219
220 /* set type, direction, address; reset fifo counters */ 220 /* set type, direction, address; reset fifo counters */
221 writel ((1 << FIFO_FLUSH), &ep->regs->ep_stat); 221 writel(BIT(FIFO_FLUSH), &ep->regs->ep_stat);
222 tmp = (desc->bmAttributes & USB_ENDPOINT_XFERTYPE_MASK); 222 tmp = (desc->bmAttributes & USB_ENDPOINT_XFERTYPE_MASK);
223 if (tmp == USB_ENDPOINT_XFER_INT) { 223 if (tmp == USB_ENDPOINT_XFER_INT) {
224 /* erratum 0105 workaround prevents hs NYET */ 224 /* erratum 0105 workaround prevents hs NYET */
225 if (dev->chiprev == 0100 225 if (dev->chiprev == 0100
226 && dev->gadget.speed == USB_SPEED_HIGH 226 && dev->gadget.speed == USB_SPEED_HIGH
227 && !(desc->bEndpointAddress & USB_DIR_IN)) 227 && !(desc->bEndpointAddress & USB_DIR_IN))
228 writel ((1 << CLEAR_NAK_OUT_PACKETS_MODE), 228 writel(BIT(CLEAR_NAK_OUT_PACKETS_MODE),
229 &ep->regs->ep_rsp); 229 &ep->regs->ep_rsp);
230 } else if (tmp == USB_ENDPOINT_XFER_BULK) { 230 } else if (tmp == USB_ENDPOINT_XFER_BULK) {
231 /* catch some particularly blatant driver bugs */ 231 /* catch some particularly blatant driver bugs */
@@ -243,18 +243,18 @@ net2280_enable (struct usb_ep *_ep, const struct usb_endpoint_descriptor *desc)
243 tmp |= desc->bEndpointAddress; 243 tmp |= desc->bEndpointAddress;
244 /* default full fifo lines */ 244 /* default full fifo lines */
245 tmp |= (4 << ENDPOINT_BYTE_COUNT); 245 tmp |= (4 << ENDPOINT_BYTE_COUNT);
246 tmp |= 1 << ENDPOINT_ENABLE; 246 tmp |= BIT(ENDPOINT_ENABLE);
247 ep->is_in = (tmp & USB_DIR_IN) != 0; 247 ep->is_in = (tmp & USB_DIR_IN) != 0;
248 } else { 248 } else {
249 /* In Legacy mode, only OUT endpoints are used */ 249 /* In Legacy mode, only OUT endpoints are used */
250 if (dev->enhanced_mode && ep->is_in) { 250 if (dev->enhanced_mode && ep->is_in) {
251 tmp <<= IN_ENDPOINT_TYPE; 251 tmp <<= IN_ENDPOINT_TYPE;
252 tmp |= (1 << IN_ENDPOINT_ENABLE); 252 tmp |= BIT(IN_ENDPOINT_ENABLE);
253 /* Not applicable to Legacy */ 253 /* Not applicable to Legacy */
254 tmp |= (1 << ENDPOINT_DIRECTION); 254 tmp |= BIT(ENDPOINT_DIRECTION);
255 } else { 255 } else {
256 tmp <<= OUT_ENDPOINT_TYPE; 256 tmp <<= OUT_ENDPOINT_TYPE;
257 tmp |= (1 << OUT_ENDPOINT_ENABLE); 257 tmp |= BIT(OUT_ENDPOINT_ENABLE);
258 tmp |= (ep->is_in << ENDPOINT_DIRECTION); 258 tmp |= (ep->is_in << ENDPOINT_DIRECTION);
259 } 259 }
260 260
@@ -267,13 +267,13 @@ net2280_enable (struct usb_ep *_ep, const struct usb_endpoint_descriptor *desc)
267 267
268 /* for OUT transfers, block the rx fifo until a read is posted */ 268 /* for OUT transfers, block the rx fifo until a read is posted */
269 if (!ep->is_in) 269 if (!ep->is_in)
270 writel ((1 << SET_NAK_OUT_PACKETS), &ep->regs->ep_rsp); 270 writel(BIT(SET_NAK_OUT_PACKETS), &ep->regs->ep_rsp);
271 else if (dev->pdev->device != 0x2280) { 271 else if (dev->pdev->device != 0x2280) {
272 /* Added for 2282, Don't use nak packets on an in endpoint, 272 /* Added for 2282, Don't use nak packets on an in endpoint,
273 * this was ignored on 2280 273 * this was ignored on 2280
274 */ 274 */
275 writel ((1 << CLEAR_NAK_OUT_PACKETS) 275 writel(BIT(CLEAR_NAK_OUT_PACKETS) |
276 | (1 << CLEAR_NAK_OUT_PACKETS_MODE), &ep->regs->ep_rsp); 276 BIT(CLEAR_NAK_OUT_PACKETS_MODE), &ep->regs->ep_rsp);
277 } 277 }
278 278
279 writel(tmp, &ep->cfg->ep_cfg); 279 writel(tmp, &ep->cfg->ep_cfg);
@@ -282,13 +282,13 @@ net2280_enable (struct usb_ep *_ep, const struct usb_endpoint_descriptor *desc)
282 if (!ep->dma) { /* pio, per-packet */ 282 if (!ep->dma) { /* pio, per-packet */
283 enable_pciirqenb(ep); 283 enable_pciirqenb(ep);
284 284
285 tmp = (1 << DATA_PACKET_RECEIVED_INTERRUPT_ENABLE) 285 tmp = BIT(DATA_PACKET_RECEIVED_INTERRUPT_ENABLE) |
286 | (1 << DATA_PACKET_TRANSMITTED_INTERRUPT_ENABLE); 286 BIT(DATA_PACKET_TRANSMITTED_INTERRUPT_ENABLE);
287 if (dev->pdev->device == 0x2280) 287 if (dev->pdev->device == 0x2280)
288 tmp |= readl (&ep->regs->ep_irqenb); 288 tmp |= readl (&ep->regs->ep_irqenb);
289 writel (tmp, &ep->regs->ep_irqenb); 289 writel (tmp, &ep->regs->ep_irqenb);
290 } else { /* dma, per-request */ 290 } else { /* dma, per-request */
291 tmp = (1 << (8 + ep->num)); /* completion */ 291 tmp = BIT((8 + ep->num)); /* completion */
292 tmp |= readl (&dev->regs->pciirqenb1); 292 tmp |= readl (&dev->regs->pciirqenb1);
293 writel (tmp, &dev->regs->pciirqenb1); 293 writel (tmp, &dev->regs->pciirqenb1);
294 294
@@ -297,7 +297,7 @@ net2280_enable (struct usb_ep *_ep, const struct usb_endpoint_descriptor *desc)
297 * NOTE erratum 0112 workaround #2 297 * NOTE erratum 0112 workaround #2
298 */ 298 */
299 if ((desc->bEndpointAddress & USB_DIR_IN) == 0) { 299 if ((desc->bEndpointAddress & USB_DIR_IN) == 0) {
300 tmp = (1 << SHORT_PACKET_TRANSFERRED_INTERRUPT_ENABLE); 300 tmp = BIT(SHORT_PACKET_TRANSFERRED_INTERRUPT_ENABLE);
301 writel (tmp, &ep->regs->ep_irqenb); 301 writel (tmp, &ep->regs->ep_irqenb);
302 302
303 enable_pciirqenb(ep); 303 enable_pciirqenb(ep);
@@ -348,17 +348,17 @@ static void ep_reset_228x(struct net2280_regs __iomem *regs,
348 /* disable the dma, irqs, endpoint... */ 348 /* disable the dma, irqs, endpoint... */
349 if (ep->dma) { 349 if (ep->dma) {
350 writel (0, &ep->dma->dmactl); 350 writel (0, &ep->dma->dmactl);
351 writel ( (1 << DMA_SCATTER_GATHER_DONE_INTERRUPT) 351 writel(BIT(DMA_SCATTER_GATHER_DONE_INTERRUPT) |
352 | (1 << DMA_TRANSACTION_DONE_INTERRUPT) 352 BIT(DMA_TRANSACTION_DONE_INTERRUPT) |
353 | (1 << DMA_ABORT) 353 BIT(DMA_ABORT),
354 , &ep->dma->dmastat); 354 &ep->dma->dmastat);
355 355
356 tmp = readl (&regs->pciirqenb0); 356 tmp = readl (&regs->pciirqenb0);
357 tmp &= ~(1 << ep->num); 357 tmp &= ~BIT(ep->num);
358 writel (tmp, &regs->pciirqenb0); 358 writel (tmp, &regs->pciirqenb0);
359 } else { 359 } else {
360 tmp = readl (&regs->pciirqenb1); 360 tmp = readl (&regs->pciirqenb1);
361 tmp &= ~(1 << (8 + ep->num)); /* completion */ 361 tmp &= ~BIT((8 + ep->num)); /* completion */
362 writel (tmp, &regs->pciirqenb1); 362 writel (tmp, &regs->pciirqenb1);
363 } 363 }
364 writel (0, &ep->regs->ep_irqenb); 364 writel (0, &ep->regs->ep_irqenb);
@@ -367,44 +367,44 @@ static void ep_reset_228x(struct net2280_regs __iomem *regs,
367 * packets until the driver queues a read (+note erratum 0112) 367 * packets until the driver queues a read (+note erratum 0112)
368 */ 368 */
369 if (!ep->is_in || ep->dev->pdev->device == 0x2280) { 369 if (!ep->is_in || ep->dev->pdev->device == 0x2280) {
370 tmp = (1 << SET_NAK_OUT_PACKETS_MODE) 370 tmp = BIT(SET_NAK_OUT_PACKETS_MODE) |
371 | (1 << SET_NAK_OUT_PACKETS) 371 BIT(SET_NAK_OUT_PACKETS) |
372 | (1 << CLEAR_EP_HIDE_STATUS_PHASE) 372 BIT(CLEAR_EP_HIDE_STATUS_PHASE) |
373 | (1 << CLEAR_INTERRUPT_MODE); 373 BIT(CLEAR_INTERRUPT_MODE);
374 } else { 374 } else {
375 /* added for 2282 */ 375 /* added for 2282 */
376 tmp = (1 << CLEAR_NAK_OUT_PACKETS_MODE) 376 tmp = BIT(CLEAR_NAK_OUT_PACKETS_MODE) |
377 | (1 << CLEAR_NAK_OUT_PACKETS) 377 BIT(CLEAR_NAK_OUT_PACKETS) |
378 | (1 << CLEAR_EP_HIDE_STATUS_PHASE) 378 BIT(CLEAR_EP_HIDE_STATUS_PHASE) |
379 | (1 << CLEAR_INTERRUPT_MODE); 379 BIT(CLEAR_INTERRUPT_MODE);
380 } 380 }
381 381
382 if (ep->num != 0) { 382 if (ep->num != 0) {
383 tmp |= (1 << CLEAR_ENDPOINT_TOGGLE) 383 tmp |= BIT(CLEAR_ENDPOINT_TOGGLE) |
384 | (1 << CLEAR_ENDPOINT_HALT); 384 BIT(CLEAR_ENDPOINT_HALT);
385 } 385 }
386 writel (tmp, &ep->regs->ep_rsp); 386 writel (tmp, &ep->regs->ep_rsp);
387 387
388 /* scrub most status bits, and flush any fifo state */ 388 /* scrub most status bits, and flush any fifo state */
389 if (ep->dev->pdev->device == 0x2280) 389 if (ep->dev->pdev->device == 0x2280)
390 tmp = (1 << FIFO_OVERFLOW) 390 tmp = BIT(FIFO_OVERFLOW) |
391 | (1 << FIFO_UNDERFLOW); 391 BIT(FIFO_UNDERFLOW);
392 else 392 else
393 tmp = 0; 393 tmp = 0;
394 394
395 writel (tmp | (1 << TIMEOUT) 395 writel(tmp | BIT(TIMEOUT) |
396 | (1 << USB_STALL_SENT) 396 BIT(USB_STALL_SENT) |
397 | (1 << USB_IN_NAK_SENT) 397 BIT(USB_IN_NAK_SENT) |
398 | (1 << USB_IN_ACK_RCVD) 398 BIT(USB_IN_ACK_RCVD) |
399 | (1 << USB_OUT_PING_NAK_SENT) 399 BIT(USB_OUT_PING_NAK_SENT) |
400 | (1 << USB_OUT_ACK_SENT) 400 BIT(USB_OUT_ACK_SENT) |
401 | (1 << FIFO_FLUSH) 401 BIT(FIFO_FLUSH) |
402 | (1 << SHORT_PACKET_OUT_DONE_INTERRUPT) 402 BIT(SHORT_PACKET_OUT_DONE_INTERRUPT) |
403 | (1 << SHORT_PACKET_TRANSFERRED_INTERRUPT) 403 BIT(SHORT_PACKET_TRANSFERRED_INTERRUPT) |
404 | (1 << DATA_PACKET_RECEIVED_INTERRUPT) 404 BIT(DATA_PACKET_RECEIVED_INTERRUPT) |
405 | (1 << DATA_PACKET_TRANSMITTED_INTERRUPT) 405 BIT(DATA_PACKET_TRANSMITTED_INTERRUPT) |
406 | (1 << DATA_OUT_PING_TOKEN_INTERRUPT) 406 BIT(DATA_OUT_PING_TOKEN_INTERRUPT) |
407 | (1 << DATA_IN_TOKEN_INTERRUPT) 407 BIT(DATA_IN_TOKEN_INTERRUPT)
408 , &ep->regs->ep_stat); 408 , &ep->regs->ep_stat);
409 409
410 /* fifo size is handled separately */ 410 /* fifo size is handled separately */
@@ -424,11 +424,11 @@ static void ep_reset_338x(struct net2280_regs __iomem *regs,
424 /* disable the dma, irqs, endpoint... */ 424 /* disable the dma, irqs, endpoint... */
425 if (ep->dma) { 425 if (ep->dma) {
426 writel(0, &ep->dma->dmactl); 426 writel(0, &ep->dma->dmactl);
427 writel((1 << DMA_ABORT_DONE_INTERRUPT) | 427 writel(BIT(DMA_ABORT_DONE_INTERRUPT) |
428 (1 << DMA_PAUSE_DONE_INTERRUPT) | 428 BIT(DMA_PAUSE_DONE_INTERRUPT) |
429 (1 << DMA_SCATTER_GATHER_DONE_INTERRUPT) | 429 BIT(DMA_SCATTER_GATHER_DONE_INTERRUPT) |
430 (1 << DMA_TRANSACTION_DONE_INTERRUPT) 430 BIT(DMA_TRANSACTION_DONE_INTERRUPT)
431 /* | (1 << DMA_ABORT) */ 431 /* | BIT(DMA_ABORT) */
432 , &ep->dma->dmastat); 432 , &ep->dma->dmastat);
433 433
434 dmastat = readl(&ep->dma->dmastat); 434 dmastat = readl(&ep->dma->dmastat);
@@ -439,24 +439,24 @@ static void ep_reset_338x(struct net2280_regs __iomem *regs,
439 } 439 }
440 440
441 tmp = readl(&regs->pciirqenb0); 441 tmp = readl(&regs->pciirqenb0);
442 tmp &= ~(1 << ep_bit[ep->num]); 442 tmp &= ~BIT(ep_bit[ep->num]);
443 writel(tmp, &regs->pciirqenb0); 443 writel(tmp, &regs->pciirqenb0);
444 } else { 444 } else {
445 if (ep->num < 5) { 445 if (ep->num < 5) {
446 tmp = readl(&regs->pciirqenb1); 446 tmp = readl(&regs->pciirqenb1);
447 tmp &= ~(1 << (8 + ep->num)); /* completion */ 447 tmp &= ~BIT((8 + ep->num)); /* completion */
448 writel(tmp, &regs->pciirqenb1); 448 writel(tmp, &regs->pciirqenb1);
449 } 449 }
450 } 450 }
451 writel(0, &ep->regs->ep_irqenb); 451 writel(0, &ep->regs->ep_irqenb);
452 452
453 writel((1 << SHORT_PACKET_OUT_DONE_INTERRUPT) | 453 writel(BIT(SHORT_PACKET_OUT_DONE_INTERRUPT) |
454 (1 << SHORT_PACKET_TRANSFERRED_INTERRUPT) | 454 BIT(SHORT_PACKET_TRANSFERRED_INTERRUPT) |
455 (1 << FIFO_OVERFLOW) | 455 BIT(FIFO_OVERFLOW) |
456 (1 << DATA_PACKET_RECEIVED_INTERRUPT) | 456 BIT(DATA_PACKET_RECEIVED_INTERRUPT) |
457 (1 << DATA_PACKET_TRANSMITTED_INTERRUPT) | 457 BIT(DATA_PACKET_TRANSMITTED_INTERRUPT) |
458 (1 << DATA_OUT_PING_TOKEN_INTERRUPT) | 458 BIT(DATA_OUT_PING_TOKEN_INTERRUPT) |
459 (1 << DATA_IN_TOKEN_INTERRUPT), &ep->regs->ep_stat); 459 BIT(DATA_IN_TOKEN_INTERRUPT), &ep->regs->ep_stat);
460} 460}
461 461
462static void nuke (struct net2280_ep *); 462static void nuke (struct net2280_ep *);
@@ -621,20 +621,20 @@ static void out_flush (struct net2280_ep *ep)
621 ASSERT_OUT_NAKING (ep); 621 ASSERT_OUT_NAKING (ep);
622 622
623 statp = &ep->regs->ep_stat; 623 statp = &ep->regs->ep_stat;
624 writel ( (1 << DATA_OUT_PING_TOKEN_INTERRUPT) 624 writel(BIT(DATA_OUT_PING_TOKEN_INTERRUPT) |
625 | (1 << DATA_PACKET_RECEIVED_INTERRUPT) 625 BIT(DATA_PACKET_RECEIVED_INTERRUPT)
626 , statp); 626 , statp);
627 writel ((1 << FIFO_FLUSH), statp); 627 writel(BIT(FIFO_FLUSH), statp);
628 mb (); 628 mb ();
629 tmp = readl (statp); 629 tmp = readl (statp);
630 if (tmp & (1 << DATA_OUT_PING_TOKEN_INTERRUPT) 630 if (tmp & BIT(DATA_OUT_PING_TOKEN_INTERRUPT)
631 /* high speed did bulk NYET; fifo isn't filling */ 631 /* high speed did bulk NYET; fifo isn't filling */
632 && ep->dev->gadget.speed == USB_SPEED_FULL) { 632 && ep->dev->gadget.speed == USB_SPEED_FULL) {
633 unsigned usec; 633 unsigned usec;
634 634
635 usec = 50; /* 64 byte bulk/interrupt */ 635 usec = 50; /* 64 byte bulk/interrupt */
636 handshake (statp, (1 << USB_OUT_PING_NAK_SENT), 636 handshake(statp, BIT(USB_OUT_PING_NAK_SENT),
637 (1 << USB_OUT_PING_NAK_SENT), usec); 637 BIT(USB_OUT_PING_NAK_SENT), usec);
638 /* NAK done; now CLEAR_NAK_OUT_PACKETS is safe */ 638 /* NAK done; now CLEAR_NAK_OUT_PACKETS is safe */
639 } 639 }
640} 640}
@@ -661,9 +661,9 @@ read_fifo (struct net2280_ep *ep, struct net2280_request *req)
661 && ep->dev->gadget.speed == USB_SPEED_FULL) { 661 && ep->dev->gadget.speed == USB_SPEED_FULL) {
662 udelay (1); 662 udelay (1);
663 tmp = readl (&ep->regs->ep_stat); 663 tmp = readl (&ep->regs->ep_stat);
664 if ((tmp & (1 << NAK_OUT_PACKETS))) 664 if ((tmp & BIT(NAK_OUT_PACKETS)))
665 cleanup = 1; 665 cleanup = 1;
666 else if ((tmp & (1 << FIFO_FULL))) { 666 else if ((tmp & BIT(FIFO_FULL))) {
667 start_out_naking (ep); 667 start_out_naking (ep);
668 prevent = 1; 668 prevent = 1;
669 } 669 }
@@ -680,7 +680,7 @@ read_fifo (struct net2280_ep *ep, struct net2280_request *req)
680 tmp = readl (&ep->regs->ep_stat); 680 tmp = readl (&ep->regs->ep_stat);
681 count = readl (&regs->ep_avail); 681 count = readl (&regs->ep_avail);
682 /* handled that data already? */ 682 /* handled that data already? */
683 if (count == 0 && (tmp & (1 << NAK_OUT_PACKETS)) == 0) 683 if (count == 0 && (tmp & BIT(NAK_OUT_PACKETS)) == 0)
684 return 0; 684 return 0;
685 } 685 }
686 686
@@ -726,7 +726,7 @@ read_fifo (struct net2280_ep *ep, struct net2280_request *req)
726 if (cleanup) 726 if (cleanup)
727 out_flush (ep); 727 out_flush (ep);
728 if (prevent) { 728 if (prevent) {
729 writel ((1 << CLEAR_NAK_OUT_PACKETS), &ep->regs->ep_rsp); 729 writel(BIT(CLEAR_NAK_OUT_PACKETS), &ep->regs->ep_rsp);
730 (void) readl (&ep->regs->ep_rsp); 730 (void) readl (&ep->regs->ep_rsp);
731 } 731 }
732 732
@@ -747,16 +747,16 @@ fill_dma_desc (struct net2280_ep *ep, struct net2280_request *req, int valid)
747 * stop the fifo from filling but we can flush it. 747 * stop the fifo from filling but we can flush it.
748 */ 748 */
749 if (ep->is_in) 749 if (ep->is_in)
750 dmacount |= (1 << DMA_DIRECTION); 750 dmacount |= BIT(DMA_DIRECTION);
751 if ((!ep->is_in && (dmacount % ep->ep.maxpacket) != 0) 751 if ((!ep->is_in && (dmacount % ep->ep.maxpacket) != 0)
752 || ep->dev->pdev->device != 0x2280) 752 || ep->dev->pdev->device != 0x2280)
753 dmacount |= (1 << END_OF_CHAIN); 753 dmacount |= BIT(END_OF_CHAIN);
754 754
755 req->valid = valid; 755 req->valid = valid;
756 if (valid) 756 if (valid)
757 dmacount |= (1 << VALID_BIT); 757 dmacount |= BIT(VALID_BIT);
758 if (likely(!req->req.no_interrupt || !use_dma_chaining)) 758 if (likely(!req->req.no_interrupt || !use_dma_chaining))
759 dmacount |= (1 << DMA_DONE_INTERRUPT_ENABLE); 759 dmacount |= BIT(DMA_DONE_INTERRUPT_ENABLE);
760 760
761 /* td->dmadesc = previously set by caller */ 761 /* td->dmadesc = previously set by caller */
762 td->dmaaddr = cpu_to_le32 (req->req.dma); 762 td->dmaaddr = cpu_to_le32 (req->req.dma);
@@ -767,47 +767,47 @@ fill_dma_desc (struct net2280_ep *ep, struct net2280_request *req, int valid)
767} 767}
768 768
769static const u32 dmactl_default = 769static const u32 dmactl_default =
770 (1 << DMA_SCATTER_GATHER_DONE_INTERRUPT) 770 BIT(DMA_SCATTER_GATHER_DONE_INTERRUPT) |
771 | (1 << DMA_CLEAR_COUNT_ENABLE) 771 BIT(DMA_CLEAR_COUNT_ENABLE) |
772 /* erratum 0116 workaround part 1 (use POLLING) */ 772 /* erratum 0116 workaround part 1 (use POLLING) */
773 | (POLL_100_USEC << DESCRIPTOR_POLLING_RATE) 773 (POLL_100_USEC << DESCRIPTOR_POLLING_RATE) |
774 | (1 << DMA_VALID_BIT_POLLING_ENABLE) 774 BIT(DMA_VALID_BIT_POLLING_ENABLE) |
775 | (1 << DMA_VALID_BIT_ENABLE) 775 BIT(DMA_VALID_BIT_ENABLE) |
776 | (1 << DMA_SCATTER_GATHER_ENABLE) 776 BIT(DMA_SCATTER_GATHER_ENABLE) |
777 /* erratum 0116 workaround part 2 (no AUTOSTART) */ 777 /* erratum 0116 workaround part 2 (no AUTOSTART) */
778 | (1 << DMA_ENABLE); 778 BIT(DMA_ENABLE);
779 779
780static inline void spin_stop_dma (struct net2280_dma_regs __iomem *dma) 780static inline void spin_stop_dma (struct net2280_dma_regs __iomem *dma)
781{ 781{
782 handshake (&dma->dmactl, (1 << DMA_ENABLE), 0, 50); 782 handshake(&dma->dmactl, BIT(DMA_ENABLE), 0, 50);
783} 783}
784 784
785static inline void stop_dma (struct net2280_dma_regs __iomem *dma) 785static inline void stop_dma (struct net2280_dma_regs __iomem *dma)
786{ 786{
787 writel (readl (&dma->dmactl) & ~(1 << DMA_ENABLE), &dma->dmactl); 787 writel(readl(&dma->dmactl) & ~BIT(DMA_ENABLE), &dma->dmactl);
788 spin_stop_dma (dma); 788 spin_stop_dma (dma);
789} 789}
790 790
791static void start_queue (struct net2280_ep *ep, u32 dmactl, u32 td_dma) 791static void start_queue (struct net2280_ep *ep, u32 dmactl, u32 td_dma)
792{ 792{
793 struct net2280_dma_regs __iomem *dma = ep->dma; 793 struct net2280_dma_regs __iomem *dma = ep->dma;
794 unsigned int tmp = (1 << VALID_BIT) | (ep->is_in << DMA_DIRECTION); 794 unsigned int tmp = BIT(VALID_BIT) | (ep->is_in << DMA_DIRECTION);
795 795
796 if (ep->dev->pdev->device != 0x2280) 796 if (ep->dev->pdev->device != 0x2280)
797 tmp |= (1 << END_OF_CHAIN); 797 tmp |= BIT(END_OF_CHAIN);
798 798
799 writel (tmp, &dma->dmacount); 799 writel (tmp, &dma->dmacount);
800 writel (readl (&dma->dmastat), &dma->dmastat); 800 writel (readl (&dma->dmastat), &dma->dmastat);
801 801
802 writel (td_dma, &dma->dmadesc); 802 writel (td_dma, &dma->dmadesc);
803 if (ep->dev->pdev->vendor == PCI_VENDOR_ID_PLX) 803 if (ep->dev->pdev->vendor == PCI_VENDOR_ID_PLX)
804 dmactl |= (0x01 << DMA_REQUEST_OUTSTANDING); 804 dmactl |= BIT(DMA_REQUEST_OUTSTANDING);
805 writel (dmactl, &dma->dmactl); 805 writel (dmactl, &dma->dmactl);
806 806
807 /* erratum 0116 workaround part 3: pci arbiter away from net2280 */ 807 /* erratum 0116 workaround part 3: pci arbiter away from net2280 */
808 (void) readl (&ep->dev->pci->pcimstctl); 808 (void) readl (&ep->dev->pci->pcimstctl);
809 809
810 writel ((1 << DMA_START), &dma->dmastat); 810 writel(BIT(DMA_START), &dma->dmastat);
811 811
812 if (!ep->is_in) 812 if (!ep->is_in)
813 stop_out_naking (ep); 813 stop_out_naking (ep);
@@ -821,13 +821,13 @@ static void start_dma (struct net2280_ep *ep, struct net2280_request *req)
821 /* FIXME can't use DMA for ZLPs */ 821 /* FIXME can't use DMA for ZLPs */
822 822
823 /* on this path we "know" there's no dma active (yet) */ 823 /* on this path we "know" there's no dma active (yet) */
824 WARN_ON (readl (&dma->dmactl) & (1 << DMA_ENABLE)); 824 WARN_ON(readl(&dma->dmactl) & BIT(DMA_ENABLE));
825 writel (0, &ep->dma->dmactl); 825 writel (0, &ep->dma->dmactl);
826 826
827 /* previous OUT packet might have been short */ 827 /* previous OUT packet might have been short */
828 if (!ep->is_in && ((tmp = readl (&ep->regs->ep_stat)) 828 if (!ep->is_in && ((tmp = readl (&ep->regs->ep_stat))
829 & (1 << NAK_OUT_PACKETS)) != 0) { 829 & BIT(NAK_OUT_PACKETS)) != 0) {
830 writel ((1 << SHORT_PACKET_TRANSFERRED_INTERRUPT), 830 writel(BIT(SHORT_PACKET_TRANSFERRED_INTERRUPT),
831 &ep->regs->ep_stat); 831 &ep->regs->ep_stat);
832 832
833 tmp = readl (&ep->regs->ep_avail); 833 tmp = readl (&ep->regs->ep_avail);
@@ -840,13 +840,13 @@ static void start_dma (struct net2280_ep *ep, struct net2280_request *req)
840 840
841 /* dma irq, faking scatterlist status */ 841 /* dma irq, faking scatterlist status */
842 req->td->dmacount = cpu_to_le32 (req->req.length - tmp); 842 req->td->dmacount = cpu_to_le32 (req->req.length - tmp);
843 writel ((1 << DMA_DONE_INTERRUPT_ENABLE) 843 writel(BIT(DMA_DONE_INTERRUPT_ENABLE)
844 | tmp, &dma->dmacount); 844 | tmp, &dma->dmacount);
845 req->td->dmadesc = 0; 845 req->td->dmadesc = 0;
846 req->valid = 1; 846 req->valid = 1;
847 847
848 writel ((1 << DMA_ENABLE), &dma->dmactl); 848 writel(BIT(DMA_ENABLE), &dma->dmactl);
849 writel ((1 << DMA_START), &dma->dmastat); 849 writel(BIT(DMA_START), &dma->dmastat);
850 return; 850 return;
851 } 851 }
852 } 852 }
@@ -860,7 +860,7 @@ static void start_dma (struct net2280_ep *ep, struct net2280_request *req)
860 if (ep->is_in) { 860 if (ep->is_in) {
861 if (likely ((req->req.length % ep->ep.maxpacket) != 0 861 if (likely ((req->req.length % ep->ep.maxpacket) != 0
862 || req->req.zero)) { 862 || req->req.zero)) {
863 tmp |= (1 << DMA_FIFO_VALIDATE); 863 tmp |= BIT(DMA_FIFO_VALIDATE);
864 ep->in_fifo_validate = 1; 864 ep->in_fifo_validate = 1;
865 } else 865 } else
866 ep->in_fifo_validate = 0; 866 ep->in_fifo_validate = 0;
@@ -871,21 +871,21 @@ static void start_dma (struct net2280_ep *ep, struct net2280_request *req)
871 fill_dma_desc (ep, req, 1); 871 fill_dma_desc (ep, req, 1);
872 872
873 if (!use_dma_chaining) 873 if (!use_dma_chaining)
874 req->td->dmacount |= cpu_to_le32 (1 << END_OF_CHAIN); 874 req->td->dmacount |= cpu_to_le32(BIT(END_OF_CHAIN));
875 875
876 start_queue (ep, tmp, req->td_dma); 876 start_queue (ep, tmp, req->td_dma);
877} 877}
878 878
879static inline void resume_dma(struct net2280_ep *ep) 879static inline void resume_dma(struct net2280_ep *ep)
880{ 880{
881 writel(readl(&ep->dma->dmactl) | (1 << DMA_ENABLE), &ep->dma->dmactl); 881 writel(readl(&ep->dma->dmactl) | BIT(DMA_ENABLE), &ep->dma->dmactl);
882 882
883 ep->dma_started = true; 883 ep->dma_started = true;
884} 884}
885 885
886static inline void ep_stop_dma(struct net2280_ep *ep) 886static inline void ep_stop_dma(struct net2280_ep *ep)
887{ 887{
888 writel(readl(&ep->dma->dmactl) & ~(1 << DMA_ENABLE), &ep->dma->dmactl); 888 writel(readl(&ep->dma->dmactl) & ~BIT(DMA_ENABLE), &ep->dma->dmactl);
889 spin_stop_dma(ep->dma); 889 spin_stop_dma(ep->dma);
890 890
891 ep->dma_started = false; 891 ep->dma_started = false;
@@ -995,7 +995,7 @@ net2280_queue (struct usb_ep *_ep, struct usb_request *_req, gfp_t gfp_flags)
995 if (list_empty (&ep->queue) && !ep->stopped) { 995 if (list_empty (&ep->queue) && !ep->stopped) {
996 /* DMA request while EP halted */ 996 /* DMA request while EP halted */
997 if (ep->dma && 997 if (ep->dma &&
998 (readl(&ep->regs->ep_rsp) & (1 << CLEAR_ENDPOINT_HALT)) && 998 (readl(&ep->regs->ep_rsp) & BIT(CLEAR_ENDPOINT_HALT)) &&
999 (dev->pdev->vendor == PCI_VENDOR_ID_PLX)) { 999 (dev->pdev->vendor == PCI_VENDOR_ID_PLX)) {
1000 int valid = 1; 1000 int valid = 1;
1001 if (ep->is_in) { 1001 if (ep->is_in) {
@@ -1028,7 +1028,7 @@ net2280_queue (struct usb_ep *_ep, struct usb_request *_req, gfp_t gfp_flags)
1028 1028
1029 /* OUT FIFO might have packet(s) buffered */ 1029 /* OUT FIFO might have packet(s) buffered */
1030 s = readl (&ep->regs->ep_stat); 1030 s = readl (&ep->regs->ep_stat);
1031 if ((s & (1 << FIFO_EMPTY)) == 0) { 1031 if ((s & BIT(FIFO_EMPTY)) == 0) {
1032 /* note: _req->short_not_ok is 1032 /* note: _req->short_not_ok is
1033 * ignored here since PIO _always_ 1033 * ignored here since PIO _always_
1034 * stops queue advance here, and 1034 * stops queue advance here, and
@@ -1046,8 +1046,8 @@ net2280_queue (struct usb_ep *_ep, struct usb_request *_req, gfp_t gfp_flags)
1046 } 1046 }
1047 1047
1048 /* don't NAK, let the fifo fill */ 1048 /* don't NAK, let the fifo fill */
1049 if (req && (s & (1 << NAK_OUT_PACKETS))) 1049 if (req && (s & BIT(NAK_OUT_PACKETS)))
1050 writel ((1 << CLEAR_NAK_OUT_PACKETS), 1050 writel(BIT(CLEAR_NAK_OUT_PACKETS),
1051 &ep->regs->ep_rsp); 1051 &ep->regs->ep_rsp);
1052 } 1052 }
1053 } 1053 }
@@ -1109,7 +1109,7 @@ static void scan_dma_completions (struct net2280_ep *ep)
1109 break; 1109 break;
1110 rmb (); 1110 rmb ();
1111 tmp = le32_to_cpup (&req->td->dmacount); 1111 tmp = le32_to_cpup (&req->td->dmacount);
1112 if ((tmp & (1 << VALID_BIT)) != 0) 1112 if ((tmp & BIT(VALID_BIT)) != 0)
1113 break; 1113 break;
1114 1114
1115 /* SHORT_PACKET_TRANSFERRED_INTERRUPT handles "usb-short" 1115 /* SHORT_PACKET_TRANSFERRED_INTERRUPT handles "usb-short"
@@ -1134,7 +1134,7 @@ static void scan_dma_completions (struct net2280_ep *ep)
1134 * your gadget driver. That helps avoids errata 0121, 1134 * your gadget driver. That helps avoids errata 0121,
1135 * 0122, and 0124; not all cases trigger the warning. 1135 * 0122, and 0124; not all cases trigger the warning.
1136 */ 1136 */
1137 if ((tmp & (1 << NAK_OUT_PACKETS)) == 0) { 1137 if ((tmp & BIT(NAK_OUT_PACKETS)) == 0) {
1138 WARNING (ep->dev, "%s lost packet sync!\n", 1138 WARNING (ep->dev, "%s lost packet sync!\n",
1139 ep->ep.name); 1139 ep->ep.name);
1140 req->req.status = -EOVERFLOW; 1140 req->req.status = -EOVERFLOW;
@@ -1179,7 +1179,7 @@ static void restart_dma (struct net2280_ep *ep)
1179 ep->in_fifo_validate = likely (req->req.zero 1179 ep->in_fifo_validate = likely (req->req.zero
1180 || (req->req.length % ep->ep.maxpacket) != 0); 1180 || (req->req.length % ep->ep.maxpacket) != 0);
1181 if (ep->in_fifo_validate) 1181 if (ep->in_fifo_validate)
1182 dmactl |= (1 << DMA_FIFO_VALIDATE); 1182 dmactl |= BIT(DMA_FIFO_VALIDATE);
1183 list_for_each_entry (entry, &ep->queue, queue) { 1183 list_for_each_entry (entry, &ep->queue, queue) {
1184 __le32 dmacount; 1184 __le32 dmacount;
1185 1185
@@ -1220,7 +1220,7 @@ static void abort_dma_228x(struct net2280_ep *ep)
1220 /* abort the current transfer */ 1220 /* abort the current transfer */
1221 if (likely (!list_empty (&ep->queue))) { 1221 if (likely (!list_empty (&ep->queue))) {
1222 /* FIXME work around errata 0121, 0122, 0124 */ 1222 /* FIXME work around errata 0121, 0122, 0124 */
1223 writel ((1 << DMA_ABORT), &ep->dma->dmastat); 1223 writel(BIT(DMA_ABORT), &ep->dma->dmastat);
1224 spin_stop_dma (ep->dma); 1224 spin_stop_dma (ep->dma);
1225 } else 1225 } else
1226 stop_dma (ep->dma); 1226 stop_dma (ep->dma);
@@ -1229,7 +1229,7 @@ static void abort_dma_228x(struct net2280_ep *ep)
1229 1229
1230static void abort_dma_338x(struct net2280_ep *ep) 1230static void abort_dma_338x(struct net2280_ep *ep)
1231{ 1231{
1232 writel((1 << DMA_ABORT), &ep->dma->dmastat); 1232 writel(BIT(DMA_ABORT), &ep->dma->dmastat);
1233 spin_stop_dma(ep->dma); 1233 spin_stop_dma(ep->dma);
1234} 1234}
1235 1235
@@ -1431,7 +1431,7 @@ net2280_fifo_status (struct usb_ep *_ep)
1431 if (!ep->dev->driver || ep->dev->gadget.speed == USB_SPEED_UNKNOWN) 1431 if (!ep->dev->driver || ep->dev->gadget.speed == USB_SPEED_UNKNOWN)
1432 return -ESHUTDOWN; 1432 return -ESHUTDOWN;
1433 1433
1434 avail = readl (&ep->regs->ep_avail) & ((1 << 12) - 1); 1434 avail = readl(&ep->regs->ep_avail) & (BIT(12) - 1);
1435 if (avail > ep->fifo_size) 1435 if (avail > ep->fifo_size)
1436 return -EOVERFLOW; 1436 return -EOVERFLOW;
1437 if (ep->is_in) 1437 if (ep->is_in)
@@ -1450,7 +1450,7 @@ net2280_fifo_flush (struct usb_ep *_ep)
1450 if (!ep->dev->driver || ep->dev->gadget.speed == USB_SPEED_UNKNOWN) 1450 if (!ep->dev->driver || ep->dev->gadget.speed == USB_SPEED_UNKNOWN)
1451 return; 1451 return;
1452 1452
1453 writel ((1 << FIFO_FLUSH), &ep->regs->ep_stat); 1453 writel(BIT(FIFO_FLUSH), &ep->regs->ep_stat);
1454 (void) readl (&ep->regs->ep_rsp); 1454 (void) readl (&ep->regs->ep_rsp);
1455} 1455}
1456 1456
@@ -1499,8 +1499,8 @@ static int net2280_wakeup (struct usb_gadget *_gadget)
1499 1499
1500 spin_lock_irqsave (&dev->lock, flags); 1500 spin_lock_irqsave (&dev->lock, flags);
1501 tmp = readl (&dev->usb->usbctl); 1501 tmp = readl (&dev->usb->usbctl);
1502 if (tmp & (1 << DEVICE_REMOTE_WAKEUP_ENABLE)) 1502 if (tmp & BIT(DEVICE_REMOTE_WAKEUP_ENABLE))
1503 writel (1 << GENERATE_RESUME, &dev->usb->usbstat); 1503 writel(BIT(GENERATE_RESUME), &dev->usb->usbstat);
1504 spin_unlock_irqrestore (&dev->lock, flags); 1504 spin_unlock_irqrestore (&dev->lock, flags);
1505 1505
1506 /* pci writes may still be posted */ 1506 /* pci writes may still be posted */
@@ -1520,10 +1520,10 @@ static int net2280_set_selfpowered (struct usb_gadget *_gadget, int value)
1520 spin_lock_irqsave (&dev->lock, flags); 1520 spin_lock_irqsave (&dev->lock, flags);
1521 tmp = readl (&dev->usb->usbctl); 1521 tmp = readl (&dev->usb->usbctl);
1522 if (value) { 1522 if (value) {
1523 tmp |= (1 << SELF_POWERED_STATUS); 1523 tmp |= BIT(SELF_POWERED_STATUS);
1524 dev->selfpowered = 1; 1524 dev->selfpowered = 1;
1525 } else { 1525 } else {
1526 tmp &= ~(1 << SELF_POWERED_STATUS); 1526 tmp &= ~BIT(SELF_POWERED_STATUS);
1527 dev->selfpowered = 0; 1527 dev->selfpowered = 0;
1528 } 1528 }
1529 writel (tmp, &dev->usb->usbctl); 1529 writel (tmp, &dev->usb->usbctl);
@@ -1546,9 +1546,9 @@ static int net2280_pullup(struct usb_gadget *_gadget, int is_on)
1546 tmp = readl (&dev->usb->usbctl); 1546 tmp = readl (&dev->usb->usbctl);
1547 dev->softconnect = (is_on != 0); 1547 dev->softconnect = (is_on != 0);
1548 if (is_on) 1548 if (is_on)
1549 tmp |= (1 << USB_DETECT_ENABLE); 1549 tmp |= BIT(USB_DETECT_ENABLE);
1550 else 1550 else
1551 tmp &= ~(1 << USB_DETECT_ENABLE); 1551 tmp &= ~BIT(USB_DETECT_ENABLE);
1552 writel (tmp, &dev->usb->usbctl); 1552 writel (tmp, &dev->usb->usbctl);
1553 spin_unlock_irqrestore (&dev->lock, flags); 1553 spin_unlock_irqrestore (&dev->lock, flags);
1554 1554
@@ -1636,8 +1636,8 @@ static ssize_t registers_show(struct device *_dev,
1636 /* USB Control Registers */ 1636 /* USB Control Registers */
1637 t1 = readl (&dev->usb->usbctl); 1637 t1 = readl (&dev->usb->usbctl);
1638 t2 = readl (&dev->usb->usbstat); 1638 t2 = readl (&dev->usb->usbstat);
1639 if (t1 & (1 << VBUS_PIN)) { 1639 if (t1 & BIT(VBUS_PIN)) {
1640 if (t2 & (1 << HIGH_SPEED)) 1640 if (t2 & BIT(HIGH_SPEED))
1641 s = "high speed"; 1641 s = "high speed";
1642 else if (dev->gadget.speed == USB_SPEED_UNKNOWN) 1642 else if (dev->gadget.speed == USB_SPEED_UNKNOWN)
1643 s = "powered"; 1643 s = "powered";
@@ -1672,21 +1672,21 @@ static ssize_t registers_show(struct device *_dev,
1672 "\n%s\tcfg %05x rsp (%02x) %s%s%s%s%s%s%s%s" 1672 "\n%s\tcfg %05x rsp (%02x) %s%s%s%s%s%s%s%s"
1673 "irqenb %02x\n", 1673 "irqenb %02x\n",
1674 ep->ep.name, t1, t2, 1674 ep->ep.name, t1, t2,
1675 (t2 & (1 << CLEAR_NAK_OUT_PACKETS)) 1675 (t2 & BIT(CLEAR_NAK_OUT_PACKETS))
1676 ? "NAK " : "", 1676 ? "NAK " : "",
1677 (t2 & (1 << CLEAR_EP_HIDE_STATUS_PHASE)) 1677 (t2 & BIT(CLEAR_EP_HIDE_STATUS_PHASE))
1678 ? "hide " : "", 1678 ? "hide " : "",
1679 (t2 & (1 << CLEAR_EP_FORCE_CRC_ERROR)) 1679 (t2 & BIT(CLEAR_EP_FORCE_CRC_ERROR))
1680 ? "CRC " : "", 1680 ? "CRC " : "",
1681 (t2 & (1 << CLEAR_INTERRUPT_MODE)) 1681 (t2 & BIT(CLEAR_INTERRUPT_MODE))
1682 ? "interrupt " : "", 1682 ? "interrupt " : "",
1683 (t2 & (1<<CLEAR_CONTROL_STATUS_PHASE_HANDSHAKE)) 1683 (t2 & BIT(CLEAR_CONTROL_STATUS_PHASE_HANDSHAKE))
1684 ? "status " : "", 1684 ? "status " : "",
1685 (t2 & (1 << CLEAR_NAK_OUT_PACKETS_MODE)) 1685 (t2 & BIT(CLEAR_NAK_OUT_PACKETS_MODE))
1686 ? "NAKmode " : "", 1686 ? "NAKmode " : "",
1687 (t2 & (1 << CLEAR_ENDPOINT_TOGGLE)) 1687 (t2 & BIT(CLEAR_ENDPOINT_TOGGLE))
1688 ? "DATA1 " : "DATA0 ", 1688 ? "DATA1 " : "DATA0 ",
1689 (t2 & (1 << CLEAR_ENDPOINT_HALT)) 1689 (t2 & BIT(CLEAR_ENDPOINT_HALT))
1690 ? "HALT " : "", 1690 ? "HALT " : "",
1691 readl (&ep->regs->ep_irqenb)); 1691 readl (&ep->regs->ep_irqenb));
1692 size -= t; 1692 size -= t;
@@ -1922,10 +1922,10 @@ static void defect7374_disable_data_eps(struct net2280 *dev)
1922 1922
1923 /* Change settings on some selected endpoints */ 1923 /* Change settings on some selected endpoints */
1924 tmp_reg = readl(&dev->plregs->pl_ep_cfg_4); 1924 tmp_reg = readl(&dev->plregs->pl_ep_cfg_4);
1925 tmp_reg &= ~(1 << NON_CTRL_IN_TOLERATE_BAD_DIR); 1925 tmp_reg &= ~BIT(NON_CTRL_IN_TOLERATE_BAD_DIR);
1926 writel(tmp_reg, &dev->plregs->pl_ep_cfg_4); 1926 writel(tmp_reg, &dev->plregs->pl_ep_cfg_4);
1927 tmp_reg = readl(&dev->plregs->pl_ep_ctrl); 1927 tmp_reg = readl(&dev->plregs->pl_ep_ctrl);
1928 tmp_reg |= (1 << EP_INITIALIZED); 1928 tmp_reg |= BIT(EP_INITIALIZED);
1929 writel(tmp_reg, &dev->plregs->pl_ep_ctrl); 1929 writel(tmp_reg, &dev->plregs->pl_ep_ctrl);
1930 } 1930 }
1931} 1931}
@@ -1947,17 +1947,17 @@ static void defect7374_enable_data_eps_zero(struct net2280 *dev)
1947 WARNING(dev, "It will operate on cold-reboot and SS connect"); 1947 WARNING(dev, "It will operate on cold-reboot and SS connect");
1948 1948
1949 /*GPEPs:*/ 1949 /*GPEPs:*/
1950 tmp = ((0 << ENDPOINT_NUMBER) | (1 << ENDPOINT_DIRECTION) | 1950 tmp = ((0 << ENDPOINT_NUMBER) | BIT(ENDPOINT_DIRECTION) |
1951 (2 << OUT_ENDPOINT_TYPE) | (2 << IN_ENDPOINT_TYPE) | 1951 (2 << OUT_ENDPOINT_TYPE) | (2 << IN_ENDPOINT_TYPE) |
1952 ((dev->enhanced_mode) ? 1952 ((dev->enhanced_mode) ?
1953 1 << OUT_ENDPOINT_ENABLE : 1 << ENDPOINT_ENABLE) | 1953 BIT(OUT_ENDPOINT_ENABLE) : BIT(ENDPOINT_ENABLE)) |
1954 (1 << IN_ENDPOINT_ENABLE)); 1954 BIT(IN_ENDPOINT_ENABLE));
1955 1955
1956 for (i = 1; i < 5; i++) 1956 for (i = 1; i < 5; i++)
1957 writel(tmp, &dev->ep[i].cfg->ep_cfg); 1957 writel(tmp, &dev->ep[i].cfg->ep_cfg);
1958 1958
1959 /* CSRIN, PCIIN, STATIN, RCIN*/ 1959 /* CSRIN, PCIIN, STATIN, RCIN*/
1960 tmp = ((0 << ENDPOINT_NUMBER) | (1 << ENDPOINT_ENABLE)); 1960 tmp = ((0 << ENDPOINT_NUMBER) | BIT(ENDPOINT_ENABLE));
1961 writel(tmp, &dev->dep[1].dep_cfg); 1961 writel(tmp, &dev->dep[1].dep_cfg);
1962 writel(tmp, &dev->dep[3].dep_cfg); 1962 writel(tmp, &dev->dep[3].dep_cfg);
1963 writel(tmp, &dev->dep[4].dep_cfg); 1963 writel(tmp, &dev->dep[4].dep_cfg);
@@ -1974,7 +1974,7 @@ static void defect7374_enable_data_eps_zero(struct net2280 *dev)
1974 if (ep_sel == 1) { 1974 if (ep_sel == 1) {
1975 tmp = 1975 tmp =
1976 (readl(&dev->plregs->pl_ep_ctrl) | 1976 (readl(&dev->plregs->pl_ep_ctrl) |
1977 (1 << CLEAR_ACK_ERROR_CODE) | 0); 1977 BIT(CLEAR_ACK_ERROR_CODE) | 0);
1978 writel(tmp, &dev->plregs->pl_ep_ctrl); 1978 writel(tmp, &dev->plregs->pl_ep_ctrl);
1979 continue; 1979 continue;
1980 } 1980 }
@@ -1984,11 +1984,11 @@ static void defect7374_enable_data_eps_zero(struct net2280 *dev)
1984 continue; 1984 continue;
1985 1985
1986 tmp = (readl(&dev->plregs->pl_ep_cfg_4) | 1986 tmp = (readl(&dev->plregs->pl_ep_cfg_4) |
1987 (1 << NON_CTRL_IN_TOLERATE_BAD_DIR) | 0); 1987 BIT(NON_CTRL_IN_TOLERATE_BAD_DIR) | 0);
1988 writel(tmp, &dev->plregs->pl_ep_cfg_4); 1988 writel(tmp, &dev->plregs->pl_ep_cfg_4);
1989 1989
1990 tmp = readl(&dev->plregs->pl_ep_ctrl) & 1990 tmp = readl(&dev->plregs->pl_ep_ctrl) &
1991 ~(1 << EP_INITIALIZED); 1991 ~BIT(EP_INITIALIZED);
1992 writel(tmp, &dev->plregs->pl_ep_ctrl); 1992 writel(tmp, &dev->plregs->pl_ep_ctrl);
1993 1993
1994 } 1994 }
@@ -2036,14 +2036,14 @@ static void usb_reset_228x(struct net2280 *dev)
2036 } 2036 }
2037 2037
2038 writel (~0, &dev->regs->irqstat0), 2038 writel (~0, &dev->regs->irqstat0),
2039 writel (~(1 << SUSPEND_REQUEST_INTERRUPT), &dev->regs->irqstat1), 2039 writel(~(u32)BIT(SUSPEND_REQUEST_INTERRUPT), &dev->regs->irqstat1),
2040 2040
2041 /* reset, and enable pci */ 2041 /* reset, and enable pci */
2042 tmp = readl (&dev->regs->devinit) 2042 tmp = readl(&dev->regs->devinit) |
2043 | (1 << PCI_ENABLE) 2043 BIT(PCI_ENABLE) |
2044 | (1 << FIFO_SOFT_RESET) 2044 BIT(FIFO_SOFT_RESET) |
2045 | (1 << USB_SOFT_RESET) 2045 BIT(USB_SOFT_RESET) |
2046 | (1 << M8051_RESET); 2046 BIT(M8051_RESET);
2047 writel (tmp, &dev->regs->devinit); 2047 writel (tmp, &dev->regs->devinit);
2048 2048
2049 /* standard fifo and endpoint allocations */ 2049 /* standard fifo and endpoint allocations */
@@ -2087,10 +2087,10 @@ static void usb_reset_338x(struct net2280 *dev)
2087 if (fsmvalue == DEFECT7374_FSM_SS_CONTROL_READ) { 2087 if (fsmvalue == DEFECT7374_FSM_SS_CONTROL_READ) {
2088 /* reset, and enable pci */ 2088 /* reset, and enable pci */
2089 tmp = readl(&dev->regs->devinit) | 2089 tmp = readl(&dev->regs->devinit) |
2090 (1 << PCI_ENABLE) | 2090 BIT(PCI_ENABLE) |
2091 (1 << FIFO_SOFT_RESET) | 2091 BIT(FIFO_SOFT_RESET) |
2092 (1 << USB_SOFT_RESET) | 2092 BIT(USB_SOFT_RESET) |
2093 (1 << M8051_RESET); 2093 BIT(M8051_RESET);
2094 2094
2095 writel(tmp, &dev->regs->devinit); 2095 writel(tmp, &dev->regs->devinit);
2096 } 2096 }
@@ -2206,7 +2206,7 @@ static void usb_reinit_338x(struct net2280 *dev)
2206 __func__, fsmvalue); 2206 __func__, fsmvalue);
2207 else { 2207 else {
2208 tmp = readl(&dev->usb_ext->usbctl2) & 2208 tmp = readl(&dev->usb_ext->usbctl2) &
2209 ~((1 << U1_ENABLE) | (1 << U2_ENABLE) | (1 << LTM_ENABLE)); 2209 ~(BIT(U1_ENABLE) | BIT(U2_ENABLE) | BIT(LTM_ENABLE));
2210 writel(tmp, &dev->usb_ext->usbctl2); 2210 writel(tmp, &dev->usb_ext->usbctl2);
2211 } 2211 }
2212 2212
@@ -2245,7 +2245,7 @@ static void usb_reinit_338x(struct net2280 *dev)
2245 * - Reference PLX TT-7372 2245 * - Reference PLX TT-7372
2246 */ 2246 */
2247 val = readl(&dev->ll_chicken_reg->ll_tsn_chicken_bit); 2247 val = readl(&dev->ll_chicken_reg->ll_tsn_chicken_bit);
2248 val |= (1 << RECOVERY_IDLE_TO_RECOVER_FMW); 2248 val |= BIT(RECOVERY_IDLE_TO_RECOVER_FMW);
2249 writel(val, &dev->ll_chicken_reg->ll_tsn_chicken_bit); 2249 writel(val, &dev->ll_chicken_reg->ll_tsn_chicken_bit);
2250 2250
2251 INIT_LIST_HEAD(&dev->gadget.ep0->ep_list); 2251 INIT_LIST_HEAD(&dev->gadget.ep0->ep_list);
@@ -2268,9 +2268,9 @@ static void usb_reinit(struct net2280 *dev)
2268 2268
2269static void ep0_start_228x(struct net2280 *dev) 2269static void ep0_start_228x(struct net2280 *dev)
2270{ 2270{
2271 writel ( (1 << CLEAR_EP_HIDE_STATUS_PHASE) 2271 writel(BIT(CLEAR_EP_HIDE_STATUS_PHASE) |
2272 | (1 << CLEAR_NAK_OUT_PACKETS) 2272 BIT(CLEAR_NAK_OUT_PACKETS) |
2273 | (1 << CLEAR_CONTROL_STATUS_PHASE_HANDSHAKE) 2273 BIT(CLEAR_CONTROL_STATUS_PHASE_HANDSHAKE)
2274 , &dev->epregs [0].ep_rsp); 2274 , &dev->epregs [0].ep_rsp);
2275 2275
2276 /* 2276 /*
@@ -2279,31 +2279,31 @@ static void ep0_start_228x(struct net2280 *dev)
2279 * endpoint status/features are handled in software, to 2279 * endpoint status/features are handled in software, to
2280 * help pass tests for some dubious behavior. 2280 * help pass tests for some dubious behavior.
2281 */ 2281 */
2282 writel ( (1 << SET_TEST_MODE) 2282 writel(BIT(SET_TEST_MODE) |
2283 | (1 << SET_ADDRESS) 2283 BIT(SET_ADDRESS) |
2284 | (1 << DEVICE_SET_CLEAR_DEVICE_REMOTE_WAKEUP) 2284 BIT(DEVICE_SET_CLEAR_DEVICE_REMOTE_WAKEUP) |
2285 | (1 << GET_DEVICE_STATUS) 2285 BIT(GET_DEVICE_STATUS) |
2286 | (1 << GET_INTERFACE_STATUS) 2286 BIT(GET_INTERFACE_STATUS)
2287 , &dev->usb->stdrsp); 2287 , &dev->usb->stdrsp);
2288 writel ( (1 << USB_ROOT_PORT_WAKEUP_ENABLE) 2288 writel(BIT(USB_ROOT_PORT_WAKEUP_ENABLE) |
2289 | (1 << SELF_POWERED_USB_DEVICE) 2289 BIT(SELF_POWERED_USB_DEVICE) |
2290 | (1 << REMOTE_WAKEUP_SUPPORT) 2290 BIT(REMOTE_WAKEUP_SUPPORT) |
2291 | (dev->softconnect << USB_DETECT_ENABLE) 2291 (dev->softconnect << USB_DETECT_ENABLE) |
2292 | (1 << SELF_POWERED_STATUS) 2292 BIT(SELF_POWERED_STATUS),
2293 , &dev->usb->usbctl); 2293 &dev->usb->usbctl);
2294 2294
2295 /* enable irqs so we can see ep0 and general operation */ 2295 /* enable irqs so we can see ep0 and general operation */
2296 writel ( (1 << SETUP_PACKET_INTERRUPT_ENABLE) 2296 writel(BIT(SETUP_PACKET_INTERRUPT_ENABLE) |
2297 | (1 << ENDPOINT_0_INTERRUPT_ENABLE) 2297 BIT(ENDPOINT_0_INTERRUPT_ENABLE),
2298 , &dev->regs->pciirqenb0); 2298 &dev->regs->pciirqenb0);
2299 writel ( (1 << PCI_INTERRUPT_ENABLE) 2299 writel(BIT(PCI_INTERRUPT_ENABLE) |
2300 | (1 << PCI_MASTER_ABORT_RECEIVED_INTERRUPT_ENABLE) 2300 BIT(PCI_MASTER_ABORT_RECEIVED_INTERRUPT_ENABLE) |
2301 | (1 << PCI_TARGET_ABORT_RECEIVED_INTERRUPT_ENABLE) 2301 BIT(PCI_TARGET_ABORT_RECEIVED_INTERRUPT_ENABLE) |
2302 | (1 << PCI_RETRY_ABORT_INTERRUPT_ENABLE) 2302 BIT(PCI_RETRY_ABORT_INTERRUPT_ENABLE) |
2303 | (1 << VBUS_INTERRUPT_ENABLE) 2303 BIT(VBUS_INTERRUPT_ENABLE) |
2304 | (1 << ROOT_PORT_RESET_INTERRUPT_ENABLE) 2304 BIT(ROOT_PORT_RESET_INTERRUPT_ENABLE) |
2305 | (1 << SUSPEND_REQUEST_CHANGE_INTERRUPT_ENABLE) 2305 BIT(SUSPEND_REQUEST_CHANGE_INTERRUPT_ENABLE),
2306 , &dev->regs->pciirqenb1); 2306 &dev->regs->pciirqenb1);
2307 2307
2308 /* don't leave any writes posted */ 2308 /* don't leave any writes posted */
2309 (void) readl (&dev->usb->usbctl); 2309 (void) readl (&dev->usb->usbctl);
@@ -2320,8 +2320,8 @@ static void ep0_start_338x(struct net2280 *dev)
2320 INFO(dev, "%s: Defect 7374 FsmValue %08x\n", __func__, 2320 INFO(dev, "%s: Defect 7374 FsmValue %08x\n", __func__,
2321 fsmvalue); 2321 fsmvalue);
2322 else 2322 else
2323 writel((1 << CLEAR_NAK_OUT_PACKETS_MODE) | 2323 writel(BIT(CLEAR_NAK_OUT_PACKETS_MODE) |
2324 (1 << SET_EP_HIDE_STATUS_PHASE), 2324 BIT(SET_EP_HIDE_STATUS_PHASE),
2325 &dev->epregs[0].ep_rsp); 2325 &dev->epregs[0].ep_rsp);
2326 2326
2327 /* 2327 /*
@@ -2330,27 +2330,27 @@ static void ep0_start_338x(struct net2280 *dev)
2330 * endpoint status/features are handled in software, to 2330 * endpoint status/features are handled in software, to
2331 * help pass tests for some dubious behavior. 2331 * help pass tests for some dubious behavior.
2332 */ 2332 */
2333 writel((1 << SET_ISOCHRONOUS_DELAY) | 2333 writel(BIT(SET_ISOCHRONOUS_DELAY) |
2334 (1 << SET_SEL) | 2334 BIT(SET_SEL) |
2335 (1 << SET_TEST_MODE) | 2335 BIT(SET_TEST_MODE) |
2336 (1 << SET_ADDRESS) | 2336 BIT(SET_ADDRESS) |
2337 (1 << GET_INTERFACE_STATUS) | 2337 BIT(GET_INTERFACE_STATUS) |
2338 (1 << GET_DEVICE_STATUS), 2338 BIT(GET_DEVICE_STATUS),
2339 &dev->usb->stdrsp); 2339 &dev->usb->stdrsp);
2340 dev->wakeup_enable = 1; 2340 dev->wakeup_enable = 1;
2341 writel((1 << USB_ROOT_PORT_WAKEUP_ENABLE) | 2341 writel(BIT(USB_ROOT_PORT_WAKEUP_ENABLE) |
2342 (dev->softconnect << USB_DETECT_ENABLE) | 2342 (dev->softconnect << USB_DETECT_ENABLE) |
2343 (1 << DEVICE_REMOTE_WAKEUP_ENABLE), 2343 BIT(DEVICE_REMOTE_WAKEUP_ENABLE),
2344 &dev->usb->usbctl); 2344 &dev->usb->usbctl);
2345 2345
2346 /* enable irqs so we can see ep0 and general operation */ 2346 /* enable irqs so we can see ep0 and general operation */
2347 writel((1 << SETUP_PACKET_INTERRUPT_ENABLE) | 2347 writel(BIT(SETUP_PACKET_INTERRUPT_ENABLE) |
2348 (1 << ENDPOINT_0_INTERRUPT_ENABLE) 2348 BIT(ENDPOINT_0_INTERRUPT_ENABLE)
2349 , &dev->regs->pciirqenb0); 2349 , &dev->regs->pciirqenb0);
2350 writel((1 << PCI_INTERRUPT_ENABLE) | 2350 writel(BIT(PCI_INTERRUPT_ENABLE) |
2351 (1 << ROOT_PORT_RESET_INTERRUPT_ENABLE) | 2351 BIT(ROOT_PORT_RESET_INTERRUPT_ENABLE) |
2352 (1 << SUSPEND_REQUEST_CHANGE_INTERRUPT_ENABLE) | 2352 BIT(SUSPEND_REQUEST_CHANGE_INTERRUPT_ENABLE) |
2353 (1 << VBUS_INTERRUPT_ENABLE), 2353 BIT(VBUS_INTERRUPT_ENABLE),
2354 &dev->regs->pciirqenb1); 2354 &dev->regs->pciirqenb1);
2355 2355
2356 /* don't leave any writes posted */ 2356 /* don't leave any writes posted */
@@ -2402,7 +2402,7 @@ static int net2280_start(struct usb_gadget *_gadget,
2402 2402
2403 /* Enable force-full-speed testing mode, if desired */ 2403 /* Enable force-full-speed testing mode, if desired */
2404 if (full_speed && dev->pdev->vendor == PCI_VENDOR_ID_PLX_LEGACY) 2404 if (full_speed && dev->pdev->vendor == PCI_VENDOR_ID_PLX_LEGACY)
2405 writel(1 << FORCE_FULL_SPEED_MODE, &dev->usb->xcvrdiag); 2405 writel(BIT(FORCE_FULL_SPEED_MODE), &dev->usb->xcvrdiag);
2406 2406
2407 /* ... then enable host detection and ep0; and we're ready 2407 /* ... then enable host detection and ep0; and we're ready
2408 * for set_configuration as well as eventual disconnect. 2408 * for set_configuration as well as eventual disconnect.
@@ -2511,7 +2511,7 @@ static void handle_ep_small (struct net2280_ep *ep)
2511 ep->ep.name, t, req ? &req->req : 0); 2511 ep->ep.name, t, req ? &req->req : 0);
2512#endif 2512#endif
2513 if (!ep->is_in || ep->dev->pdev->device == 0x2280) 2513 if (!ep->is_in || ep->dev->pdev->device == 0x2280)
2514 writel (t & ~(1 << NAK_OUT_PACKETS), &ep->regs->ep_stat); 2514 writel(t & ~BIT(NAK_OUT_PACKETS), &ep->regs->ep_stat);
2515 else 2515 else
2516 /* Added for 2282 */ 2516 /* Added for 2282 */
2517 writel (t, &ep->regs->ep_stat); 2517 writel (t, &ep->regs->ep_stat);
@@ -2529,7 +2529,7 @@ static void handle_ep_small (struct net2280_ep *ep)
2529 if (unlikely (ep->num == 0)) { 2529 if (unlikely (ep->num == 0)) {
2530 if (ep->is_in) { 2530 if (ep->is_in) {
2531 /* status; stop NAKing */ 2531 /* status; stop NAKing */
2532 if (t & (1 << DATA_OUT_PING_TOKEN_INTERRUPT)) { 2532 if (t & BIT(DATA_OUT_PING_TOKEN_INTERRUPT)) {
2533 if (ep->dev->protocol_stall) { 2533 if (ep->dev->protocol_stall) {
2534 ep->stopped = 1; 2534 ep->stopped = 1;
2535 set_halt (ep); 2535 set_halt (ep);
@@ -2538,7 +2538,7 @@ static void handle_ep_small (struct net2280_ep *ep)
2538 allow_status (ep); 2538 allow_status (ep);
2539 mode = 2; 2539 mode = 2;
2540 /* reply to extra IN data tokens with a zlp */ 2540 /* reply to extra IN data tokens with a zlp */
2541 } else if (t & (1 << DATA_IN_TOKEN_INTERRUPT)) { 2541 } else if (t & BIT(DATA_IN_TOKEN_INTERRUPT)) {
2542 if (ep->dev->protocol_stall) { 2542 if (ep->dev->protocol_stall) {
2543 ep->stopped = 1; 2543 ep->stopped = 1;
2544 set_halt (ep); 2544 set_halt (ep);
@@ -2549,14 +2549,14 @@ static void handle_ep_small (struct net2280_ep *ep)
2549 } 2549 }
2550 } else { 2550 } else {
2551 /* status; stop NAKing */ 2551 /* status; stop NAKing */
2552 if (t & (1 << DATA_IN_TOKEN_INTERRUPT)) { 2552 if (t & BIT(DATA_IN_TOKEN_INTERRUPT)) {
2553 if (ep->dev->protocol_stall) { 2553 if (ep->dev->protocol_stall) {
2554 ep->stopped = 1; 2554 ep->stopped = 1;
2555 set_halt (ep); 2555 set_halt (ep);
2556 } 2556 }
2557 mode = 2; 2557 mode = 2;
2558 /* an extra OUT token is an error */ 2558 /* an extra OUT token is an error */
2559 } else if (((t & (1 << DATA_OUT_PING_TOKEN_INTERRUPT)) 2559 } else if (((t & BIT(DATA_OUT_PING_TOKEN_INTERRUPT))
2560 && req 2560 && req
2561 && req->req.actual == req->req.length) 2561 && req->req.actual == req->req.length)
2562 || (ep->responded && !req)) { 2562 || (ep->responded && !req)) {
@@ -2575,7 +2575,7 @@ static void handle_ep_small (struct net2280_ep *ep)
2575 2575
2576 /* manual DMA queue advance after short OUT */ 2576 /* manual DMA queue advance after short OUT */
2577 if (likely (ep->dma)) { 2577 if (likely (ep->dma)) {
2578 if (t & (1 << SHORT_PACKET_TRANSFERRED_INTERRUPT)) { 2578 if (t & BIT(SHORT_PACKET_TRANSFERRED_INTERRUPT)) {
2579 u32 count; 2579 u32 count;
2580 int stopped = ep->stopped; 2580 int stopped = ep->stopped;
2581 2581
@@ -2601,7 +2601,7 @@ static void handle_ep_small (struct net2280_ep *ep)
2601 /* here either (M < N), a "real" short rx; 2601 /* here either (M < N), a "real" short rx;
2602 * or (M == N) and the queue didn't empty 2602 * or (M == N) and the queue didn't empty
2603 */ 2603 */
2604 if (likely (t & (1 << FIFO_EMPTY))) { 2604 if (likely(t & BIT(FIFO_EMPTY))) {
2605 count = readl (&ep->dma->dmacount); 2605 count = readl (&ep->dma->dmacount);
2606 count &= DMA_BYTE_COUNT_MASK; 2606 count &= DMA_BYTE_COUNT_MASK;
2607 if (readl (&ep->dma->dmadesc) 2607 if (readl (&ep->dma->dmadesc)
@@ -2613,7 +2613,7 @@ static void handle_ep_small (struct net2280_ep *ep)
2613 } 2613 }
2614 2614
2615 /* stop DMA, leave ep NAKing */ 2615 /* stop DMA, leave ep NAKing */
2616 writel ((1 << DMA_ABORT), &ep->dma->dmastat); 2616 writel(BIT(DMA_ABORT), &ep->dma->dmastat);
2617 spin_stop_dma (ep->dma); 2617 spin_stop_dma (ep->dma);
2618 2618
2619 if (likely (req)) { 2619 if (likely (req)) {
@@ -2643,12 +2643,12 @@ static void handle_ep_small (struct net2280_ep *ep)
2643 return; 2643 return;
2644 2644
2645 /* data packet(s) received (in the fifo, OUT) */ 2645 /* data packet(s) received (in the fifo, OUT) */
2646 } else if (t & (1 << DATA_PACKET_RECEIVED_INTERRUPT)) { 2646 } else if (t & BIT(DATA_PACKET_RECEIVED_INTERRUPT)) {
2647 if (read_fifo (ep, req) && ep->num != 0) 2647 if (read_fifo (ep, req) && ep->num != 0)
2648 mode = 2; 2648 mode = 2;
2649 2649
2650 /* data packet(s) transmitted (IN) */ 2650 /* data packet(s) transmitted (IN) */
2651 } else if (t & (1 << DATA_PACKET_TRANSMITTED_INTERRUPT)) { 2651 } else if (t & BIT(DATA_PACKET_TRANSMITTED_INTERRUPT)) {
2652 unsigned len; 2652 unsigned len;
2653 2653
2654 len = req->req.length - req->req.actual; 2654 len = req->req.length - req->req.actual;
@@ -2699,7 +2699,7 @@ static void handle_ep_small (struct net2280_ep *ep)
2699 if (req && !ep->stopped) { 2699 if (req && !ep->stopped) {
2700 2700
2701 /* load IN fifo with next packet (may be zlp) */ 2701 /* load IN fifo with next packet (may be zlp) */
2702 if (t & (1 << DATA_PACKET_TRANSMITTED_INTERRUPT)) 2702 if (t & BIT(DATA_PACKET_TRANSMITTED_INTERRUPT))
2703 write_fifo (ep, &req->req); 2703 write_fifo (ep, &req->req);
2704 } 2704 }
2705} 2705}
@@ -2740,7 +2740,7 @@ static void defect7374_workaround(struct net2280 *dev, struct usb_ctrlrequest r)
2740 return; 2740 return;
2741 2741
2742 /* This is the first Control Read for this connection: */ 2742 /* This is the first Control Read for this connection: */
2743 if (!(readl(&dev->usb->usbstat) & (1 << SUPER_SPEED_MODE))) { 2743 if (!(readl(&dev->usb->usbstat) & BIT(SUPER_SPEED_MODE))) {
2744 /* 2744 /*
2745 * Connection is NOT SS: 2745 * Connection is NOT SS:
2746 * - Connection must be FS or HS. 2746 * - Connection must be FS or HS.
@@ -2804,9 +2804,9 @@ static void ep_stall(struct net2280_ep *ep, int stall)
2804 static const u32 ep_pl[9] = { 0, 3, 4, 7, 8, 2, 5, 6, 9 }; 2804 static const u32 ep_pl[9] = { 0, 3, 4, 7, 8, 2, 5, 6, 9 };
2805 2805
2806 if (stall) { 2806 if (stall) {
2807 writel((1 << SET_ENDPOINT_HALT) | 2807 writel(BIT(SET_ENDPOINT_HALT) |
2808 /* (1 << SET_NAK_PACKETS) | */ 2808 /* BIT(SET_NAK_PACKETS) | */
2809 (1 << CLEAR_CONTROL_STATUS_PHASE_HANDSHAKE), 2809 BIT(CLEAR_CONTROL_STATUS_PHASE_HANDSHAKE),
2810 &ep->regs->ep_rsp); 2810 &ep->regs->ep_rsp);
2811 ep->is_halt = 1; 2811 ep->is_halt = 1;
2812 } else { 2812 } else {
@@ -2819,14 +2819,14 @@ static void ep_stall(struct net2280_ep *ep, int stall)
2819 val = (val & ~0x1f) | ep_pl[ep->num]; 2819 val = (val & ~0x1f) | ep_pl[ep->num];
2820 writel(val, &dev->plregs->pl_ep_ctrl); 2820 writel(val, &dev->plregs->pl_ep_ctrl);
2821 2821
2822 val |= (1 << SEQUENCE_NUMBER_RESET); 2822 val |= BIT(SEQUENCE_NUMBER_RESET);
2823 writel(val, &dev->plregs->pl_ep_ctrl); 2823 writel(val, &dev->plregs->pl_ep_ctrl);
2824 } 2824 }
2825 val = readl(&ep->regs->ep_rsp); 2825 val = readl(&ep->regs->ep_rsp);
2826 val |= (1 << CLEAR_ENDPOINT_HALT) | 2826 val |= BIT(CLEAR_ENDPOINT_HALT) |
2827 (1 << CLEAR_ENDPOINT_TOGGLE); 2827 BIT(CLEAR_ENDPOINT_TOGGLE);
2828 writel(val 2828 writel(val
2829 /* | (1 << CLEAR_NAK_PACKETS)*/ 2829 /* | BIT(CLEAR_NAK_PACKETS)*/
2830 , &ep->regs->ep_rsp); 2830 , &ep->regs->ep_rsp);
2831 ep->is_halt = 0; 2831 ep->is_halt = 0;
2832 val = readl(&ep->regs->ep_rsp); 2832 val = readl(&ep->regs->ep_rsp);
@@ -2895,7 +2895,7 @@ static void handle_stat0_irqs_superspeed(struct net2280 *dev,
2895 case (USB_DIR_IN | USB_TYPE_STANDARD | USB_RECIP_DEVICE): 2895 case (USB_DIR_IN | USB_TYPE_STANDARD | USB_RECIP_DEVICE):
2896 status = dev->wakeup_enable ? 0x02 : 0x00; 2896 status = dev->wakeup_enable ? 0x02 : 0x00;
2897 if (dev->selfpowered) 2897 if (dev->selfpowered)
2898 status |= 1 << 0; 2898 status |= BIT(0);
2899 status |= (dev->u1_enable << 2 | dev->u2_enable << 3 | 2899 status |= (dev->u1_enable << 2 | dev->u2_enable << 3 |
2900 dev->ltm_enable << 4); 2900 dev->ltm_enable << 4);
2901 writel(0, &dev->epregs[0].ep_irqenb); 2901 writel(0, &dev->epregs[0].ep_irqenb);
@@ -2909,7 +2909,7 @@ static void handle_stat0_irqs_superspeed(struct net2280 *dev,
2909 if (!e) 2909 if (!e)
2910 goto do_stall3; 2910 goto do_stall3;
2911 status = readl(&e->regs->ep_rsp) & 2911 status = readl(&e->regs->ep_rsp) &
2912 (1 << CLEAR_ENDPOINT_HALT); 2912 BIT(CLEAR_ENDPOINT_HALT);
2913 writel(0, &dev->epregs[0].ep_irqenb); 2913 writel(0, &dev->epregs[0].ep_irqenb);
2914 set_fifo_bytecount(ep, sizeof(status)); 2914 set_fifo_bytecount(ep, sizeof(status));
2915 writel((__force u32) status, &dev->epregs[0].ep_data); 2915 writel((__force u32) status, &dev->epregs[0].ep_data);
@@ -2929,7 +2929,7 @@ static void handle_stat0_irqs_superspeed(struct net2280 *dev,
2929 case USB_DEVICE_U1_ENABLE: 2929 case USB_DEVICE_U1_ENABLE:
2930 dev->u1_enable = 0; 2930 dev->u1_enable = 0;
2931 writel(readl(&dev->usb_ext->usbctl2) & 2931 writel(readl(&dev->usb_ext->usbctl2) &
2932 ~(1 << U1_ENABLE), 2932 ~BIT(U1_ENABLE),
2933 &dev->usb_ext->usbctl2); 2933 &dev->usb_ext->usbctl2);
2934 allow_status_338x(ep); 2934 allow_status_338x(ep);
2935 goto next_endpoints3; 2935 goto next_endpoints3;
@@ -2937,7 +2937,7 @@ static void handle_stat0_irqs_superspeed(struct net2280 *dev,
2937 case USB_DEVICE_U2_ENABLE: 2937 case USB_DEVICE_U2_ENABLE:
2938 dev->u2_enable = 0; 2938 dev->u2_enable = 0;
2939 writel(readl(&dev->usb_ext->usbctl2) & 2939 writel(readl(&dev->usb_ext->usbctl2) &
2940 ~(1 << U2_ENABLE), 2940 ~BIT(U2_ENABLE),
2941 &dev->usb_ext->usbctl2); 2941 &dev->usb_ext->usbctl2);
2942 allow_status_338x(ep); 2942 allow_status_338x(ep);
2943 goto next_endpoints3; 2943 goto next_endpoints3;
@@ -2945,7 +2945,7 @@ static void handle_stat0_irqs_superspeed(struct net2280 *dev,
2945 case USB_DEVICE_LTM_ENABLE: 2945 case USB_DEVICE_LTM_ENABLE:
2946 dev->ltm_enable = 0; 2946 dev->ltm_enable = 0;
2947 writel(readl(&dev->usb_ext->usbctl2) & 2947 writel(readl(&dev->usb_ext->usbctl2) &
2948 ~(1 << LTM_ENABLE), 2948 ~BIT(LTM_ENABLE),
2949 &dev->usb_ext->usbctl2); 2949 &dev->usb_ext->usbctl2);
2950 allow_status_338x(ep); 2950 allow_status_338x(ep);
2951 goto next_endpoints3; 2951 goto next_endpoints3;
@@ -2957,7 +2957,7 @@ static void handle_stat0_irqs_superspeed(struct net2280 *dev,
2957 if (w_value == USB_DEVICE_REMOTE_WAKEUP) { 2957 if (w_value == USB_DEVICE_REMOTE_WAKEUP) {
2958 dev->wakeup_enable = 0; 2958 dev->wakeup_enable = 0;
2959 writel(readl(&dev->usb->usbctl) & 2959 writel(readl(&dev->usb->usbctl) &
2960 ~(1 << DEVICE_REMOTE_WAKEUP_ENABLE), 2960 ~BIT(DEVICE_REMOTE_WAKEUP_ENABLE),
2961 &dev->usb->usbctl); 2961 &dev->usb->usbctl);
2962 allow_status_338x(ep); 2962 allow_status_338x(ep);
2963 break; 2963 break;
@@ -2990,7 +2990,7 @@ static void handle_stat0_irqs_superspeed(struct net2280 *dev,
2990 case USB_DEVICE_U1_ENABLE: 2990 case USB_DEVICE_U1_ENABLE:
2991 dev->u1_enable = 1; 2991 dev->u1_enable = 1;
2992 writel(readl(&dev->usb_ext->usbctl2) | 2992 writel(readl(&dev->usb_ext->usbctl2) |
2993 (1 << U1_ENABLE), 2993 BIT(U1_ENABLE),
2994 &dev->usb_ext->usbctl2); 2994 &dev->usb_ext->usbctl2);
2995 allow_status_338x(ep); 2995 allow_status_338x(ep);
2996 goto next_endpoints3; 2996 goto next_endpoints3;
@@ -2998,7 +2998,7 @@ static void handle_stat0_irqs_superspeed(struct net2280 *dev,
2998 case USB_DEVICE_U2_ENABLE: 2998 case USB_DEVICE_U2_ENABLE:
2999 dev->u2_enable = 1; 2999 dev->u2_enable = 1;
3000 writel(readl(&dev->usb_ext->usbctl2) | 3000 writel(readl(&dev->usb_ext->usbctl2) |
3001 (1 << U2_ENABLE), 3001 BIT(U2_ENABLE),
3002 &dev->usb_ext->usbctl2); 3002 &dev->usb_ext->usbctl2);
3003 allow_status_338x(ep); 3003 allow_status_338x(ep);
3004 goto next_endpoints3; 3004 goto next_endpoints3;
@@ -3006,7 +3006,7 @@ static void handle_stat0_irqs_superspeed(struct net2280 *dev,
3006 case USB_DEVICE_LTM_ENABLE: 3006 case USB_DEVICE_LTM_ENABLE:
3007 dev->ltm_enable = 1; 3007 dev->ltm_enable = 1;
3008 writel(readl(&dev->usb_ext->usbctl2) | 3008 writel(readl(&dev->usb_ext->usbctl2) |
3009 (1 << LTM_ENABLE), 3009 BIT(LTM_ENABLE),
3010 &dev->usb_ext->usbctl2); 3010 &dev->usb_ext->usbctl2);
3011 allow_status_338x(ep); 3011 allow_status_338x(ep);
3012 goto next_endpoints3; 3012 goto next_endpoints3;
@@ -3018,7 +3018,7 @@ static void handle_stat0_irqs_superspeed(struct net2280 *dev,
3018 if (w_value == USB_DEVICE_REMOTE_WAKEUP) { 3018 if (w_value == USB_DEVICE_REMOTE_WAKEUP) {
3019 dev->wakeup_enable = 1; 3019 dev->wakeup_enable = 1;
3020 writel(readl(&dev->usb->usbctl) | 3020 writel(readl(&dev->usb->usbctl) |
3021 (1 << DEVICE_REMOTE_WAKEUP_ENABLE), 3021 BIT(DEVICE_REMOTE_WAKEUP_ENABLE),
3022 &dev->usb->usbctl); 3022 &dev->usb->usbctl);
3023 allow_status_338x(ep); 3023 allow_status_338x(ep);
3024 break; 3024 break;
@@ -3075,13 +3075,13 @@ static void handle_stat0_irqs (struct net2280 *dev, u32 stat)
3075 u32 num, scratch; 3075 u32 num, scratch;
3076 3076
3077 /* most of these don't need individual acks */ 3077 /* most of these don't need individual acks */
3078 stat &= ~(1 << INTA_ASSERTED); 3078 stat &= ~BIT(INTA_ASSERTED);
3079 if (!stat) 3079 if (!stat)
3080 return; 3080 return;
3081 // DEBUG (dev, "irqstat0 %04x\n", stat); 3081 // DEBUG (dev, "irqstat0 %04x\n", stat);
3082 3082
3083 /* starting a control request? */ 3083 /* starting a control request? */
3084 if (unlikely (stat & (1 << SETUP_PACKET_INTERRUPT))) { 3084 if (unlikely(stat & BIT(SETUP_PACKET_INTERRUPT))) {
3085 union { 3085 union {
3086 u32 raw [2]; 3086 u32 raw [2];
3087 struct usb_ctrlrequest r; 3087 struct usb_ctrlrequest r;
@@ -3091,11 +3091,11 @@ static void handle_stat0_irqs (struct net2280 *dev, u32 stat)
3091 3091
3092 if (dev->gadget.speed == USB_SPEED_UNKNOWN) { 3092 if (dev->gadget.speed == USB_SPEED_UNKNOWN) {
3093 u32 val = readl(&dev->usb->usbstat); 3093 u32 val = readl(&dev->usb->usbstat);
3094 if (val & (1 << SUPER_SPEED)) { 3094 if (val & BIT(SUPER_SPEED)) {
3095 dev->gadget.speed = USB_SPEED_SUPER; 3095 dev->gadget.speed = USB_SPEED_SUPER;
3096 usb_ep_set_maxpacket_limit(&dev->ep[0].ep, 3096 usb_ep_set_maxpacket_limit(&dev->ep[0].ep,
3097 EP0_SS_MAX_PACKET_SIZE); 3097 EP0_SS_MAX_PACKET_SIZE);
3098 } else if (val & (1 << HIGH_SPEED)) { 3098 } else if (val & BIT(HIGH_SPEED)) {
3099 dev->gadget.speed = USB_SPEED_HIGH; 3099 dev->gadget.speed = USB_SPEED_HIGH;
3100 usb_ep_set_maxpacket_limit(&dev->ep[0].ep, 3100 usb_ep_set_maxpacket_limit(&dev->ep[0].ep,
3101 EP0_HS_MAX_PACKET_SIZE); 3101 EP0_HS_MAX_PACKET_SIZE);
@@ -3112,7 +3112,7 @@ static void handle_stat0_irqs (struct net2280 *dev, u32 stat)
3112 ep->irqs++; 3112 ep->irqs++;
3113 3113
3114 /* make sure any leftover request state is cleared */ 3114 /* make sure any leftover request state is cleared */
3115 stat &= ~(1 << ENDPOINT_0_INTERRUPT); 3115 stat &= ~BIT(ENDPOINT_0_INTERRUPT);
3116 while (!list_empty (&ep->queue)) { 3116 while (!list_empty (&ep->queue)) {
3117 req = list_entry (ep->queue.next, 3117 req = list_entry (ep->queue.next,
3118 struct net2280_request, queue); 3118 struct net2280_request, queue);
@@ -3125,23 +3125,23 @@ static void handle_stat0_irqs (struct net2280 *dev, u32 stat)
3125 ep->is_halt = 0; 3125 ep->is_halt = 0;
3126 else{ 3126 else{
3127 if (ep->dev->pdev->device == 0x2280) 3127 if (ep->dev->pdev->device == 0x2280)
3128 tmp = (1 << FIFO_OVERFLOW) | 3128 tmp = BIT(FIFO_OVERFLOW) |
3129 (1 << FIFO_UNDERFLOW); 3129 BIT(FIFO_UNDERFLOW);
3130 else 3130 else
3131 tmp = 0; 3131 tmp = 0;
3132 3132
3133 writel(tmp | (1 << TIMEOUT) | 3133 writel(tmp | BIT(TIMEOUT) |
3134 (1 << USB_STALL_SENT) | 3134 BIT(USB_STALL_SENT) |
3135 (1 << USB_IN_NAK_SENT) | 3135 BIT(USB_IN_NAK_SENT) |
3136 (1 << USB_IN_ACK_RCVD) | 3136 BIT(USB_IN_ACK_RCVD) |
3137 (1 << USB_OUT_PING_NAK_SENT) | 3137 BIT(USB_OUT_PING_NAK_SENT) |
3138 (1 << USB_OUT_ACK_SENT) | 3138 BIT(USB_OUT_ACK_SENT) |
3139 (1 << SHORT_PACKET_OUT_DONE_INTERRUPT) | 3139 BIT(SHORT_PACKET_OUT_DONE_INTERRUPT) |
3140 (1 << SHORT_PACKET_TRANSFERRED_INTERRUPT) | 3140 BIT(SHORT_PACKET_TRANSFERRED_INTERRUPT) |
3141 (1 << DATA_PACKET_RECEIVED_INTERRUPT) | 3141 BIT(DATA_PACKET_RECEIVED_INTERRUPT) |
3142 (1 << DATA_PACKET_TRANSMITTED_INTERRUPT) | 3142 BIT(DATA_PACKET_TRANSMITTED_INTERRUPT) |
3143 (1 << DATA_OUT_PING_TOKEN_INTERRUPT) | 3143 BIT(DATA_OUT_PING_TOKEN_INTERRUPT) |
3144 (1 << DATA_IN_TOKEN_INTERRUPT) 3144 BIT(DATA_IN_TOKEN_INTERRUPT)
3145 , &ep->regs->ep_stat); 3145 , &ep->regs->ep_stat);
3146 } 3146 }
3147 u.raw[0] = readl(&dev->usb->setup0123); 3147 u.raw[0] = readl(&dev->usb->setup0123);
@@ -3160,8 +3160,8 @@ static void handle_stat0_irqs (struct net2280 *dev, u32 stat)
3160#define w_length le16_to_cpu(u.r.wLength) 3160#define w_length le16_to_cpu(u.r.wLength)
3161 3161
3162 /* ack the irq */ 3162 /* ack the irq */
3163 writel (1 << SETUP_PACKET_INTERRUPT, &dev->regs->irqstat0); 3163 writel(BIT(SETUP_PACKET_INTERRUPT), &dev->regs->irqstat0);
3164 stat ^= (1 << SETUP_PACKET_INTERRUPT); 3164 stat ^= BIT(SETUP_PACKET_INTERRUPT);
3165 3165
3166 /* watch control traffic at the token level, and force 3166 /* watch control traffic at the token level, and force
3167 * synchronization before letting the status stage happen. 3167 * synchronization before letting the status stage happen.
@@ -3170,14 +3170,14 @@ static void handle_stat0_irqs (struct net2280 *dev, u32 stat)
3170 */ 3170 */
3171 ep->is_in = (u.r.bRequestType & USB_DIR_IN) != 0; 3171 ep->is_in = (u.r.bRequestType & USB_DIR_IN) != 0;
3172 if (ep->is_in) { 3172 if (ep->is_in) {
3173 scratch = (1 << DATA_PACKET_TRANSMITTED_INTERRUPT) 3173 scratch = BIT(DATA_PACKET_TRANSMITTED_INTERRUPT) |
3174 | (1 << DATA_OUT_PING_TOKEN_INTERRUPT) 3174 BIT(DATA_OUT_PING_TOKEN_INTERRUPT) |
3175 | (1 << DATA_IN_TOKEN_INTERRUPT); 3175 BIT(DATA_IN_TOKEN_INTERRUPT);
3176 stop_out_naking (ep); 3176 stop_out_naking (ep);
3177 } else 3177 } else
3178 scratch = (1 << DATA_PACKET_RECEIVED_INTERRUPT) 3178 scratch = BIT(DATA_PACKET_RECEIVED_INTERRUPT) |
3179 | (1 << DATA_OUT_PING_TOKEN_INTERRUPT) 3179 BIT(DATA_OUT_PING_TOKEN_INTERRUPT) |
3180 | (1 << DATA_IN_TOKEN_INTERRUPT); 3180 BIT(DATA_IN_TOKEN_INTERRUPT);
3181 writel (scratch, &dev->epregs [0].ep_irqenb); 3181 writel (scratch, &dev->epregs [0].ep_irqenb);
3182 3182
3183 /* we made the hardware handle most lowlevel requests; 3183 /* we made the hardware handle most lowlevel requests;
@@ -3202,8 +3202,7 @@ static void handle_stat0_irqs (struct net2280 *dev, u32 stat)
3202 || w_length > 2) 3202 || w_length > 2)
3203 goto do_stall; 3203 goto do_stall;
3204 3204
3205 if (readl (&e->regs->ep_rsp) 3205 if (readl(&e->regs->ep_rsp) & BIT(SET_ENDPOINT_HALT))
3206 & (1 << SET_ENDPOINT_HALT))
3207 status = cpu_to_le32 (1); 3206 status = cpu_to_le32 (1);
3208 else 3207 else
3209 status = cpu_to_le32 (0); 3208 status = cpu_to_le32 (0);
@@ -3303,7 +3302,7 @@ next_endpoints:
3303 u32 t; 3302 u32 t;
3304 3303
3305 /* do this endpoint's FIFO and queue need tending? */ 3304 /* do this endpoint's FIFO and queue need tending? */
3306 t = 1 << num; 3305 t = BIT(num);
3307 if ((scratch & t) == 0) 3306 if ((scratch & t) == 0)
3308 continue; 3307 continue;
3309 scratch ^= t; 3308 scratch ^= t;
@@ -3316,15 +3315,14 @@ next_endpoints:
3316 DEBUG (dev, "unhandled irqstat0 %08x\n", stat); 3315 DEBUG (dev, "unhandled irqstat0 %08x\n", stat);
3317} 3316}
3318 3317
3319#define DMA_INTERRUPTS ( \ 3318#define DMA_INTERRUPTS (BIT(DMA_D_INTERRUPT) | \
3320 (1 << DMA_D_INTERRUPT) \ 3319 BIT(DMA_C_INTERRUPT) | \
3321 | (1 << DMA_C_INTERRUPT) \ 3320 BIT(DMA_B_INTERRUPT) | \
3322 | (1 << DMA_B_INTERRUPT) \ 3321 BIT(DMA_A_INTERRUPT))
3323 | (1 << DMA_A_INTERRUPT))
3324#define PCI_ERROR_INTERRUPTS ( \ 3322#define PCI_ERROR_INTERRUPTS ( \
3325 (1 << PCI_MASTER_ABORT_RECEIVED_INTERRUPT) \ 3323 BIT(PCI_MASTER_ABORT_RECEIVED_INTERRUPT) | \
3326 | (1 << PCI_TARGET_ABORT_RECEIVED_INTERRUPT) \ 3324 BIT(PCI_TARGET_ABORT_RECEIVED_INTERRUPT) | \
3327 | (1 << PCI_RETRY_ABORT_INTERRUPT)) 3325 BIT(PCI_RETRY_ABORT_INTERRUPT))
3328 3326
3329static void handle_stat1_irqs (struct net2280 *dev, u32 stat) 3327static void handle_stat1_irqs (struct net2280 *dev, u32 stat)
3330{ 3328{
@@ -3332,8 +3330,8 @@ static void handle_stat1_irqs (struct net2280 *dev, u32 stat)
3332 u32 tmp, num, mask, scratch; 3330 u32 tmp, num, mask, scratch;
3333 3331
3334 /* after disconnect there's nothing else to do! */ 3332 /* after disconnect there's nothing else to do! */
3335 tmp = (1 << VBUS_INTERRUPT) | (1 << ROOT_PORT_RESET_INTERRUPT); 3333 tmp = BIT(VBUS_INTERRUPT) | BIT(ROOT_PORT_RESET_INTERRUPT);
3336 mask = (1 << SUPER_SPEED) | (1 << HIGH_SPEED) | (1 << FULL_SPEED); 3334 mask = BIT(SUPER_SPEED) | BIT(HIGH_SPEED) | BIT(FULL_SPEED);
3337 3335
3338 /* VBUS disconnect is indicated by VBUS_PIN and VBUS_INTERRUPT set. 3336 /* VBUS disconnect is indicated by VBUS_PIN and VBUS_INTERRUPT set.
3339 * Root Port Reset is indicated by ROOT_PORT_RESET_INTERRUPT set and 3337 * Root Port Reset is indicated by ROOT_PORT_RESET_INTERRUPT set and
@@ -3342,11 +3340,11 @@ static void handle_stat1_irqs (struct net2280 *dev, u32 stat)
3342 */ 3340 */
3343 if (stat & tmp) { 3341 if (stat & tmp) {
3344 writel (tmp, &dev->regs->irqstat1); 3342 writel (tmp, &dev->regs->irqstat1);
3345 if ((((stat & (1 << ROOT_PORT_RESET_INTERRUPT)) 3343 if ((((stat & BIT(ROOT_PORT_RESET_INTERRUPT))
3346 && ((readl (&dev->usb->usbstat) & mask) 3344 && ((readl (&dev->usb->usbstat) & mask)
3347 == 0)) 3345 == 0))
3348 || ((readl (&dev->usb->usbctl) 3346 || ((readl (&dev->usb->usbctl)
3349 & (1 << VBUS_PIN)) == 0) 3347 & BIT(VBUS_PIN)) == 0)
3350 ) && ( dev->gadget.speed != USB_SPEED_UNKNOWN)) { 3348 ) && ( dev->gadget.speed != USB_SPEED_UNKNOWN)) {
3351 DEBUG (dev, "disconnect %s\n", 3349 DEBUG (dev, "disconnect %s\n",
3352 dev->driver->driver.name); 3350 dev->driver->driver.name);
@@ -3366,14 +3364,14 @@ static void handle_stat1_irqs (struct net2280 *dev, u32 stat)
3366 /* NOTE: chip stays in PCI D0 state for now, but it could 3364 /* NOTE: chip stays in PCI D0 state for now, but it could
3367 * enter D1 to save more power 3365 * enter D1 to save more power
3368 */ 3366 */
3369 tmp = (1 << SUSPEND_REQUEST_CHANGE_INTERRUPT); 3367 tmp = BIT(SUSPEND_REQUEST_CHANGE_INTERRUPT);
3370 if (stat & tmp) { 3368 if (stat & tmp) {
3371 writel (tmp, &dev->regs->irqstat1); 3369 writel (tmp, &dev->regs->irqstat1);
3372 if (stat & (1 << SUSPEND_REQUEST_INTERRUPT)) { 3370 if (stat & BIT(SUSPEND_REQUEST_INTERRUPT)) {
3373 if (dev->driver->suspend) 3371 if (dev->driver->suspend)
3374 dev->driver->suspend (&dev->gadget); 3372 dev->driver->suspend (&dev->gadget);
3375 if (!enable_suspend) 3373 if (!enable_suspend)
3376 stat &= ~(1 << SUSPEND_REQUEST_INTERRUPT); 3374 stat &= ~BIT(SUSPEND_REQUEST_INTERRUPT);
3377 } else { 3375 } else {
3378 if (dev->driver->resume) 3376 if (dev->driver->resume)
3379 dev->driver->resume (&dev->gadget); 3377 dev->driver->resume (&dev->gadget);
@@ -3388,15 +3386,15 @@ static void handle_stat1_irqs (struct net2280 *dev, u32 stat)
3388 3386
3389 /* some status we can just ignore */ 3387 /* some status we can just ignore */
3390 if (dev->pdev->device == 0x2280) 3388 if (dev->pdev->device == 0x2280)
3391 stat &= ~((1 << CONTROL_STATUS_INTERRUPT) 3389 stat &= ~(BIT(CONTROL_STATUS_INTERRUPT) |
3392 | (1 << SUSPEND_REQUEST_INTERRUPT) 3390 BIT(SUSPEND_REQUEST_INTERRUPT) |
3393 | (1 << RESUME_INTERRUPT) 3391 BIT(RESUME_INTERRUPT) |
3394 | (1 << SOF_INTERRUPT)); 3392 BIT(SOF_INTERRUPT));
3395 else 3393 else
3396 stat &= ~((1 << CONTROL_STATUS_INTERRUPT) 3394 stat &= ~(BIT(CONTROL_STATUS_INTERRUPT) |
3397 | (1 << RESUME_INTERRUPT) 3395 BIT(RESUME_INTERRUPT) |
3398 | (1 << SOF_DOWN_INTERRUPT) 3396 BIT(SOF_DOWN_INTERRUPT) |
3399 | (1 << SOF_INTERRUPT)); 3397 BIT(SOF_INTERRUPT));
3400 3398
3401 if (!stat) 3399 if (!stat)
3402 return; 3400 return;
@@ -3409,7 +3407,7 @@ static void handle_stat1_irqs (struct net2280 *dev, u32 stat)
3409 for (num = 0; scratch; num++) { 3407 for (num = 0; scratch; num++) {
3410 struct net2280_dma_regs __iomem *dma; 3408 struct net2280_dma_regs __iomem *dma;
3411 3409
3412 tmp = 1 << num; 3410 tmp = BIT(num);
3413 if ((tmp & scratch) == 0) 3411 if ((tmp & scratch) == 0)
3414 continue; 3412 continue;
3415 scratch ^= tmp; 3413 scratch ^= tmp;
@@ -3428,7 +3426,7 @@ static void handle_stat1_irqs (struct net2280 *dev, u32 stat)
3428 if (dev->pdev->vendor == PCI_VENDOR_ID_PLX) { 3426 if (dev->pdev->vendor == PCI_VENDOR_ID_PLX) {
3429 u32 r_dmacount = readl(&dma->dmacount); 3427 u32 r_dmacount = readl(&dma->dmacount);
3430 if (!ep->is_in && (r_dmacount & 0x00FFFFFF) && 3428 if (!ep->is_in && (r_dmacount & 0x00FFFFFF) &&
3431 (tmp & (1 << DMA_TRANSACTION_DONE_INTERRUPT))) 3429 (tmp & BIT(DMA_TRANSACTION_DONE_INTERRUPT)))
3432 continue; 3430 continue;
3433 } 3431 }
3434 3432
@@ -3436,7 +3434,7 @@ static void handle_stat1_irqs (struct net2280 *dev, u32 stat)
3436 * or (stat0 codepath) short OUT transfer. 3434 * or (stat0 codepath) short OUT transfer.
3437 */ 3435 */
3438 if (!use_dma_chaining) { 3436 if (!use_dma_chaining) {
3439 if (!(tmp & (1 << DMA_TRANSACTION_DONE_INTERRUPT))) { 3437 if (!(tmp & BIT(DMA_TRANSACTION_DONE_INTERRUPT))) {
3440 DEBUG (ep->dev, "%s no xact done? %08x\n", 3438 DEBUG (ep->dev, "%s no xact done? %08x\n",
3441 ep->ep.name, tmp); 3439 ep->ep.name, tmp);
3442 continue; 3440 continue;
@@ -3462,8 +3460,7 @@ static void handle_stat1_irqs (struct net2280 *dev, u32 stat)
3462 stop_dma (ep->dma); 3460 stop_dma (ep->dma);
3463 } else { 3461 } else {
3464 tmp = readl (&dma->dmactl); 3462 tmp = readl (&dma->dmactl);
3465 if (!use_dma_chaining 3463 if (!use_dma_chaining || (tmp & BIT(DMA_ENABLE)) == 0)
3466 || (tmp & (1 << DMA_ENABLE)) == 0)
3467 restart_dma (ep); 3464 restart_dma (ep);
3468 else if (ep->is_in && use_dma_chaining) { 3465 else if (ep->is_in && use_dma_chaining) {
3469 struct net2280_request *req; 3466 struct net2280_request *req;
@@ -3477,9 +3474,8 @@ static void handle_stat1_irqs (struct net2280 *dev, u32 stat)
3477 req = list_entry (ep->queue.next, 3474 req = list_entry (ep->queue.next,
3478 struct net2280_request, queue); 3475 struct net2280_request, queue);
3479 dmacount = req->td->dmacount; 3476 dmacount = req->td->dmacount;
3480 dmacount &= cpu_to_le32 ( 3477 dmacount &= cpu_to_le32(BIT(VALID_BIT) |
3481 (1 << VALID_BIT) 3478 DMA_BYTE_COUNT_MASK);
3482 | DMA_BYTE_COUNT_MASK);
3483 if (dmacount && (dmacount & valid_bit) == 0) 3479 if (dmacount && (dmacount & valid_bit) == 0)
3484 restart_dma (ep); 3480 restart_dma (ep);
3485 } 3481 }
@@ -3511,7 +3507,7 @@ static irqreturn_t net2280_irq (int irq, void *_dev)
3511 3507
3512 /* shared interrupt, not ours */ 3508 /* shared interrupt, not ours */
3513 if (dev->pdev->vendor == PCI_VENDOR_ID_PLX_LEGACY && 3509 if (dev->pdev->vendor == PCI_VENDOR_ID_PLX_LEGACY &&
3514 (!(readl(&dev->regs->irqstat0) & (1 << INTA_ASSERTED)))) 3510 (!(readl(&dev->regs->irqstat0) & BIT(INTA_ASSERTED))))
3515 return IRQ_NONE; 3511 return IRQ_NONE;
3516 3512
3517 spin_lock (&dev->lock); 3513 spin_lock (&dev->lock);
@@ -3664,7 +3660,7 @@ static int net2280_probe (struct pci_dev *pdev, const struct pci_device_id *id)
3664 dev->plregs = (struct usb338x_pl_regs __iomem *) 3660 dev->plregs = (struct usb338x_pl_regs __iomem *)
3665 (base + 0x0800); 3661 (base + 0x0800);
3666 usbstat = readl(&dev->usb->usbstat); 3662 usbstat = readl(&dev->usb->usbstat);
3667 dev->enhanced_mode = (usbstat & (1 << 11)) ? 1 : 0; 3663 dev->enhanced_mode = (usbstat & BIT(11)) ? 1 : 0;
3668 dev->n_ep = (dev->enhanced_mode) ? 9 : 5; 3664 dev->n_ep = (dev->enhanced_mode) ? 9 : 5;
3669 /* put into initial config, link up all endpoints */ 3665 /* put into initial config, link up all endpoints */
3670 fsmvalue = get_idx_reg(dev->regs, SCRATCH) & 3666 fsmvalue = get_idx_reg(dev->regs, SCRATCH) &
@@ -3729,12 +3725,14 @@ static int net2280_probe (struct pci_dev *pdev, const struct pci_device_id *id)
3729 3725
3730 /* enable lower-overhead pci memory bursts during DMA */ 3726 /* enable lower-overhead pci memory bursts during DMA */
3731 if (dev->pdev->vendor == PCI_VENDOR_ID_PLX_LEGACY) 3727 if (dev->pdev->vendor == PCI_VENDOR_ID_PLX_LEGACY)
3732 writel((1 << DMA_MEMORY_WRITE_AND_INVALIDATE_ENABLE) 3728 writel(BIT(DMA_MEMORY_WRITE_AND_INVALIDATE_ENABLE) |
3733 // 256 write retries may not be enough... 3729 /*
3734 // | (1 << PCI_RETRY_ABORT_ENABLE) 3730 * 256 write retries may not be enough...
3735 | (1 << DMA_READ_MULTIPLE_ENABLE) 3731 BIT(PCI_RETRY_ABORT_ENABLE) |
3736 | (1 << DMA_READ_LINE_ENABLE) 3732 */
3737 , &dev->pci->pcimstctl); 3733 BIT(DMA_READ_MULTIPLE_ENABLE) |
3734 BIT(DMA_READ_LINE_ENABLE),
3735 &dev->pci->pcimstctl);
3738 /* erratum 0115 shouldn't appear: Linux inits PCI_LATENCY_TIMER */ 3736 /* erratum 0115 shouldn't appear: Linux inits PCI_LATENCY_TIMER */
3739 pci_set_master (pdev); 3737 pci_set_master (pdev);
3740 pci_try_set_mwi (pdev); 3738 pci_try_set_mwi (pdev);
diff --git a/drivers/usb/gadget/net2280.h b/drivers/usb/gadget/net2280.h
index 30478c8ed878..e1c5d1a5a7d0 100644
--- a/drivers/usb/gadget/net2280.h
+++ b/drivers/usb/gadget/net2280.h
@@ -116,9 +116,9 @@ struct net2280_ep {
116static inline void allow_status (struct net2280_ep *ep) 116static inline void allow_status (struct net2280_ep *ep)
117{ 117{
118 /* ep0 only */ 118 /* ep0 only */
119 writel ( (1 << CLEAR_CONTROL_STATUS_PHASE_HANDSHAKE) 119 writel(BIT(CLEAR_CONTROL_STATUS_PHASE_HANDSHAKE) |
120 | (1 << CLEAR_NAK_OUT_PACKETS) 120 BIT(CLEAR_NAK_OUT_PACKETS) |
121 | (1 << CLEAR_NAK_OUT_PACKETS_MODE) 121 BIT(CLEAR_NAK_OUT_PACKETS_MODE)
122 , &ep->regs->ep_rsp); 122 , &ep->regs->ep_rsp);
123 ep->stopped = 1; 123 ep->stopped = 1;
124} 124}
@@ -130,7 +130,7 @@ static void allow_status_338x(struct net2280_ep *ep)
130 * packet arrived. While set, the chip automatically NAKs the host's 130 * packet arrived. While set, the chip automatically NAKs the host's
131 * Status Phase tokens. 131 * Status Phase tokens.
132 */ 132 */
133 writel(1 << CLEAR_CONTROL_STATUS_PHASE_HANDSHAKE, &ep->regs->ep_rsp); 133 writel(BIT(CLEAR_CONTROL_STATUS_PHASE_HANDSHAKE), &ep->regs->ep_rsp);
134 134
135 ep->stopped = 1; 135 ep->stopped = 1;
136 136
@@ -191,23 +191,24 @@ struct net2280 {
191static inline void set_halt (struct net2280_ep *ep) 191static inline void set_halt (struct net2280_ep *ep)
192{ 192{
193 /* ep0 and bulk/intr endpoints */ 193 /* ep0 and bulk/intr endpoints */
194 writel ( (1 << CLEAR_CONTROL_STATUS_PHASE_HANDSHAKE) 194 writel(BIT(CLEAR_CONTROL_STATUS_PHASE_HANDSHAKE) |
195 /* set NAK_OUT for erratum 0114 */ 195 /* set NAK_OUT for erratum 0114 */
196 | ((ep->dev->chiprev == CHIPREV_1) << SET_NAK_OUT_PACKETS) 196 ((ep->dev->chiprev == CHIPREV_1) << SET_NAK_OUT_PACKETS) |
197 | (1 << SET_ENDPOINT_HALT) 197 BIT(SET_ENDPOINT_HALT),
198 , &ep->regs->ep_rsp); 198 &ep->regs->ep_rsp);
199} 199}
200 200
201static inline void clear_halt (struct net2280_ep *ep) 201static inline void clear_halt (struct net2280_ep *ep)
202{ 202{
203 /* ep0 and bulk/intr endpoints */ 203 /* ep0 and bulk/intr endpoints */
204 writel ( (1 << CLEAR_ENDPOINT_HALT) 204 writel(BIT(CLEAR_ENDPOINT_HALT) |
205 | (1 << CLEAR_ENDPOINT_TOGGLE) 205 BIT(CLEAR_ENDPOINT_TOGGLE) |
206 /* unless the gadget driver left a short packet in the 206 /*
207 * unless the gadget driver left a short packet in the
207 * fifo, this reverses the erratum 0114 workaround. 208 * fifo, this reverses the erratum 0114 workaround.
208 */ 209 */
209 | ((ep->dev->chiprev == CHIPREV_1) << CLEAR_NAK_OUT_PACKETS) 210 ((ep->dev->chiprev == CHIPREV_1) << CLEAR_NAK_OUT_PACKETS),
210 , &ep->regs->ep_rsp); 211 &ep->regs->ep_rsp);
211} 212}
212 213
213/* 214/*
@@ -225,7 +226,7 @@ static inline void clear_halt (struct net2280_ep *ep)
225 * - Tip: Upon the first SS Control Read the FSM never 226 * - Tip: Upon the first SS Control Read the FSM never
226 * returns to this state. 227 * returns to this state.
227 */ 228 */
228#define DEFECT7374_FSM_WAITING_FOR_CONTROL_READ (1 << DEFECT7374_FSM_FIELD) 229#define DEFECT7374_FSM_WAITING_FOR_CONTROL_READ BIT(DEFECT7374_FSM_FIELD)
229 230
230/* Non-SS Control Read: 231/* Non-SS Control Read:
231 * - A transition to this state indicates detection of the first HS 232 * - A transition to this state indicates detection of the first HS
@@ -252,12 +253,12 @@ static inline void clear_halt (struct net2280_ep *ep)
252static inline void net2280_led_init (struct net2280 *dev) 253static inline void net2280_led_init (struct net2280 *dev)
253{ 254{
254 /* LED3 (green) is on during USB activity. note erratum 0113. */ 255 /* LED3 (green) is on during USB activity. note erratum 0113. */
255 writel ((1 << GPIO3_LED_SELECT) 256 writel(BIT(GPIO3_LED_SELECT) |
256 | (1 << GPIO3_OUTPUT_ENABLE) 257 BIT(GPIO3_OUTPUT_ENABLE) |
257 | (1 << GPIO2_OUTPUT_ENABLE) 258 BIT(GPIO2_OUTPUT_ENABLE) |
258 | (1 << GPIO1_OUTPUT_ENABLE) 259 BIT(GPIO1_OUTPUT_ENABLE) |
259 | (1 << GPIO0_OUTPUT_ENABLE) 260 BIT(GPIO0_OUTPUT_ENABLE),
260 , &dev->regs->gpioctl); 261 &dev->regs->gpioctl);
261} 262}
262 263
263/* indicate speed with bi-color LED 0/1 */ 264/* indicate speed with bi-color LED 0/1 */
@@ -267,18 +268,18 @@ void net2280_led_speed (struct net2280 *dev, enum usb_device_speed speed)
267 u32 val = readl (&dev->regs->gpioctl); 268 u32 val = readl (&dev->regs->gpioctl);
268 switch (speed) { 269 switch (speed) {
269 case USB_SPEED_SUPER: /* green + red */ 270 case USB_SPEED_SUPER: /* green + red */
270 val |= (1 << GPIO0_DATA) | (1 << GPIO1_DATA); 271 val |= BIT(GPIO0_DATA) | BIT(GPIO1_DATA);
271 break; 272 break;
272 case USB_SPEED_HIGH: /* green */ 273 case USB_SPEED_HIGH: /* green */
273 val &= ~(1 << GPIO0_DATA); 274 val &= ~BIT(GPIO0_DATA);
274 val |= (1 << GPIO1_DATA); 275 val |= BIT(GPIO1_DATA);
275 break; 276 break;
276 case USB_SPEED_FULL: /* red */ 277 case USB_SPEED_FULL: /* red */
277 val &= ~(1 << GPIO1_DATA); 278 val &= ~BIT(GPIO1_DATA);
278 val |= (1 << GPIO0_DATA); 279 val |= BIT(GPIO0_DATA);
279 break; 280 break;
280 default: /* (off/black) */ 281 default: /* (off/black) */
281 val &= ~((1 << GPIO1_DATA) | (1 << GPIO0_DATA)); 282 val &= ~(BIT(GPIO1_DATA) | BIT(GPIO0_DATA));
282 break; 283 break;
283 } 284 }
284 writel (val, &dev->regs->gpioctl); 285 writel (val, &dev->regs->gpioctl);
@@ -356,7 +357,7 @@ static inline void set_fifo_bytecount(struct net2280_ep *ep, unsigned count)
356static inline void start_out_naking (struct net2280_ep *ep) 357static inline void start_out_naking (struct net2280_ep *ep)
357{ 358{
358 /* NOTE: hardware races lurk here, and PING protocol issues */ 359 /* NOTE: hardware races lurk here, and PING protocol issues */
359 writel ((1 << SET_NAK_OUT_PACKETS), &ep->regs->ep_rsp); 360 writel(BIT(SET_NAK_OUT_PACKETS), &ep->regs->ep_rsp);
360 /* synch with device */ 361 /* synch with device */
361 readl (&ep->regs->ep_rsp); 362 readl (&ep->regs->ep_rsp);
362} 363}
@@ -366,10 +367,10 @@ static inline void assert_out_naking (struct net2280_ep *ep, const char *where)
366{ 367{
367 u32 tmp = readl (&ep->regs->ep_stat); 368 u32 tmp = readl (&ep->regs->ep_stat);
368 369
369 if ((tmp & (1 << NAK_OUT_PACKETS)) == 0) { 370 if ((tmp & BIT(NAK_OUT_PACKETS)) == 0) {
370 DEBUG (ep->dev, "%s %s %08x !NAK\n", 371 DEBUG (ep->dev, "%s %s %08x !NAK\n",
371 ep->ep.name, where, tmp); 372 ep->ep.name, where, tmp);
372 writel ((1 << SET_NAK_OUT_PACKETS), 373 writel(BIT(SET_NAK_OUT_PACKETS),
373 &ep->regs->ep_rsp); 374 &ep->regs->ep_rsp);
374 } 375 }
375} 376}
@@ -383,8 +384,8 @@ static inline void stop_out_naking (struct net2280_ep *ep)
383 u32 tmp; 384 u32 tmp;
384 385
385 tmp = readl (&ep->regs->ep_stat); 386 tmp = readl (&ep->regs->ep_stat);
386 if ((tmp & (1 << NAK_OUT_PACKETS)) != 0) 387 if ((tmp & BIT(NAK_OUT_PACKETS)) != 0)
387 writel ((1 << CLEAR_NAK_OUT_PACKETS), &ep->regs->ep_rsp); 388 writel(BIT(CLEAR_NAK_OUT_PACKETS), &ep->regs->ep_rsp);
388} 389}
389 390
390 391