Date: Thu, 17 Dec 2009 13:09:09 GMT From: Rafal Jaworowski <raj@FreeBSD.org> To: Perforce Change Reviews <perforce@freebsd.org> Subject: PERFORCE change 171867 for review Message-ID: <200912171309.nBHD99tP089559@repoman.freebsd.org>
next in thread | raw e-mail | index | archive | help
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;
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200912171309.nBHD99tP089559>