From owner-p4-projects@FreeBSD.ORG Sat Nov 3 20:08:00 2007 Return-Path: Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id 692AD16A46B; Sat, 3 Nov 2007 20:08:00 +0000 (UTC) Delivered-To: perforce@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 251AC16A419 for ; Sat, 3 Nov 2007 20:08:00 +0000 (UTC) (envelope-from andrew@freebsd.org) Received: from repoman.freebsd.org (repoman.freebsd.org [IPv6:2001:4f8:fff6::29]) by mx1.freebsd.org (Postfix) with ESMTP id 1401213C4BC for ; Sat, 3 Nov 2007 20:08:00 +0000 (UTC) (envelope-from andrew@freebsd.org) Received: from repoman.freebsd.org (localhost [127.0.0.1]) by repoman.freebsd.org (8.14.1/8.14.1) with ESMTP id lA3K7x8m072998 for ; Sat, 3 Nov 2007 20:07:59 GMT (envelope-from andrew@freebsd.org) Received: (from perforce@localhost) by repoman.freebsd.org (8.14.1/8.14.1/Submit) id lA3K7xYn072995 for perforce@freebsd.org; Sat, 3 Nov 2007 20:07:59 GMT (envelope-from andrew@freebsd.org) Date: Sat, 3 Nov 2007 20:07:59 GMT Message-Id: <200711032007.lA3K7xYn072995@repoman.freebsd.org> X-Authentication-Warning: repoman.freebsd.org: perforce set sender to andrew@freebsd.org using -f From: Andrew Turner To: Perforce Change Reviews Cc: Subject: PERFORCE change 128579 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: Sat, 03 Nov 2007 20:08:00 -0000 http://perforce.freebsd.org/chv.cgi?CH=128579 Change 128579 by andrew@andrew_hermies on 2007/11/03 20:07:24 Implement the bus_setup_intr and bus_alloc_resource functions Add the timer to the children to probe for in the s3c2410 bus driver Probe and attach the children of the s3c2410 bus Fix the s3c24x0_timer driver to use the updated bus_setup_intr Affected files ... .. //depot/projects/arm/src/sys/arm/s3c2xx0/s3c2410.c#6 edit .. //depot/projects/arm/src/sys/arm/s3c2xx0/s3c24x0_clk.c#3 edit .. //depot/projects/arm/src/sys/arm/s3c2xx0/s3c2xx0var.h#3 edit Differences ... ==== //depot/projects/arm/src/sys/arm/s3c2xx0/s3c2410.c#6 (text+ko) ==== @@ -55,7 +55,7 @@ /* prototypes */ static int s3c2410_probe(device_t); -static void s3c2410_attach(device_t); +static int s3c2410_attach(device_t); static void s3c2410_identify(driver_t *, device_t); static struct resource *s3c2410_alloc_resource(device_t, device_t, int, int *, @@ -64,7 +64,7 @@ static int s3c2410_activate_resource(device_t, device_t, int, int, struct resource *); static int s3c2410_setup_intr(device_t, device_t, struct resource *, int, - driver_intr_t *, void *, void **); + driver_filter_t *, driver_intr_t *, void *, void **); static device_method_t s3c2410_methods[] = { DEVMETHOD(device_probe, s3c2410_probe), @@ -85,11 +85,28 @@ DRIVER_MODULE(s3c2410, nexus, s3c2410_driver, s3c2410_devclass, 0, 0); +struct s3c2xx0_softc *s3c2xx0_softc = NULL; + static int s3c2410_setup_intr(device_t dev, device_t child, - struct resource *ires, int flags, driver_intr_t *intr, void *arg, - void **cookiep) + struct resource *ires, int flags, driver_filter_t *filt, + driver_intr_t *intr, void *arg, void **cookiep) { + int saved_cpsr; + + if (flags & INTR_TYPE_TTY) + rman_set_start(ires, 15); + else if (flags & INTR_TYPE_CLK) { + if (rman_get_start(ires) == 0) + rman_set_start(ires, 26); + else + rman_set_start(ires, 27); + } + saved_cpsr = SetCPSR(I32_bit, I32_bit); + + SetCPSR(I32_bit, saved_cpsr & I32_bit); + BUS_SETUP_INTR(device_get_parent(dev), child, ires, flags, filt, + intr, arg, cookiep); return (0); } @@ -97,7 +114,14 @@ s3c2410_alloc_resource(device_t bus, device_t child, int type, int *rid, u_long start, u_long end, u_long count, u_int flags) { - return (NULL); + struct resource *res; + + res = rman_reserve_resource(&s3c2xx0_softc->s3c2xx0_rman, *rid, *rid, + count, flags, child); + if (res != NULL) + rman_set_rid(res, *rid); + + return (res); } void @@ -120,9 +144,7 @@ return 0; } -struct s3c2xx0_softc *s3c2xx0_softc = NULL; - -void +int s3c2410_attach(device_t dev) { struct s3c24x0_softc *sc = device_get_softc(dev); @@ -169,7 +191,19 @@ printf("\n"); #endif - /* get busdma tag for the platform */ + /* + * Attach children devices + */ + s3c2xx0_softc->s3c2xx0_rman.rm_type = RMAN_ARRAY; + s3c2xx0_softc->s3c2xx0_rman.rm_descr = "S3C2410 IRQs"; + if (rman_init(&s3c2xx0_softc->s3c2xx0_rman) != 0 || + rman_manage_region(&s3c2xx0_softc->s3c2xx0_rman, 0, 32) != 0) + panic("s3c2410_attach: failed to set up rman"); + device_add_child(dev, "timer", 0); + bus_generic_probe(dev); + bus_generic_attach(dev); + + return (0); } /* ==== //depot/projects/arm/src/sys/arm/s3c2xx0/s3c24x0_clk.c#3 (text+ko) ==== @@ -194,7 +194,7 @@ panic("Unable to setup the clock irq handler.\n"); else bus_setup_intr(dev, irq, INTR_TYPE_CLK | INTR_FAST, - hardintr, NULL, &ihl); + hardintr, NULL, NULL, &ihl); /* set prescaler1 */ reg = bus_space_read_4(iot, ioh, TIMER_TCFG0); ==== //depot/projects/arm/src/sys/arm/s3c2xx0/s3c2xx0var.h#3 (text+ko) ==== @@ -36,6 +36,7 @@ #define _ARM_S3C2XX0VAR_H_ #include +#include struct s3c2xx0_softc { device_t sc_dev; @@ -54,6 +55,8 @@ int sc_fclk; /* CPU clock */ int sc_hclk; /* AHB bus clock */ int sc_pclk; /* peripheral clock */ + + struct rman s3c2xx0_rman; }; typedef void *s3c2xx0_chipset_tag_t;