~ubuntu-branches/ubuntu/trusty/linux-linaro-omap/trusty

« back to all changes in this revision

Viewing changes to drivers/usb/host/uhci-hcd.h

  • Committer: Package Import Robot
  • Author(s): John Rigby, John Rigby
  • Date: 2011-09-26 10:44:23 UTC
  • Revision ID: package-import@ubuntu.com-20110926104423-57i0gl3v99b3lkfg
Tags: 3.0.0-1007.9
[ John Rigby ]

Enable crypto modules and remove crypto-modules from
exclude-module files
LP: #826021

Show diffs side-by-side

added added

removed removed

Lines of Context:
78
78
#define   USBPORT1EN            0x01
79
79
#define   USBPORT2EN            0x02
80
80
 
81
 
#define UHCI_PTR_BITS           cpu_to_le32(0x000F)
82
 
#define UHCI_PTR_TERM           cpu_to_le32(0x0001)
83
 
#define UHCI_PTR_QH             cpu_to_le32(0x0002)
84
 
#define UHCI_PTR_DEPTH          cpu_to_le32(0x0004)
85
 
#define UHCI_PTR_BREADTH        cpu_to_le32(0x0000)
 
81
#define UHCI_PTR_BITS(uhci)     cpu_to_hc32((uhci), 0x000F)
 
82
#define UHCI_PTR_TERM(uhci)     cpu_to_hc32((uhci), 0x0001)
 
83
#define UHCI_PTR_QH(uhci)       cpu_to_hc32((uhci), 0x0002)
 
84
#define UHCI_PTR_DEPTH(uhci)    cpu_to_hc32((uhci), 0x0004)
 
85
#define UHCI_PTR_BREADTH(uhci)  cpu_to_hc32((uhci), 0x0000)
86
86
 
87
87
#define UHCI_NUMFRAMES          1024    /* in the frame list [array] */
88
88
#define UHCI_MAX_SOF_NUMBER     2047    /* in an SOF packet */
99
99
 
100
100
 
101
101
/*
 
102
 * __hc32 and __hc16 are "Host Controller" types, they may be equivalent to
 
103
 * __leXX (normally) or __beXX (given UHCI_BIG_ENDIAN_DESC), depending on
 
104
 * the host controller implementation.
 
105
 *
 
106
 * To facilitate the strongest possible byte-order checking from "sparse"
 
107
 * and so on, we use __leXX unless that's not practical.
 
108
 */
 
109
#ifdef CONFIG_USB_UHCI_BIG_ENDIAN_DESC
 
110
typedef __u32 __bitwise __hc32;
 
111
typedef __u16 __bitwise __hc16;
 
112
#else
 
113
#define __hc32  __le32
 
114
#define __hc16  __le16
 
115
#endif
 
116
 
 
117
/*
102
118
 *      Queue Headers
103
119
 */
104
120
 
130
146
 
131
147
struct uhci_qh {
132
148
        /* Hardware fields */
133
 
        __le32 link;                    /* Next QH in the schedule */
134
 
        __le32 element;                 /* Queue element (TD) pointer */
 
149
        __hc32 link;                    /* Next QH in the schedule */
 
150
        __hc32 element;                 /* Queue element (TD) pointer */
135
151
 
136
152
        /* Software fields */
137
153
        dma_addr_t dma_handle;
168
184
 * We need a special accessor for the element pointer because it is
169
185
 * subject to asynchronous updates by the controller.
170
186
 */
171
 
static inline __le32 qh_element(struct uhci_qh *qh) {
172
 
        __le32 element = qh->element;
173
 
 
174
 
        barrier();
175
 
        return element;
176
 
}
177
 
 
178
 
#define LINK_TO_QH(qh)          (UHCI_PTR_QH | cpu_to_le32((qh)->dma_handle))
 
187
#define qh_element(qh)          ACCESS_ONCE((qh)->element)
 
188
 
 
189
#define LINK_TO_QH(uhci, qh)    (UHCI_PTR_QH((uhci)) | \
 
190
                                cpu_to_hc32((uhci), (qh)->dma_handle))
179
191
 
180
192
 
181
193
/*
212
224
/*
213
225
 * for TD <info>: (a.k.a. Token)
214
226
 */
215
 
#define td_token(td)            le32_to_cpu((td)->token)
 
227
#define td_token(uhci, td)      hc32_to_cpu((uhci), (td)->token)
216
228
#define TD_TOKEN_DEVADDR_SHIFT  8
217
229
#define TD_TOKEN_TOGGLE_SHIFT   19
218
230
#define TD_TOKEN_TOGGLE         (1 << 19)
245
257
 */
246
258
struct uhci_td {
247
259
        /* Hardware fields */
248
 
        __le32 link;
249
 
        __le32 status;
250
 
        __le32 token;
251
 
        __le32 buffer;
 
260
        __hc32 link;
 
261
        __hc32 status;
 
262
        __hc32 token;
 
263
        __hc32 buffer;
252
264
 
253
265
        /* Software fields */
254
266
        dma_addr_t dma_handle;
263
275
 * We need a special accessor for the control/status word because it is
264
276
 * subject to asynchronous updates by the controller.
265
277
 */
266
 
static inline u32 td_status(struct uhci_td *td) {
267
 
        __le32 status = td->status;
268
 
 
269
 
        barrier();
270
 
        return le32_to_cpu(status);
271
 
}
272
 
 
273
 
#define LINK_TO_TD(td)          (cpu_to_le32((td)->dma_handle))
 
278
#define td_status(uhci, td)             hc32_to_cpu((uhci), \
 
279
                                                ACCESS_ONCE((td)->status))
 
280
 
 
281
#define LINK_TO_TD(uhci, td)            (cpu_to_hc32((uhci), (td)->dma_handle))
274
282
 
275
283
 
276
284
/*
393
401
        spinlock_t lock;
394
402
 
395
403
        dma_addr_t frame_dma_handle;    /* Hardware frame list */
396
 
        __le32 *frame;
 
404
        __hc32 *frame;
397
405
        void **frame_cpu;               /* CPU's frame list */
398
406
 
399
407
        enum uhci_rh_state rh_state;
421
429
        /* Silicon quirks */
422
430
        unsigned int oc_low:1;                  /* OverCurrent bit active low */
423
431
        unsigned int wait_for_hp:1;             /* Wait for HP port reset */
 
432
        unsigned int big_endian_mmio:1;         /* Big endian registers */
 
433
        unsigned int big_endian_desc:1;         /* Big endian descriptors */
424
434
 
425
435
        /* Support for port suspend/resume/reset */
426
436
        unsigned long port_c_suspend;           /* Bit-arrays of ports */
490
500
 * we use memory mapped registers.
491
501
 */
492
502
 
493
 
#if !defined(CONFIG_USB_UHCI_SUPPORT_NON_PCI_HC)
 
503
#ifndef CONFIG_USB_UHCI_SUPPORT_NON_PCI_HC
494
504
/* Support PCI only */
495
 
static inline u32 uhci_readl(struct uhci_hcd *uhci, int reg)
 
505
static inline u32 uhci_readl(const struct uhci_hcd *uhci, int reg)
496
506
{
497
507
        return inl(uhci->io_addr + reg);
498
508
}
499
509
 
500
 
static inline void uhci_writel(struct uhci_hcd *uhci, u32 val, int reg)
 
510
static inline void uhci_writel(const struct uhci_hcd *uhci, u32 val, int reg)
501
511
{
502
512
        outl(val, uhci->io_addr + reg);
503
513
}
504
514
 
505
 
static inline u16 uhci_readw(struct uhci_hcd *uhci, int reg)
 
515
static inline u16 uhci_readw(const struct uhci_hcd *uhci, int reg)
506
516
{
507
517
        return inw(uhci->io_addr + reg);
508
518
}
509
519
 
510
 
static inline void uhci_writew(struct uhci_hcd *uhci, u16 val, int reg)
 
520
static inline void uhci_writew(const struct uhci_hcd *uhci, u16 val, int reg)
511
521
{
512
522
        outw(val, uhci->io_addr + reg);
513
523
}
514
524
 
515
 
static inline u8 uhci_readb(struct uhci_hcd *uhci, int reg)
 
525
static inline u8 uhci_readb(const struct uhci_hcd *uhci, int reg)
516
526
{
517
527
        return inb(uhci->io_addr + reg);
518
528
}
519
529
 
520
 
static inline void uhci_writeb(struct uhci_hcd *uhci, u8 val, int reg)
 
530
static inline void uhci_writeb(const struct uhci_hcd *uhci, u8 val, int reg)
521
531
{
522
532
        outb(val, uhci->io_addr + reg);
523
533
}
524
534
 
525
535
#else
 
536
/* Support non-PCI host controllers */
 
537
#ifdef CONFIG_PCI
526
538
/* Support PCI and non-PCI host controllers */
527
 
 
528
539
#define uhci_has_pci_registers(u)       ((u)->io_addr != 0)
529
 
 
530
 
static inline u32 uhci_readl(struct uhci_hcd *uhci, int reg)
 
540
#else
 
541
/* Support non-PCI host controllers only */
 
542
#define uhci_has_pci_registers(u)       0
 
543
#endif
 
544
 
 
545
#ifdef CONFIG_USB_UHCI_BIG_ENDIAN_MMIO
 
546
/* Support (non-PCI) big endian host controllers */
 
547
#define uhci_big_endian_mmio(u)         ((u)->big_endian_mmio)
 
548
#else
 
549
#define uhci_big_endian_mmio(u)         0
 
550
#endif
 
551
 
 
552
static inline u32 uhci_readl(const struct uhci_hcd *uhci, int reg)
531
553
{
532
554
        if (uhci_has_pci_registers(uhci))
533
555
                return inl(uhci->io_addr + reg);
 
556
#ifdef CONFIG_USB_UHCI_BIG_ENDIAN_MMIO
 
557
        else if (uhci_big_endian_mmio(uhci))
 
558
                return readl_be(uhci->regs + reg);
 
559
#endif
534
560
        else
535
561
                return readl(uhci->regs + reg);
536
562
}
537
563
 
538
 
static inline void uhci_writel(struct uhci_hcd *uhci, u32 val, int reg)
 
564
static inline void uhci_writel(const struct uhci_hcd *uhci, u32 val, int reg)
539
565
{
540
566
        if (uhci_has_pci_registers(uhci))
541
567
                outl(val, uhci->io_addr + reg);
 
568
#ifdef CONFIG_USB_UHCI_BIG_ENDIAN_MMIO
 
569
        else if (uhci_big_endian_mmio(uhci))
 
570
                writel_be(val, uhci->regs + reg);
 
571
#endif
542
572
        else
543
573
                writel(val, uhci->regs + reg);
544
574
}
545
575
 
546
 
static inline u16 uhci_readw(struct uhci_hcd *uhci, int reg)
 
576
static inline u16 uhci_readw(const struct uhci_hcd *uhci, int reg)
547
577
{
548
578
        if (uhci_has_pci_registers(uhci))
549
579
                return inw(uhci->io_addr + reg);
 
580
#ifdef CONFIG_USB_UHCI_BIG_ENDIAN_MMIO
 
581
        else if (uhci_big_endian_mmio(uhci))
 
582
                return readw_be(uhci->regs + reg);
 
583
#endif
550
584
        else
551
585
                return readw(uhci->regs + reg);
552
586
}
553
587
 
554
 
static inline void uhci_writew(struct uhci_hcd *uhci, u16 val, int reg)
 
588
static inline void uhci_writew(const struct uhci_hcd *uhci, u16 val, int reg)
555
589
{
556
590
        if (uhci_has_pci_registers(uhci))
557
591
                outw(val, uhci->io_addr + reg);
 
592
#ifdef CONFIG_USB_UHCI_BIG_ENDIAN_MMIO
 
593
        else if (uhci_big_endian_mmio(uhci))
 
594
                writew_be(val, uhci->regs + reg);
 
595
#endif
558
596
        else
559
597
                writew(val, uhci->regs + reg);
560
598
}
561
599
 
562
 
static inline u8 uhci_readb(struct uhci_hcd *uhci, int reg)
 
600
static inline u8 uhci_readb(const struct uhci_hcd *uhci, int reg)
563
601
{
564
602
        if (uhci_has_pci_registers(uhci))
565
603
                return inb(uhci->io_addr + reg);
 
604
#ifdef CONFIG_USB_UHCI_BIG_ENDIAN_MMIO
 
605
        else if (uhci_big_endian_mmio(uhci))
 
606
                return readb_be(uhci->regs + reg);
 
607
#endif
566
608
        else
567
609
                return readb(uhci->regs + reg);
568
610
}
569
611
 
570
 
static inline void uhci_writeb(struct uhci_hcd *uhci, u8 val, int reg)
 
612
static inline void uhci_writeb(const struct uhci_hcd *uhci, u8 val, int reg)
571
613
{
572
614
        if (uhci_has_pci_registers(uhci))
573
615
                outb(val, uhci->io_addr + reg);
 
616
#ifdef CONFIG_USB_UHCI_BIG_ENDIAN_MMIO
 
617
        else if (uhci_big_endian_mmio(uhci))
 
618
                writeb_be(val, uhci->regs + reg);
 
619
#endif
574
620
        else
575
621
                writeb(val, uhci->regs + reg);
576
622
}
577
 
#endif /* !defined(CONFIG_USB_UHCI_SUPPORT_NON_PCI_HC) */
 
623
#endif /* CONFIG_USB_UHCI_SUPPORT_NON_PCI_HC */
 
624
 
 
625
/*
 
626
 * The GRLIB GRUSBHC controller can use big endian format for its descriptors.
 
627
 *
 
628
 * UHCI controllers accessed through PCI work normally (little-endian
 
629
 * everywhere), so we don't bother supporting a BE-only mode.
 
630
 */
 
631
#ifdef CONFIG_USB_UHCI_BIG_ENDIAN_DESC
 
632
#define uhci_big_endian_desc(u)         ((u)->big_endian_desc)
 
633
 
 
634
/* cpu to uhci */
 
635
static inline __hc32 cpu_to_hc32(const struct uhci_hcd *uhci, const u32 x)
 
636
{
 
637
        return uhci_big_endian_desc(uhci)
 
638
                ? (__force __hc32)cpu_to_be32(x)
 
639
                : (__force __hc32)cpu_to_le32(x);
 
640
}
 
641
 
 
642
/* uhci to cpu */
 
643
static inline u32 hc32_to_cpu(const struct uhci_hcd *uhci, const __hc32 x)
 
644
{
 
645
        return uhci_big_endian_desc(uhci)
 
646
                ? be32_to_cpu((__force __be32)x)
 
647
                : le32_to_cpu((__force __le32)x);
 
648
}
 
649
 
 
650
#else
 
651
/* cpu to uhci */
 
652
static inline __hc32 cpu_to_hc32(const struct uhci_hcd *uhci, const u32 x)
 
653
{
 
654
        return cpu_to_le32(x);
 
655
}
 
656
 
 
657
/* uhci to cpu */
 
658
static inline u32 hc32_to_cpu(const struct uhci_hcd *uhci, const __hc32 x)
 
659
{
 
660
        return le32_to_cpu(x);
 
661
}
 
662
#endif
578
663
 
579
664
#endif