From owner-p4-projects@FreeBSD.ORG Thu Dec 17 13:09:09 2009 Return-Path: Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id D76C4106568B; Thu, 17 Dec 2009 13:09:09 +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 9BB571065670 for ; Thu, 17 Dec 2009 13:09:09 +0000 (UTC) (envelope-from raj@freebsd.org) Received: from repoman.freebsd.org (repoman.freebsd.org [IPv6:2001:4f8:fff6::29]) by mx1.freebsd.org (Postfix) with ESMTP id 6FBD08FC13 for ; Thu, 17 Dec 2009 13:09:09 +0000 (UTC) Received: from repoman.freebsd.org (localhost [127.0.0.1]) by repoman.freebsd.org (8.14.3/8.14.3) with ESMTP id nBHD997W089561 for ; Thu, 17 Dec 2009 13:09:09 GMT (envelope-from raj@freebsd.org) Received: (from perforce@localhost) by repoman.freebsd.org (8.14.3/8.14.3/Submit) id nBHD99tP089559 for perforce@freebsd.org; Thu, 17 Dec 2009 13:09:09 GMT (envelope-from raj@freebsd.org) Date: Thu, 17 Dec 2009 13:09:09 GMT Message-Id: <200912171309.nBHD99tP089559@repoman.freebsd.org> X-Authentication-Warning: repoman.freebsd.org: perforce set sender to raj@freebsd.org using -f From: Rafal Jaworowski To: Perforce Change Reviews Precedence: bulk Cc: Subject: PERFORCE change 171867 for review X-BeenThere: p4-projects@freebsd.org X-Mailman-Version: 2.1.5 List-Id: p4 projects tree changes List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 17 Dec 2009 13:09:10 -0000 http://p4web.freebsd.org/chv.cgi?CH=171867 Change 171867 by raj@raj_fdt on 2009/12/17 13:08:48 Improve simplebus driver a bit. - Perform bus-frequency property fixup (based on bus-frequency value of the CPU node) - Use default MEM resources for allocation even if the caller does not really follow bus_alloc_resource_any() convention, e.g. uart(4) - Mimic SYS_RES_IOPORT with a mem-mapped resource. - Optimize probe routine. Affected files ... .. //depot/projects/fdt/sys/powerpc/mpc85xx/simplebus.c#4 edit Differences ... ==== //depot/projects/fdt/sys/powerpc/mpc85xx/simplebus.c#4 (text+ko) ==== @@ -90,6 +90,7 @@ int di_intr_num; }; + /* * Prototypes. */ @@ -152,14 +153,10 @@ static int simplebus_probe(device_t dev) { - const char *compat; - compat = ofw_bus_get_compat(dev); - - /* XXX multistring compat entries should be handled */ - if (compat != NULL && strcmp(compat, "simple-bus") == 0) { - device_set_desc(dev, "FDT simple bus"); - return (0); + if (ofw_bus_is_compatible(dev, "simple-bus")) { + device_set_desc(dev, "Flattened Device Tree simple bus"); + return (BUS_PROBE_DEFAULT); } return (ENXIO); @@ -516,6 +513,27 @@ return (rv); } +static void +simplebus_fixup(phandle_t node) +{ + phandle_t cpus, child; + pcell_t freq; + + /* XXX this whole fixup should depend on 8555 SOC */ + + if ((cpus = OF_finddevice("/cpus")) == 0) + panic("simplebus: no /cpus node"); + + if ((child = OF_child(cpus)) == 0) + return; + + if (OF_getprop(child, "bus-frequency", (void *)&freq, + sizeof(freq)) <= 0) + return; + + OF_setprop(node, "bus-frequency", (void *)&freq, sizeof(freq)); +} + static int simplebus_attach(device_t dev) { @@ -534,6 +552,8 @@ node = ofw_bus_get_node(dev); cell_size = sizeof(cell); + simplebus_fixup(node); + /* * Retrieve #{address,size}-cells. */ @@ -675,14 +695,17 @@ * Request for the default allocation with a given rid: use resource * list stored in the local device info. */ - if ((start == 0UL) && (end == ~0UL) && (count == 1)) { + if ((start == 0UL) && (end == ~0UL)) { if ((di = device_get_ivars(child)) == NULL) return (NULL); + if (type == SYS_RES_IOPORT) + type = SYS_RES_MEMORY; + rle = resource_list_find(&di->di_res, type, *rid); if (rle == NULL) { device_printf(bus, "no default resources for " - "rid = %d\n", *rid); + "rid = %d, type = %d\n", *rid, type); return (NULL); } start = rle->start;