ata_kauai.c (e865720075d5ac0fd1532c91748d926f475bdf22) | ata_kauai.c (066f913a94b134b6d5e32b6af88f297c7da9c031) |
---|---|
1/*- 2 * Copyright 2004 by Peter Grehan. All rights reserved. 3 * 4 * Redistribution and use in source and binary forms, with or without 5 * modification, are permitted provided that the following conditions 6 * are met: 7 * 1. Redistributions of source code must retain the above copyright 8 * notice, this list of conditions and the following disclaimer. --- 71 unchanged lines hidden (view full) --- 80 81#define USE_DBDMA_IRQ 0 82 83/* 84 * Define the kauai pci bus attachment. 85 */ 86static int ata_kauai_probe(device_t dev); 87static int ata_kauai_attach(device_t dev); | 1/*- 2 * Copyright 2004 by Peter Grehan. All rights reserved. 3 * 4 * Redistribution and use in source and binary forms, with or without 5 * modification, are permitted provided that the following conditions 6 * are met: 7 * 1. Redistributions of source code must retain the above copyright 8 * notice, this list of conditions and the following disclaimer. --- 71 unchanged lines hidden (view full) --- 80 81#define USE_DBDMA_IRQ 0 82 83/* 84 * Define the kauai pci bus attachment. 85 */ 86static int ata_kauai_probe(device_t dev); 87static int ata_kauai_attach(device_t dev); |
88static void ata_kauai_setmode(device_t parent, device_t dev); | 88static int ata_kauai_setmode(device_t dev, int target, int mode); |
89static int ata_kauai_begin_transaction(struct ata_request *request); 90 91static device_method_t ata_kauai_methods[] = { 92 /* Device interface */ 93 DEVMETHOD(device_probe, ata_kauai_probe), 94 DEVMETHOD(device_attach, ata_kauai_attach), 95 DEVMETHOD(device_detach, bus_generic_detach), 96 DEVMETHOD(device_shutdown, bus_generic_shutdown), --- 205 unchanged lines hidden (view full) --- 302 bus_write_4(sc->sc_memr, 0, 0x00000007); 303 304 /* Set begin_transaction */ 305 sc->sc_ch.sc_ch.hw.begin_transaction = ata_kauai_begin_transaction; 306 307 return ata_attach(dev); 308} 309 | 89static int ata_kauai_begin_transaction(struct ata_request *request); 90 91static device_method_t ata_kauai_methods[] = { 92 /* Device interface */ 93 DEVMETHOD(device_probe, ata_kauai_probe), 94 DEVMETHOD(device_attach, ata_kauai_attach), 95 DEVMETHOD(device_detach, bus_generic_detach), 96 DEVMETHOD(device_shutdown, bus_generic_shutdown), --- 205 unchanged lines hidden (view full) --- 302 bus_write_4(sc->sc_memr, 0, 0x00000007); 303 304 /* Set begin_transaction */ 305 sc->sc_ch.sc_ch.hw.begin_transaction = ata_kauai_begin_transaction; 306 307 return ata_attach(dev); 308} 309 |
310static void 311ata_kauai_setmode(device_t parent, device_t dev) | 310static int 311ata_kauai_setmode(device_t dev, int target, int mode) |
312{ | 312{ |
313 struct ata_device *atadev = device_get_softc(dev); 314 struct ata_kauai_softc *sc = device_get_softc(parent); 315 uint32_t mode; | 313 struct ata_kauai_softc *sc = device_get_softc(dev); |
316 | 314 |
317 mode = ata_limit_mode(dev,atadev->mode, 318 (sc->shasta) ? ATA_UDMA6 : ATA_UDMA5); | 315 mode = min(mode,sc->shasta ? ATA_UDMA6 : ATA_UDMA5); |
319 | 316 |
320 if (ata_controlcmd(dev, ATA_SETFEATURES, ATA_SF_SETXFER, 0, mode)) 321 return; 322 323 atadev->mode = mode; 324 | |
325 if (sc->shasta) { 326 switch (mode & ATA_DMA_MASK) { 327 case ATA_UDMA0: | 317 if (sc->shasta) { 318 switch (mode & ATA_DMA_MASK) { 319 case ATA_UDMA0: |
328 sc->udmaconf[atadev->unit] | 320 sc->udmaconf[target] |
329 = udma_timing_shasta[mode & ATA_MODE_MASK]; 330 break; 331 case ATA_WDMA0: | 321 = udma_timing_shasta[mode & ATA_MODE_MASK]; 322 break; 323 case ATA_WDMA0: |
332 sc->udmaconf[atadev->unit] = 0; 333 sc->wdmaconf[atadev->unit] | 324 sc->udmaconf[target] = 0; 325 sc->wdmaconf[target] |
334 = dma_timing_shasta[mode & ATA_MODE_MASK]; 335 break; 336 default: | 326 = dma_timing_shasta[mode & ATA_MODE_MASK]; 327 break; 328 default: |
337 sc->pioconf[atadev->unit] | 329 sc->pioconf[target] |
338 = pio_timing_shasta[(mode & ATA_MODE_MASK) - 339 ATA_PIO0]; 340 break; 341 } 342 } else { 343 switch (mode & ATA_DMA_MASK) { 344 case ATA_UDMA0: | 330 = pio_timing_shasta[(mode & ATA_MODE_MASK) - 331 ATA_PIO0]; 332 break; 333 } 334 } else { 335 switch (mode & ATA_DMA_MASK) { 336 case ATA_UDMA0: |
345 sc->udmaconf[atadev->unit] | 337 sc->udmaconf[target] |
346 = udma_timing_kauai[mode & ATA_MODE_MASK]; 347 break; 348 case ATA_WDMA0: | 338 = udma_timing_kauai[mode & ATA_MODE_MASK]; 339 break; 340 case ATA_WDMA0: |
349 sc->udmaconf[atadev->unit] = 0; 350 sc->wdmaconf[atadev->unit] | 341 sc->udmaconf[target] = 0; 342 sc->wdmaconf[target] |
351 = dma_timing_kauai[mode & ATA_MODE_MASK]; 352 break; 353 default: | 343 = dma_timing_kauai[mode & ATA_MODE_MASK]; 344 break; 345 default: |
354 sc->pioconf[atadev->unit] | 346 sc->pioconf[target] |
355 = pio_timing_kauai[(mode & ATA_MODE_MASK) 356 - ATA_PIO0]; 357 break; 358 } 359 } | 347 = pio_timing_kauai[(mode & ATA_MODE_MASK) 348 - ATA_PIO0]; 349 break; 350 } 351 } |
352 353 return (mode); |
|
360} 361 362static int 363ata_kauai_begin_transaction(struct ata_request *request) 364{ | 354} 355 356static int 357ata_kauai_begin_transaction(struct ata_request *request) 358{ |
365 struct ata_device *atadev = device_get_softc(request->dev); | |
366 struct ata_kauai_softc *sc = device_get_softc(request->parent); 367 | 359 struct ata_kauai_softc *sc = device_get_softc(request->parent); 360 |
368 bus_write_4(sc->sc_memr, UDMA_CONFIG_REG, sc->udmaconf[atadev->unit]); | 361 bus_write_4(sc->sc_memr, UDMA_CONFIG_REG, sc->udmaconf[request->unit]); |
369 bus_write_4(sc->sc_memr, PIO_CONFIG_REG, | 362 bus_write_4(sc->sc_memr, PIO_CONFIG_REG, |
370 sc->wdmaconf[atadev->unit] | sc->pioconf[atadev->unit]); | 363 sc->wdmaconf[request->unit] | sc->pioconf[request->unit]); |
371 372 return ata_begin_transaction(request); 373} 374 | 364 365 return ata_begin_transaction(request); 366} 367 |