[U-Boot-Users] [RFC][PATCH] pci: Divided PCI driver for PowerPC.

Nobuhiro Iwamatsu iwamatsu at nigauri.org
Wed Mar 12 08:08:18 CET 2008


Hi, 

I have the consultation about PCI of PowerPC.
I read PCI souce code, I notice that pci_hose_phys_to_bus and pci_hose_bus_to_phys 
functions are PowerPC specific. Is this correct?
I wrote patch so that these functions might use only PPC. 
When this patch is applied, driver's useless macro is lost. 
(ex. #ifndef CONFIG_PPC ....)

I don't have knowledge of PowerPC Architecture.
Could you indicate the mistake?

regards,
 Nobuhiro

--- 
pci_hose_phys_to_bus and pci_hose_bus_to_phys functions are PowerPC specific.
These functions were divided for PowerPC.
A specific code to PowerPC can be removed from driver.

Signed-off-by: Nobuhiro Iwamatsu <iwamatsu at nigauri.org>
---
 drivers/net/dc2114x.c  |    4 ----
 drivers/net/eepro100.c |    5 -----
 drivers/pci/pci.c      |    8 +++++---
 include/pci.h          |   28 ++++++++++++++++++++++------
 4 files changed, 27 insertions(+), 18 deletions(-)

diff --git a/drivers/net/dc2114x.c b/drivers/net/dc2114x.c
index 7238922..5bd279b 100644
--- a/drivers/net/dc2114x.c
+++ b/drivers/net/dc2114x.c
@@ -185,11 +185,7 @@ static void  dc21x4x_halt(struct eth_device* dev);
 extern void  dc21x4x_select_media(struct eth_device* dev);
 #endif
 
-#if defined(CONFIG_E500)
-#define phys_to_bus(a) (a)
-#else
 #define phys_to_bus(a)	pci_phys_to_mem((pci_dev_t)dev->priv, a)
-#endif
 
 static int INL(struct eth_device* dev, u_long addr)
 {
diff --git a/drivers/net/eepro100.c b/drivers/net/eepro100.c
index 96ed271..94e9bff 100644
--- a/drivers/net/eepro100.c
+++ b/drivers/net/eepro100.c
@@ -249,13 +249,8 @@ static int eepro100_send (struct eth_device *dev, volatile void *packet,
 static int eepro100_recv (struct eth_device *dev);
 static void eepro100_halt (struct eth_device *dev);
 
-#if defined(CONFIG_E500) || defined(CONFIG_DB64360) || defined(CONFIG_DB64460)
-#define bus_to_phys(a) (a)
-#define phys_to_bus(a) (a)
-#else
 #define bus_to_phys(a)	pci_mem_to_phys((pci_dev_t)dev->priv, a)
 #define phys_to_bus(a)	pci_phys_to_mem((pci_dev_t)dev->priv, a)
-#endif
 
 static inline int INW (struct eth_device *dev, u_long addr)
 {
diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c
index 50ca6b0..2183f02 100644
--- a/drivers/pci/pci.c
+++ b/drivers/pci/pci.c
@@ -217,9 +217,11 @@ pci_dev_t pci_find_device(unsigned int vendor, unsigned int device, int index)
 }
 
 /*
- *
+ * These function is PPC specific.
+ *  - pci_hose_phys_to_bus
+ *  - pci_hose_bus_to_phys
  */
-
+#if defined(CONFIG_PPC)
 unsigned long pci_hose_phys_to_bus (struct pci_controller *hose,
 				    unsigned long phys_addr,
 				    unsigned long flags)
@@ -282,7 +284,7 @@ unsigned long pci_hose_bus_to_phys(struct pci_controller* hose,
 Done:
 	return 0;
 }
-
+#endif /* CONFIG_PPC */
 /*
  *
  */
diff --git a/include/pci.h b/include/pci.h
index 8e5dacc..543c0db 100644
--- a/include/pci.h
+++ b/include/pci.h
@@ -432,20 +432,36 @@ extern __inline__ void pci_set_ops(struct pci_controller *hose,
 
 extern void pci_setup_indirect(struct pci_controller* hose, u32 cfg_addr, u32 cfg_data);
 
+#if defined(CONFIG_PPC)
 extern unsigned long pci_hose_bus_to_phys(struct pci_controller* hose,
 					  unsigned long addr, unsigned long flags);
 extern unsigned long pci_hose_phys_to_bus(struct pci_controller* hose,
 					  unsigned long addr, unsigned long flags);
 
-#define pci_phys_to_bus(dev, addr, flags) \
+# define pci_phys_to_bus(dev, addr, flags) \
 	pci_hose_phys_to_bus(pci_bus_to_hose(PCI_BUS(dev)), (addr), (flags))
-#define pci_bus_to_phys(dev, addr, flags) \
+# define pci_bus_to_phys(dev, addr, flags) \
 	pci_hose_bus_to_phys(pci_bus_to_hose(PCI_BUS(dev)), (addr), (flags))
 
-#define pci_phys_to_mem(dev, addr)	pci_phys_to_bus((dev), (addr), PCI_REGION_MEM)
-#define pci_mem_to_phys(dev, addr)	pci_bus_to_phys((dev), (addr), PCI_REGION_MEM)
-#define pci_phys_to_io(dev, addr)	pci_phys_to_bus((dev), (addr), PCI_REGION_IO)
-#define pci_io_to_phys(dev, addr)	pci_bus_to_phys((dev), (addr), PCI_REGION_IO)
+# if defined(CONFIG_E500) || defined(CONFIG_DB64360) || defined(CONFIG_DB64460)
+#  define pci_phys_to_mem(dev, addr)	(addr)
+#  define pci_mem_to_phys(dev, addr)	(addr)
+#  define pci_phys_to_io(dev, addr)		(addr)
+#  define pci_io_to_phys(dev, addr)		(addr)
+# else /* defined(CONFIG_E500) || defined(CONFIG_DB64360) || defined(CONFIG_DB64460) */
+#  define pci_phys_to_mem(dev, addr)	pci_phys_to_bus((dev), (addr), PCI_REGION_MEM)
+#  define pci_mem_to_phys(dev, addr)	pci_bus_to_phys((dev), (addr), PCI_REGION_MEM)
+#  define pci_phys_to_io(dev, addr)		pci_phys_to_bus((dev), (addr), PCI_REGION_IO)
+#  define pci_io_to_phys(dev, addr)		pci_bus_to_phys((dev), (addr), PCI_REGION_IO)
+# endif /* defined(CONFIG_E500) || defined(CONFIG_DB64360) || defined(CONFIG_DB64460) */
+
+#else /* CONFIG_PPC */
+/* Architectures other than PPC */
+# define pci_phys_to_mem(dev, addr) (addr)
+# define pci_mem_to_phys(dev, addr) (addr)
+# define pci_phys_to_io(dev, addr)  (addr)
+# define pci_io_to_phys(dev, addr)  (addr)
+#endif /* CONFIG_PPC */
 
 extern int pci_hose_read_config_byte(struct pci_controller *hose,
 				     pci_dev_t dev, int where, u8 *val);
-- 
1.5.4.3





More information about the U-Boot mailing list