ata-national.c (10b3b54548f2290bbe8d8f88c59c28d12b7a635d) | ata-national.c (066f913a94b134b6d5e32b6af88f297c7da9c031) |
---|---|
1/*- 2 * Copyright (c) 1998 - 2008 S�ren Schmidt <sos@FreeBSD.org> 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright --- 39 unchanged lines hidden (view full) --- 48#include <dev/pci/pcivar.h> 49#include <dev/pci/pcireg.h> 50#include <dev/ata/ata-all.h> 51#include <dev/ata/ata-pci.h> 52#include <ata_if.h> 53 54/* local prototypes */ 55static int ata_national_chipinit(device_t dev); | 1/*- 2 * Copyright (c) 1998 - 2008 S�ren Schmidt <sos@FreeBSD.org> 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright --- 39 unchanged lines hidden (view full) --- 48#include <dev/pci/pcivar.h> 49#include <dev/pci/pcireg.h> 50#include <dev/ata/ata-all.h> 51#include <dev/ata/ata-pci.h> 52#include <ata_if.h> 53 54/* local prototypes */ 55static int ata_national_chipinit(device_t dev); |
56static void ata_national_setmode(device_t dev, int mode); | 56static int ata_national_ch_attach(device_t dev); 57static int ata_national_setmode(device_t dev, int target, int mode); |
57 | 58 |
58 | |
59/* 60 * National chipset support functions 61 */ 62static int 63ata_national_probe(device_t dev) 64{ 65 struct ata_pci_controller *ctlr = device_get_softc(dev); 66 --- 9 unchanged lines hidden (view full) --- 76static int 77ata_national_chipinit(device_t dev) 78{ 79 struct ata_pci_controller *ctlr = device_get_softc(dev); 80 81 if (ata_setup_interrupt(dev, ata_generic_intr)) 82 return ENXIO; 83 | 59/* 60 * National chipset support functions 61 */ 62static int 63ata_national_probe(device_t dev) 64{ 65 struct ata_pci_controller *ctlr = device_get_softc(dev); 66 --- 9 unchanged lines hidden (view full) --- 76static int 77ata_national_chipinit(device_t dev) 78{ 79 struct ata_pci_controller *ctlr = device_get_softc(dev); 80 81 if (ata_setup_interrupt(dev, ata_generic_intr)) 82 return ENXIO; 83 |
84 ctlr->ch_attach = ata_national_ch_attach; |
|
84 ctlr->setmode = ata_national_setmode; 85 return 0; 86} 87 | 85 ctlr->setmode = ata_national_setmode; 86 return 0; 87} 88 |
88static void 89ata_national_setmode(device_t dev, int mode) | 89static int 90ata_national_ch_attach(device_t dev) |
90{ | 91{ |
91 device_t gparent = GRANDPARENT(dev); 92 struct ata_channel *ch = device_get_softc(device_get_parent(dev)); 93 struct ata_device *atadev = device_get_softc(dev); 94 int devno = (ch->unit << 1) + atadev->unit; 95 u_int32_t piotiming[] = 96 { 0x9172d132, 0x21717121, 0x00803020, 0x20102010, 0x00100010, 97 0x00803020, 0x20102010, 0x00100010, 98 0x00100010, 0x00100010, 0x00100010 }; 99 u_int32_t dmatiming[] = { 0x80077771, 0x80012121, 0x80002020 }; 100 u_int32_t udmatiming[] = { 0x80921250, 0x80911140, 0x80911030 }; 101 int error; | 92 struct ata_channel *ch = device_get_softc(dev); 93 int error; 94 95 error = ata_pci_ch_attach(dev); 96 ch->dma.alignment = 16; 97 ch->dma.max_iosize = 64 * DEV_BSIZE; 98 return (error); 99} |
102 | 100 |
103 ch->dma.alignment = 16; 104 ch->dma.max_iosize = 64 * DEV_BSIZE; | 101static int 102ata_national_setmode(device_t dev, int target, int mode) 103{ 104 device_t parent = device_get_parent(dev); 105 struct ata_channel *ch = device_get_softc(dev); 106 int devno = (ch->unit << 1) + target; 107 int piomode; 108 u_int32_t piotiming[] = 109 { 0x9172d132, 0x21717121, 0x00803020, 0x20102010, 0x00100010, 110 0x9172d132, 0x20102010, 0x00100010 }; 111 u_int32_t dmatiming[] = { 0x80077771, 0x80012121, 0x80002020 }; 112 u_int32_t udmatiming[] = { 0x80921250, 0x80911140, 0x80911030 }; |
105 | 113 |
106 mode = ata_limit_mode(dev, mode, ATA_UDMA2); | 114 mode = min(mode, ATA_UDMA2); |
107 | 115 |
108 error = ata_controlcmd(dev, ATA_SETFEATURES, ATA_SF_SETXFER, 0, mode); 109 110 if (bootverbose) 111 device_printf(dev, "%s setting %s on National chip\n", 112 (error) ? "failed" : "success", ata_mode2str(mode)); 113 if (!error) { | |
114 if (mode >= ATA_UDMA0) { | 116 if (mode >= ATA_UDMA0) { |
115 pci_write_config(gparent, 0x44 + (devno << 3), | 117 pci_write_config(parent, 0x44 + (devno << 3), |
116 udmatiming[mode & ATA_MODE_MASK], 4); | 118 udmatiming[mode & ATA_MODE_MASK], 4); |
117 } 118 else if (mode >= ATA_WDMA0) { 119 pci_write_config(gparent, 0x44 + (devno << 3), | 119 piomode = ATA_PIO4; 120 } else if (mode >= ATA_WDMA0) { 121 pci_write_config(parent, 0x44 + (devno << 3), |
120 dmatiming[mode & ATA_MODE_MASK], 4); | 122 dmatiming[mode & ATA_MODE_MASK], 4); |
121 } 122 else { 123 pci_write_config(gparent, 0x44 + (devno << 3), 124 pci_read_config(gparent, 0x44 + (devno << 3), 4) | | 123 piomode = mode; 124 } else { 125 pci_write_config(parent, 0x44 + (devno << 3), 126 pci_read_config(parent, 0x44 + (devno << 3), 4) | |
125 0x80000000, 4); | 127 0x80000000, 4); |
128 piomode = mode; |
|
126 } | 129 } |
127 pci_write_config(gparent, 0x40 + (devno << 3), 128 piotiming[ata_mode2idx(mode)], 4); 129 atadev->mode = mode; 130 } | 130 pci_write_config(parent, 0x40 + (devno << 3), 131 piotiming[ata_mode2idx(piomode)], 4); 132 return (mode); |
131} 132 133ATA_DECLARE_DRIVER(ata_national); | 133} 134 135ATA_DECLARE_DRIVER(ata_national); |