From owner-p4-projects@FreeBSD.ORG Sat Jun 28 21:52:05 2008 Return-Path: Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id C1274106567D; Sat, 28 Jun 2008 21:52:05 +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 4FF88106567F for ; Sat, 28 Jun 2008 21:52:05 +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 3D6D88FC18 for ; Sat, 28 Jun 2008 21:52:05 +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 m5SLq4fs017573 for ; Sat, 28 Jun 2008 21:52:04 GMT (envelope-from andrew@freebsd.org) Received: (from perforce@localhost) by repoman.freebsd.org (8.14.1/8.14.1/Submit) id m5SLq439017571 for perforce@freebsd.org; Sat, 28 Jun 2008 21:52:04 GMT (envelope-from andrew@freebsd.org) Date: Sat, 28 Jun 2008 21:52:04 GMT Message-Id: <200806282152.m5SLq439017571@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 144242 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, 28 Jun 2008 21:52:06 -0000 http://perforce.freebsd.org/chv.cgi?CH=144242 Change 144242 by andrew@andrew_bender on 2008/06/28 21:51:56 Add memory and ioport resource allocation to s3c2410_alloc_resource and set the uart ioport Implement bus_release_resource Affected files ... .. //depot/projects/arm/src/sys/arm/s3c2xx0/s3c2410.c#14 edit .. //depot/projects/arm/src/sys/arm/s3c2xx0/s3c2410reg.h#3 edit .. //depot/projects/arm/src/sys/arm/s3c2xx0/s3c2xx0var.h#6 edit Differences ... ==== //depot/projects/arm/src/sys/arm/s3c2xx0/s3c2410.c#14 (text+ko) ==== @@ -66,6 +66,8 @@ u_long, u_long, u_long, u_int); static int s3c2410_activate_resource(device_t, device_t, int, int, struct resource *); +static int s3c2410_release_resource(device_t, device_t, int, int, + struct resource *); static struct resource_list *s3c2410_get_resource_list(device_t, device_t); static device_method_t s3c2410_methods[] = { @@ -75,6 +77,7 @@ DEVMETHOD(bus_setup_intr, s3c2410_setup_intr), DEVMETHOD(bus_alloc_resource, s3c2410_alloc_resource), DEVMETHOD(bus_activate_resource, s3c2410_activate_resource), + DEVMETHOD(bus_release_resource, s3c2410_release_resource), DEVMETHOD(bus_get_resource_list,s3c2410_get_resource_list), DEVMETHOD(bus_set_resource, bus_generic_rl_set_resource), DEVMETHOD(bus_get_resource, bus_generic_rl_get_resource), @@ -193,6 +196,15 @@ &s3c2xx0_softc->s3c2xx0_irq_rman, start, end, count, flags, child); break; + + case SYS_RES_IOPORT: + case SYS_RES_MEMORY: + res = rman_reserve_resource( + &s3c2xx0_softc->s3c2xx0_mem_rman, + start, end, count, flags, child); + rman_set_bustag(res, &s3c2xx0_bs_tag); + rman_set_bushandle(res, start); + break; } if (res != NULL) { @@ -211,6 +223,27 @@ return (0); } +static int +s3c2410_release_resource(device_t bus, device_t child, int type, int rid, + struct resource *r) +{ + struct s3c2xx0_ivar *ivar = device_get_ivars(child); + struct resource_list *rl = &ivar->resources; + struct resource_list_entry *rle; + + if (rl == NULL) + return (EINVAL); + + rle = resource_list_find(rl, type, rid); + if (rle == NULL) + return (EINVAL); + + rman_release_resource(r); + rle->res = NULL; + + return 0; +} + static struct resource_list * s3c2410_get_resource_list(device_t dev, device_t child) { @@ -286,16 +319,26 @@ */ s3c2xx0_softc->s3c2xx0_irq_rman.rm_type = RMAN_ARRAY; s3c2xx0_softc->s3c2xx0_irq_rman.rm_descr = "S3C2410 IRQs"; + s3c2xx0_softc->s3c2xx0_mem_rman.rm_type = RMAN_ARRAY; + s3c2xx0_softc->s3c2xx0_mem_rman.rm_descr = "S3C2410 Memory"; if (rman_init(&s3c2xx0_softc->s3c2xx0_irq_rman) != 0 || rman_manage_region(&s3c2xx0_softc->s3c2xx0_irq_rman, 0, S3C2410_SUBIRQ_MAX - 1) != 0) panic("s3c2410_attach: failed to set up IRQ rman"); + /* Manage the registor memoty space */ + if (rman_init(&s3c2xx0_softc->s3c2xx0_mem_rman) != 0 || + rman_manage_region(&s3c2xx0_softc->s3c2xx0_mem_rman, S3C2410_REG_BASE, + S3C2410_REG_BASE + S3C2410_REG_SIZE) != 0) + panic("s3c2410_attach: failed to set up register rman"); + s3c2410_add_child(dev, 0, "nand", 0); s3c2410_add_child(dev, 0, "timer", 0); - /* Add the uart and set it's irq */ + /* Add the uart and set it's irq and registers */ child = s3c2410_add_child(dev, 0, "uart", 0); bus_set_resource(child, SYS_RES_IRQ, 0, S3C2410_INT_UART0, 1); + bus_set_resource(child, SYS_RES_IOPORT, 0, S3C2410_UART0_BASE, + S3C2410_UART_BASE(1) - S3C2410_UART0_BASE); bus_generic_probe(dev); bus_generic_attach(dev); ==== //depot/projects/arm/src/sys/arm/s3c2xx0/s3c2410reg.h#3 (text+ko) ==== @@ -80,6 +80,9 @@ #define S3C2410_SDI_BASE 0x5a000000 /* SD Interface */ #define S3C2410_SDI_SIZE 0x44 +#define S3C2410_REG_BASE 0x48000000 +#define S3C2410_REG_SIZE 0x13000000 + /* interrupt control (additional defs for 2410) */ #define ICU_LEN (32+11) ==== //depot/projects/arm/src/sys/arm/s3c2xx0/s3c2xx0var.h#6 (text+ko) ==== @@ -57,6 +57,7 @@ int sc_pclk; /* peripheral clock */ struct rman s3c2xx0_irq_rman; + struct rman s3c2xx0_mem_rman; }; struct s3c2xx0_ivar {