[POWERPC] Celleb: bug fix caused by not casting pointer types

This fixes a bug caused by changes of pointer type in
commit f1fda89522c5aaa1bd4ef69605e85e6ee9c85faf.

hose->cfg_addr type is "volatile unsigned int __iomem *", so
"hose->cfg_addr + X" will not make an intended address.

This patch also adds comments for usage of cfg_addr and cfg_data in
pci_controller structure. We use them in irregular way, and the
original code is short of explanations about them.

Signed-off-by: Kou Ishizaki <kou.ishizaki@toshiba.co.jp>
Acked-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Signed-off-by: Paul Mackerras <paulus@samba.org>

authored by Ishizaki Kou and committed by Paul Mackerras 8388374f c99176a2

+61 -21
+61 -21
arch/powerpc/platforms/celleb/scc_epci.c
··· 43 43 44 44 #define iob() __asm__ __volatile__("eieio; sync":::"memory") 45 45 46 + static inline volatile void __iomem *celleb_epci_get_epci_base( 47 + struct pci_controller *hose) 48 + { 49 + /* 50 + * Note: 51 + * Celleb epci uses cfg_addr as a base address for 52 + * epci control registers. 53 + */ 54 + 55 + return hose->cfg_addr; 56 + } 57 + 58 + static inline volatile void __iomem *celleb_epci_get_epci_cfg( 59 + struct pci_controller *hose) 60 + { 61 + /* 62 + * Note: 63 + * Celleb epci uses cfg_data as a base address for 64 + * configuration area for epci devices. 65 + */ 66 + 67 + return hose->cfg_data; 68 + } 46 69 47 70 #if 0 /* test code for epci dummy read */ 48 71 static void celleb_epci_dummy_read(struct pci_dev *dev) 49 72 { 50 - void __iomem *epci_base; 73 + volatile void __iomem *epci_base; 51 74 struct device_node *node; 52 75 struct pci_controller *hose; 53 76 u32 val; ··· 81 58 if (!hose) 82 59 return; 83 60 84 - epci_base = hose->cfg_addr; 61 + epci_base = celleb_epci_get_epci_base(hose); 85 62 86 63 val = in_be32(epci_base + SCC_EPCI_WATRP); 87 64 iosync(); ··· 93 70 static inline void clear_and_disable_master_abort_interrupt( 94 71 struct pci_controller *hose) 95 72 { 96 - void __iomem *addr; 97 - addr = hose->cfg_addr + PCI_COMMAND; 98 - out_be32(addr, in_be32(addr) | (PCI_STATUS_REC_MASTER_ABORT << 16)); 73 + volatile void __iomem *epci_base, *reg; 74 + epci_base = celleb_epci_get_epci_base(hose); 75 + reg = epci_base + PCI_COMMAND; 76 + out_be32(reg, in_be32(reg) | (PCI_STATUS_REC_MASTER_ABORT << 16)); 99 77 } 100 78 101 79 static int celleb_epci_check_abort(struct pci_controller *hose, 102 - void __iomem *addr) 80 + volatile void __iomem *addr) 103 81 { 104 - void __iomem *reg, *epci_base; 82 + volatile void __iomem *reg, *epci_base; 105 83 u32 val; 106 84 107 85 iob(); 108 - epci_base = hose->cfg_addr; 86 + epci_base = celleb_epci_get_epci_base(hose); 109 87 110 88 reg = epci_base + PCI_COMMAND; 111 89 val = in_be32(reg); ··· 132 108 return PCIBIOS_SUCCESSFUL; 133 109 } 134 110 135 - static void __iomem *celleb_epci_make_config_addr(struct pci_controller *hose, 111 + static volatile void __iomem *celleb_epci_make_config_addr( 112 + struct pci_controller *hose, 136 113 unsigned int devfn, int where) 137 114 { 138 - void __iomem *addr; 115 + volatile void __iomem *addr; 139 116 struct pci_bus *bus = hose->bus; 140 117 141 118 if (bus->self) 142 - addr = hose->cfg_data + 119 + addr = celleb_epci_get_epci_cfg(hose) + 143 120 (((bus->number & 0xff) << 16) 144 121 | ((devfn & 0xff) << 8) 145 122 | (where & 0xff) 146 123 | 0x01000000); 147 124 else 148 - addr = hose->cfg_data + 125 + addr = celleb_epci_get_epci_cfg(hose) + 149 126 (((devfn & 0xff) << 8) | (where & 0xff)); 150 127 151 128 pr_debug("EPCI: config_addr = 0x%p\n", addr); ··· 157 132 static int celleb_epci_read_config(struct pci_bus *bus, 158 133 unsigned int devfn, int where, int size, u32 * val) 159 134 { 160 - void __iomem *addr; 135 + volatile void __iomem *epci_base, *addr; 161 136 struct device_node *node; 162 137 struct pci_controller *hose; 163 138 ··· 167 142 node = (struct device_node *)bus->sysdata; 168 143 hose = pci_find_hose_for_OF_device(node); 169 144 170 - if (!hose->cfg_data) 145 + if (!celleb_epci_get_epci_cfg(hose)) 171 146 return PCIBIOS_DEVICE_NOT_FOUND; 172 147 173 148 if (bus->number == hose->first_busno && devfn == 0) { 174 149 /* EPCI controller self */ 175 150 176 - addr = hose->cfg_addr + where; 151 + epci_base = celleb_epci_get_epci_base(hose); 152 + addr = epci_base + where; 177 153 178 154 switch (size) { 179 155 case 1: ··· 211 185 } 212 186 213 187 pr_debug("EPCI: " 214 - "addr=0x%lx, devfn=0x%x, where=0x%x, size=0x%x, val=0x%x\n", 188 + "addr=0x%p, devfn=0x%x, where=0x%x, size=0x%x, val=0x%x\n", 215 189 addr, devfn, where, size, *val); 216 190 217 191 return celleb_epci_check_abort(hose, NULL); ··· 220 194 static int celleb_epci_write_config(struct pci_bus *bus, 221 195 unsigned int devfn, int where, int size, u32 val) 222 196 { 223 - void __iomem *addr; 197 + volatile void __iomem *epci_base, *addr; 224 198 struct device_node *node; 225 199 struct pci_controller *hose; 226 200 ··· 230 204 node = (struct device_node *)bus->sysdata; 231 205 hose = pci_find_hose_for_OF_device(node); 232 206 233 - if (!hose->cfg_data) 207 + 208 + if (!celleb_epci_get_epci_cfg(hose)) 234 209 return PCIBIOS_DEVICE_NOT_FOUND; 235 210 236 211 if (bus->number == hose->first_busno && devfn == 0) { 237 212 /* EPCI controller self */ 238 213 239 - addr = hose->cfg_addr + where; 214 + epci_base = celleb_epci_get_epci_base(hose); 215 + addr = epci_base + where; 240 216 241 217 switch (size) { 242 218 case 1: ··· 286 258 static int __devinit celleb_epci_init(struct pci_controller *hose) 287 259 { 288 260 u32 val; 289 - void __iomem *reg, *epci_base; 261 + volatile void __iomem *reg, *epci_base; 290 262 int hwres = 0; 291 263 292 - epci_base = hose->cfg_addr; 264 + epci_base = celleb_epci_get_epci_base(hose); 293 265 294 266 /* PCI core reset(Internal bus and PCI clock) */ 295 267 reg = epci_base + SCC_EPCI_CKCTRL; ··· 409 381 struct resource r; 410 382 411 383 pr_debug("PCI: celleb_setup_epci()\n"); 384 + 385 + /* 386 + * Note: 387 + * Celleb epci uses cfg_addr and cfg_data member of 388 + * pci_controller structure in irregular way. 389 + * 390 + * cfg_addr is used to map for control registers of 391 + * celleb epci. 392 + * 393 + * cfg_data is used for configuration area of devices 394 + * on Celleb epci buses. 395 + */ 412 396 413 397 if (of_address_to_resource(node, 0, &r)) 414 398 goto error;