Thu Sep 20 17:53:49 2012 UTC ()
sc_ahci_cap should be uint32_t


(matt)
diff -r1.13 -r1.14 src/sys/dev/ic/ahcisatavar.h

cvs diff -r1.13 -r1.14 src/sys/dev/ic/ahcisatavar.h (switch to unified diff)

--- src/sys/dev/ic/ahcisatavar.h 2012/08/20 12:48:47 1.13
+++ src/sys/dev/ic/ahcisatavar.h 2012/09/20 17:53:48 1.14
@@ -1,111 +1,111 @@ @@ -1,111 +1,111 @@
1/* $NetBSD: ahcisatavar.h,v 1.13 2012/08/20 12:48:47 bouyer Exp $ */ 1/* $NetBSD: ahcisatavar.h,v 1.14 2012/09/20 17:53:48 matt Exp $ */
2 2
3/* 3/*
4 * Copyright (c) 2006 Manuel Bouyer. 4 * Copyright (c) 2006 Manuel Bouyer.
5 * 5 *
6 * Redistribution and use in source and binary forms, with or without 6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions 7 * modification, are permitted provided that the following conditions
8 * are met: 8 * are met:
9 * 1. Redistributions of source code must retain the above copyright 9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer. 10 * notice, this list of conditions and the following disclaimer.
11 * 2. Redistributions in binary form must reproduce the above copyright 11 * 2. Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the 12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution. 13 * documentation and/or other materials provided with the distribution.
14 * 14 *
15 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 15 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
16 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 16 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
17 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 17 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
18 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 18 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
19 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 19 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
20 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 20 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
21 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 21 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
22 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 22 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 23 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
24 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 24 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25 * 25 *
26 */ 26 */
27 27
28#include <dev/ic/ahcisatareg.h> 28#include <dev/ic/ahcisatareg.h>
29 29
30#define AHCI_DEBUG 30#define AHCI_DEBUG
31 31
32#define DEBUG_INTR 0x01 32#define DEBUG_INTR 0x01
33#define DEBUG_XFERS 0x02 33#define DEBUG_XFERS 0x02
34#define DEBUG_FUNCS 0x08 34#define DEBUG_FUNCS 0x08
35#define DEBUG_PROBE 0x10 35#define DEBUG_PROBE 0x10
36#define DEBUG_DETACH 0x20 36#define DEBUG_DETACH 0x20
37#ifdef AHCI_DEBUG 37#ifdef AHCI_DEBUG
38extern int ahcidebug_mask; 38extern int ahcidebug_mask;
39#define AHCIDEBUG_PRINT(args, level) \ 39#define AHCIDEBUG_PRINT(args, level) \
40 if (ahcidebug_mask & (level)) \ 40 if (ahcidebug_mask & (level)) \
41 printf args 41 printf args
42#else 42#else
43#define AHCIDEBUG_PRINT(args, level) 43#define AHCIDEBUG_PRINT(args, level)
44#endif 44#endif
45 45
46struct ahci_softc { 46struct ahci_softc {
47 struct atac_softc sc_atac; 47 struct atac_softc sc_atac;
48 bus_space_tag_t sc_ahcit; /* ahci registers mapping */ 48 bus_space_tag_t sc_ahcit; /* ahci registers mapping */
49 bus_space_handle_t sc_ahcih; 49 bus_space_handle_t sc_ahcih;
50 bus_size_t sc_ahcis; 50 bus_size_t sc_ahcis;
51 bus_dma_tag_t sc_dmat; /* DMA memory mappings: */ 51 bus_dma_tag_t sc_dmat; /* DMA memory mappings: */
52 void *sc_cmd_hdr; /* command tables and received FIS */ 52 void *sc_cmd_hdr; /* command tables and received FIS */
53 bus_dmamap_t sc_cmd_hdrd; 53 bus_dmamap_t sc_cmd_hdrd;
54 bus_dma_segment_t sc_cmd_hdr_seg; 54 bus_dma_segment_t sc_cmd_hdr_seg;
55 int sc_cmd_hdr_nseg; 55 int sc_cmd_hdr_nseg;
56 int sc_atac_capflags; 56 int sc_atac_capflags;
57 int sc_ahci_quirks; 57 int sc_ahci_quirks;
58#define AHCI_PCI_QUIRK_FORCE __BIT(0) /* force attach */ 58#define AHCI_PCI_QUIRK_FORCE __BIT(0) /* force attach */
59#define AHCI_PCI_QUIRK_BAD64 __BIT(1) /* broken 64-bit DMA */ 59#define AHCI_PCI_QUIRK_BAD64 __BIT(1) /* broken 64-bit DMA */
60#define AHCI_QUIRK_BADPMP __BIT(2) /* broken PMP support, ignore */ 60#define AHCI_QUIRK_BADPMP __BIT(2) /* broken PMP support, ignore */
61#define AHCI_QUIRK_BADPMPRESET __BIT(3) /* broken PMP support for reset */ 61#define AHCI_QUIRK_BADPMPRESET __BIT(3) /* broken PMP support for reset */
62 62
63 int32_t sc_ahci_cap; /* copy of AHCI_CAP */ 63 uint32_t sc_ahci_cap; /* copy of AHCI_CAP */
64 int sc_ncmds; /* number of command slots */ 64 int sc_ncmds; /* number of command slots */
65 struct ata_channel *sc_chanarray[AHCI_MAX_PORTS]; 65 struct ata_channel *sc_chanarray[AHCI_MAX_PORTS];
66 struct ahci_channel { 66 struct ahci_channel {
67 struct ata_channel ata_channel; /* generic part */ 67 struct ata_channel ata_channel; /* generic part */
68 bus_space_handle_t ahcic_scontrol; 68 bus_space_handle_t ahcic_scontrol;
69 bus_space_handle_t ahcic_sstatus; 69 bus_space_handle_t ahcic_sstatus;
70 bus_space_handle_t ahcic_serror; 70 bus_space_handle_t ahcic_serror;
71 /* pointers allocated from sc_cmd_hdrd */ 71 /* pointers allocated from sc_cmd_hdrd */
72 struct ahci_r_fis *ahcic_rfis; /* received FIS */ 72 struct ahci_r_fis *ahcic_rfis; /* received FIS */
73 bus_addr_t ahcic_bus_rfis; 73 bus_addr_t ahcic_bus_rfis;
74 struct ahci_cmd_header *ahcic_cmdh; /* command headers */ 74 struct ahci_cmd_header *ahcic_cmdh; /* command headers */
75 bus_addr_t ahcic_bus_cmdh; 75 bus_addr_t ahcic_bus_cmdh;
76 /* command tables (allocated per-channel) */ 76 /* command tables (allocated per-channel) */
77 bus_dmamap_t ahcic_cmd_tbld; 77 bus_dmamap_t ahcic_cmd_tbld;
78 bus_dma_segment_t ahcic_cmd_tbl_seg; 78 bus_dma_segment_t ahcic_cmd_tbl_seg;
79 int ahcic_cmd_tbl_nseg; 79 int ahcic_cmd_tbl_nseg;
80 struct ahci_cmd_tbl *ahcic_cmd_tbl[AHCI_MAX_CMDS]; 80 struct ahci_cmd_tbl *ahcic_cmd_tbl[AHCI_MAX_CMDS];
81 bus_addr_t ahcic_bus_cmd_tbl[AHCI_MAX_CMDS]; 81 bus_addr_t ahcic_bus_cmd_tbl[AHCI_MAX_CMDS];
82 bus_dmamap_t ahcic_datad[AHCI_MAX_CMDS]; 82 bus_dmamap_t ahcic_datad[AHCI_MAX_CMDS];
83 uint32_t ahcic_cmds_active; /* active commands */ 83 uint32_t ahcic_cmds_active; /* active commands */
84 } sc_channels[AHCI_MAX_PORTS]; 84 } sc_channels[AHCI_MAX_PORTS];
85}; 85};
86 86
87#define AHCINAME(sc) (device_xname((sc)->sc_atac.atac_dev)) 87#define AHCINAME(sc) (device_xname((sc)->sc_atac.atac_dev))
88 88
89#define AHCI_CMDH_SYNC(sc, achp, cmd, op) bus_dmamap_sync((sc)->sc_dmat, \ 89#define AHCI_CMDH_SYNC(sc, achp, cmd, op) bus_dmamap_sync((sc)->sc_dmat, \
90 (sc)->sc_cmd_hdrd, \ 90 (sc)->sc_cmd_hdrd, \
91 (char *)(&(achp)->ahcic_cmdh[(cmd)]) - (char *)(sc)->sc_cmd_hdr, \ 91 (char *)(&(achp)->ahcic_cmdh[(cmd)]) - (char *)(sc)->sc_cmd_hdr, \
92 sizeof(struct ahci_cmd_header), (op)) 92 sizeof(struct ahci_cmd_header), (op))
93#define AHCI_RFIS_SYNC(sc, achp, op) bus_dmamap_sync((sc)->sc_dmat, \ 93#define AHCI_RFIS_SYNC(sc, achp, op) bus_dmamap_sync((sc)->sc_dmat, \
94 (sc)->sc_cmd_hdrd, (void *)(achp)->ahcic_rfis - (sc)->sc_cmd_hdr, \ 94 (sc)->sc_cmd_hdrd, (void *)(achp)->ahcic_rfis - (sc)->sc_cmd_hdr, \
95 AHCI_RFIS_SIZE, (op)) 95 AHCI_RFIS_SIZE, (op))
96#define AHCI_CMDTBL_SYNC(sc, achp, cmd, op) bus_dmamap_sync((sc)->sc_dmat, \ 96#define AHCI_CMDTBL_SYNC(sc, achp, cmd, op) bus_dmamap_sync((sc)->sc_dmat, \
97 (achp)->ahcic_cmd_tbld, AHCI_CMDTBL_SIZE * (cmd), \ 97 (achp)->ahcic_cmd_tbld, AHCI_CMDTBL_SIZE * (cmd), \
98 AHCI_CMDTBL_SIZE, (op)) 98 AHCI_CMDTBL_SIZE, (op))
99 99
100#define AHCI_READ(sc, reg) bus_space_read_4((sc)->sc_ahcit, \ 100#define AHCI_READ(sc, reg) bus_space_read_4((sc)->sc_ahcit, \
101 (sc)->sc_ahcih, (reg)) 101 (sc)->sc_ahcih, (reg))
102#define AHCI_WRITE(sc, reg, val) bus_space_write_4((sc)->sc_ahcit, \ 102#define AHCI_WRITE(sc, reg, val) bus_space_write_4((sc)->sc_ahcit, \
103 (sc)->sc_ahcih, (reg), (val)) 103 (sc)->sc_ahcih, (reg), (val))
104  104
105 105
106void ahci_attach(struct ahci_softc *); 106void ahci_attach(struct ahci_softc *);
107int ahci_detach(struct ahci_softc *, int); 107int ahci_detach(struct ahci_softc *, int);
108void ahci_resume(struct ahci_softc *); 108void ahci_resume(struct ahci_softc *);
109 109
110int ahci_intr(void *); 110int ahci_intr(void *);
111 111