diff options
author | andrew <andrew@FreeBSD.org> | 2015-09-01 15:26:21 +0000 |
---|---|---|
committer | andrew <andrew@FreeBSD.org> | 2015-09-01 15:26:21 +0000 |
commit | 00e3c0ad5cb6389cb6ca6d0baee9686b34c8ef4b (patch) | |
tree | ccb824093786637e1f6f838ebaace1431ddfe89a /sys/dev/mmc | |
parent | 7f517dc1f33a0e9ca23bb7df7ad79a8aa2a0ff81 (diff) | |
download | FreeBSD-src-00e3c0ad5cb6389cb6ca6d0baee9686b34c8ef4b.zip FreeBSD-src-00e3c0ad5cb6389cb6ca6d0baee9686b34c8ef4b.tar.gz |
Finish allowing the dwmmc driver to be subclassed, move the softc to a new
header, along with the hwtype enum, device attach prototype, and driver_t.
Sponsored by: ABT Systems Ltd
Diffstat (limited to 'sys/dev/mmc')
-rw-r--r-- | sys/dev/mmc/host/dwmmc.c | 55 | ||||
-rw-r--r-- | sys/dev/mmc/host/dwmmc_var.h | 81 |
2 files changed, 91 insertions, 45 deletions
diff --git a/sys/dev/mmc/host/dwmmc.c b/sys/dev/mmc/host/dwmmc.c index 262ee21..a80c8f6 100644 --- a/sys/dev/mmc/host/dwmmc.c +++ b/sys/dev/mmc/host/dwmmc.c @@ -60,6 +60,7 @@ __FBSDID("$FreeBSD$"); #include <machine/intr.h> #include <dev/mmc/host/dwmmc_reg.h> +#include <dev/mmc/host/dwmmc_var.h> #include "mmcbr_if.h" @@ -115,39 +116,6 @@ struct idmac_desc { #define DESC_SIZE (sizeof(struct idmac_desc) * DESC_MAX) #define DEF_MSIZE 0x2 /* Burst size of multiple transaction */ -struct dwmmc_softc { - struct resource *res[2]; - device_t dev; - void *intr_cookie; - struct mmc_host host; - struct mtx sc_mtx; - struct mmc_request *req; - struct mmc_command *curcmd; - uint32_t flags; - uint32_t hwtype; - uint32_t use_auto_stop; - uint32_t use_pio; - uint32_t pwren_inverted; - u_int desc_count; - - bus_dma_tag_t desc_tag; - bus_dmamap_t desc_map; - struct idmac_desc *desc_ring; - bus_addr_t desc_ring_paddr; - bus_dma_tag_t buf_tag; - bus_dmamap_t buf_map; - - uint32_t bus_busy; - uint32_t dto_rcvd; - uint32_t acd_rcvd; - uint32_t cmd_done; - uint32_t bus_hz; - uint32_t fifo_depth; - uint32_t num_slots; - uint32_t sdr_timing; - uint32_t ddr_timing; -}; - static void dwmmc_next_operation(struct dwmmc_softc *); static int dwmmc_setup_bus(struct dwmmc_softc *, int); static int dma_done(struct dwmmc_softc *, struct mmc_command *); @@ -161,13 +129,6 @@ static struct resource_spec dwmmc_spec[] = { { -1, 0 } }; -enum { - HWTYPE_NONE, - HWTYPE_ALTERA, - HWTYPE_EXYNOS, - HWTYPE_ROCKCHIP, -}; - #define HWTYPE_MASK (0x0000ffff) #define HWFLAG_MASK (0xffff << 16) @@ -534,7 +495,7 @@ dwmmc_probe(device_t dev) return (BUS_PROBE_DEFAULT); } -static int +int dwmmc_attach(device_t dev) { struct dwmmc_softc *sc; @@ -544,7 +505,10 @@ dwmmc_attach(device_t dev) sc = device_get_softc(dev); sc->dev = dev; - sc->hwtype = ofw_bus_search_compatible(dev, compat_data)->ocd_data; + if (sc->hwtype == HWTYPE_NONE) { + sc->hwtype = + ofw_bus_search_compatible(dev, compat_data)->ocd_data; + } /* Why not to use Auto Stop? It save a hundred of irq per second */ sc->use_auto_stop = 1; @@ -573,7 +537,8 @@ dwmmc_attach(device_t dev) device_printf(dev, "Hardware version ID is %04x\n", READ4(sc, SDMMC_VERID) & 0xffff); - sc->desc_count = DESC_MAX; + if (sc->desc_count == 0) + sc->desc_count = DESC_MAX; if ((sc->hwtype & HWTYPE_MASK) == HWTYPE_ROCKCHIP) { sc->use_pio = 1; @@ -648,7 +613,7 @@ dwmmc_attach(device_t dev) sc->host.host_ocr = MMC_OCR_320_330 | MMC_OCR_330_340; sc->host.caps = MMC_CAP_4_BIT_DATA; - device_add_child(dev, "mmc", 0); + device_add_child(dev, "mmc", -1); return (bus_generic_attach(dev)); } @@ -1202,7 +1167,7 @@ static device_method_t dwmmc_methods[] = { DEVMETHOD_END }; -static driver_t dwmmc_driver = { +driver_t dwmmc_driver = { "dwmmc", dwmmc_methods, sizeof(struct dwmmc_softc), diff --git a/sys/dev/mmc/host/dwmmc_var.h b/sys/dev/mmc/host/dwmmc_var.h new file mode 100644 index 0000000..034a07e --- /dev/null +++ b/sys/dev/mmc/host/dwmmc_var.h @@ -0,0 +1,81 @@ +/*- + * Copyright (c) 2014 Ruslan Bukin <br@bsdpad.com> + * All rights reserved. + * + * This software was developed by SRI International and the University of + * Cambridge Computer Laboratory under DARPA/AFRL contract (FA8750-10-C-0237) + * ("CTSRD"), as part of the DARPA CRASH research programme. + * + * 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. + * + * 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. + * + * $FreeBSD$ + */ + +#ifndef DEV_MMC_HOST_DWMMC_VAR_H +#define DEV_MMC_HOST_DWMMC_VAR_H + +enum { + HWTYPE_NONE, + HWTYPE_ALTERA, + HWTYPE_EXYNOS, + HWTYPE_HISILICON, + HWTYPE_ROCKCHIP, +}; + +struct dwmmc_softc { + struct resource *res[2]; + device_t dev; + void *intr_cookie; + struct mmc_host host; + struct mtx sc_mtx; + struct mmc_request *req; + struct mmc_command *curcmd; + uint32_t flags; + uint32_t hwtype; + uint32_t use_auto_stop; + uint32_t use_pio; + uint32_t pwren_inverted; + u_int desc_count; + + bus_dma_tag_t desc_tag; + bus_dmamap_t desc_map; + struct idmac_desc *desc_ring; + bus_addr_t desc_ring_paddr; + bus_dma_tag_t buf_tag; + bus_dmamap_t buf_map; + + uint32_t bus_busy; + uint32_t dto_rcvd; + uint32_t acd_rcvd; + uint32_t cmd_done; + uint32_t bus_hz; + uint32_t fifo_depth; + uint32_t num_slots; + uint32_t sdr_timing; + uint32_t ddr_timing; +}; + +extern driver_t dwmmc_driver; + +int dwmmc_attach(device_t); + +#endif |