~ubuntu-branches/ubuntu/precise/linux-ti-omap4/precise

« back to all changes in this revision

Viewing changes to drivers/usb/host/xhci.h

  • Committer: Bazaar Package Importer
  • Author(s): Paolo Pisati
  • Date: 2011-06-29 15:23:51 UTC
  • mfrom: (26.1.1 natty-proposed)
  • Revision ID: james.westby@ubuntu.com-20110629152351-xs96tm303d95rpbk
Tags: 3.0.0-1200.2
* Rebased against 3.0.0-6.7
* BSP from TI based on 3.0.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
30
30
 
31
31
/* Code sharing between pci-quirks and xhci hcd */
32
32
#include        "xhci-ext-caps.h"
 
33
#include "pci-quirks.h"
33
34
 
34
35
/* xHCI PCI Configuration Registers */
35
36
#define XHCI_SBRN_OFFSET        (0x60)
56
57
 * @run_regs_off:       RTSOFF - Runtime register space offset
57
58
 */
58
59
struct xhci_cap_regs {
59
 
        u32     hc_capbase;
60
 
        u32     hcs_params1;
61
 
        u32     hcs_params2;
62
 
        u32     hcs_params3;
63
 
        u32     hcc_params;
64
 
        u32     db_off;
65
 
        u32     run_regs_off;
 
60
        __le32  hc_capbase;
 
61
        __le32  hcs_params1;
 
62
        __le32  hcs_params2;
 
63
        __le32  hcs_params3;
 
64
        __le32  hcc_params;
 
65
        __le32  db_off;
 
66
        __le32  run_regs_off;
66
67
        /* Reserved up to (CAPLENGTH - 0x1C) */
67
68
};
68
69
 
154
155
 *                      devices.
155
156
 */
156
157
struct xhci_op_regs {
157
 
        u32     command;
158
 
        u32     status;
159
 
        u32     page_size;
160
 
        u32     reserved1;
161
 
        u32     reserved2;
162
 
        u32     dev_notification;
163
 
        u64     cmd_ring;
 
158
        __le32  command;
 
159
        __le32  status;
 
160
        __le32  page_size;
 
161
        __le32  reserved1;
 
162
        __le32  reserved2;
 
163
        __le32  dev_notification;
 
164
        __le64  cmd_ring;
164
165
        /* rsvd: offset 0x20-2F */
165
 
        u32     reserved3[4];
166
 
        u64     dcbaa_ptr;
167
 
        u32     config_reg;
 
166
        __le32  reserved3[4];
 
167
        __le64  dcbaa_ptr;
 
168
        __le32  config_reg;
168
169
        /* rsvd: offset 0x3C-3FF */
169
 
        u32     reserved4[241];
 
170
        __le32  reserved4[241];
170
171
        /* port 1 registers, which serve as a base address for other ports */
171
 
        u32     port_status_base;
172
 
        u32     port_power_base;
173
 
        u32     port_link_base;
174
 
        u32     reserved5;
 
172
        __le32  port_status_base;
 
173
        __le32  port_power_base;
 
174
        __le32  port_link_base;
 
175
        __le32  reserved5;
175
176
        /* registers for ports 2-255 */
176
 
        u32     reserved6[NUM_PORT_REGS*254];
 
177
        __le32  reserved6[NUM_PORT_REGS*254];
177
178
};
178
179
 
179
180
/* USBCMD - USB command - command bitmasks */
348
349
/* Initiate a warm port reset - complete when PORT_WRC is '1' */
349
350
#define PORT_WR         (1 << 31)
350
351
 
 
352
/* We mark duplicate entries with -1 */
 
353
#define DUPLICATE_ENTRY ((u8)(-1))
 
354
 
351
355
/* Port Power Management Status and Control - port_power_base bitmasks */
352
356
/* Inactivity timer value for transitions into U1, in microseconds.
353
357
 * Timeout can be up to 127us.  0xFF means an infinite timeout.
378
382
 * updates the dequeue pointer.
379
383
 */
380
384
struct xhci_intr_reg {
381
 
        u32     irq_pending;
382
 
        u32     irq_control;
383
 
        u32     erst_size;
384
 
        u32     rsvd;
385
 
        u64     erst_base;
386
 
        u64     erst_dequeue;
 
385
        __le32  irq_pending;
 
386
        __le32  irq_control;
 
387
        __le32  erst_size;
 
388
        __le32  rsvd;
 
389
        __le64  erst_base;
 
390
        __le64  erst_dequeue;
387
391
};
388
392
 
389
393
/* irq_pending bitmasks */
428
432
 * or larger accesses"
429
433
 */
430
434
struct xhci_run_regs {
431
 
        u32                     microframe_index;
432
 
        u32                     rsvd[7];
 
435
        __le32                  microframe_index;
 
436
        __le32                  rsvd[7];
433
437
        struct xhci_intr_reg    ir_set[128];
434
438
};
435
439
 
443
447
 * Section 5.6
444
448
 */
445
449
struct xhci_doorbell_array {
446
 
        u32     doorbell[256];
 
450
        __le32  doorbell[256];
447
451
};
448
452
 
449
453
#define DB_VALUE(ep, stream)    ((((ep) + 1) & 0xff) | ((stream) << 16))
500
504
 * reserved at the end of the slot context for HC internal use.
501
505
 */
502
506
struct xhci_slot_ctx {
503
 
        u32     dev_info;
504
 
        u32     dev_info2;
505
 
        u32     tt_info;
506
 
        u32     dev_state;
 
507
        __le32  dev_info;
 
508
        __le32  dev_info2;
 
509
        __le32  tt_info;
 
510
        __le32  dev_state;
507
511
        /* offset 0x10 to 0x1f reserved for HC internal use */
508
 
        u32     reserved[4];
 
512
        __le32  reserved[4];
509
513
};
510
514
 
511
515
/* dev_info bitmasks */
556
560
#define SLOT_STATE      (0x1f << 27)
557
561
#define GET_SLOT_STATE(p)       (((p) & (0x1f << 27)) >> 27)
558
562
 
 
563
#define SLOT_STATE_DISABLED     0
 
564
#define SLOT_STATE_ENABLED      SLOT_STATE_DISABLED
 
565
#define SLOT_STATE_DEFAULT      1
 
566
#define SLOT_STATE_ADDRESSED    2
 
567
#define SLOT_STATE_CONFIGURED   3
559
568
 
560
569
/**
561
570
 * struct xhci_ep_ctx
576
585
 * reserved at the end of the endpoint context for HC internal use.
577
586
 */
578
587
struct xhci_ep_ctx {
579
 
        u32     ep_info;
580
 
        u32     ep_info2;
581
 
        u64     deq;
582
 
        u32     tx_info;
 
588
        __le32  ep_info;
 
589
        __le32  ep_info2;
 
590
        __le64  deq;
 
591
        __le32  tx_info;
583
592
        /* offset 0x14 - 0x1f reserved for HC internal use */
584
 
        u32     reserved[3];
 
593
        __le32  reserved[3];
585
594
};
586
595
 
587
596
/* ep_info bitmasks */
656
665
 * @add_context:        set the bit of the endpoint context you want to enable
657
666
 */
658
667
struct xhci_input_control_ctx {
659
 
        u32     drop_flags;
660
 
        u32     add_flags;
661
 
        u32     rsvd2[6];
 
668
        __le32  drop_flags;
 
669
        __le32  add_flags;
 
670
        __le32  rsvd2[6];
662
671
};
663
672
 
664
673
/* Represents everything that is needed to issue a command on the command ring.
684
693
 
685
694
struct xhci_stream_ctx {
686
695
        /* 64-bit stream ring address, cycle state, and stream type */
687
 
        u64     stream_ring;
 
696
        __le64  stream_ring;
688
697
        /* offset 0x14 - 0x1f reserved for HC internal use */
689
 
        u32     reserved[2];
 
698
        __le32  reserved[2];
690
699
};
691
700
 
692
701
/* Stream Context Types (section 6.4.1) - bits 3:1 of stream ctx deq ptr */
799
808
 */
800
809
struct xhci_device_context_array {
801
810
        /* 64-bit device addresses; we only write 32-bit addresses */
802
 
        u64                     dev_context_ptrs[MAX_HC_SLOTS];
 
811
        __le64                  dev_context_ptrs[MAX_HC_SLOTS];
803
812
        /* private xHCD pointers */
804
813
        dma_addr_t      dma;
805
814
};
812
821
 
813
822
struct xhci_transfer_event {
814
823
        /* 64-bit buffer address, or immediate data */
815
 
        u64     buffer;
816
 
        u32     transfer_len;
 
824
        __le64  buffer;
 
825
        __le32  transfer_len;
817
826
        /* This field is interpreted differently based on the type of TRB */
818
 
        u32     flags;
 
827
        __le32  flags;
819
828
};
820
829
 
821
830
/** Transfer Event bit fields **/
865
874
#define COMP_PING_ERR   20
866
875
/* Event Ring is full */
867
876
#define COMP_ER_FULL    21
 
877
/* Incompatible Device Error */
 
878
#define COMP_DEV_ERR    22
868
879
/* Missed Service Error - HC couldn't service an isoc ep within interval */
869
880
#define COMP_MISSED_INT 23
870
881
/* Successfully stopped command ring */
873
884
#define COMP_CMD_ABORT  25
874
885
/* Stopped - transfer was terminated by a stop endpoint command */
875
886
#define COMP_STOP       26
876
 
/* Same as COMP_EP_STOPPED, but the transfered length in the event is invalid */
 
887
/* Same as COMP_EP_STOPPED, but the transferred length in the event is invalid */
877
888
#define COMP_STOP_INVAL 27
878
889
/* Control Abort Error - Debug Capability - control pipe aborted */
879
890
#define COMP_DBG_ABORT  28
880
 
/* TRB type 29 and 30 reserved */
 
891
/* Max Exit Latency Too Large Error */
 
892
#define COMP_MEL_ERR    29
 
893
/* TRB type 30 reserved */
881
894
/* Isoc Buffer Overrun - an isoc IN ep sent more data than could fit in TD */
882
895
#define COMP_BUFF_OVER  31
883
896
/* Event Lost Error - xHC has an "internal event overrun condition" */
894
907
 
895
908
struct xhci_link_trb {
896
909
        /* 64-bit segment pointer*/
897
 
        u64 segment_ptr;
898
 
        u32 intr_target;
899
 
        u32 control;
 
910
        __le64 segment_ptr;
 
911
        __le32 intr_target;
 
912
        __le32 control;
900
913
};
901
914
 
902
915
/* control bitfields */
905
918
/* Command completion event TRB */
906
919
struct xhci_event_cmd {
907
920
        /* Pointer to command TRB, or the value passed by the event data trb */
908
 
        u64 cmd_trb;
909
 
        u32 status;
910
 
        u32 flags;
 
921
        __le64 cmd_trb;
 
922
        __le32 status;
 
923
        __le32 flags;
911
924
};
912
925
 
913
926
/* flags bitmasks */
939
952
/* Interrupter Target - which MSI-X vector to target the completion event at */
940
953
#define TRB_INTR_TARGET(p)      (((p) & 0x3ff) << 22)
941
954
#define GET_INTR_TARGET(p)      (((p) >> 22) & 0x3ff)
 
955
#define TRB_TBC(p)              (((p) & 0x3) << 7)
 
956
#define TRB_TLBPC(p)            (((p) & 0xf) << 16)
942
957
 
943
958
/* Cycle bit - indicates TRB ownership by HC or HCD */
944
959
#define TRB_CYCLE               (1<<0)
958
973
/* The buffer pointer contains immediate data */
959
974
#define TRB_IDT                 (1<<6)
960
975
 
 
976
/* Block Event Interrupt */
 
977
#define TRB_BEI                 (1<<9)
961
978
 
962
979
/* Control transfer TRB specific fields */
963
980
#define TRB_DIR_IN              (1<<16)
 
981
#define TRB_TX_TYPE(p)          ((p) << 16)
 
982
#define TRB_DATA_OUT            2
 
983
#define TRB_DATA_IN             3
964
984
 
965
985
/* Isochronous TRB specific fields */
966
986
#define TRB_SIA                 (1<<31)
967
987
 
968
988
struct xhci_generic_trb {
969
 
        u32 field[4];
 
989
        __le32 field[4];
970
990
};
971
991
 
972
992
union xhci_trb {
1110
1130
         */
1111
1131
        u32                     cycle_state;
1112
1132
        unsigned int            stream_id;
 
1133
        bool                    last_td_was_short;
1113
1134
};
1114
1135
 
1115
1136
struct xhci_erst_entry {
1116
1137
        /* 64-bit event ring segment address */
1117
 
        u64     seg_addr;
1118
 
        u32     seg_size;
 
1138
        __le64  seg_addr;
 
1139
        __le32  seg_size;
1119
1140
        /* Set to zero */
1120
 
        u32     rsvd;
 
1141
        __le32  rsvd;
1121
1142
};
1122
1143
 
1123
1144
struct xhci_erst {
1276
1297
#define XHCI_LINK_TRB_QUIRK     (1 << 0)
1277
1298
#define XHCI_RESET_EP_QUIRK     (1 << 1)
1278
1299
#define XHCI_NEC_HOST           (1 << 2)
 
1300
#define XHCI_AMD_PLL_FIX        (1 << 3)
 
1301
#define XHCI_SPURIOUS_SUCCESS   (1 << 4)
 
1302
/*
 
1303
 * Certain Intel host controllers have a limit to the number of endpoint
 
1304
 * contexts they can handle.  Ideally, they would signal that they can't handle
 
1305
 * anymore endpoint contexts by returning a Resource Error for the Configure
 
1306
 * Endpoint command, but they don't.  Instead they expect software to keep track
 
1307
 * of the number of active endpoints for them, across configure endpoint
 
1308
 * commands, reset device commands, disable slot commands, and address device
 
1309
 * commands.
 
1310
 */
 
1311
#define XHCI_EP_LIMIT_QUIRK     (1 << 5)
 
1312
#define XHCI_BROKEN_MSI         (1 << 6)
 
1313
#define XHCI_RESET_ON_RESUME    (1 << 7)
 
1314
        unsigned int            num_active_eps;
 
1315
        unsigned int            limit_active_eps;
1279
1316
        /* There are two roothubs to keep track of bus suspend info for */
1280
1317
        struct xhci_bus_state   bus_state[2];
1281
1318
        /* Is each xHCI roothub port a USB 3.0, USB 2.0, or USB 1.1 port? */
1282
1319
        u8                      *port_array;
1283
1320
        /* Array of pointers to USB 3.0 PORTSC registers */
1284
 
        u32 __iomem             **usb3_ports;
 
1321
        __le32 __iomem          **usb3_ports;
1285
1322
        unsigned int            num_usb3_ports;
1286
1323
        /* Array of pointers to USB 2.0 PORTSC registers */
1287
 
        u32 __iomem             **usb2_ports;
 
1324
        __le32 __iomem          **usb2_ports;
1288
1325
        unsigned int            num_usb2_ports;
1289
1326
};
1290
1327
 
1317
1354
/* TODO: copied from ehci.h - can be refactored? */
1318
1355
/* xHCI spec says all registers are little endian */
1319
1356
static inline unsigned int xhci_readl(const struct xhci_hcd *xhci,
1320
 
                __u32 __iomem *regs)
 
1357
                __le32 __iomem *regs)
1321
1358
{
1322
1359
        return readl(regs);
1323
1360
}
1324
1361
static inline void xhci_writel(struct xhci_hcd *xhci,
1325
 
                const unsigned int val, __u32 __iomem *regs)
 
1362
                const unsigned int val, __le32 __iomem *regs)
1326
1363
{
1327
 
        xhci_dbg(xhci,
1328
 
                        "`MEM_WRITE_DWORD(3'b000, 32'h%p, 32'h%0x, 4'hf);\n",
1329
 
                        regs, val);
1330
1364
        writel(val, regs);
1331
1365
}
1332
1366
 
1340
1374
 * the high dword, and write order is irrelevant.
1341
1375
 */
1342
1376
static inline u64 xhci_read_64(const struct xhci_hcd *xhci,
1343
 
                __u64 __iomem *regs)
 
1377
                __le64 __iomem *regs)
1344
1378
{
1345
1379
        __u32 __iomem *ptr = (__u32 __iomem *) regs;
1346
1380
        u64 val_lo = readl(ptr);
1348
1382
        return val_lo + (val_hi << 32);
1349
1383
}
1350
1384
static inline void xhci_write_64(struct xhci_hcd *xhci,
1351
 
                const u64 val, __u64 __iomem *regs)
 
1385
                                 const u64 val, __le64 __iomem *regs)
1352
1386
{
1353
1387
        __u32 __iomem *ptr = (__u32 __iomem *) regs;
1354
1388
        u32 val_lo = lower_32_bits(val);
1355
1389
        u32 val_hi = upper_32_bits(val);
1356
1390
 
1357
 
        xhci_dbg(xhci,
1358
 
                        "`MEM_WRITE_DWORD(3'b000, 64'h%p, 64'h%0lx, 4'hf);\n",
1359
 
                        regs, (long unsigned int) val);
1360
1391
        writel(val_lo, ptr);
1361
1392
        writel(val_hi, ptr + 1);
1362
1393
}
1425
1456
void xhci_setup_no_streams_ep_input_ctx(struct xhci_hcd *xhci,
1426
1457
                struct xhci_ep_ctx *ep_ctx,
1427
1458
                struct xhci_virt_ep *ep);
 
1459
void xhci_free_device_endpoint_resources(struct xhci_hcd *xhci,
 
1460
        struct xhci_virt_device *virt_dev, bool drop_control_ep);
1428
1461
struct xhci_ring *xhci_dma_to_transfer_ring(
1429
1462
                struct xhci_virt_ep *ep,
1430
1463
                u64 address);