blob: 6411c3b3a80f8ba18984e7e7731026318bde794b [file] [log] [blame]
Michal Simek12e84142009-03-27 14:25:12 +01001/*
2 * Definitions for talking to the Open Firmware PROM on
3 * Power Macintosh computers.
4 *
5 * Copyright (C) 1996-2005 Paul Mackerras.
6 *
7 * Updates for PPC64 by Peter Bergner & David Engebretsen, IBM Corp.
8 *
9 * This program is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU General Public License
11 * as published by the Free Software Foundation; either version
12 * 2 of the License, or (at your option) any later version.
13 */
14
Grant Likely9d24c882009-10-15 10:57:44 -060015#include <linux/of.h> /* linux/of.h gets to determine #include ordering */
16
Michal Simek12e84142009-03-27 14:25:12 +010017#ifndef _ASM_MICROBLAZE_PROM_H
18#define _ASM_MICROBLAZE_PROM_H
19#ifdef __KERNEL__
John Williams909964e2009-06-22 14:02:09 +100020#ifndef __ASSEMBLY__
21
Michal Simek12e84142009-03-27 14:25:12 +010022#include <linux/types.h>
Grant Likely6b884a82010-06-08 07:48:09 -060023#include <linux/of_address.h>
Grant Likelye3873442010-06-18 11:09:59 -060024#include <linux/of_irq.h>
Grant Likelyd8678b52009-10-15 10:57:53 -060025#include <linux/of_fdt.h>
Michal Simek12e84142009-03-27 14:25:12 +010026#include <linux/proc_fs.h>
27#include <linux/platform_device.h>
28#include <asm/irq.h>
29#include <asm/atomic.h>
30
Michal Simek12e84142009-03-27 14:25:12 +010031#define HAVE_ARCH_DEVTREE_FIXUPS
32
Michal Simek12e84142009-03-27 14:25:12 +010033/* Other Prototypes */
Michal Simek12e84142009-03-27 14:25:12 +010034extern int early_uartlite_console(void);
Michal Simek12e84142009-03-27 14:25:12 +010035
Michal Simeka6475c12010-01-18 15:27:10 +010036#ifdef CONFIG_PCI
37/*
38 * PCI <-> OF matching functions
39 * (XXX should these be here?)
40 */
41struct pci_bus;
42struct pci_dev;
43extern int pci_device_from_OF_node(struct device_node *node,
44 u8 *bus, u8 *devfn);
45extern struct device_node *pci_busdev_to_OF_node(struct pci_bus *bus,
46 int devfn);
47extern struct device_node *pci_device_to_OF_node(struct pci_dev *dev);
48extern void pci_create_OF_bus_map(void);
49#endif
50
Michal Simek12e84142009-03-27 14:25:12 +010051/*
52 * OF address retreival & translation
53 */
54
Michal Simek12e84142009-03-27 14:25:12 +010055/* Translate an OF address block into a CPU physical address
56 */
57extern u64 of_translate_address(struct device_node *np, const u32 *addr);
58
59/* Extract an address from a device, returns the region size and
60 * the address space flags too. The PCI version uses a BAR number
61 * instead of an absolute index
62 */
63extern const u32 *of_get_address(struct device_node *dev, int index,
64 u64 *size, unsigned int *flags);
65extern const u32 *of_get_pci_address(struct device_node *dev, int bar_no,
66 u64 *size, unsigned int *flags);
67
68/* Get an address as a resource. Note that if your address is
69 * a PIO address, the conversion will fail if the physical address
70 * can't be internally converted to an IO token with
71 * pci_address_to_pio(), that is because it's either called to early
72 * or it can't be matched to any host bridge IO space
73 */
74extern int of_address_to_resource(struct device_node *dev, int index,
75 struct resource *r);
76extern int of_pci_address_to_resource(struct device_node *dev, int bar,
77 struct resource *r);
78
79/* Parse the ibm,dma-window property of an OF node into the busno, phys and
80 * size parameters.
81 */
82void of_parse_dma_window(struct device_node *dn, const void *dma_window_prop,
83 unsigned long *busno, unsigned long *phys, unsigned long *size);
84
85extern void kdump_move_device_tree(void);
86
87/* CPU OF node matching */
88struct device_node *of_get_cpu_node(int cpu, unsigned int *thread);
89
90/* Get the MAC address */
91extern const void *of_get_mac_address(struct device_node *np);
92
Michal Simek12e84142009-03-27 14:25:12 +010093/**
Michal Simek12e84142009-03-27 14:25:12 +010094 * of_irq_map_pci - Resolve the interrupt for a PCI device
95 * @pdev: the device whose interrupt is to be resolved
96 * @out_irq: structure of_irq filled by this function
97 *
98 * This function resolves the PCI interrupt for a given PCI device. If a
99 * device-node exists for a given pci_dev, it will use normal OF tree
100 * walking. If not, it will implement standard swizzling and walk up the
101 * PCI tree until an device-node is found, at which point it will finish
102 * resolving using the OF tree walking.
103 */
104struct pci_dev;
105extern int of_irq_map_pci(struct pci_dev *pdev, struct of_irq *out_irq);
106
John Williams909964e2009-06-22 14:02:09 +1000107#endif /* __ASSEMBLY__ */
Michal Simek12e84142009-03-27 14:25:12 +0100108#endif /* __KERNEL__ */
109#endif /* _ASM_MICROBLAZE_PROM_H */