From owner-svn-src-all@FreeBSD.ORG Sat Aug 28 07:58:11 2010 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 1C01410656A3; Sat, 28 Aug 2010 07:58:11 +0000 (UTC) (envelope-from jchandra@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 0A2F98FC0C; Sat, 28 Aug 2010 07:58:11 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id o7S7wAFk023320; Sat, 28 Aug 2010 07:58:10 GMT (envelope-from jchandra@svn.freebsd.org) Received: (from jchandra@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id o7S7wAXq023314; Sat, 28 Aug 2010 07:58:10 GMT (envelope-from jchandra@svn.freebsd.org) Message-Id: <201008280758.o7S7wAXq023314@svn.freebsd.org> From: "Jayachandran C." Date: Sat, 28 Aug 2010 07:58:10 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r211923 - head/sys/mips/rmi X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 28 Aug 2010 07:58:11 -0000 Author: jchandra Date: Sat Aug 28 07:58:10 2010 New Revision: 211923 URL: http://svn.freebsd.org/changeset/base/211923 Log: Initial code for XLR CompactFlash driver. Submitted by: Sreekanth M. S. Added: head/sys/mips/rmi/xlr_pcmcia.c (contents, props changed) Modified: head/sys/mips/rmi/board.c head/sys/mips/rmi/board.h head/sys/mips/rmi/files.xlr head/sys/mips/rmi/iodi.c Modified: head/sys/mips/rmi/board.c ============================================================================== --- head/sys/mips/rmi/board.c Sat Aug 28 07:24:45 2010 (r211922) +++ head/sys/mips/rmi/board.c Sat Aug 28 07:58:10 2010 (r211923) @@ -88,6 +88,16 @@ struct stn_cc *xls_core_cc_configs[] = { 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; Modified: head/sys/mips/rmi/board.h ============================================================================== --- head/sys/mips/rmi/board.h Sat Aug 28 07:24:45 2010 (r211922) +++ head/sys/mips/rmi/board.h Sat Aug 28 07:58:10 2010 (r211923) @@ -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 Modified: head/sys/mips/rmi/files.xlr ============================================================================== --- head/sys/mips/rmi/files.xlr Sat Aug 28 07:24:45 2010 (r211922) +++ head/sys/mips/rmi/files.xlr Sat Aug 28 07:58:10 2010 (r211923) @@ -14,6 +14,7 @@ mips/rmi/xlr_i2c.c option 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 Modified: head/sys/mips/rmi/iodi.c ============================================================================== --- head/sys/mips/rmi/iodi.c Sat Aug 28 07:24:45 2010 (r211922) +++ head/sys/mips/rmi/iodi.c Sat Aug 28 07:58:10 2010 (r211923) @@ -89,6 +89,20 @@ iodi_setup_intr(device_t, device_t, stru 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 c 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 } 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]); Added: head/sys/mips/rmi/xlr_pcmcia.c ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/sys/mips/rmi/xlr_pcmcia.c Sat Aug 28 07:58:10 2010 (r211923) @@ -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 +__FBSDID("$FreeBSD$"); + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include + +#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);