Пример #1
0
static bool find_by_address(u64 base_address)
{
	struct device_node *dn = of_find_all_nodes(NULL);
	struct resource res;

	while (dn) {
		if (!of_address_to_resource(dn, 0, &res)) {
			if (res.start == base_address) {
				of_node_put(dn);
				return true;
			}
		}
		dn = of_find_all_nodes(dn);
	}

	return false;
}
Пример #2
0
void lite52xx_show_cpuinfo(struct seq_file *m)
{
	struct device_node* np = of_find_all_nodes(NULL);
	const char *model = NULL;

	if (np)
		model = get_property(np, "model", NULL);

	seq_printf(m, "vendor\t\t:	Freescale Semiconductor\n");
	seq_printf(m, "machine\t\t:	%s\n", model ? model : "unknown");

	of_node_put(np);
}
static void __iomem *gator_events_l2c310_probe(void)
{
	phys_addr_t variants[] = {
#if defined(CONFIG_ARCH_EXYNOS4) || defined(CONFIG_ARCH_S5PV310)
		0x10502000,
#endif
#if defined(CONFIG_ARCH_OMAP4)
		0x48242000,
#endif
#if defined(CONFIG_ARCH_TEGRA)
		0x50043000,
#endif
#if defined(CONFIG_ARCH_U8500)
		0xa0412000,
#endif
#if defined(CONFIG_ARCH_VEXPRESS)
		0x1e00a000, /* A9x4 core tile (HBI-0191) */
		0x2c0f0000, /* New memory map tiles */
#endif
	};
	int i;
	void __iomem *base;
#if defined(CONFIG_OF)
	struct device_node *node = of_find_all_nodes(NULL);

	if (node) {
		of_node_put(node);

		node = of_find_compatible_node(NULL, NULL, "arm,pl310-cache");
		base = of_iomap(node, 0);
		of_node_put(node);

		return base;
	}
#endif

	for (i = 0; i < ARRAY_SIZE(variants); i++) {
		base = ioremap(variants[i], SZ_4K);
		if (base) {
			u32 cache_id = readl(base + L2X0_CACHE_ID);

			if ((cache_id & 0xff0003c0) == 0x410000c0)
				return base;

			iounmap(base);
		}
	}

	return NULL;
}
Пример #4
0
static int mpic_msi_reserve_u3_hwirqs(struct mpic *mpic)
{
	irq_hw_number_t hwirq;
	const struct irq_domain_ops *ops = mpic->irqhost->ops;
	struct device_node *np;
	int flags, index, i;
	struct of_phandle_args oirq;

	pr_debug("mpic: found U3, guessing msi allocator setup\n");

	/* Reserve source numbers we know are reserved in the HW.
	 *
	 * This is a bit of a mix of U3 and U4 reserves but that's going
	 * to work fine, we have plenty enugh numbers left so let's just
	 * mark anything we don't like reserved.
	 */
	for (i = 0;   i < 8;   i++)
		msi_bitmap_reserve_hwirq(&mpic->msi_bitmap, i);

	for (i = 42;  i < 46;  i++)
		msi_bitmap_reserve_hwirq(&mpic->msi_bitmap, i);

	for (i = 100; i < 105; i++)
		msi_bitmap_reserve_hwirq(&mpic->msi_bitmap, i);

	for (i = 124; i < mpic->num_sources; i++)
		msi_bitmap_reserve_hwirq(&mpic->msi_bitmap, i);


	np = NULL;
	while ((np = of_find_all_nodes(np))) {
		pr_debug("mpic: mapping hwirqs for %s\n", np->full_name);

		index = 0;
		while (of_irq_parse_one(np, index++, &oirq) == 0) {
			ops->xlate(mpic->irqhost, NULL, oirq.args,
						oirq.args_count, &hwirq, &flags);
			msi_bitmap_reserve_hwirq(&mpic->msi_bitmap, hwirq);
		}
	}

	return 0;
}
Пример #5
0
/* This doesn't need to be called if you don't have any special workaround
 * flags to pass
 */
void of_irq_map_init(unsigned int flags)
{
	of_irq_workarounds = flags;

	/* OldWorld, don't bother looking at other things */
	if (flags & OF_IMAP_OLDWORLD_MAC)
		return;

	/* If we don't have phandles, let's try to locate a default interrupt
	 * controller (happens when booting with BootX). We do a first match
	 * here, hopefully, that only ever happens on machines with one
	 * controller.
	 */
	if (flags & OF_IMAP_NO_PHANDLE) {
		struct device_node *np;

		for(np = NULL; (np = of_find_all_nodes(np)) != NULL;) {
			if (of_get_property(np, "interrupt-controller", NULL)
			    == NULL)
				continue;
			/* Skip /chosen/interrupt-controller */
			if (strcmp(np->name, "chosen") == 0)
				continue;
			/* It seems like at least one person on this planet wants
			 * to use BootX on a machine with an AppleKiwi controller
			 * which happens to pretend to be an interrupt
			 * controller too.
			 */
			if (strcmp(np->name, "AppleKiwi") == 0)
				continue;
			/* I think we found one ! */
			of_irq_dflt_pic = np;
			break;
		}
	}

}
Пример #6
0
static int of_get_gpiochip_base(struct device_node *np)
{
	struct device_node *gc = NULL;
	int gpiochip_base = 0;

	while ((gc = of_find_all_nodes(gc))) {
		if (!of_get_property(gc, "gpio-controller", NULL))
			continue;

		if (gc != np) {
			gpiochip_base += ARCH_OF_GPIOS_PER_CHIP;
			continue;
		}

		of_node_put(gc);

		if (gpiochip_base >= ARCH_OF_GPIOS_END)
			return -ENOSPC;

		return gpiochip_base;
	}

	return -ENOENT;
}
Пример #7
0
/*
 * This is called very early, as part of setup_system() or eventually
 * setup_arch(), basically before anything else in this file. This function
 * will try to build a list of all the available 8250-compatible serial ports
 * in the machine using the Open Firmware device-tree. It currently only deals
 * with ISA and PCI busses but could be extended. It allows a very early boot
 * console to be initialized, that list is also used later to provide 8250 with
 * the machine non-PCI ports and to properly pick the default console port
 */
void __init find_legacy_serial_ports(void)
{
	struct device_node *np, *stdout = NULL;
	const char *path;
	int index;

	DBG(" -> find_legacy_serial_port()\n");

	/* Now find out if one of these is out firmware console */
	path = of_get_property(of_chosen, "linux,stdout-path", NULL);
	if (path != NULL) {
		stdout = of_find_node_by_path(path);
		if (stdout)
			DBG("stdout is %s\n", stdout->full_name);
	} else {
		DBG(" no linux,stdout-path !\n");
	}

	/* First fill our array with SOC ports */
	for (np = NULL; (np = of_find_compatible_node(np, "serial", "ns16550")) != NULL;) {
		struct device_node *soc = of_get_parent(np);
		if (soc && !strcmp(soc->type, "soc")) {
			index = add_legacy_soc_port(np, np);
			if (index >= 0 && np == stdout)
				legacy_serial_console = index;
		}
		of_node_put(soc);
	}

	/* First fill our array with ISA ports */
	for (np = NULL; (np = of_find_node_by_type(np, "serial"));) {
		struct device_node *isa = of_get_parent(np);
		if (isa && !strcmp(isa->name, "isa")) {
			index = add_legacy_isa_port(np, isa);
			if (index >= 0 && np == stdout)
				legacy_serial_console = index;
		}
		of_node_put(isa);
	}

	/* First fill our array with tsi-bridge ports */
	for (np = NULL; (np = of_find_compatible_node(np, "serial", "ns16550")) != NULL;) {
		struct device_node *tsi = of_get_parent(np);
		if (tsi && !strcmp(tsi->type, "tsi-bridge")) {
			index = add_legacy_soc_port(np, np);
			if (index >= 0 && np == stdout)
				legacy_serial_console = index;
		}
		of_node_put(tsi);
	}

	/* First fill our array with opb bus ports */
	for (np = NULL; (np = of_find_compatible_node(np, "serial", "ns16750")) != NULL;) {
		struct device_node *opb = of_get_parent(np);
		if (opb && !strcmp(opb->type, "opb")) {
			index = add_legacy_soc_port(np, np);
			if (index >= 0 && np == stdout)
				legacy_serial_console = index;
		}
		of_node_put(opb);
	}

#ifdef CONFIG_PCI
	/* Next, try to locate PCI ports */
	for (np = NULL; (np = of_find_all_nodes(np));) {
		struct device_node *pci, *parent = of_get_parent(np);
		if (parent && !strcmp(parent->name, "isa")) {
			of_node_put(parent);
			continue;
		}
		if (strcmp(np->name, "serial") && strcmp(np->type, "serial")) {
			of_node_put(parent);
			continue;
		}
		/* Check for known pciclass, and also check wether we have
		 * a device with child nodes for ports or not
		 */
		if (of_device_is_compatible(np, "pciclass,0700") ||
		    of_device_is_compatible(np, "pciclass,070002"))
			pci = np;
		else if (of_device_is_compatible(parent, "pciclass,0700") ||
			 of_device_is_compatible(parent, "pciclass,070002"))
			pci = parent;
		else {
			of_node_put(parent);
			continue;
		}
		index = add_legacy_pci_port(np, pci);
		if (index >= 0 && np == stdout)
			legacy_serial_console = index;
		of_node_put(parent);
	}
#endif

	DBG("legacy_serial_console = %d\n", legacy_serial_console);
	if (legacy_serial_console >= 0)
		setup_legacy_serial_console(legacy_serial_console);
	DBG(" <- find_legacy_serial_port()\n");
}