Deleted Added
full compact
ata-ati.c (200171) ata-ati.c (201993)
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-ati.c 200171 2009-12-06 00:10:13Z mav $");
28__FBSDID("$FreeBSD: head/sys/dev/ata/chipsets/ata-ati.c 201993 2010-01-10 11:02:10Z 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>

--- 11 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_ati_chipinit(device_t dev);
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>

--- 11 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_ati_chipinit(device_t dev);
56static int ata_ati_ixp700_ch_attach(device_t dev);
56static int ata_ati_setmode(device_t dev, int target, int mode);
57
58/* misc defines */
59#define ATI_PATA 0x01
60#define ATI_SATA 0x02
61#define ATI_AHCI 0x04
62#define SII_MEMIO 1
63#define SII_BUG 0x04

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

116 return (BUS_PROBE_DEFAULT);
117}
118
119static int
120ata_ati_chipinit(device_t dev)
121{
122 struct ata_pci_controller *ctlr = device_get_softc(dev);
123 device_t smbdev;
57static int ata_ati_setmode(device_t dev, int target, int mode);
58
59/* misc defines */
60#define ATI_PATA 0x01
61#define ATI_SATA 0x02
62#define ATI_AHCI 0x04
63#define SII_MEMIO 1
64#define SII_BUG 0x04

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

117 return (BUS_PROBE_DEFAULT);
118}
119
120static int
121ata_ati_chipinit(device_t dev)
122{
123 struct ata_pci_controller *ctlr = device_get_softc(dev);
124 device_t smbdev;
124 int satacfg;
125 uint8_t satacfg;
125
126 if (ata_setup_interrupt(dev, ata_generic_intr))
127 return ENXIO;
128
129 switch (ctlr->chip->chipid) {
130 case ATA_ATI_IXP600:
131 /* IXP600 only has 1 PATA channel */
132 ctlr->channels = 1;

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

140 smbdev = pci_find_device(ATA_ATI_ID, 0x4385);
141 if (smbdev != NULL) {
142 satacfg = pci_read_config(smbdev, 0xad, 1);
143 if (bootverbose)
144 device_printf(dev, "SATA controller %s (%s%s channel)\n",
145 (satacfg & 0x01) == 0 ? "disabled" : "enabled",
146 (satacfg & 0x08) == 0 ? "" : "combined mode, ",
147 (satacfg & 0x10) == 0 ? "primary" : "secondary");
126
127 if (ata_setup_interrupt(dev, ata_generic_intr))
128 return ENXIO;
129
130 switch (ctlr->chip->chipid) {
131 case ATA_ATI_IXP600:
132 /* IXP600 only has 1 PATA channel */
133 ctlr->channels = 1;

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

141 smbdev = pci_find_device(ATA_ATI_ID, 0x4385);
142 if (smbdev != NULL) {
143 satacfg = pci_read_config(smbdev, 0xad, 1);
144 if (bootverbose)
145 device_printf(dev, "SATA controller %s (%s%s channel)\n",
146 (satacfg & 0x01) == 0 ? "disabled" : "enabled",
147 (satacfg & 0x08) == 0 ? "" : "combined mode, ",
148 (satacfg & 0x10) == 0 ? "primary" : "secondary");
148
149 ctlr->chipset_data = (void *)(uintptr_t)satacfg;
149 /*
150 * If SATA controller is enabled but combined mode is disabled,
151 * we have only one PATA channel. Ignore a non-existent channel.
152 */
153 if ((satacfg & 0x09) == 0x01)
154 ctlr->ichannels &= ~(1 << ((satacfg & 0x10) >> 4));
150 /*
151 * If SATA controller is enabled but combined mode is disabled,
152 * we have only one PATA channel. Ignore a non-existent channel.
153 */
154 if ((satacfg & 0x09) == 0x01)
155 ctlr->ichannels &= ~(1 << ((satacfg & 0x10) >> 4));
156 else {
157 ctlr->ch_attach = ata_ati_ixp700_ch_attach;
158 }
155 }
156 break;
157 }
158
159 ctlr->setmode = ata_ati_setmode;
160 return 0;
161}
162
163static int
159 }
160 break;
161 }
162
163 ctlr->setmode = ata_ati_setmode;
164 return 0;
165}
166
167static int
168ata_ati_ixp700_ch_attach(device_t dev)
169{
170 struct ata_pci_controller *ctlr = device_get_softc(device_get_parent(dev));
171 struct ata_channel *ch = device_get_softc(dev);
172 uint8_t satacfg = (uint8_t)(uintptr_t)ctlr->chipset_data;
173
174 /* Setup the usual register normal pci style. */
175 if (ata_pci_ch_attach(dev))
176 return ENXIO;
177
178 /* One of channels is PATA, another is SATA. */
179 if (ch->unit == ((satacfg & 0x10) >> 4))
180 ch->flags |= ATA_SATA;
181 return (0);
182}
183
184static int
164ata_ati_setmode(device_t dev, int target, int mode)
165{
166 device_t parent = device_get_parent(dev);
167 struct ata_pci_controller *ctlr = device_get_softc(parent);
168 struct ata_channel *ch = device_get_softc(dev);
169 int devno = (ch->unit << 1) + target;
170 int offset = (devno ^ 0x01) << 3;
171 int piomode;

--- 51 unchanged lines hidden ---
185ata_ati_setmode(device_t dev, int target, int mode)
186{
187 device_t parent = device_get_parent(dev);
188 struct ata_pci_controller *ctlr = device_get_softc(parent);
189 struct ata_channel *ch = device_get_softc(dev);
190 int devno = (ch->unit << 1) + target;
191 int offset = (devno ^ 0x01) << 3;
192 int piomode;

--- 51 unchanged lines hidden ---