From owner-svn-src-all@FreeBSD.ORG Sun Aug 31 17:56:56 2014 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 22B059DC; Sun, 31 Aug 2014 17:56:56 +0000 (UTC) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 026C91447; Sun, 31 Aug 2014 17:56:56 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.9/8.14.9) with ESMTP id s7VHutab075171; Sun, 31 Aug 2014 17:56:55 GMT (envelope-from marius@FreeBSD.org) Received: (from marius@localhost) by svn.freebsd.org (8.14.9/8.14.9/Submit) id s7VHutRE075166; Sun, 31 Aug 2014 17:56:55 GMT (envelope-from marius@FreeBSD.org) Message-Id: <201408311756.s7VHutRE075166@svn.freebsd.org> X-Authentication-Warning: svn.freebsd.org: marius set sender to marius@FreeBSD.org using -f From: Marius Strobl Date: Sun, 31 Aug 2014 17:56:54 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r270885 - head/sys/dev/sdhci X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.18-1 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: Sun, 31 Aug 2014 17:56:56 -0000 Author: marius Date: Sun Aug 31 17:56:54 2014 New Revision: 270885 URL: http://svnweb.freebsd.org/changeset/base/270885 Log: - Nuke unused sdhci_softc. - Static'ize sdhci_debug local to sdhci.c. - Const'ify PCI device description strings. - Nuke redundant resource ID members from sdhci_pci_softc. - Nuke unused hw.sdhci_pci.debug tunable. - Add support for using MSI instead of INTx, controllable via the tunable hw.sdhci.enable_msi (defaulting to on) and tested with a RICOH R5CE823 SD controller. - Use NULL instead of 0 for pointers. MFC after: 3 days Modified: head/sys/dev/sdhci/sdhci.c head/sys/dev/sdhci/sdhci.h head/sys/dev/sdhci/sdhci_fdt.c head/sys/dev/sdhci/sdhci_if.m head/sys/dev/sdhci/sdhci_pci.c Modified: head/sys/dev/sdhci/sdhci.c ============================================================================== --- head/sys/dev/sdhci/sdhci.c Sun Aug 31 17:40:19 2014 (r270884) +++ head/sys/dev/sdhci/sdhci.c Sun Aug 31 17:56:54 2014 (r270885) @@ -52,21 +52,9 @@ __FBSDID("$FreeBSD$"); #include "sdhci.h" #include "sdhci_if.h" -struct sdhci_softc; +SYSCTL_NODE(_hw, OID_AUTO, sdhci, CTLFLAG_RD, 0, "sdhci driver"); -struct sdhci_softc { - device_t dev; /* Controller device */ - struct resource *irq_res; /* IRQ resource */ - int irq_rid; - void *intrhand; /* Interrupt handle */ - - int num_slots; /* Number of slots on this controller */ - struct sdhci_slot slots[6]; -}; - -static SYSCTL_NODE(_hw, OID_AUTO, sdhci, CTLFLAG_RD, 0, "sdhci driver"); - -int sdhci_debug = 0; +static int sdhci_debug; SYSCTL_INT(_hw_sdhci, OID_AUTO, debug, CTLFLAG_RWTUN, &sdhci_debug, 0, "Debug level"); #define RD1(slot, off) SDHCI_READ_1((slot)->bus, (slot), (off)) Modified: head/sys/dev/sdhci/sdhci.h ============================================================================== --- head/sys/dev/sdhci/sdhci.h Sun Aug 31 17:40:19 2014 (r270884) +++ head/sys/dev/sdhci/sdhci.h Sun Aug 31 17:56:54 2014 (r270885) @@ -223,6 +223,8 @@ #define SDHCI_SPEC_200 1 #define SDHCI_SPEC_300 2 +SYSCTL_DECL(_hw_sdhci); + struct sdhci_slot { u_int quirks; /* Chip specific quirks */ u_int caps; /* Override SDHCI_CAPABILITIES */ Modified: head/sys/dev/sdhci/sdhci_fdt.c ============================================================================== --- head/sys/dev/sdhci/sdhci_fdt.c Sun Aug 31 17:40:19 2014 (r270884) +++ head/sys/dev/sdhci/sdhci_fdt.c Sun Aug 31 17:56:54 2014 (r270885) @@ -180,7 +180,6 @@ sdhci_fdt_probe(device_t dev) if ((OF_getencprop(node, "max-frequency", &cid, sizeof(cid))) > 0) sc->max_clk = cid; - return (0); } @@ -189,7 +188,7 @@ sdhci_fdt_attach(device_t dev) { struct sdhci_fdt_softc *sc = device_get_softc(dev); int err, slots, rid, i; - + sc->dev = dev; /* Allocate IRQ. */ @@ -241,7 +240,7 @@ sdhci_fdt_attach(device_t dev) struct sdhci_slot *slot = &sc->slots[i]; sdhci_start_slot(slot); } - + return (0); } @@ -305,5 +304,6 @@ static driver_t sdhci_fdt_driver = { }; static devclass_t sdhci_fdt_devclass; -DRIVER_MODULE(sdhci_fdt, simplebus, sdhci_fdt_driver, sdhci_fdt_devclass, 0,0); +DRIVER_MODULE(sdhci_fdt, simplebus, sdhci_fdt_driver, sdhci_fdt_devclass, + NULL, NULL); MODULE_DEPEND(sdhci_fdt, sdhci, 1, 1, 1); Modified: head/sys/dev/sdhci/sdhci_if.m ============================================================================== --- head/sys/dev/sdhci/sdhci_if.m Sun Aug 31 17:40:19 2014 (r270884) +++ head/sys/dev/sdhci/sdhci_if.m Sun Aug 31 17:56:54 2014 (r270885) @@ -62,6 +62,7 @@ #include #include #include +#include #include #include Modified: head/sys/dev/sdhci/sdhci_pci.c ============================================================================== --- head/sys/dev/sdhci/sdhci_pci.c Sun Aug 31 17:40:19 2014 (r270884) +++ head/sys/dev/sdhci/sdhci_pci.c Sun Aug 31 17:56:54 2014 (r270885) @@ -78,7 +78,7 @@ __FBSDID("$FreeBSD$"); static const struct sdhci_device { uint32_t model; uint16_t subvendor; - char *desc; + const char *desc; u_int quirks; } sdhci_devices[] = { { 0x08221180, 0xffff, "RICOH R5C822 SD", @@ -112,19 +112,16 @@ struct sdhci_pci_softc { device_t dev; /* Controller device */ u_int quirks; /* Chip specific quirks */ struct resource *irq_res; /* IRQ resource */ - int irq_rid; void *intrhand; /* Interrupt handle */ int num_slots; /* Number of slots on this controller */ struct sdhci_slot slots[6]; struct resource *mem_res[6]; /* Memory resource */ - int mem_rid[6]; }; -static SYSCTL_NODE(_hw, OID_AUTO, sdhci_pci, CTLFLAG_RD, 0, "sdhci PCI driver"); - -int sdhci_pci_debug; -SYSCTL_INT(_hw_sdhci_pci, OID_AUTO, debug, CTLFLAG_RWTUN, &sdhci_pci_debug, 0, "Debug level"); +static int sdhci_enable_msi = 1; +SYSCTL_INT(_hw_sdhci, OID_AUTO, enable_msi, CTLFLAG_RDTUN, &sdhci_enable_msi, + 0, "Enable MSI interrupts"); static uint8_t sdhci_pci_read_1(device_t dev, struct sdhci_slot *slot, bus_size_t off) @@ -231,13 +228,13 @@ sdhci_pci_probe(device_t dev) uint16_t subvendor; uint8_t class, subclass; int i, result; - + model = (uint32_t)pci_get_device(dev) << 16; model |= (uint32_t)pci_get_vendor(dev) & 0x0000ffff; subvendor = pci_get_subvendor(dev); class = pci_get_class(dev); subclass = pci_get_subclass(dev); - + result = ENXIO; for (i = 0; sdhci_devices[i].model != 0; i++) { if (sdhci_devices[i].model == model && @@ -253,7 +250,7 @@ sdhci_pci_probe(device_t dev) device_set_desc(dev, "Generic SD HCI"); result = BUS_PROBE_GENERIC; } - + return (result); } @@ -264,7 +261,7 @@ sdhci_pci_attach(device_t dev) uint32_t model; uint16_t subvendor; uint8_t class, subclass, progif; - int err, slots, bar, i; + int bar, err, rid, slots, i; sc->dev = dev; model = (uint32_t)pci_get_device(dev) << 16; @@ -295,11 +292,15 @@ sdhci_pci_attach(device_t dev) return (EINVAL); } /* Allocate IRQ. */ - sc->irq_rid = 0; - sc->irq_res = bus_alloc_resource_any(dev, SYS_RES_IRQ, &sc->irq_rid, - RF_SHAREABLE | RF_ACTIVE); + i = 1; + rid = 0; + if (sdhci_enable_msi != 0 && pci_alloc_msi(dev, &i) == 0) + rid = 1; + sc->irq_res = bus_alloc_resource_any(dev, SYS_RES_IRQ, &rid, + RF_ACTIVE | (rid != 0 ? 0 : RF_SHAREABLE)); if (sc->irq_res == NULL) { device_printf(dev, "Can't allocate IRQ\n"); + pci_release_msi(dev); return (ENOMEM); } /* Scan all slots. */ @@ -307,9 +308,9 @@ sdhci_pci_attach(device_t dev) struct sdhci_slot *slot = &sc->slots[sc->num_slots]; /* Allocate memory. */ - sc->mem_rid[i] = PCIR_BAR(bar + i); - sc->mem_res[i] = bus_alloc_resource(dev, - SYS_RES_MEMORY, &(sc->mem_rid[i]), 0ul, ~0ul, 0x100, RF_ACTIVE); + rid = PCIR_BAR(bar + i); + sc->mem_res[i] = bus_alloc_resource(dev, SYS_RES_MEMORY, + &rid, 0ul, ~0ul, 0x100, RF_ACTIVE); if (sc->mem_res[i] == NULL) { device_printf(dev, "Can't allocate memory for slot %d\n", i); continue; @@ -318,7 +319,6 @@ sdhci_pci_attach(device_t dev) if (sdhci_init_slot(dev, slot, i) != 0) continue; - sc->num_slots++; } device_printf(dev, "%d slot(s) allocated\n", sc->num_slots); @@ -334,7 +334,7 @@ sdhci_pci_attach(device_t dev) sdhci_start_slot(slot); } - + return (0); } @@ -346,14 +346,15 @@ sdhci_pci_detach(device_t dev) bus_teardown_intr(dev, sc->irq_res, sc->intrhand); bus_release_resource(dev, SYS_RES_IRQ, - sc->irq_rid, sc->irq_res); + rman_get_rid(sc->irq_res), sc->irq_res); + pci_release_msi(dev); for (i = 0; i < sc->num_slots; i++) { struct sdhci_slot *slot = &sc->slots[i]; sdhci_cleanup_slot(slot); bus_release_resource(dev, SYS_RES_MEMORY, - sc->mem_rid[i], sc->mem_res[i]); + rman_get_rid(sc->mem_res[i]), sc->mem_res[i]); } return (0); } @@ -368,7 +369,7 @@ sdhci_pci_suspend(device_t dev) if (err) return (err); for (i = 0; i < sc->num_slots; i++) - sdhci_generic_suspend(&sc->slots[i]); + sdhci_generic_suspend(&sc->slots[i]); return (0); } @@ -383,7 +384,6 @@ sdhci_pci_resume(device_t dev) return (bus_generic_resume(dev)); } - static void sdhci_pci_intr(void *arg) { @@ -435,5 +435,6 @@ static driver_t sdhci_pci_driver = { }; static devclass_t sdhci_pci_devclass; -DRIVER_MODULE(sdhci_pci, pci, sdhci_pci_driver, sdhci_pci_devclass, 0, 0); +DRIVER_MODULE(sdhci_pci, pci, sdhci_pci_driver, sdhci_pci_devclass, NULL, + NULL); MODULE_DEPEND(sdhci_pci, sdhci, 1, 1, 1);