Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 204891
b: refs/heads/master
c: 1f5bef3
h: refs/heads/master
i:
  204889: 4766c8e
  204887: 47730b3
v: v3
  • Loading branch information
Grant Likely committed Jul 5, 2010
1 parent 20e68dd commit 0e69baf
Show file tree
Hide file tree
Showing 9 changed files with 77 additions and 118 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 6b884a8d50a6eea2fb3dad7befe748f67193073b
refs/heads/master: 1f5bef30cf6c66f097ea5dfc580a41924df888d1
5 changes: 0 additions & 5 deletions trunk/arch/microblaze/include/asm/pci-bridge.h
Original file line number Diff line number Diff line change
Expand Up @@ -172,13 +172,8 @@ static inline int pci_has_flag(int flag)

extern struct list_head hose_list;

extern unsigned long pci_address_to_pio(phys_addr_t address);
extern int pcibios_vaddr_is_ioport(void __iomem *address);
#else
static inline unsigned long pci_address_to_pio(phys_addr_t address)
{
return (unsigned long)-1;
}
static inline int pcibios_vaddr_is_ioport(void __iomem *address)
{
return 0;
Expand Down
17 changes: 9 additions & 8 deletions trunk/arch/microblaze/include/asm/prom.h
Original file line number Diff line number Diff line change
Expand Up @@ -65,17 +65,18 @@ extern const u32 *of_get_address(struct device_node *dev, int index,
extern const u32 *of_get_pci_address(struct device_node *dev, int bar_no,
u64 *size, unsigned int *flags);

/* Get an address as a resource. Note that if your address is
* a PIO address, the conversion will fail if the physical address
* can't be internally converted to an IO token with
* pci_address_to_pio(), that is because it's either called to early
* or it can't be matched to any host bridge IO space
*/
extern int of_address_to_resource(struct device_node *dev, int index,
struct resource *r);
extern int of_pci_address_to_resource(struct device_node *dev, int bar,
struct resource *r);

#ifdef CONFIG_PCI
extern unsigned long pci_address_to_pio(phys_addr_t address);
#else
static inline unsigned long pci_address_to_pio(phys_addr_t address)
{
return (unsigned long)-1;
}
#endif /* CONFIG_PCI */

/* Parse the ibm,dma-window property of an OF node into the busno, phys and
* size parameters.
*/
Expand Down
46 changes: 1 addition & 45 deletions trunk/arch/microblaze/kernel/prom_parse.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
#include <linux/module.h>
#include <linux/ioport.h>
#include <linux/etherdevice.h>
#include <linux/of_address.h>
#include <asm/prom.h>
#include <asm/pci-bridge.h>

Expand All @@ -17,9 +18,6 @@
(ns) > 0)

static struct of_bus *of_match_bus(struct device_node *np);
static int __of_address_to_resource(struct device_node *dev,
const u32 *addrp, u64 size, unsigned int flags,
struct resource *r);

/* Debug utility */
#ifdef DEBUG
Expand Down Expand Up @@ -576,48 +574,6 @@ const u32 *of_get_address(struct device_node *dev, int index, u64 *size,
}
EXPORT_SYMBOL(of_get_address);

static int __of_address_to_resource(struct device_node *dev, const u32 *addrp,
u64 size, unsigned int flags,
struct resource *r)
{
u64 taddr;

if ((flags & (IORESOURCE_IO | IORESOURCE_MEM)) == 0)
return -EINVAL;
taddr = of_translate_address(dev, addrp);
if (taddr == OF_BAD_ADDR)
return -EINVAL;
memset(r, 0, sizeof(struct resource));
if (flags & IORESOURCE_IO) {
unsigned long port;
port = -1; /* pci_address_to_pio(taddr); */
if (port == (unsigned long)-1)
return -EINVAL;
r->start = port;
r->end = port + size - 1;
} else {
r->start = taddr;
r->end = taddr + size - 1;
}
r->flags = flags;
r->name = dev->name;
return 0;
}

int of_address_to_resource(struct device_node *dev, int index,
struct resource *r)
{
const u32 *addrp;
u64 size;
unsigned int flags;

addrp = of_get_address(dev, index, &size, &flags);
if (addrp == NULL)
return -EINVAL;
return __of_address_to_resource(dev, addrp, size, flags, r);
}
EXPORT_SYMBOL_GPL(of_address_to_resource);

void of_parse_dma_window(struct device_node *dn, const void *dma_window_prop,
unsigned long *busno, unsigned long *phys, unsigned long *size)
{
Expand Down
5 changes: 0 additions & 5 deletions trunk/arch/powerpc/include/asm/pci-bridge.h
Original file line number Diff line number Diff line change
Expand Up @@ -303,13 +303,8 @@ extern void pcibios_free_controller(struct pci_controller *phb);
extern void pcibios_setup_phb_resources(struct pci_controller *hose);

#ifdef CONFIG_PCI
extern unsigned long pci_address_to_pio(phys_addr_t address);
extern int pcibios_vaddr_is_ioport(void __iomem *address);
#else
static inline unsigned long pci_address_to_pio(phys_addr_t address)
{
return (unsigned long)-1;
}
static inline int pcibios_vaddr_is_ioport(void __iomem *address)
{
return 0;
Expand Down
17 changes: 9 additions & 8 deletions trunk/arch/powerpc/include/asm/prom.h
Original file line number Diff line number Diff line change
Expand Up @@ -70,14 +70,6 @@ static inline const u32 *of_get_pci_address(struct device_node *dev,
}
#endif /* CONFIG_PCI */

/* Get an address as a resource. Note that if your address is
* a PIO address, the conversion will fail if the physical address
* can't be internally converted to an IO token with
* pci_address_to_pio(), that is because it's either called to early
* or it can't be matched to any host bridge IO space
*/
extern int of_address_to_resource(struct device_node *dev, int index,
struct resource *r);
#ifdef CONFIG_PCI
extern int of_pci_address_to_resource(struct device_node *dev, int bar,
struct resource *r);
Expand All @@ -89,6 +81,15 @@ static inline int of_pci_address_to_resource(struct device_node *dev, int bar,
}
#endif /* CONFIG_PCI */

#ifdef CONFIG_PCI
extern unsigned long pci_address_to_pio(phys_addr_t address);
#else
static inline unsigned long pci_address_to_pio(phys_addr_t address)
{
return (unsigned long)-1;
}
#endif /* CONFIG_PCI */

/* Parse the ibm,dma-window property of an OF node into the busno, phys and
* size parameters.
*/
Expand Down
47 changes: 1 addition & 46 deletions trunk/arch/powerpc/kernel/prom_parse.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
#include <linux/module.h>
#include <linux/ioport.h>
#include <linux/etherdevice.h>
#include <linux/of_address.h>
#include <asm/prom.h>
#include <asm/pci-bridge.h>

Expand All @@ -27,10 +28,6 @@
(ns) > 0)

static struct of_bus *of_match_bus(struct device_node *np);
static int __of_address_to_resource(struct device_node *dev,
const u32 *addrp, u64 size, unsigned int flags,
struct resource *r);


/* Debug utility */
#ifdef DEBUG
Expand Down Expand Up @@ -610,48 +607,6 @@ const u32 *of_get_address(struct device_node *dev, int index, u64 *size,
}
EXPORT_SYMBOL(of_get_address);

static int __of_address_to_resource(struct device_node *dev, const u32 *addrp,
u64 size, unsigned int flags,
struct resource *r)
{
u64 taddr;

if ((flags & (IORESOURCE_IO | IORESOURCE_MEM)) == 0)
return -EINVAL;
taddr = of_translate_address(dev, addrp);
if (taddr == OF_BAD_ADDR)
return -EINVAL;
memset(r, 0, sizeof(struct resource));
if (flags & IORESOURCE_IO) {
unsigned long port;
port = pci_address_to_pio(taddr);
if (port == (unsigned long)-1)
return -EINVAL;
r->start = port;
r->end = port + size - 1;
} else {
r->start = taddr;
r->end = taddr + size - 1;
}
r->flags = flags;
r->name = dev->name;
return 0;
}

int of_address_to_resource(struct device_node *dev, int index,
struct resource *r)
{
const u32 *addrp;
u64 size;
unsigned int flags;

addrp = of_get_address(dev, index, &size, &flags);
if (addrp == NULL)
return -EINVAL;
return __of_address_to_resource(dev, addrp, size, flags, r);
}
EXPORT_SYMBOL_GPL(of_address_to_resource);

void of_parse_dma_window(struct device_node *dn, const void *dma_window_prop,
unsigned long *busno, unsigned long *phys, unsigned long *size)
{
Expand Down
51 changes: 51 additions & 0 deletions trunk/drivers/of/address.c
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,57 @@
#include <linux/ioport.h>
#include <linux/of_address.h>

int __of_address_to_resource(struct device_node *dev, const u32 *addrp,
u64 size, unsigned int flags,
struct resource *r)
{
u64 taddr;

if ((flags & (IORESOURCE_IO | IORESOURCE_MEM)) == 0)
return -EINVAL;
taddr = of_translate_address(dev, addrp);
if (taddr == OF_BAD_ADDR)
return -EINVAL;
memset(r, 0, sizeof(struct resource));
if (flags & IORESOURCE_IO) {
unsigned long port;
port = pci_address_to_pio(taddr);
if (port == (unsigned long)-1)
return -EINVAL;
r->start = port;
r->end = port + size - 1;
} else {
r->start = taddr;
r->end = taddr + size - 1;
}
r->flags = flags;
r->name = dev->name;
return 0;
}

/**
* of_address_to_resource - Translate device tree address and return as resource
*
* Note that if your address is a PIO address, the conversion will fail if
* the physical address can't be internally converted to an IO token with
* pci_address_to_pio(), that is because it's either called to early or it
* can't be matched to any host bridge IO space
*/
int of_address_to_resource(struct device_node *dev, int index,
struct resource *r)
{
const u32 *addrp;
u64 size;
unsigned int flags;

addrp = of_get_address(dev, index, &size, &flags);
if (addrp == NULL)
return -EINVAL;
return __of_address_to_resource(dev, addrp, size, flags, r);
}
EXPORT_SYMBOL_GPL(of_address_to_resource);


/**
* of_iomap - Maps the memory mapped IO for a given device_node
* @device: the device whose io range will be mapped
Expand Down
5 changes: 5 additions & 0 deletions trunk/include/linux/of_address.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,11 @@
#include <linux/ioport.h>
#include <linux/of.h>

extern int __of_address_to_resource(struct device_node *dev, const u32 *addrp,
u64 size, unsigned int flags,
struct resource *r);
extern int of_address_to_resource(struct device_node *dev, int index,
struct resource *r);
extern void __iomem *of_iomap(struct device_node *device, int index);

#endif /* __OF_ADDRESS_H */
Expand Down

0 comments on commit 0e69baf

Please sign in to comment.