Initial code for XLR CompactFlash driver.
Submitted by: Sreekanth M. S. <kanthms at netlogicmicro com>
This commit is contained in:
parent
0c82a20a06
commit
145f151a79
@ -88,6 +88,16 @@ struct stn_cc *xls_core_cc_configs[] = {&xls_cc_table_cpu_0, &xls_cc_table_cpu_1
|
||||
|
||||
struct xlr_board_info xlr_board_info;
|
||||
|
||||
static int
|
||||
xlr_pcmcia_present(void)
|
||||
{
|
||||
xlr_reg_t *mmio = xlr_io_mmio(XLR_IO_GPIO_OFFSET);
|
||||
uint32_t resetconf;
|
||||
|
||||
resetconf = xlr_read_reg(mmio, 21);
|
||||
return ((resetconf & 0x4000) != 0);
|
||||
}
|
||||
|
||||
/*
|
||||
* All our knowledge of chip and board that cannot be detected by probing
|
||||
* at run-time goes here
|
||||
@ -103,6 +113,7 @@ xlr_board_info_setup()
|
||||
/* Board version 8 has NAND flash */
|
||||
xlr_board_info.cfi =
|
||||
(xlr_boot1_info.board_major_version != RMI_XLR_BOARD_ARIZONA_VIII);
|
||||
xlr_board_info.ata = xlr_pcmcia_present();
|
||||
xlr_board_info.pci_irq = 0;
|
||||
xlr_board_info.credit_configs = xls_core_cc_configs;
|
||||
xlr_board_info.bucket_sizes = &xls_bucket_sizes;
|
||||
@ -155,6 +166,7 @@ xlr_board_info_setup()
|
||||
xlr_board_info.nr_cpus = 32;
|
||||
xlr_board_info.usb = 0;
|
||||
xlr_board_info.cfi = 1;
|
||||
xlr_board_info.ata = xlr_pcmcia_present();
|
||||
xlr_board_info.pci_irq = 0;
|
||||
xlr_board_info.credit_configs = xlr_core_cc_configs;
|
||||
xlr_board_info.bucket_sizes = &bucket_sizes;
|
||||
|
@ -147,7 +147,8 @@ struct xlr_board_info {
|
||||
int is_xls;
|
||||
int nr_cpus;
|
||||
int usb; /* usb enabled ? */
|
||||
int cfi; /* compact flash driver for NOR? */
|
||||
int cfi; /* NOR flash */
|
||||
int ata; /* PCMCIA/compactflash driver */
|
||||
int pci_irq;
|
||||
struct stn_cc **credit_configs; /* pointer to Core station credits */
|
||||
struct bucket_size *bucket_sizes; /* pointer to Core station
|
||||
|
@ -14,6 +14,7 @@ mips/rmi/xlr_i2c.c optional iic
|
||||
mips/rmi/uart_bus_xlr_iodi.c optional uart
|
||||
mips/rmi/uart_cpu_mips_xlr.c optional uart
|
||||
mips/rmi/xlr_pci.c optional pci
|
||||
mips/rmi/xlr_pcmcia.c optional ata
|
||||
mips/rmi/xls_ehci.c optional usb ehci
|
||||
mips/rmi/bus_space_rmi.c standard
|
||||
mips/rmi/bus_space_rmi_pci.c standard
|
||||
|
@ -89,6 +89,20 @@ iodi_setup_intr(device_t, device_t, struct resource *, int,
|
||||
|
||||
struct iodi_softc *iodi_softc; /* There can be only one. */
|
||||
|
||||
/*
|
||||
* We will manage the Flash/PCMCIA devices in IODI for now.
|
||||
* The NOR flash, Compact flash etc. which can be connected on
|
||||
* various chip selects on the peripheral IO, should have a
|
||||
* separate bus later.
|
||||
*/
|
||||
static void
|
||||
bridge_pcmcia_ack(int irq)
|
||||
{
|
||||
xlr_reg_t *mmio = xlr_io_mmio(XLR_IO_FLASH_OFFSET);
|
||||
|
||||
xlr_write_reg(mmio, 0x60, 0xffffffff);
|
||||
}
|
||||
|
||||
static int
|
||||
iodi_setup_intr(device_t dev, device_t child,
|
||||
struct resource *ires, int flags, driver_filter_t * filt,
|
||||
@ -112,6 +126,10 @@ iodi_setup_intr(device_t dev, device_t child,
|
||||
cpu_establish_hardintr("ehci", filt, intr, arg, PIC_USB_IRQ, flags,
|
||||
cookiep);
|
||||
pic_setup_intr(PIC_USB_IRQ - PIC_IRQ_BASE, PIC_USB_IRQ, 0x1, 0);
|
||||
} else if (strcmp(device_get_name(child), "ata") == 0) {
|
||||
xlr_establish_intr("ata", filt, intr, arg, PIC_PCMCIA_IRQ, flags,
|
||||
cookiep, bridge_pcmcia_ack);
|
||||
pic_setup_intr(PIC_PCMCIA_IRQ - PIC_IRQ_BASE, PIC_PCMCIA_IRQ, 0x1, 0);
|
||||
}
|
||||
|
||||
return (0);
|
||||
@ -158,6 +176,9 @@ iodi_alloc_resource(device_t bus, device_t child, int type, int *rid,
|
||||
} else if (strcmp(device_get_name(child), "cfi") == 0) {
|
||||
res->r_bushandle = MIPS_PHYS_TO_KSEG1(0x1c000000);
|
||||
res->r_bustag = 0;
|
||||
} else if (strcmp(device_get_name(child), "ata") == 0) {
|
||||
res->r_bushandle = MIPS_PHYS_TO_KSEG1(0x1d000000);
|
||||
res->r_bustag = rmi_pci_bus_space; /* byte swapping (not really PCI) */
|
||||
}
|
||||
/* res->r_start = *rid; */
|
||||
return (res);
|
||||
@ -206,6 +227,9 @@ iodi_attach(device_t dev)
|
||||
if (xlr_board_info.cfi)
|
||||
device_add_child(dev, "cfi", 0);
|
||||
|
||||
if (xlr_board_info.ata)
|
||||
device_add_child(dev, "ata", 0);
|
||||
|
||||
if (xlr_board_info.gmac_block[0].enabled) {
|
||||
tmpd = device_add_child(dev, "rge", 0);
|
||||
device_set_ivars(tmpd, &xlr_board_info.gmac_block[0]);
|
||||
|
149
sys/mips/rmi/xlr_pcmcia.c
Normal file
149
sys/mips/rmi/xlr_pcmcia.c
Normal file
@ -0,0 +1,149 @@
|
||||
/*-
|
||||
* Copyright (c) 2003-2009 RMI Corporation
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. Neither the name of RMI Corporation, nor the names of its contributors,
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* RMI_BSD */
|
||||
/*
|
||||
* ATA driver for the XLR_PCMCIA Host adapter on the RMI XLR/XLS/.
|
||||
*/
|
||||
#include <sys/cdefs.h>
|
||||
__FBSDID("$FreeBSD$");
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <sys/systm.h>
|
||||
#include <sys/kernel.h>
|
||||
#include <sys/module.h>
|
||||
#include <sys/bus.h>
|
||||
#include <sys/rman.h>
|
||||
#include <vm/uma.h>
|
||||
#include <sys/ata.h>
|
||||
#include <sys/sema.h>
|
||||
#include <sys/taskqueue.h>
|
||||
#include <sys/bus_dma.h>
|
||||
|
||||
#include <dev/ata/ata-all.h>
|
||||
#include <mips/rmi/pic.h>
|
||||
#include <mips/rmi/iomap.h>
|
||||
#include <mips/include/resource.h>
|
||||
#include <mips/rmi/interrupt.h>
|
||||
|
||||
#define XLR_PCMCIA_DATA_REG 0x1f0
|
||||
#define XLR_PCMCIA_ERROR_REG 0x1f1
|
||||
#define XLR_PCMCIA_SECT_CNT_REG 0x1f2
|
||||
#define XLR_PCMCIA_SECT_NUM_REG 0x1f3
|
||||
#define XLR_PCMCIA_CYLINDER_LOW_REG 0x1f4
|
||||
#define XLR_PCMCIA_CYLINDER_HIGH_REG 0x1f5
|
||||
#define XLR_PCMCIA_SECT_DRIVE_HEAD_REG 0x1f6
|
||||
#define XLR_PCMCIA_CMD_STATUS_REG 0x1f7
|
||||
#define XLR_PCMCIA_ALT_STATUS_REG 0x3f6
|
||||
#define XLR_PCMCIA_CONTROL_REG 0x3f6
|
||||
|
||||
/*
|
||||
* Device methods
|
||||
*/
|
||||
static int xlr_pcmcia_probe(device_t);
|
||||
static int xlr_pcmcia_attach(device_t);
|
||||
static int xlr_pcmcia_detach(device_t);
|
||||
|
||||
static int
|
||||
xlr_pcmcia_probe(device_t dev)
|
||||
{
|
||||
struct ata_channel *ch = device_get_softc(dev);
|
||||
|
||||
ch->unit = 0;
|
||||
ch->flags |= ATA_USE_16BIT | ATA_NO_SLAVE ;
|
||||
device_set_desc(dev, "PCMCIA ATA controller");
|
||||
|
||||
return (ata_probe(dev));
|
||||
}
|
||||
|
||||
/*
|
||||
* We add all the devices which we know about.
|
||||
* The generic attach routine will attach them if they are alive.
|
||||
*/
|
||||
static int
|
||||
xlr_pcmcia_attach(device_t dev)
|
||||
{
|
||||
struct ata_channel *ch = device_get_softc(dev);
|
||||
int i;
|
||||
int rid =0;
|
||||
struct resource *mem_res;
|
||||
|
||||
|
||||
mem_res = bus_alloc_resource_any(dev, SYS_RES_MEMORY, &rid, RF_ACTIVE);
|
||||
for (i = 0; i < ATA_MAX_RES; i++)
|
||||
ch->r_io[i].res = mem_res;
|
||||
|
||||
/*
|
||||
* CF+ Specification.
|
||||
*/
|
||||
ch->r_io[ATA_DATA].offset = XLR_PCMCIA_DATA_REG;
|
||||
ch->r_io[ATA_FEATURE].offset = XLR_PCMCIA_ERROR_REG;
|
||||
ch->r_io[ATA_COUNT].offset = XLR_PCMCIA_SECT_CNT_REG;
|
||||
ch->r_io[ATA_SECTOR].offset = XLR_PCMCIA_SECT_NUM_REG;
|
||||
ch->r_io[ATA_CYL_LSB].offset = XLR_PCMCIA_CYLINDER_LOW_REG;
|
||||
ch->r_io[ATA_CYL_MSB].offset = XLR_PCMCIA_CYLINDER_HIGH_REG;
|
||||
ch->r_io[ATA_DRIVE].offset = XLR_PCMCIA_SECT_DRIVE_HEAD_REG;
|
||||
ch->r_io[ATA_COMMAND].offset = XLR_PCMCIA_CMD_STATUS_REG;
|
||||
ch->r_io[ATA_ERROR].offset = XLR_PCMCIA_ERROR_REG;
|
||||
ch->r_io[ATA_IREASON].offset = XLR_PCMCIA_SECT_CNT_REG;
|
||||
ch->r_io[ATA_STATUS].offset = XLR_PCMCIA_CMD_STATUS_REG;
|
||||
ch->r_io[ATA_ALTSTAT].offset = XLR_PCMCIA_ALT_STATUS_REG;
|
||||
ch->r_io[ATA_CONTROL].offset = XLR_PCMCIA_CONTROL_REG;
|
||||
|
||||
/* Should point at the base of registers. */
|
||||
ch->r_io[ATA_IDX_ADDR].offset = XLR_PCMCIA_DATA_REG;
|
||||
|
||||
ata_generic_hw(dev);
|
||||
|
||||
return (ata_attach(dev));
|
||||
}
|
||||
|
||||
static int
|
||||
xlr_pcmcia_detach(device_t dev)
|
||||
{
|
||||
bus_generic_detach(dev);
|
||||
|
||||
return (0);
|
||||
}
|
||||
|
||||
static device_method_t xlr_pcmcia_methods[] = {
|
||||
/* device interface */
|
||||
DEVMETHOD(device_probe, xlr_pcmcia_probe),
|
||||
DEVMETHOD(device_attach, xlr_pcmcia_attach),
|
||||
DEVMETHOD(device_detach, xlr_pcmcia_detach),
|
||||
|
||||
{ 0, 0 }
|
||||
};
|
||||
|
||||
static driver_t xlr_pcmcia_driver = {
|
||||
"ata",
|
||||
xlr_pcmcia_methods,
|
||||
sizeof(struct ata_channel),
|
||||
};
|
||||
|
||||
DRIVER_MODULE(ata, iodi, xlr_pcmcia_driver, ata_devclass, 0, 0);
|
Loading…
Reference in New Issue
Block a user