2 * Copyright (c) 2003-2009 RMI Corporation
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution.
13 * 3. Neither the name of RMI Corporation, nor the names of its contributors,
14 * may be used to endorse or promote products derived from this software
15 * without specific prior written permission.
17 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
18 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
21 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
23 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
24 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
25 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
26 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
31 * ATA driver for the XLR_PCMCIA Host adapter on the RMI XLR/XLS/.
33 #include <sys/cdefs.h>
34 __FBSDID("$FreeBSD$");
36 #include <sys/param.h>
37 #include <sys/systm.h>
38 #include <sys/kernel.h>
39 #include <sys/module.h>
45 #include <sys/taskqueue.h>
46 #include <sys/bus_dma.h>
48 #include <dev/ata/ata-all.h>
49 #include <mips/rmi/pic.h>
50 #include <mips/rmi/iomap.h>
51 #include <mips/include/resource.h>
52 #include <mips/rmi/interrupt.h>
54 #define XLR_PCMCIA_DATA_REG 0x1f0
55 #define XLR_PCMCIA_ERROR_REG 0x1f1
56 #define XLR_PCMCIA_SECT_CNT_REG 0x1f2
57 #define XLR_PCMCIA_SECT_NUM_REG 0x1f3
58 #define XLR_PCMCIA_CYLINDER_LOW_REG 0x1f4
59 #define XLR_PCMCIA_CYLINDER_HIGH_REG 0x1f5
60 #define XLR_PCMCIA_SECT_DRIVE_HEAD_REG 0x1f6
61 #define XLR_PCMCIA_CMD_STATUS_REG 0x1f7
62 #define XLR_PCMCIA_ALT_STATUS_REG 0x3f6
63 #define XLR_PCMCIA_CONTROL_REG 0x3f6
68 static int xlr_pcmcia_probe(device_t);
69 static int xlr_pcmcia_attach(device_t);
70 static int xlr_pcmcia_detach(device_t);
73 xlr_pcmcia_probe(device_t dev)
75 struct ata_channel *ch = device_get_softc(dev);
78 ch->flags |= ATA_USE_16BIT | ATA_NO_SLAVE ;
79 device_set_desc(dev, "PCMCIA ATA controller");
81 return (ata_probe(dev));
85 * We add all the devices which we know about.
86 * The generic attach routine will attach them if they are alive.
89 xlr_pcmcia_attach(device_t dev)
91 struct ata_channel *ch = device_get_softc(dev);
94 struct resource *mem_res;
97 mem_res = bus_alloc_resource_any(dev, SYS_RES_MEMORY, &rid, RF_ACTIVE);
98 for (i = 0; i < ATA_MAX_RES; i++)
99 ch->r_io[i].res = mem_res;
104 ch->r_io[ATA_DATA].offset = XLR_PCMCIA_DATA_REG;
105 ch->r_io[ATA_FEATURE].offset = XLR_PCMCIA_ERROR_REG;
106 ch->r_io[ATA_COUNT].offset = XLR_PCMCIA_SECT_CNT_REG;
107 ch->r_io[ATA_SECTOR].offset = XLR_PCMCIA_SECT_NUM_REG;
108 ch->r_io[ATA_CYL_LSB].offset = XLR_PCMCIA_CYLINDER_LOW_REG;
109 ch->r_io[ATA_CYL_MSB].offset = XLR_PCMCIA_CYLINDER_HIGH_REG;
110 ch->r_io[ATA_DRIVE].offset = XLR_PCMCIA_SECT_DRIVE_HEAD_REG;
111 ch->r_io[ATA_COMMAND].offset = XLR_PCMCIA_CMD_STATUS_REG;
112 ch->r_io[ATA_ERROR].offset = XLR_PCMCIA_ERROR_REG;
113 ch->r_io[ATA_IREASON].offset = XLR_PCMCIA_SECT_CNT_REG;
114 ch->r_io[ATA_STATUS].offset = XLR_PCMCIA_CMD_STATUS_REG;
115 ch->r_io[ATA_ALTSTAT].offset = XLR_PCMCIA_ALT_STATUS_REG;
116 ch->r_io[ATA_CONTROL].offset = XLR_PCMCIA_CONTROL_REG;
118 /* Should point at the base of registers. */
119 ch->r_io[ATA_IDX_ADDR].offset = XLR_PCMCIA_DATA_REG;
123 return (ata_attach(dev));
127 xlr_pcmcia_detach(device_t dev)
129 bus_generic_detach(dev);
134 static device_method_t xlr_pcmcia_methods[] = {
135 /* device interface */
136 DEVMETHOD(device_probe, xlr_pcmcia_probe),
137 DEVMETHOD(device_attach, xlr_pcmcia_attach),
138 DEVMETHOD(device_detach, xlr_pcmcia_detach),
143 static driver_t xlr_pcmcia_driver = {
146 sizeof(struct ata_channel),
149 DRIVER_MODULE(ata, iodi, xlr_pcmcia_driver, ata_devclass, 0, 0);