From owner-p4-projects@FreeBSD.ORG Fri Jun 2 07:15:18 2006 Return-Path: X-Original-To: p4-projects@freebsd.org Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id 99CAF16A939; Fri, 2 Jun 2006 07:15:18 +0000 (UTC) X-Original-To: perforce@freebsd.org Delivered-To: perforce@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 8E70A16A927 for ; Fri, 2 Jun 2006 07:15:17 +0000 (UTC) (envelope-from imp@freebsd.org) Received: from repoman.freebsd.org (repoman.freebsd.org [216.136.204.115]) by mx1.FreeBSD.org (Postfix) with ESMTP id 28D8243D46 for ; Fri, 2 Jun 2006 07:15:17 +0000 (GMT) (envelope-from imp@freebsd.org) Received: from repoman.freebsd.org (localhost [127.0.0.1]) by repoman.freebsd.org (8.13.6/8.13.6) with ESMTP id k527DlEf047817 for ; Fri, 2 Jun 2006 07:13:47 GMT (envelope-from imp@freebsd.org) Received: (from perforce@localhost) by repoman.freebsd.org (8.13.6/8.13.4/Submit) id k527DlVK047814 for perforce@freebsd.org; Fri, 2 Jun 2006 07:13:47 GMT (envelope-from imp@freebsd.org) Date: Fri, 2 Jun 2006 07:13:47 GMT Message-Id: <200606020713.k527DlVK047814@repoman.freebsd.org> X-Authentication-Warning: repoman.freebsd.org: perforce set sender to imp@freebsd.org using -f From: Warner Losh To: Perforce Change Reviews Cc: Subject: PERFORCE change 98318 for review X-BeenThere: p4-projects@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: p4 projects tree changes List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 02 Jun 2006 07:15:20 -0000 http://perforce.freebsd.org/chv.cgi?CH=98318 Change 98318 by imp@imp_lighthouse on 2006/06/02 07:12:50 Move the MI parts of the driver into sdhc. Implement the resource stuff. Interrupt stuff needs doing still, as well as all of the functionality of the driver now that the glue is in place. Affected files ... .. //depot/projects/arm/src/sys/dev/sdhc/sdhc.c#2 edit .. //depot/projects/arm/src/sys/dev/sdhc/sdhc_pci.c#6 edit .. //depot/projects/arm/src/sys/dev/sdhc/sdhcvar.h#2 edit Differences ... ==== //depot/projects/arm/src/sys/dev/sdhc/sdhc.c#2 (text+ko) ==== @@ -51,6 +51,67 @@ devclass_t sdhc_devclass; int +sdhc_read_ivar(device_t dev, device_t child, int which, uintptr_t *result) +{ + struct sdhc_ivars *ivars = device_get_softc(dev); + + switch (which) { + case SDHC_IVAR_RESOURCE: + *(struct resource **)result = ivars->res; + return (0); + } + + return (ENOENT); +} + +int +sdhc_write_ivar(device_t dev, device_t child, int which, uintptr_t value) +{ + struct sdhc_ivars *ivars = device_get_softc(dev); + + switch (which) { + case SDHC_IVAR_RESOURCE: + ivars->res = *(struct resource **)value; + return (0); + } + + return (ENOENT); +} + +struct resource * +sdhc_alloc_resource(device_t dev, device_t child, int type, int *rid, + u_long start, u_long end, u_long count, u_int flags) +{ + struct resource *r; + + if (*rid != 0 || type != SYS_RES_MEMORY || + device_get_parent(child) != dev) + return (NULL); + r = sdhc_get_resource(child); + rman_set_device(r, child); + + return (r); +} + +int +sdhc_release_resource(device_t dev, device_t child, int type, int rid, + struct resource *r) +{ + if (rid != 0 || type != SYS_RES_MEMORY || + device_get_parent(child) != dev || rman_get_device(r) != dev) + return (EINVAL); + rman_set_device(r, dev); + + return (0); +} + +void +sdhc_child_detached(device_t dev, device_t child) +{ + // XXX +} + +int sdhc_attach(device_t dev) { return (0); ==== //depot/projects/arm/src/sys/dev/sdhc/sdhc_pci.c#6 (text+ko) ==== @@ -86,59 +86,10 @@ ivars->res = res; device_set_ivars(child, ivars); } + return (sdhc_attach(dev)); } -static int -sdhc_read_ivar(device_t brdev, device_t child, int which, uintptr_t *result) -{ - return (ENOENT); -} - -static int -sdhc_write_ivar(device_t brdev, device_t child, int which, uintptr_t value) -{ - return (ENOENT); -} - -static struct resource * -sdhc_alloc_resource(device_t brdev, device_t child, int type, int *rid, - u_long start, u_long end, u_long count, u_int flags) -{ - return (0); -} - -static int -sdhc_release_resource(device_t brdev, device_t child, int type, int rid, - struct resource *r) -{ - return (EIO); -} - -static int -sdhc_activate_resource(device_t dev, device_t child, int type, int rid, - struct resource *r) -{ - if (rid != 0 || type != SYS_RES_MEMORY || - device_get_parent(child) != dev || rman_get_device(r) != dev) - return (EINVAL); - rman_set_device(r, child); - return (0); -} - -static int -sdhc_deactivate_resource(device_t dev, device_t child, int type, - int rid, struct resource *r) -{ - rman_set_device(r, dev); - return (0); -} - -static void -sdhc_child_detached(device_t dev, device_t child) -{ -} - static device_method_t sdhc_pci_methods[] = { /* Device interface */ DEVMETHOD(device_probe, sdhc_pci_probe), @@ -146,17 +97,11 @@ DEVMETHOD(device_detach, sdhc_detach), /* bus methods */ - DEVMETHOD(bus_print_child, bus_generic_print_child), DEVMETHOD(bus_read_ivar, sdhc_read_ivar), DEVMETHOD(bus_write_ivar, sdhc_write_ivar), DEVMETHOD(bus_alloc_resource, sdhc_alloc_resource), DEVMETHOD(bus_release_resource, sdhc_release_resource), - DEVMETHOD(bus_activate_resource, sdhc_activate_resource), - DEVMETHOD(bus_deactivate_resource, sdhc_deactivate_resource), - DEVMETHOD(bus_driver_added, bus_generic_driver_added), DEVMETHOD(bus_child_detached, sdhc_child_detached), -// DEVMETHOD(bus_setup_intr, sdhc_setup_intr), -// DEVMETHOD(bus_teardown_intr, sdhc_teardown_intr), { 0, 0 } }; @@ -168,5 +113,6 @@ }; DRIVER_MODULE(sdhc, pci, sdhc_pci_driver, sdhc_devclass, 0, 0); +DRIVER_MODULE(sdhc, cardbus, sdhc_pci_driver, sdhc_devclass, 0, 0); MODULE_DEPEND(sdhc, pci, 1, 1, 1); MODULE_DEPEND(sdhc, cardbus, 1, 1, 1); ==== //depot/projects/arm/src/sys/dev/sdhc/sdhcvar.h#2 (text+ko) ==== @@ -40,6 +40,29 @@ int sdhc_attach(device_t dev); int sdhc_detach(device_t dev); +int sdhc_read_ivar(device_t dev, device_t child, int which, uintptr_t *result); +int sdhc_write_ivar(device_t dev, device_t child, int which, uintptr_t value); +struct resource * +sdhc_alloc_resource(device_t dev, device_t child, int type, int *rid, + u_long start, u_long end, u_long count, u_int flags); +int sdhc_release_resource(device_t dev, device_t child, int type, int rid, + struct resource *r); +void sdhc_child_detached(device_t dev, device_t child); + extern devclass_t sdhc_devclass; +enum sdhc_device_ivars { + SDHC_IVAR_RESOURCE +}; + +/* + * Simplified accessors for pci devices + */ +#define SDHC_ACCESSOR(var, ivar, type) \ + __BUS_ACCESSOR(sdhc, var, SDHC, ivar, type) + +SDHC_ACCESSOR(resource, RESOURCE, struct resource *) + +#undef SDHC_ACCESSOR + #endif /* ! DEV_SDHC_SDHCVAR_H */