Lines 78-84
enum {
Link Here
|
78 |
}; |
78 |
}; |
79 |
|
79 |
|
80 |
enum { |
80 |
enum { |
81 |
VIA_IDFLAG_SINGLE = (1 << 0), /* single channel controller) */ |
81 |
VIA_IDFLAG_SINGLE = (1 << 0), /* single channel controller) */ |
|
|
82 |
VIA_IDFLAG_NO_ENABLES = (1 << 1), /* has no enable bits */ |
82 |
}; |
83 |
}; |
83 |
|
84 |
|
84 |
/* |
85 |
/* |
Lines 139-144
struct via_port {
Link Here
|
139 |
u8 cached_device; |
140 |
u8 cached_device; |
140 |
}; |
141 |
}; |
141 |
|
142 |
|
|
|
143 |
struct via_host { |
144 |
const struct via_isa_bridge *bridge; |
145 |
unsigned long flags; |
146 |
}; |
147 |
|
142 |
/* |
148 |
/* |
143 |
* Cable special cases |
149 |
* Cable special cases |
144 |
*/ |
150 |
*/ |
Lines 166-171
static int via_cable_override(struct pci_dev *pdev)
Link Here
|
166 |
} |
172 |
} |
167 |
|
173 |
|
168 |
|
174 |
|
|
|
175 |
static const struct via_isa_bridge *via_bridge(struct ata_port *ap) |
176 |
{ |
177 |
struct via_host *h = ap->host->private_data; |
178 |
return h->bridge; |
179 |
} |
180 |
|
169 |
/** |
181 |
/** |
170 |
* via_cable_detect - cable detection |
182 |
* via_cable_detect - cable detection |
171 |
* @ap: ATA port |
183 |
* @ap: ATA port |
Lines 179-185
static int via_cable_override(struct pci_dev *pdev)
Link Here
|
179 |
*/ |
191 |
*/ |
180 |
|
192 |
|
181 |
static int via_cable_detect(struct ata_port *ap) { |
193 |
static int via_cable_detect(struct ata_port *ap) { |
182 |
const struct via_isa_bridge *config = ap->host->private_data; |
194 |
const struct via_isa_bridge *config = via_bridge(ap); |
183 |
struct pci_dev *pdev = to_pci_dev(ap->host->dev); |
195 |
struct pci_dev *pdev = to_pci_dev(ap->host->dev); |
184 |
u32 ata66; |
196 |
u32 ata66; |
185 |
|
197 |
|
Lines 211-219
static int via_cable_detect(struct ata_port *ap) {
Link Here
|
211 |
static int via_pre_reset(struct ata_link *link, unsigned long deadline) |
223 |
static int via_pre_reset(struct ata_link *link, unsigned long deadline) |
212 |
{ |
224 |
{ |
213 |
struct ata_port *ap = link->ap; |
225 |
struct ata_port *ap = link->ap; |
214 |
const struct via_isa_bridge *config = ap->host->private_data; |
226 |
const struct via_host *vh = ap->host->private_data; |
215 |
|
227 |
|
216 |
if (!(config->flags & VIA_NO_ENABLES)) { |
228 |
if (!(vh->flags & VIA_IDFLAG_NO_ENABLES)) { |
217 |
static const struct pci_bits via_enable_bits[] = { |
229 |
static const struct pci_bits via_enable_bits[] = { |
218 |
{ 0x40, 1, 0x02, 0x02 }, |
230 |
{ 0x40, 1, 0x02, 0x02 }, |
219 |
{ 0x40, 1, 0x01, 0x01 } |
231 |
{ 0x40, 1, 0x01, 0x01 } |
Lines 329-335
static void via_do_set_mode(struct ata_port *ap, struct ata_device *adev,
Link Here
|
329 |
|
341 |
|
330 |
static void via_set_piomode(struct ata_port *ap, struct ata_device *adev) |
342 |
static void via_set_piomode(struct ata_port *ap, struct ata_device *adev) |
331 |
{ |
343 |
{ |
332 |
const struct via_isa_bridge *config = ap->host->private_data; |
344 |
const struct via_isa_bridge *config = via_bridge(ap); |
333 |
int set_ast = (config->flags & VIA_BAD_AST) ? 0 : 1; |
345 |
int set_ast = (config->flags & VIA_BAD_AST) ? 0 : 1; |
334 |
|
346 |
|
335 |
via_do_set_mode(ap, adev, adev->pio_mode, set_ast, config->udma_mask); |
347 |
via_do_set_mode(ap, adev, adev->pio_mode, set_ast, config->udma_mask); |
Lines 337-343
static void via_set_piomode(struct ata_port *ap, struct ata_device *adev)
Link Here
|
337 |
|
349 |
|
338 |
static void via_set_dmamode(struct ata_port *ap, struct ata_device *adev) |
350 |
static void via_set_dmamode(struct ata_port *ap, struct ata_device *adev) |
339 |
{ |
351 |
{ |
340 |
const struct via_isa_bridge *config = ap->host->private_data; |
352 |
const struct via_isa_bridge *config = via_bridge(ap); |
341 |
int set_ast = (config->flags & VIA_BAD_AST) ? 0 : 1; |
353 |
int set_ast = (config->flags & VIA_BAD_AST) ? 0 : 1; |
342 |
|
354 |
|
343 |
via_do_set_mode(ap, adev, adev->dma_mode, set_ast, config->udma_mask); |
355 |
via_do_set_mode(ap, adev, adev->dma_mode, set_ast, config->udma_mask); |
Lines 354-361
static void via_set_dmamode(struct ata_port *ap, struct ata_device *adev)
Link Here
|
354 |
|
366 |
|
355 |
static unsigned long via_mode_filter(struct ata_device *dev, unsigned long mask) |
367 |
static unsigned long via_mode_filter(struct ata_device *dev, unsigned long mask) |
356 |
{ |
368 |
{ |
357 |
struct ata_host *host = dev->link->ap->host; |
369 |
const struct via_isa_bridge *config = via_bridge(dev->link->ap); |
358 |
const struct via_isa_bridge *config = host->private_data; |
|
|
359 |
unsigned char model_num[ATA_ID_PROD_LEN + 1]; |
370 |
unsigned char model_num[ATA_ID_PROD_LEN + 1]; |
360 |
|
371 |
|
361 |
if (config->id == PCI_DEVICE_ID_VIA_82C586_0) { |
372 |
if (config->id == PCI_DEVICE_ID_VIA_82C586_0) { |
Lines 509-516
static void via_config_fifo(struct pci_dev *pdev, unsigned int flags)
Link Here
|
509 |
} |
520 |
} |
510 |
} |
521 |
} |
511 |
|
522 |
|
512 |
static void via_fixup(struct pci_dev *pdev, const struct via_isa_bridge *config) |
523 |
static void via_fixup(struct pci_dev *pdev, struct via_host *vh) |
513 |
{ |
524 |
{ |
|
|
525 |
const struct via_isa_bridge *config = vh->bridge; |
514 |
u32 timing; |
526 |
u32 timing; |
515 |
|
527 |
|
516 |
/* Initialise the FIFO for the enabled channels. */ |
528 |
/* Initialise the FIFO for the enabled channels. */ |
Lines 590-600
static int via_init_one(struct pci_dev *pdev, const struct pci_device_id *id)
Link Here
|
590 |
const struct ata_port_info *ppi[] = { NULL, NULL }; |
602 |
const struct ata_port_info *ppi[] = { NULL, NULL }; |
591 |
struct pci_dev *isa; |
603 |
struct pci_dev *isa; |
592 |
const struct via_isa_bridge *config; |
604 |
const struct via_isa_bridge *config; |
|
|
605 |
struct via_host *vh; |
593 |
u8 enable; |
606 |
u8 enable; |
594 |
unsigned long flags = id->driver_data; |
607 |
unsigned long flags = id->driver_data; |
595 |
int rc; |
608 |
int rc; |
596 |
|
609 |
|
597 |
ata_print_version_once(&pdev->dev, DRV_VERSION); |
610 |
ata_print_version_once(&pdev->dev, DRV_VERSION); |
|
|
611 |
|
612 |
vh = devm_kzalloc(&pdev->dev, sizeof(struct via_host), GFP_KERNEL); |
613 |
if (vh == NULL) |
614 |
return-ENOMEM; |
598 |
|
615 |
|
599 |
rc = pcim_enable_device(pdev); |
616 |
rc = pcim_enable_device(pdev); |
600 |
if (rc) |
617 |
if (rc) |
Lines 620-627
static int via_init_one(struct pci_dev *pdev, const struct pci_device_id *id)
Link Here
|
620 |
if (rev >= config->rev_min && rev <= config->rev_max) |
637 |
if (rev >= config->rev_min && rev <= config->rev_max) |
621 |
break; |
638 |
break; |
622 |
} |
639 |
} |
623 |
|
640 |
|
624 |
if (!(config->flags & VIA_NO_ENABLES)) { |
641 |
vh->bridge = config; |
|
|
642 |
vh->flags = flags; |
643 |
|
644 |
/* Lack of enables is both a bridge and device property */ |
645 |
if (config->flags & VIA_NO_ENABLES) |
646 |
vh->flags |= VIA_IDFLAG_NO_ENABLES; |
647 |
|
648 |
if (vh->flags & VIA_IDFLAG_NO_ENABLES) { |
625 |
/* 0x40 low bits indicate enabled channels */ |
649 |
/* 0x40 low bits indicate enabled channels */ |
626 |
pci_read_config_byte(pdev, 0x40 , &enable); |
650 |
pci_read_config_byte(pdev, 0x40 , &enable); |
627 |
enable &= 3; |
651 |
enable &= 3; |
Lines 654-663
static int via_init_one(struct pci_dev *pdev, const struct pci_device_id *id)
Link Here
|
654 |
return -ENODEV; |
678 |
return -ENODEV; |
655 |
} |
679 |
} |
656 |
|
680 |
|
657 |
via_fixup(pdev, config); |
681 |
via_fixup(pdev, vh); |
658 |
|
682 |
|
659 |
/* We have established the device type, now fire it up */ |
683 |
/* We have established the device type, now fire it up */ |
660 |
return ata_pci_bmdma_init_one(pdev, ppi, &via_sht, (void *)config, 0); |
684 |
return ata_pci_bmdma_init_one(pdev, ppi, &via_sht, (void *)vh, 0); |
661 |
} |
685 |
} |
662 |
|
686 |
|
663 |
#ifdef CONFIG_PM |
687 |
#ifdef CONFIG_PM |