/******************************************************************************* * hwitag_add_irq * * add the irq tag to device <hwi_off> and and set the tag vector field to * <vector>. * * Note that the <hwi_off> parameter is ignored because there is currently no * way to add tags to an existing item. The API provides for the removal of this * restriction in the future * * Returns: -1 on error or the vector tag index that was set (base 0) * */ void hwitag_add_irq(unsigned hwi_off, unsigned vector) { hwi_tag *tag; tag = hwi_alloc_tag(HWI_TAG_INFO(irq)); tag->irq.vector = vector; }
/******************************************************************************* * hwitag_add_irq_range * * add the irqrange tag to device <hwi_off> and and set the tag fields as * specified in <start_vector> and <num>. * * Note that the <hwi_off> parameter is ignored because there is currently no * way to add tags to an existing item. The API provides for the removal of this * restriction in the future * * Returns: -1 on error or the vector tag index that was set (base 0) * */ void hwitag_add_irqrange(unsigned hwi_off, unsigned start_vector, unsigned num) { hwi_tag *tag; tag = hwi_alloc_tag(HWI_TAG_INFO(irqrange)); tag->irqrange.irq = start_vector; tag->irqrange.num = num; }
/******************************************************************************* * hwitag_add_inputclk * * add the input clock tag to device <hwi_off> and set the tag fields as * specified in <clk> and <div>. * * Note that the <hwi_off> parameter is ignored because there is currently no * way to add tags to an existing item. The API provides for the removal of this * restriction in the future * * Returns: -1 on error or the vector tag index that was set (base 0) * */ void hwitag_add_inputclk(unsigned hwi_off, unsigned clk, unsigned div) { hwi_tag *tag; tag = hwi_alloc_tag(HWI_TAG_INFO(inputclk)); tag->inputclk.clk = clk; tag->inputclk.div = div; }
/******************************************************************************* * hwitag_add_busattr * * add the bus attributes tag to device <hwi_off> and set the tag fields as * specified in <attr>. * * Note that the <hwi_off> parameter is ignored because there is currently no * way to add tags to an existing item. The API provides for the removal of this * restriction in the future * * Returns: -1 on error or the vector tag index that was set (base 0) * */ void hwitag_add_busattr(unsigned hwi_off, struct hwi_busattr *attr) { hwi_tag *tag; tag = hwi_alloc_tag(HWI_TAG_INFO(busattr)); tag->busattr.speed = attr ? attr->speed : 0; tag->busattr.width = attr ? attr->width : 0; tag->busattr.addr = attr ? attr->addr : 0; tag->busattr.flags = attr ? attr->flags : 0; }
/******************************************************************************* * hwitag_add_location * * add the location tag to device <hwi_off> and set the tag fields as specified * in remaining arguments. * * Note that the <hwi_off> parameter is ignored because there is currently no * way to add tags to an existing item. The API provides for the removal of this * restriction in the future * * Returns: -1 on error or the vector tag index that was set (base 0) * */ void hwitag_add_location(unsigned hwi_off, paddr_t base, paddr_t len, unsigned reg_shift, unsigned addr_space) { hwi_tag *tag; tag = hwi_alloc_tag(HWI_TAG_INFO(location)); tag->location.base = base; tag->location.len = len; tag->location.regshift = reg_shift; tag->location.addrspace = addr_space; }
void hwi_add_device(const char *bname, const char *cname, const char *dname, unsigned pnp) { hwi_tag *tag; unsigned bus; unsigned class; bus = hwi_find_item(HWI_NULL_OFF, bname, NULL); if(bus == HWI_NULL_OFF) { unsigned off = hwi_find_item(HWI_NULL_OFF, HWI_ITEM_ROOT_HW, NULL); tag = hwi_alloc_item(HWI_TAG_INFO(bus), bname, off); bus = hwi_tag2off(tag); } class = hwi_find_item(HWI_NULL_OFF, bname, cname, NULL); if(class == HWI_NULL_OFF) { tag = hwi_alloc_item(HWI_TAG_INFO(group), cname, bus); class = hwi_tag2off(tag); } tag = hwi_alloc_item(HWI_TAG_INFO(device), dname, class); tag->device.pnpid = pnp; }
/******************************************************************************* * hwibus_add * * adds the bus <bus_name> to the device (or bus) <parent_hwi_off>. We ignore * the class specifier * * Returns: the hwi_off for the added bus or HWI_NULL_OFF on error * * Note that although we used the name 'bus' to be consistent with previous * nomenclature, from a topology perscpective, we actually mean any interconnect * to which a device is connected */ unsigned hwibus_add(const char *bus_name, unsigned parent_hwi_off) { unsigned hwi_off = HWI_NULL_OFF; /* if no parent is provided for the bus, it will get added to HWI_ITEM_ROOT_HW */ if ((parent_hwi_off != HWI_NULL_OFF) || (parent_hwi_off = hwi_find_item(HWI_NULL_OFF, HWI_ITEM_ROOT_HW, NULL)) != HWI_NULL_OFF) { hwi_tag *tag = hwi_alloc_item(HWI_TAG_INFO(bus), bus_name, parent_hwi_off); if (tag != NULL) hwi_off = hwi_tag2off(tag); } return hwi_off; }
void hwi_add_rtc(const char *name, paddr_t base, unsigned reg_shift, unsigned len, int mmap, int cent_reg) { hwi_add_device(HWI_ITEM_BUS_UNKNOWN, HWI_ITEM_DEVCLASS_RTC, name, 0); hwi_add_location(base, len << reg_shift, reg_shift, hwi_find_as(base, mmap)); if(cent_reg != -1) { hwi_tag *cent = hwi_alloc_tag(HWI_TAG_INFO(regname)); cent->regname.regname = 0; cent->regname.offset = cent_reg; } }