Deleted Added
full compact
ata-via.c (200171) ata-via.c (200754)
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

--- 11 unchanged lines hidden (view full) ---

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.
25 */
26
27#include <sys/cdefs.h>
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

--- 11 unchanged lines hidden (view full) ---

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.
25 */
26
27#include <sys/cdefs.h>
28__FBSDID("$FreeBSD: head/sys/dev/ata/chipsets/ata-via.c 200171 2009-12-06 00:10:13Z mav $");
28__FBSDID("$FreeBSD: head/sys/dev/ata/chipsets/ata-via.c 200754 2009-12-20 16:23:11Z mav $");
29
30#include "opt_ata.h"
31#include <sys/param.h>
32#include <sys/module.h>
33#include <sys/systm.h>
34#include <sys/kernel.h>
35#include <sys/ata.h>
36#include <sys/bus.h>

--- 17 unchanged lines hidden (view full) ---

54/* local prototypes */
55static int ata_via_chipinit(device_t dev);
56static int ata_via_ch_attach(device_t dev);
57static int ata_via_ch_detach(device_t dev);
58static void ata_via_reset(device_t dev);
59static int ata_via_old_setmode(device_t dev, int target, int mode);
60static void ata_via_southbridge_fixup(device_t dev);
61static int ata_via_new_setmode(device_t dev, int target, int mode);
29
30#include "opt_ata.h"
31#include <sys/param.h>
32#include <sys/module.h>
33#include <sys/systm.h>
34#include <sys/kernel.h>
35#include <sys/ata.h>
36#include <sys/bus.h>

--- 17 unchanged lines hidden (view full) ---

54/* local prototypes */
55static int ata_via_chipinit(device_t dev);
56static int ata_via_ch_attach(device_t dev);
57static int ata_via_ch_detach(device_t dev);
58static void ata_via_reset(device_t dev);
59static int ata_via_old_setmode(device_t dev, int target, int mode);
60static void ata_via_southbridge_fixup(device_t dev);
61static int ata_via_new_setmode(device_t dev, int target, int mode);
62static int ata_via_sata_ch_attach(device_t dev);
63static int ata_via_sata_getrev(device_t dev, int target);
64static int ata_via_sata_setmode(device_t dev, int target, int mode);
62
63/* misc defines */
64#define VIA33 0
65#define VIA66 1
66#define VIA100 2
67#define VIA133 3
68
69#define VIACLK 0x01
70#define VIABUG 0x02
71#define VIABAR 0x04
72#define VIAAHCI 0x08
65
66/* misc defines */
67#define VIA33 0
68#define VIA66 1
69#define VIA100 2
70#define VIA133 3
71
72#define VIACLK 0x01
73#define VIABUG 0x02
74#define VIABAR 0x04
75#define VIAAHCI 0x08
76#define VIASATA 0x10
73
74
75/*
76 * VIA Technologies Inc. chipset support functions
77 */
78static int
79ata_via_probe(device_t dev)
80{

--- 12 unchanged lines hidden (view full) ---

93 { ATA_VIA8233A, 0x00, VIA133, 0x00, ATA_UDMA6, "8233A" },
94 { ATA_VIA8235, 0x00, VIA133, 0x00, ATA_UDMA6, "8235" },
95 { ATA_VIA8237, 0x00, VIA133, 0x00, ATA_UDMA6, "8237" },
96 { ATA_VIA8237A, 0x00, VIA133, 0x00, ATA_UDMA6, "8237A" },
97 { ATA_VIA8237S, 0x00, VIA133, 0x00, ATA_UDMA6, "8237S" },
98 { ATA_VIA8237_5372, 0x00, VIA133, 0x00, ATA_UDMA6, "8237" },
99 { ATA_VIA8237_7372, 0x00, VIA133, 0x00, ATA_UDMA6, "8237" },
100 { ATA_VIA8251, 0x00, VIA133, 0x00, ATA_UDMA6, "8251" },
77
78
79/*
80 * VIA Technologies Inc. chipset support functions
81 */
82static int
83ata_via_probe(device_t dev)
84{

--- 12 unchanged lines hidden (view full) ---

97 { ATA_VIA8233A, 0x00, VIA133, 0x00, ATA_UDMA6, "8233A" },
98 { ATA_VIA8235, 0x00, VIA133, 0x00, ATA_UDMA6, "8235" },
99 { ATA_VIA8237, 0x00, VIA133, 0x00, ATA_UDMA6, "8237" },
100 { ATA_VIA8237A, 0x00, VIA133, 0x00, ATA_UDMA6, "8237A" },
101 { ATA_VIA8237S, 0x00, VIA133, 0x00, ATA_UDMA6, "8237S" },
102 { ATA_VIA8237_5372, 0x00, VIA133, 0x00, ATA_UDMA6, "8237" },
103 { ATA_VIA8237_7372, 0x00, VIA133, 0x00, ATA_UDMA6, "8237" },
104 { ATA_VIA8251, 0x00, VIA133, 0x00, ATA_UDMA6, "8251" },
105 { ATA_VIACX700, 0x00, VIA133, VIASATA, ATA_SA150, "CX700" },
106 { ATA_VIAVX800, 0x00, VIA133, VIASATA, ATA_SA150, "VX800" },
107 { ATA_VIAVX855, 0x00, VIA133, 0x00, ATA_UDMA6, "VX855" },
101 { 0, 0, 0, 0, 0, 0 }};
102 static struct ata_chip_id new_ids[] =
103 {{ ATA_VIA6410, 0x00, 0, 0x00, ATA_UDMA6, "6410" },
104 { ATA_VIA6420, 0x00, 7, 0x00, ATA_SA150, "6420" },
105 { ATA_VIA6421, 0x00, 6, VIABAR, ATA_SA150, "6421" },
106 { ATA_VIA8237A, 0x00, 7, 0x00, ATA_SA150, "8237A" },
107 { ATA_VIA8237S, 0x00, 7, 0x00, ATA_SA150, "8237S" },
108 { ATA_VIA8237_5372, 0x00, 7, 0x00, ATA_SA300, "8237" },
109 { ATA_VIA8237_7372, 0x00, 7, 0x00, ATA_SA300, "8237" },
110 { ATA_VIA8251, 0x00, 0, VIAAHCI, ATA_SA300, "8251" },
111 { 0, 0, 0, 0, 0, 0 }};
112
113 if (pci_get_vendor(dev) != ATA_VIA_ID)
114 return ENXIO;
115
108 { 0, 0, 0, 0, 0, 0 }};
109 static struct ata_chip_id new_ids[] =
110 {{ ATA_VIA6410, 0x00, 0, 0x00, ATA_UDMA6, "6410" },
111 { ATA_VIA6420, 0x00, 7, 0x00, ATA_SA150, "6420" },
112 { ATA_VIA6421, 0x00, 6, VIABAR, ATA_SA150, "6421" },
113 { ATA_VIA8237A, 0x00, 7, 0x00, ATA_SA150, "8237A" },
114 { ATA_VIA8237S, 0x00, 7, 0x00, ATA_SA150, "8237S" },
115 { ATA_VIA8237_5372, 0x00, 7, 0x00, ATA_SA300, "8237" },
116 { ATA_VIA8237_7372, 0x00, 7, 0x00, ATA_SA300, "8237" },
117 { ATA_VIA8251, 0x00, 0, VIAAHCI, ATA_SA300, "8251" },
118 { 0, 0, 0, 0, 0, 0 }};
119
120 if (pci_get_vendor(dev) != ATA_VIA_ID)
121 return ENXIO;
122
116 if (pci_get_devid(dev) == ATA_VIA82C571) {
123 if (pci_get_devid(dev) == ATA_VIA82C571 ||
124 pci_get_devid(dev) == ATA_VIACX700IDE ||
125 pci_get_devid(dev) == ATA_VIASATAIDE) {
117 if (!(ctlr->chip = ata_find_chip(dev, ids, -99)))
118 return ENXIO;
119 }
120 else {
121 if (!(ctlr->chip = ata_match_chip(dev, new_ids)))
122 return ENXIO;
123 }
124

--- 4 unchanged lines hidden (view full) ---

129
130static int
131ata_via_chipinit(device_t dev)
132{
133 struct ata_pci_controller *ctlr = device_get_softc(dev);
134
135 if (ata_setup_interrupt(dev, ata_generic_intr))
136 return ENXIO;
126 if (!(ctlr->chip = ata_find_chip(dev, ids, -99)))
127 return ENXIO;
128 }
129 else {
130 if (!(ctlr->chip = ata_match_chip(dev, new_ids)))
131 return ENXIO;
132 }
133

--- 4 unchanged lines hidden (view full) ---

138
139static int
140ata_via_chipinit(device_t dev)
141{
142 struct ata_pci_controller *ctlr = device_get_softc(dev);
143
144 if (ata_setup_interrupt(dev, ata_generic_intr))
145 return ENXIO;
137
138 if (ctlr->chip->max_dma >= ATA_SA150) {
139 /* do we have AHCI capability ? */
140 if ((ctlr->chip->cfg2 == VIAAHCI) && ata_ahci_chipinit(dev) != ENXIO)
141 return 0;
142
146
147 /* AHCI SATA */
148 if (ctlr->chip->cfg2 & VIAAHCI) {
149 if (ata_ahci_chipinit(dev) != ENXIO)
150 return (0);
151 }
152 /* 2 SATA without SATA registers on first channel + 1 PATA on second */
153 if (ctlr->chip->cfg2 & VIASATA) {
154 ctlr->ch_attach = ata_via_sata_ch_attach;
155 ctlr->setmode = ata_via_sata_setmode;
156 ctlr->getrev = ata_via_sata_getrev;
157 return 0;
158 }
159 /* Legacy SATA/SATA+PATA with SATA registers in BAR(5). */
160 if (ctlr->chip->max_dma >= ATA_SA150) {
143 ctlr->r_type2 = SYS_RES_IOPORT;
144 ctlr->r_rid2 = PCIR_BAR(5);
145 if ((ctlr->r_res2 = bus_alloc_resource_any(dev, ctlr->r_type2,
146 &ctlr->r_rid2, RF_ACTIVE))) {
147 ctlr->ch_attach = ata_via_ch_attach;
148 ctlr->ch_detach = ata_via_ch_detach;
149 ctlr->reset = ata_via_reset;
150 }
161 ctlr->r_type2 = SYS_RES_IOPORT;
162 ctlr->r_rid2 = PCIR_BAR(5);
163 if ((ctlr->r_res2 = bus_alloc_resource_any(dev, ctlr->r_type2,
164 &ctlr->r_rid2, RF_ACTIVE))) {
165 ctlr->ch_attach = ata_via_ch_attach;
166 ctlr->ch_detach = ata_via_ch_detach;
167 ctlr->reset = ata_via_reset;
168 }
151
152 if (ctlr->chip->cfg2 & VIABAR) {
153 ctlr->channels = 3;
154 ctlr->setmode = ata_via_new_setmode;
155 } else
156 ctlr->setmode = ata_sata_setmode;
157 ctlr->getrev = ata_sata_getrev;
158 return 0;
159 }

--- 200 unchanged lines hidden (view full) ---

360 pci_write_config(children[i], 0x76, (reg76 & 0x0f) | 0xd0, 1);
361 }
362 break;
363 }
364 }
365 free(children, M_TEMP);
366}
367
169 if (ctlr->chip->cfg2 & VIABAR) {
170 ctlr->channels = 3;
171 ctlr->setmode = ata_via_new_setmode;
172 } else
173 ctlr->setmode = ata_sata_setmode;
174 ctlr->getrev = ata_sata_getrev;
175 return 0;
176 }

--- 200 unchanged lines hidden (view full) ---

377 pci_write_config(children[i], 0x76, (reg76 & 0x0f) | 0xd0, 1);
378 }
379 break;
380 }
381 }
382 free(children, M_TEMP);
383}
384
385static int
386ata_via_sata_ch_attach(device_t dev)
387{
388 struct ata_channel *ch = device_get_softc(dev);
389
390 if (ata_pci_ch_attach(dev))
391 return ENXIO;
392 if (ch->unit == 0)
393 ch->flags |= ATA_SATA;
394 return (0);
395}
396
397static int
398ata_via_sata_getrev(device_t dev, int target)
399{
400 struct ata_channel *ch = device_get_softc(dev);
401
402 if (ch->unit == 0)
403 return (1);
404 return (0);
405}
406
407static int
408ata_via_sata_setmode(device_t dev, int target, int mode)
409{
410 struct ata_channel *ch = device_get_softc(dev);
411
412 if (ch->unit == 0)
413 return (mode);
414 return (ata_via_old_setmode(dev, target, mode));
415}
416
368ATA_DECLARE_DRIVER(ata_via);
369MODULE_DEPEND(ata_via, ata_ahci, 1, 1, 1);
417ATA_DECLARE_DRIVER(ata_via);
418MODULE_DEPEND(ata_via, ata_ahci, 1, 1, 1);