1 /* $NetBSD: siside.c,v 1.24 2009/03/12 15:02:42 bsh Exp $ */
4 * Copyright (c) 1999, 2000, 2001 Manuel Bouyer.
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 * 2. Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
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
17 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
18 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
19 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
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
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
24 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 #include <sys/cdefs.h>
28 __KERNEL_RCSID(0, "$NetBSD: siside.c,v 1.24 2009/03/12 15:02:42 bsh Exp $");
30 #include <sys/param.h>
31 #include <sys/systm.h>
33 #include <dev/pci/pcivar.h>
34 #include <dev/pci/pcidevs.h>
35 #include <dev/pci/pciidereg.h>
36 #include <dev/pci/pciidevar.h>
37 #include <dev/pci/pciide_sis_reg.h>
39 static void sis_chip_map(struct pciide_softc
*, struct pci_attach_args
*);
40 static void sis_sata_chip_map(struct pciide_softc
*, struct pci_attach_args
*);
41 static void sis_setup_channel(struct ata_channel
*);
42 static void sis96x_setup_channel(struct ata_channel
*);
44 static int sis_hostbr_match(struct pci_attach_args
*);
45 static int sis_south_match(struct pci_attach_args
*);
47 static int siside_match(device_t
, cfdata_t
, void *);
48 static void siside_attach(device_t
, device_t
, void *);
50 CFATTACH_DECL_NEW(siside
, sizeof(struct pciide_softc
),
51 siside_match
, siside_attach
, NULL
, NULL
);
53 static const struct pciide_product_desc pciide_sis_products
[] = {
54 { PCI_PRODUCT_SIS_5597_IDE
,
59 { PCI_PRODUCT_SIS_180_SATA
,
64 { PCI_PRODUCT_SIS_181_SATA
,
69 { PCI_PRODUCT_SIS_182_SATA
,
82 siside_match(device_t parent
, cfdata_t match
, void *aux
)
84 struct pci_attach_args
*pa
= aux
;
86 if (PCI_VENDOR(pa
->pa_id
) == PCI_VENDOR_SIS
) {
87 if (pciide_lookup_product(pa
->pa_id
, pciide_sis_products
))
94 siside_attach(device_t parent
, device_t self
, void *aux
)
96 struct pci_attach_args
*pa
= aux
;
97 struct pciide_softc
*sc
= device_private(self
);
98 pci_chipset_tag_t pc
= pa
->pa_pc
;
99 pcitag_t tag
= pa
->pa_tag
;
102 sc
->sc_wdcdev
.sc_atac
.atac_dev
= self
;
104 pciide_common_attach(sc
, pa
,
105 pciide_lookup_product(pa
->pa_id
, pciide_sis_products
));
107 csr
= pci_conf_read(pc
, tag
, PCI_COMMAND_STATUS_REG
);
108 if (csr
& PCI_COMMAND_INTERRUPT_DISABLE
) {
109 csr
&= ~PCI_COMMAND_INTERRUPT_DISABLE
;
110 pci_conf_write(pc
, tag
, PCI_COMMAND_STATUS_REG
, csr
);
114 static struct sis_hostbr_type
{
120 #define SIS_TYPE_NOUDMA 0
121 #define SIS_TYPE_66 1
122 #define SIS_TYPE_100OLD 2
123 #define SIS_TYPE_100NEW 3
124 #define SIS_TYPE_133OLD 4
125 #define SIS_TYPE_133NEW 5
126 #define SIS_TYPE_SOUTH 6
127 } sis_hostbr_type
[] = {
128 /* Most infos here are from sos@freebsd.org */
129 {PCI_PRODUCT_SIS_530HB
, 0x00, 4, "530", SIS_TYPE_66
},
132 * controllers associated to a rev 0x2 530 Host to PCI Bridge
133 * have problems with UDMA (info provided by Christos)
135 {PCI_PRODUCT_SIS_530HB
, 0x02, 0, "530 (buggy)", SIS_TYPE_NOUDMA
},
137 {PCI_PRODUCT_SIS_540HB
, 0x00, 4, "540", SIS_TYPE_66
},
138 {PCI_PRODUCT_SIS_550HB
, 0x00, 4, "550", SIS_TYPE_66
},
139 {PCI_PRODUCT_SIS_620
, 0x00, 4, "620", SIS_TYPE_66
},
140 {PCI_PRODUCT_SIS_630
, 0x00, 4, "630", SIS_TYPE_66
},
141 {PCI_PRODUCT_SIS_630
, 0x30, 5, "630S", SIS_TYPE_100NEW
},
142 {PCI_PRODUCT_SIS_633
, 0x00, 5, "633", SIS_TYPE_100NEW
},
143 {PCI_PRODUCT_SIS_635
, 0x00, 5, "635", SIS_TYPE_100NEW
},
144 {PCI_PRODUCT_SIS_640
, 0x00, 4, "640", SIS_TYPE_SOUTH
},
145 {PCI_PRODUCT_SIS_645
, 0x00, 6, "645", SIS_TYPE_SOUTH
},
146 {PCI_PRODUCT_SIS_646
, 0x00, 6, "645DX", SIS_TYPE_SOUTH
},
147 {PCI_PRODUCT_SIS_648
, 0x00, 6, "648", SIS_TYPE_SOUTH
},
148 {PCI_PRODUCT_SIS_650
, 0x00, 6, "650", SIS_TYPE_SOUTH
},
149 {PCI_PRODUCT_SIS_651
, 0x00, 6, "651", SIS_TYPE_SOUTH
},
150 {PCI_PRODUCT_SIS_652
, 0x00, 6, "652", SIS_TYPE_SOUTH
},
151 {PCI_PRODUCT_SIS_655
, 0x00, 6, "655", SIS_TYPE_SOUTH
},
152 {PCI_PRODUCT_SIS_658
, 0x00, 6, "658", SIS_TYPE_SOUTH
},
153 {PCI_PRODUCT_SIS_661
, 0x00, 6, "661", SIS_TYPE_SOUTH
},
154 {PCI_PRODUCT_SIS_730
, 0x00, 5, "730", SIS_TYPE_100OLD
},
155 {PCI_PRODUCT_SIS_733
, 0x00, 5, "733", SIS_TYPE_100NEW
},
156 {PCI_PRODUCT_SIS_735
, 0x00, 5, "735", SIS_TYPE_100NEW
},
157 {PCI_PRODUCT_SIS_740
, 0x00, 5, "740", SIS_TYPE_SOUTH
},
158 {PCI_PRODUCT_SIS_741
, 0x00, 5, "741", SIS_TYPE_SOUTH
},
159 {PCI_PRODUCT_SIS_745
, 0x00, 5, "745", SIS_TYPE_100NEW
},
160 {PCI_PRODUCT_SIS_746
, 0x00, 6, "746", SIS_TYPE_SOUTH
},
161 {PCI_PRODUCT_SIS_748
, 0x00, 6, "748", SIS_TYPE_SOUTH
},
162 {PCI_PRODUCT_SIS_750
, 0x00, 6, "750", SIS_TYPE_SOUTH
},
163 {PCI_PRODUCT_SIS_751
, 0x00, 6, "751", SIS_TYPE_SOUTH
},
164 {PCI_PRODUCT_SIS_752
, 0x00, 6, "752", SIS_TYPE_SOUTH
},
165 {PCI_PRODUCT_SIS_755
, 0x00, 6, "755", SIS_TYPE_SOUTH
},
166 {PCI_PRODUCT_SIS_760
, 0x00, 6, "760", SIS_TYPE_133NEW
},
168 * From sos@freebsd.org: the 0x961 ID will never be found in real world
169 * {PCI_PRODUCT_SIS_961, 0x00, 6, "961", SIS_TYPE_133NEW},
171 {PCI_PRODUCT_SIS_962
, 0x00, 6, "962", SIS_TYPE_133NEW
},
172 {PCI_PRODUCT_SIS_963
, 0x00, 6, "963", SIS_TYPE_133NEW
},
173 {PCI_PRODUCT_SIS_964
, 0x00, 6, "964", SIS_TYPE_133NEW
},
174 {PCI_PRODUCT_SIS_965
, 0x00, 6, "965", SIS_TYPE_133NEW
},
177 static struct sis_hostbr_type
*sis_hostbr_type_match
;
180 sis_hostbr_match(struct pci_attach_args
*pa
)
185 if (PCI_VENDOR(pa
->pa_id
) != PCI_VENDOR_SIS
)
187 if (PCI_PRODUCT(pa
->pa_id
) == PCI_PRODUCT_SIS_85C503
) {
188 reg
= pci_conf_read(pa
->pa_pc
, pa
->pa_tag
, SIS96x_DETECT
);
189 pci_conf_write(pa
->pa_pc
, pa
->pa_tag
, SIS96x_DETECT
,
190 reg
| SIS96x_DETECT_MASQ
);
191 id
= pci_conf_read(pa
->pa_pc
, pa
->pa_tag
, PCI_ID_REG
);
192 if (((PCI_PRODUCT(id
) & 0xfff0) != 0x0960)
193 && (PCI_PRODUCT(id
) != 0x0018)) {
194 pci_conf_write(pa
->pa_pc
, pa
->pa_tag
, SIS96x_DETECT
,
201 sis_hostbr_type_match
= NULL
;
203 i
< sizeof(sis_hostbr_type
) / sizeof(sis_hostbr_type
[0]);
205 if (PCI_PRODUCT(pa
->pa_id
) == sis_hostbr_type
[i
].id
&&
206 PCI_REVISION(pa
->pa_class
) >= sis_hostbr_type
[i
].rev
)
207 sis_hostbr_type_match
= &sis_hostbr_type
[i
];
209 return (sis_hostbr_type_match
!= NULL
);
213 sis_south_match(struct pci_attach_args
*pa
)
216 return (PCI_VENDOR(pa
->pa_id
) == PCI_VENDOR_SIS
&&
217 PCI_PRODUCT(pa
->pa_id
) == PCI_PRODUCT_SIS_85C503
&&
218 PCI_REVISION(pa
->pa_class
) >= 0x10);
222 sis_chip_map(struct pciide_softc
*sc
, struct pci_attach_args
*pa
)
224 struct pciide_channel
*cp
;
226 u_int8_t sis_ctr0
= pciide_pci_read(sc
->sc_pc
, sc
->sc_tag
, SIS_CTRL0
);
227 pcireg_t interface
= PCI_INTERFACE(pa
->pa_class
);
228 pcireg_t rev
= PCI_REVISION(pa
->pa_class
);
229 bus_size_t cmdsize
, ctlsize
;
231 if (pciide_chipen(sc
, pa
) == 0)
234 aprint_normal_dev(sc
->sc_wdcdev
.sc_atac
.atac_dev
,
235 "Silicon Integrated Systems ");
236 pci_find_device(NULL
, sis_hostbr_match
);
237 if (sis_hostbr_type_match
) {
238 if (sis_hostbr_type_match
->type
== SIS_TYPE_SOUTH
) {
239 pciide_pci_write(sc
->sc_pc
, sc
->sc_tag
, SIS_REG_57
,
240 pciide_pci_read(sc
->sc_pc
, sc
->sc_tag
,
242 if (PCI_PRODUCT(pci_conf_read(sc
->sc_pc
, sc
->sc_tag
,
243 PCI_ID_REG
)) == SIS_PRODUCT_5518
) {
244 aprint_normal("96X UDMA%d",
245 sis_hostbr_type_match
->udma_mode
);
246 sc
->sis_type
= SIS_TYPE_133NEW
;
247 sc
->sc_wdcdev
.sc_atac
.atac_udma_cap
=
248 sis_hostbr_type_match
->udma_mode
;
250 if (pci_find_device(NULL
, sis_south_match
)) {
251 sc
->sis_type
= SIS_TYPE_133OLD
;
252 sc
->sc_wdcdev
.sc_atac
.atac_udma_cap
=
253 sis_hostbr_type_match
->udma_mode
;
255 sc
->sis_type
= SIS_TYPE_100NEW
;
256 sc
->sc_wdcdev
.sc_atac
.atac_udma_cap
=
257 sis_hostbr_type_match
->udma_mode
;
261 sc
->sis_type
= sis_hostbr_type_match
->type
;
262 sc
->sc_wdcdev
.sc_atac
.atac_udma_cap
=
263 sis_hostbr_type_match
->udma_mode
;
265 aprint_normal(sis_hostbr_type_match
->name
);
267 aprint_normal("5597/5598");
269 sc
->sc_wdcdev
.sc_atac
.atac_udma_cap
= 2;
270 sc
->sis_type
= SIS_TYPE_66
;
272 sc
->sc_wdcdev
.sc_atac
.atac_udma_cap
= 0;
273 sc
->sis_type
= SIS_TYPE_NOUDMA
;
276 aprint_normal(" IDE controller (rev. 0x%02x)\n",
277 PCI_REVISION(pa
->pa_class
));
278 aprint_verbose_dev(sc
->sc_wdcdev
.sc_atac
.atac_dev
,
279 "bus-master DMA support present");
280 pciide_mapreg_dma(sc
, pa
);
281 aprint_verbose("\n");
283 sc
->sc_wdcdev
.sc_atac
.atac_cap
= ATAC_CAP_DATA16
| ATAC_CAP_DATA32
;
285 sc
->sc_wdcdev
.sc_atac
.atac_cap
|= ATAC_CAP_DMA
;
286 sc
->sc_wdcdev
.irqack
= pciide_irqack
;
287 if (sc
->sis_type
>= SIS_TYPE_66
)
288 sc
->sc_wdcdev
.sc_atac
.atac_cap
|= ATAC_CAP_UDMA
;
291 sc
->sc_wdcdev
.sc_atac
.atac_pio_cap
= 4;
292 sc
->sc_wdcdev
.sc_atac
.atac_dma_cap
= 2;
294 sc
->sc_wdcdev
.sc_atac
.atac_channels
= sc
->wdc_chanarray
;
295 sc
->sc_wdcdev
.sc_atac
.atac_nchannels
= PCIIDE_NUM_CHANNELS
;
296 switch(sc
->sis_type
) {
297 case SIS_TYPE_NOUDMA
:
299 case SIS_TYPE_100OLD
:
300 sc
->sc_wdcdev
.sc_atac
.atac_set_modes
= sis_setup_channel
;
301 pciide_pci_write(sc
->sc_pc
, sc
->sc_tag
, SIS_MISC
,
302 pciide_pci_read(sc
->sc_pc
, sc
->sc_tag
, SIS_MISC
) |
303 SIS_MISC_TIM_SEL
| SIS_MISC_FIFO_SIZE
| SIS_MISC_GTC
);
305 case SIS_TYPE_100NEW
:
306 case SIS_TYPE_133OLD
:
307 sc
->sc_wdcdev
.sc_atac
.atac_set_modes
= sis_setup_channel
;
308 pciide_pci_write(sc
->sc_pc
, sc
->sc_tag
, SIS_REG_49
,
309 pciide_pci_read(sc
->sc_pc
, sc
->sc_tag
, SIS_REG_49
) | 0x01);
311 case SIS_TYPE_133NEW
:
312 sc
->sc_wdcdev
.sc_atac
.atac_set_modes
= sis96x_setup_channel
;
313 pciide_pci_write(sc
->sc_pc
, sc
->sc_tag
, SIS_REG_50
,
314 pciide_pci_read(sc
->sc_pc
, sc
->sc_tag
, SIS_REG_50
) & 0xf7);
315 pciide_pci_write(sc
->sc_pc
, sc
->sc_tag
, SIS_REG_52
,
316 pciide_pci_read(sc
->sc_pc
, sc
->sc_tag
, SIS_REG_52
) & 0xf7);
320 wdc_allocate_regs(&sc
->sc_wdcdev
);
322 for (channel
= 0; channel
< sc
->sc_wdcdev
.sc_atac
.atac_nchannels
;
324 cp
= &sc
->pciide_channels
[channel
];
325 if (pciide_chansetup(sc
, channel
, interface
) == 0)
327 if ((channel
== 0 && (sis_ctr0
& SIS_CTRL0_CHAN0_EN
) == 0) ||
328 (channel
== 1 && (sis_ctr0
& SIS_CTRL0_CHAN1_EN
) == 0)) {
329 aprint_normal_dev(sc
->sc_wdcdev
.sc_atac
.atac_dev
,
330 "%s channel ignored (disabled)\n", cp
->name
);
331 cp
->ata_channel
.ch_flags
|= ATACH_DISABLED
;
334 pciide_mapchan(pa
, cp
, interface
, &cmdsize
, &ctlsize
,
340 sis96x_setup_channel(struct ata_channel
*chp
)
342 struct ata_drive_datas
*drvp
;
345 u_int32_t idedma_ctl
;
347 struct pciide_channel
*cp
= CHAN_TO_PCHAN(chp
);
348 struct pciide_softc
*sc
= CHAN_TO_PCIIDE(chp
);
352 /* setup DMA if needed */
353 pciide_channel_dma_setup(cp
);
355 for (drive
= 0; drive
< 2; drive
++) {
357 pciide_pci_read(sc
->sc_pc
, sc
->sc_tag
, SIS_REG_57
),
358 chp
->ch_channel
, drive
);
359 drvp
= &chp
->ch_drive
[drive
];
360 /* If no drive, skip */
361 if ((drvp
->drive_flags
& DRIVE
) == 0)
363 /* add timing values, setup DMA if needed */
364 if (drvp
->drive_flags
& DRIVE_UDMA
) {
367 drvp
->drive_flags
&= ~DRIVE_DMA
;
369 if (pciide_pci_read(sc
->sc_pc
, sc
->sc_tag
,
370 SIS96x_REG_CBL(chp
->ch_channel
)) & SIS96x_REG_CBL_33
) {
371 if (drvp
->UDMA_mode
> 2)
374 sis_tim
|= sis_udma133new_tim
[drvp
->UDMA_mode
];
375 sis_tim
|= sis_pio133new_tim
[drvp
->PIO_mode
];
376 idedma_ctl
|= IDEDMA_CTL_DRV_DMA(drive
);
377 } else if (drvp
->drive_flags
& DRIVE_DMA
) {
380 * Timings will be used for both PIO and DMA,
381 * so adjust DMA mode if needed
383 if (drvp
->PIO_mode
> (drvp
->DMA_mode
+ 2))
384 drvp
->PIO_mode
= drvp
->DMA_mode
+ 2;
385 if (drvp
->DMA_mode
+ 2 > (drvp
->PIO_mode
))
386 drvp
->DMA_mode
= (drvp
->PIO_mode
> 2) ?
387 drvp
->PIO_mode
- 2 : 0;
388 sis_tim
|= sis_dma133new_tim
[drvp
->DMA_mode
];
389 idedma_ctl
|= IDEDMA_CTL_DRV_DMA(drive
);
391 sis_tim
|= sis_pio133new_tim
[drvp
->PIO_mode
];
393 ATADEBUG_PRINT(("sis96x_setup_channel: new timings reg for "
394 "channel %d drive %d: 0x%x (reg 0x%x)\n",
395 chp
->ch_channel
, drive
, sis_tim
, regtim
), DEBUG_PROBE
);
396 pci_conf_write(sc
->sc_pc
, sc
->sc_tag
, regtim
, sis_tim
);
398 if (idedma_ctl
!= 0) {
399 /* Add software bits in status register */
400 bus_space_write_1(sc
->sc_dma_iot
, cp
->dma_iohs
[IDEDMA_CTL
], 0,
406 sis_setup_channel(struct ata_channel
*chp
)
408 struct ata_drive_datas
*drvp
;
411 u_int32_t idedma_ctl
;
412 struct pciide_channel
*cp
= CHAN_TO_PCHAN(chp
);
413 struct pciide_softc
*sc
= CHAN_TO_PCIIDE(chp
);
415 ATADEBUG_PRINT(("sis_setup_channel: old timings reg for "
416 "channel %d 0x%x\n", chp
->ch_channel
,
417 pci_conf_read(sc
->sc_pc
, sc
->sc_tag
, SIS_TIM(chp
->ch_channel
))),
421 /* setup DMA if needed */
422 pciide_channel_dma_setup(cp
);
424 for (drive
= 0; drive
< 2; drive
++) {
425 drvp
= &chp
->ch_drive
[drive
];
426 /* If no drive, skip */
427 if ((drvp
->drive_flags
& DRIVE
) == 0)
429 /* add timing values, setup DMA if needed */
430 if ((drvp
->drive_flags
& DRIVE_DMA
) == 0 &&
431 (drvp
->drive_flags
& DRIVE_UDMA
) == 0)
434 if (drvp
->drive_flags
& DRIVE_UDMA
) {
437 drvp
->drive_flags
&= ~DRIVE_DMA
;
439 if (pciide_pci_read(sc
->sc_pc
, sc
->sc_tag
,
440 SIS_REG_CBL
) & SIS_REG_CBL_33(chp
->ch_channel
)) {
441 if (drvp
->UDMA_mode
> 2)
444 switch (sc
->sis_type
) {
446 case SIS_TYPE_100OLD
:
447 sis_tim
|= sis_udma66_tim
[drvp
->UDMA_mode
] <<
448 SIS_TIM66_UDMA_TIME_OFF(drive
);
450 case SIS_TYPE_100NEW
:
452 sis_udma100new_tim
[drvp
->UDMA_mode
] <<
453 SIS_TIM100_UDMA_TIME_OFF(drive
);
454 case SIS_TYPE_133OLD
:
456 sis_udma133old_tim
[drvp
->UDMA_mode
] <<
457 SIS_TIM100_UDMA_TIME_OFF(drive
);
460 aprint_error("unknown SiS IDE type %d\n",
466 * Timings will be used for both PIO and DMA,
467 * so adjust DMA mode if needed
469 if (drvp
->PIO_mode
> (drvp
->DMA_mode
+ 2))
470 drvp
->PIO_mode
= drvp
->DMA_mode
+ 2;
471 if (drvp
->DMA_mode
+ 2 > (drvp
->PIO_mode
))
472 drvp
->DMA_mode
= (drvp
->PIO_mode
> 2) ?
473 drvp
->PIO_mode
- 2 : 0;
474 if (drvp
->DMA_mode
== 0)
477 idedma_ctl
|= IDEDMA_CTL_DRV_DMA(drive
);
478 pio
: switch (sc
->sis_type
) {
479 case SIS_TYPE_NOUDMA
:
481 case SIS_TYPE_100OLD
:
482 sis_tim
|= sis_pio_act
[drvp
->PIO_mode
] <<
483 SIS_TIM66_ACT_OFF(drive
);
484 sis_tim
|= sis_pio_rec
[drvp
->PIO_mode
] <<
485 SIS_TIM66_REC_OFF(drive
);
487 case SIS_TYPE_100NEW
:
488 case SIS_TYPE_133OLD
:
489 sis_tim
|= sis_pio_act
[drvp
->PIO_mode
] <<
490 SIS_TIM100_ACT_OFF(drive
);
491 sis_tim
|= sis_pio_rec
[drvp
->PIO_mode
] <<
492 SIS_TIM100_REC_OFF(drive
);
495 aprint_error("unknown SiS IDE type %d\n",
499 ATADEBUG_PRINT(("sis_setup_channel: new timings reg for "
500 "channel %d 0x%x\n", chp
->ch_channel
, sis_tim
), DEBUG_PROBE
);
501 pci_conf_write(sc
->sc_pc
, sc
->sc_tag
, SIS_TIM(chp
->ch_channel
),
503 if (idedma_ctl
!= 0) {
504 /* Add software bits in status register */
505 bus_space_write_1(sc
->sc_dma_iot
, cp
->dma_iohs
[IDEDMA_CTL
], 0,
511 sis_sata_chip_map(struct pciide_softc
*sc
, struct pci_attach_args
*pa
)
513 struct pciide_channel
*cp
;
514 pcireg_t interface
= PCI_INTERFACE(pa
->pa_class
);
516 bus_size_t cmdsize
, ctlsize
;
518 if (pciide_chipen(sc
, pa
) == 0)
521 if (interface
== 0) {
522 ATADEBUG_PRINT(("sis_sata_chip_map interface == 0\n"),
524 interface
= PCIIDE_INTERFACE_BUS_MASTER_DMA
|
525 PCIIDE_INTERFACE_PCI(0) | PCIIDE_INTERFACE_PCI(1);
528 aprint_normal_dev(sc
->sc_wdcdev
.sc_atac
.atac_dev
,
529 "Silicon Integrated Systems 180/96X SATA controller "
530 "(rev. 0x%02x)\n", PCI_REVISION(pa
->pa_class
));
532 aprint_verbose_dev(sc
->sc_wdcdev
.sc_atac
.atac_dev
,
533 "bus-master DMA support present");
534 pciide_mapreg_dma(sc
, pa
);
535 aprint_verbose("\n");
538 sc
->sc_wdcdev
.sc_atac
.atac_cap
|= ATAC_CAP_UDMA
| ATAC_CAP_DMA
;
539 sc
->sc_wdcdev
.irqack
= pciide_irqack
;
541 sc
->sc_wdcdev
.sc_atac
.atac_pio_cap
= 4;
542 sc
->sc_wdcdev
.sc_atac
.atac_dma_cap
= 2;
543 sc
->sc_wdcdev
.sc_atac
.atac_udma_cap
= 6;
545 sc
->sc_wdcdev
.sc_atac
.atac_channels
= sc
->wdc_chanarray
;
546 sc
->sc_wdcdev
.sc_atac
.atac_nchannels
= PCIIDE_NUM_CHANNELS
;
547 sc
->sc_wdcdev
.sc_atac
.atac_cap
|= ATAC_CAP_DATA16
| ATAC_CAP_DATA32
;
548 sc
->sc_wdcdev
.sc_atac
.atac_set_modes
= sata_setup_channel
;
550 wdc_allocate_regs(&sc
->sc_wdcdev
);
552 for (channel
= 0; channel
< sc
->sc_wdcdev
.sc_atac
.atac_nchannels
;
554 cp
= &sc
->pciide_channels
[channel
];
555 if (pciide_chansetup(sc
, channel
, interface
) == 0)
557 pciide_mapchan(pa
, cp
, interface
, &cmdsize
, &ctlsize
,