wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 1 | /* |
Stefan Roese | a47a12b | 2010-04-15 16:07:28 +0200 | [diff] [blame] | 2 | * arch/powerpc/kernel/pci_auto.c |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 3 | * |
| 4 | * PCI autoconfiguration library |
| 5 | * |
| 6 | * Author: Matt Porter <mporter@mvista.com> |
| 7 | * |
| 8 | * Copyright 2000 MontaVista Software Inc. |
| 9 | * |
Wolfgang Denk | 1a45966 | 2013-07-08 09:37:19 +0200 | [diff] [blame] | 10 | * SPDX-License-Identifier: GPL-2.0+ |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 11 | */ |
| 12 | |
| 13 | #include <common.h> |
Simon Glass | 4a2708a | 2015-01-14 21:37:04 -0700 | [diff] [blame] | 14 | #include <errno.h> |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 15 | #include <pci.h> |
| 16 | |
Jean-Christophe PLAGNIOL-VILLARD | 6d0f6bc | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 17 | /* the user can define CONFIG_SYS_PCI_CACHE_LINE_SIZE to avoid problems */ |
| 18 | #ifndef CONFIG_SYS_PCI_CACHE_LINE_SIZE |
| 19 | #define CONFIG_SYS_PCI_CACHE_LINE_SIZE 8 |
Gary Jennejohn | 81b73de | 2007-08-31 15:21:46 +0200 | [diff] [blame] | 20 | #endif |
| 21 | |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 22 | /* |
| 23 | * |
| 24 | */ |
| 25 | |
Andrew Sharp | cb2bf93 | 2012-08-29 14:16:29 +0000 | [diff] [blame] | 26 | void pciauto_region_init(struct pci_region *res) |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 27 | { |
Sergei Shtylyov | b7598a4 | 2007-04-23 15:30:39 +0200 | [diff] [blame] | 28 | /* |
| 29 | * Avoid allocating PCI resources from address 0 -- this is illegal |
| 30 | * according to PCI 2.1 and moreover, this is known to cause Linux IDE |
| 31 | * drivers to fail. Use a reasonable starting value of 0x1000 instead. |
| 32 | */ |
| 33 | res->bus_lower = res->bus_start ? res->bus_start : 0x1000; |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 34 | } |
| 35 | |
Kumar Gala | 30e76d5 | 2008-10-21 08:36:08 -0500 | [diff] [blame] | 36 | void pciauto_region_align(struct pci_region *res, pci_size_t size) |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 37 | { |
| 38 | res->bus_lower = ((res->bus_lower - 1) | (size - 1)) + 1; |
| 39 | } |
| 40 | |
Andrew Sharp | cb2bf93 | 2012-08-29 14:16:29 +0000 | [diff] [blame] | 41 | int pciauto_region_allocate(struct pci_region *res, pci_size_t size, |
| 42 | pci_addr_t *bar) |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 43 | { |
Kumar Gala | 30e76d5 | 2008-10-21 08:36:08 -0500 | [diff] [blame] | 44 | pci_addr_t addr; |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 45 | |
wdenk | 3c74e32 | 2004-02-22 23:46:08 +0000 | [diff] [blame] | 46 | if (!res) { |
Simon Glass | da4b159 | 2015-07-31 09:31:33 -0600 | [diff] [blame] | 47 | debug("No resource"); |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 48 | goto error; |
| 49 | } |
| 50 | |
| 51 | addr = ((res->bus_lower - 1) | (size - 1)) + 1; |
| 52 | |
wdenk | 3c74e32 | 2004-02-22 23:46:08 +0000 | [diff] [blame] | 53 | if (addr - res->bus_start + size > res->size) { |
Simon Glass | da4b159 | 2015-07-31 09:31:33 -0600 | [diff] [blame] | 54 | debug("No room in resource"); |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 55 | goto error; |
| 56 | } |
| 57 | |
| 58 | res->bus_lower = addr + size; |
| 59 | |
Simon Glass | da4b159 | 2015-07-31 09:31:33 -0600 | [diff] [blame] | 60 | debug("address=0x%llx bus_lower=0x%llx", (unsigned long long)addr, |
| 61 | (unsigned long long)res->bus_lower); |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 62 | |
| 63 | *bar = addr; |
| 64 | return 0; |
| 65 | |
| 66 | error: |
Kumar Gala | 30e76d5 | 2008-10-21 08:36:08 -0500 | [diff] [blame] | 67 | *bar = (pci_addr_t)-1; |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 68 | return -1; |
| 69 | } |
| 70 | |
| 71 | /* |
| 72 | * |
| 73 | */ |
| 74 | |
| 75 | void pciauto_setup_device(struct pci_controller *hose, |
| 76 | pci_dev_t dev, int bars_num, |
| 77 | struct pci_region *mem, |
Kumar Gala | a179012 | 2006-01-11 13:24:15 -0600 | [diff] [blame] | 78 | struct pci_region *prefetch, |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 79 | struct pci_region *io) |
| 80 | { |
Kumar Gala | cf5787f | 2012-09-19 04:47:36 +0000 | [diff] [blame] | 81 | u32 bar_response; |
Kumar Gala | 30e76d5 | 2008-10-21 08:36:08 -0500 | [diff] [blame] | 82 | pci_size_t bar_size; |
Andrew Sharp | af778c6 | 2012-08-01 12:27:16 +0000 | [diff] [blame] | 83 | u16 cmdstat = 0; |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 84 | int bar, bar_nr = 0; |
Simon Glass | 53292ad | 2015-07-31 09:31:34 -0600 | [diff] [blame] | 85 | #ifndef CONFIG_PCI_ENUM_ONLY |
Bin Meng | 6c89663 | 2015-07-08 13:06:40 +0800 | [diff] [blame] | 86 | u8 header_type; |
| 87 | int rom_addr; |
Andrew Sharp | 69fd2d3 | 2012-08-29 14:16:32 +0000 | [diff] [blame] | 88 | pci_addr_t bar_value; |
| 89 | struct pci_region *bar_res; |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 90 | int found_mem64 = 0; |
Andrew Sharp | 69fd2d3 | 2012-08-29 14:16:32 +0000 | [diff] [blame] | 91 | #endif |
Bin Meng | cdf9f08 | 2015-10-01 00:35:59 -0700 | [diff] [blame^] | 92 | u16 class; |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 93 | |
Andrew Sharp | af778c6 | 2012-08-01 12:27:16 +0000 | [diff] [blame] | 94 | pci_hose_read_config_word(hose, dev, PCI_COMMAND, &cmdstat); |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 95 | cmdstat = (cmdstat & ~(PCI_COMMAND_IO | PCI_COMMAND_MEMORY)) | PCI_COMMAND_MASTER; |
| 96 | |
Andrew Sharp | cb2bf93 | 2012-08-29 14:16:29 +0000 | [diff] [blame] | 97 | for (bar = PCI_BASE_ADDRESS_0; |
| 98 | bar < PCI_BASE_ADDRESS_0 + (bars_num * 4); bar += 4) { |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 99 | /* Tickle the BAR and get the response */ |
Andrew Sharp | 69fd2d3 | 2012-08-29 14:16:32 +0000 | [diff] [blame] | 100 | #ifndef CONFIG_PCI_ENUM_ONLY |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 101 | pci_hose_write_config_dword(hose, dev, bar, 0xffffffff); |
Andrew Sharp | 69fd2d3 | 2012-08-29 14:16:32 +0000 | [diff] [blame] | 102 | #endif |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 103 | pci_hose_read_config_dword(hose, dev, bar, &bar_response); |
| 104 | |
| 105 | /* If BAR is not implemented go to the next BAR */ |
| 106 | if (!bar_response) |
| 107 | continue; |
| 108 | |
Andrew Sharp | 69fd2d3 | 2012-08-29 14:16:32 +0000 | [diff] [blame] | 109 | #ifndef CONFIG_PCI_ENUM_ONLY |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 110 | found_mem64 = 0; |
Andrew Sharp | 69fd2d3 | 2012-08-29 14:16:32 +0000 | [diff] [blame] | 111 | #endif |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 112 | |
| 113 | /* Check the BAR type and set our address mask */ |
wdenk | 3c74e32 | 2004-02-22 23:46:08 +0000 | [diff] [blame] | 114 | if (bar_response & PCI_BASE_ADDRESS_SPACE) { |
Jin Zhengxiong-R64188 | bd22c2b | 2006-06-27 18:12:02 +0800 | [diff] [blame] | 115 | bar_size = ((~(bar_response & PCI_BASE_ADDRESS_IO_MASK)) |
| 116 | & 0xffff) + 1; |
Andrew Sharp | 69fd2d3 | 2012-08-29 14:16:32 +0000 | [diff] [blame] | 117 | #ifndef CONFIG_PCI_ENUM_ONLY |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 118 | bar_res = io; |
Andrew Sharp | 69fd2d3 | 2012-08-29 14:16:32 +0000 | [diff] [blame] | 119 | #endif |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 120 | |
Simon Glass | da4b159 | 2015-07-31 09:31:33 -0600 | [diff] [blame] | 121 | debug("PCI Autoconfig: BAR %d, I/O, size=0x%llx, ", |
| 122 | bar_nr, (unsigned long long)bar_size); |
wdenk | 3c74e32 | 2004-02-22 23:46:08 +0000 | [diff] [blame] | 123 | } else { |
Andrew Sharp | cb2bf93 | 2012-08-29 14:16:29 +0000 | [diff] [blame] | 124 | if ((bar_response & PCI_BASE_ADDRESS_MEM_TYPE_MASK) == |
Kumar Gala | 30e76d5 | 2008-10-21 08:36:08 -0500 | [diff] [blame] | 125 | PCI_BASE_ADDRESS_MEM_TYPE_64) { |
| 126 | u32 bar_response_upper; |
| 127 | u64 bar64; |
Andrew Sharp | 69fd2d3 | 2012-08-29 14:16:32 +0000 | [diff] [blame] | 128 | |
| 129 | #ifndef CONFIG_PCI_ENUM_ONLY |
Andrew Sharp | cb2bf93 | 2012-08-29 14:16:29 +0000 | [diff] [blame] | 130 | pci_hose_write_config_dword(hose, dev, bar + 4, |
| 131 | 0xffffffff); |
Andrew Sharp | 69fd2d3 | 2012-08-29 14:16:32 +0000 | [diff] [blame] | 132 | #endif |
Andrew Sharp | cb2bf93 | 2012-08-29 14:16:29 +0000 | [diff] [blame] | 133 | pci_hose_read_config_dword(hose, dev, bar + 4, |
| 134 | &bar_response_upper); |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 135 | |
Kumar Gala | 30e76d5 | 2008-10-21 08:36:08 -0500 | [diff] [blame] | 136 | bar64 = ((u64)bar_response_upper << 32) | bar_response; |
| 137 | |
| 138 | bar_size = ~(bar64 & PCI_BASE_ADDRESS_MEM_MASK) + 1; |
Andrew Sharp | 69fd2d3 | 2012-08-29 14:16:32 +0000 | [diff] [blame] | 139 | #ifndef CONFIG_PCI_ENUM_ONLY |
Kumar Gala | 30e76d5 | 2008-10-21 08:36:08 -0500 | [diff] [blame] | 140 | found_mem64 = 1; |
Andrew Sharp | 69fd2d3 | 2012-08-29 14:16:32 +0000 | [diff] [blame] | 141 | #endif |
Kumar Gala | 30e76d5 | 2008-10-21 08:36:08 -0500 | [diff] [blame] | 142 | } else { |
| 143 | bar_size = (u32)(~(bar_response & PCI_BASE_ADDRESS_MEM_MASK) + 1); |
| 144 | } |
Andrew Sharp | 69fd2d3 | 2012-08-29 14:16:32 +0000 | [diff] [blame] | 145 | #ifndef CONFIG_PCI_ENUM_ONLY |
Kumar Gala | a179012 | 2006-01-11 13:24:15 -0600 | [diff] [blame] | 146 | if (prefetch && (bar_response & PCI_BASE_ADDRESS_MEM_PREFETCH)) |
| 147 | bar_res = prefetch; |
| 148 | else |
| 149 | bar_res = mem; |
Andrew Sharp | 69fd2d3 | 2012-08-29 14:16:32 +0000 | [diff] [blame] | 150 | #endif |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 151 | |
Simon Glass | 4bad2e7 | 2015-07-27 15:47:18 -0600 | [diff] [blame] | 152 | debug("PCI Autoconfig: BAR %d, %s, size=0x%llx, ", |
| 153 | bar_nr, bar_res == prefetch ? "Prf" : "Mem", |
| 154 | (unsigned long long)bar_size); |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 155 | } |
| 156 | |
Andrew Sharp | 69fd2d3 | 2012-08-29 14:16:32 +0000 | [diff] [blame] | 157 | #ifndef CONFIG_PCI_ENUM_ONLY |
wdenk | 3c74e32 | 2004-02-22 23:46:08 +0000 | [diff] [blame] | 158 | if (pciauto_region_allocate(bar_res, bar_size, &bar_value) == 0) { |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 159 | /* Write it out and update our limit */ |
Kumar Gala | 30e76d5 | 2008-10-21 08:36:08 -0500 | [diff] [blame] | 160 | pci_hose_write_config_dword(hose, dev, bar, (u32)bar_value); |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 161 | |
wdenk | 3c74e32 | 2004-02-22 23:46:08 +0000 | [diff] [blame] | 162 | if (found_mem64) { |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 163 | bar += 4; |
Kumar Gala | 30e76d5 | 2008-10-21 08:36:08 -0500 | [diff] [blame] | 164 | #ifdef CONFIG_SYS_PCI_64BIT |
| 165 | pci_hose_write_config_dword(hose, dev, bar, (u32)(bar_value>>32)); |
| 166 | #else |
| 167 | /* |
| 168 | * If we are a 64-bit decoder then increment to the |
| 169 | * upper 32 bits of the bar and force it to locate |
| 170 | * in the lower 4GB of memory. |
| 171 | */ |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 172 | pci_hose_write_config_dword(hose, dev, bar, 0x00000000); |
Kumar Gala | 30e76d5 | 2008-10-21 08:36:08 -0500 | [diff] [blame] | 173 | #endif |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 174 | } |
| 175 | |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 176 | } |
Andrew Sharp | 69fd2d3 | 2012-08-29 14:16:32 +0000 | [diff] [blame] | 177 | #endif |
| 178 | cmdstat |= (bar_response & PCI_BASE_ADDRESS_SPACE) ? |
| 179 | PCI_COMMAND_IO : PCI_COMMAND_MEMORY; |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 180 | |
Simon Glass | da4b159 | 2015-07-31 09:31:33 -0600 | [diff] [blame] | 181 | debug("\n"); |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 182 | |
| 183 | bar_nr++; |
| 184 | } |
| 185 | |
Simon Glass | 53292ad | 2015-07-31 09:31:34 -0600 | [diff] [blame] | 186 | #ifndef CONFIG_PCI_ENUM_ONLY |
Bin Meng | 6c89663 | 2015-07-08 13:06:40 +0800 | [diff] [blame] | 187 | /* Configure the expansion ROM address */ |
| 188 | pci_hose_read_config_byte(hose, dev, PCI_HEADER_TYPE, &header_type); |
Bin Meng | 7445435 | 2015-10-07 02:13:18 -0700 | [diff] [blame] | 189 | header_type &= 0x7f; |
Bin Meng | 6c89663 | 2015-07-08 13:06:40 +0800 | [diff] [blame] | 190 | if (header_type != PCI_HEADER_TYPE_CARDBUS) { |
| 191 | rom_addr = (header_type == PCI_HEADER_TYPE_NORMAL) ? |
| 192 | PCI_ROM_ADDRESS : PCI_ROM_ADDRESS1; |
| 193 | pci_hose_write_config_dword(hose, dev, rom_addr, 0xfffffffe); |
| 194 | pci_hose_read_config_dword(hose, dev, rom_addr, &bar_response); |
| 195 | if (bar_response) { |
| 196 | bar_size = -(bar_response & ~1); |
Simon Glass | da4b159 | 2015-07-31 09:31:33 -0600 | [diff] [blame] | 197 | debug("PCI Autoconfig: ROM, size=%#x, ", |
| 198 | (unsigned int)bar_size); |
Bin Meng | 6c89663 | 2015-07-08 13:06:40 +0800 | [diff] [blame] | 199 | if (pciauto_region_allocate(mem, bar_size, |
| 200 | &bar_value) == 0) { |
| 201 | pci_hose_write_config_dword(hose, dev, rom_addr, |
| 202 | bar_value); |
| 203 | } |
| 204 | cmdstat |= PCI_COMMAND_MEMORY; |
Simon Glass | da4b159 | 2015-07-31 09:31:33 -0600 | [diff] [blame] | 205 | debug("\n"); |
Bin Meng | 6c89663 | 2015-07-08 13:06:40 +0800 | [diff] [blame] | 206 | } |
| 207 | } |
Simon Glass | 53292ad | 2015-07-31 09:31:34 -0600 | [diff] [blame] | 208 | #endif |
Bin Meng | 6c89663 | 2015-07-08 13:06:40 +0800 | [diff] [blame] | 209 | |
Bin Meng | cdf9f08 | 2015-10-01 00:35:59 -0700 | [diff] [blame^] | 210 | /* PCI_COMMAND_IO must be set for VGA device */ |
| 211 | pci_hose_read_config_word(hose, dev, PCI_CLASS_DEVICE, &class); |
| 212 | if (class == PCI_CLASS_DISPLAY_VGA) |
| 213 | cmdstat |= PCI_COMMAND_IO; |
| 214 | |
Andrew Sharp | af778c6 | 2012-08-01 12:27:16 +0000 | [diff] [blame] | 215 | pci_hose_write_config_word(hose, dev, PCI_COMMAND, cmdstat); |
Gary Jennejohn | 81b73de | 2007-08-31 15:21:46 +0200 | [diff] [blame] | 216 | pci_hose_write_config_byte(hose, dev, PCI_CACHE_LINE_SIZE, |
Jean-Christophe PLAGNIOL-VILLARD | 6d0f6bc | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 217 | CONFIG_SYS_PCI_CACHE_LINE_SIZE); |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 218 | pci_hose_write_config_byte(hose, dev, PCI_LATENCY_TIMER, 0x80); |
| 219 | } |
| 220 | |
Ed Swarthout | ba5feb1 | 2007-07-11 14:51:48 -0500 | [diff] [blame] | 221 | void pciauto_prescan_setup_bridge(struct pci_controller *hose, |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 222 | pci_dev_t dev, int sub_bus) |
| 223 | { |
Bin Meng | d11d9ef | 2015-07-19 00:20:06 +0800 | [diff] [blame] | 224 | struct pci_region *pci_mem; |
| 225 | struct pci_region *pci_prefetch; |
| 226 | struct pci_region *pci_io; |
David Feng | 6eefd52 | 2015-02-02 16:53:13 +0800 | [diff] [blame] | 227 | u16 cmdstat, prefechable_64; |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 228 | |
Bin Meng | d11d9ef | 2015-07-19 00:20:06 +0800 | [diff] [blame] | 229 | #ifdef CONFIG_DM_PCI |
| 230 | /* The root controller has the region information */ |
| 231 | struct pci_controller *ctlr_hose = pci_bus_to_hose(0); |
| 232 | |
| 233 | pci_mem = ctlr_hose->pci_mem; |
| 234 | pci_prefetch = ctlr_hose->pci_prefetch; |
| 235 | pci_io = ctlr_hose->pci_io; |
| 236 | #else |
| 237 | pci_mem = hose->pci_mem; |
| 238 | pci_prefetch = hose->pci_prefetch; |
| 239 | pci_io = hose->pci_io; |
| 240 | #endif |
| 241 | |
Andrew Sharp | af778c6 | 2012-08-01 12:27:16 +0000 | [diff] [blame] | 242 | pci_hose_read_config_word(hose, dev, PCI_COMMAND, &cmdstat); |
David Feng | 6eefd52 | 2015-02-02 16:53:13 +0800 | [diff] [blame] | 243 | pci_hose_read_config_word(hose, dev, PCI_PREF_MEMORY_BASE, |
| 244 | &prefechable_64); |
| 245 | prefechable_64 &= PCI_PREF_RANGE_TYPE_MASK; |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 246 | |
| 247 | /* Configure bus number registers */ |
Bin Meng | 95f3aa2 | 2015-07-19 00:20:03 +0800 | [diff] [blame] | 248 | #ifdef CONFIG_DM_PCI |
| 249 | pci_hose_write_config_byte(hose, dev, PCI_PRIMARY_BUS, PCI_BUS(dev)); |
| 250 | pci_hose_write_config_byte(hose, dev, PCI_SECONDARY_BUS, sub_bus); |
| 251 | #else |
Ed Swarthout | e8b85f3 | 2007-07-11 14:52:08 -0500 | [diff] [blame] | 252 | pci_hose_write_config_byte(hose, dev, PCI_PRIMARY_BUS, |
| 253 | PCI_BUS(dev) - hose->first_busno); |
| 254 | pci_hose_write_config_byte(hose, dev, PCI_SECONDARY_BUS, |
| 255 | sub_bus - hose->first_busno); |
Bin Meng | 95f3aa2 | 2015-07-19 00:20:03 +0800 | [diff] [blame] | 256 | #endif |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 257 | pci_hose_write_config_byte(hose, dev, PCI_SUBORDINATE_BUS, 0xff); |
| 258 | |
wdenk | 3c74e32 | 2004-02-22 23:46:08 +0000 | [diff] [blame] | 259 | if (pci_mem) { |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 260 | /* Round memory allocator to 1MB boundary */ |
| 261 | pciauto_region_align(pci_mem, 0x100000); |
| 262 | |
| 263 | /* Set up memory and I/O filter limits, assume 32-bit I/O space */ |
| 264 | pci_hose_write_config_word(hose, dev, PCI_MEMORY_BASE, |
| 265 | (pci_mem->bus_lower & 0xfff00000) >> 16); |
| 266 | |
| 267 | cmdstat |= PCI_COMMAND_MEMORY; |
| 268 | } |
| 269 | |
Kumar Gala | a179012 | 2006-01-11 13:24:15 -0600 | [diff] [blame] | 270 | if (pci_prefetch) { |
| 271 | /* Round memory allocator to 1MB boundary */ |
| 272 | pciauto_region_align(pci_prefetch, 0x100000); |
| 273 | |
| 274 | /* Set up memory and I/O filter limits, assume 32-bit I/O space */ |
| 275 | pci_hose_write_config_word(hose, dev, PCI_PREF_MEMORY_BASE, |
| 276 | (pci_prefetch->bus_lower & 0xfff00000) >> 16); |
David Feng | 6eefd52 | 2015-02-02 16:53:13 +0800 | [diff] [blame] | 277 | if (prefechable_64 == PCI_PREF_RANGE_TYPE_64) |
| 278 | #ifdef CONFIG_SYS_PCI_64BIT |
| 279 | pci_hose_write_config_dword(hose, dev, |
| 280 | PCI_PREF_BASE_UPPER32, |
| 281 | pci_prefetch->bus_lower >> 32); |
| 282 | #else |
| 283 | pci_hose_write_config_dword(hose, dev, |
| 284 | PCI_PREF_BASE_UPPER32, |
| 285 | 0x0); |
| 286 | #endif |
Kumar Gala | a179012 | 2006-01-11 13:24:15 -0600 | [diff] [blame] | 287 | |
| 288 | cmdstat |= PCI_COMMAND_MEMORY; |
| 289 | } else { |
| 290 | /* We don't support prefetchable memory for now, so disable */ |
| 291 | pci_hose_write_config_word(hose, dev, PCI_PREF_MEMORY_BASE, 0x1000); |
Matthew McClintock | a4e1155 | 2006-06-28 10:44:23 -0500 | [diff] [blame] | 292 | pci_hose_write_config_word(hose, dev, PCI_PREF_MEMORY_LIMIT, 0x0); |
David Feng | 6eefd52 | 2015-02-02 16:53:13 +0800 | [diff] [blame] | 293 | if (prefechable_64 == PCI_PREF_RANGE_TYPE_64) { |
| 294 | pci_hose_write_config_word(hose, dev, PCI_PREF_BASE_UPPER32, 0x0); |
| 295 | pci_hose_write_config_word(hose, dev, PCI_PREF_LIMIT_UPPER32, 0x0); |
| 296 | } |
Kumar Gala | a179012 | 2006-01-11 13:24:15 -0600 | [diff] [blame] | 297 | } |
| 298 | |
wdenk | 3c74e32 | 2004-02-22 23:46:08 +0000 | [diff] [blame] | 299 | if (pci_io) { |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 300 | /* Round I/O allocator to 4KB boundary */ |
| 301 | pciauto_region_align(pci_io, 0x1000); |
| 302 | |
| 303 | pci_hose_write_config_byte(hose, dev, PCI_IO_BASE, |
| 304 | (pci_io->bus_lower & 0x0000f000) >> 8); |
| 305 | pci_hose_write_config_word(hose, dev, PCI_IO_BASE_UPPER16, |
| 306 | (pci_io->bus_lower & 0xffff0000) >> 16); |
| 307 | |
| 308 | cmdstat |= PCI_COMMAND_IO; |
| 309 | } |
| 310 | |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 311 | /* Enable memory and I/O accesses, enable bus master */ |
Andrew Sharp | af778c6 | 2012-08-01 12:27:16 +0000 | [diff] [blame] | 312 | pci_hose_write_config_word(hose, dev, PCI_COMMAND, |
| 313 | cmdstat | PCI_COMMAND_MASTER); |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 314 | } |
| 315 | |
Ed Swarthout | ba5feb1 | 2007-07-11 14:51:48 -0500 | [diff] [blame] | 316 | void pciauto_postscan_setup_bridge(struct pci_controller *hose, |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 317 | pci_dev_t dev, int sub_bus) |
| 318 | { |
Bin Meng | d11d9ef | 2015-07-19 00:20:06 +0800 | [diff] [blame] | 319 | struct pci_region *pci_mem; |
| 320 | struct pci_region *pci_prefetch; |
| 321 | struct pci_region *pci_io; |
| 322 | |
| 323 | #ifdef CONFIG_DM_PCI |
| 324 | /* The root controller has the region information */ |
| 325 | struct pci_controller *ctlr_hose = pci_bus_to_hose(0); |
| 326 | |
| 327 | pci_mem = ctlr_hose->pci_mem; |
| 328 | pci_prefetch = ctlr_hose->pci_prefetch; |
| 329 | pci_io = ctlr_hose->pci_io; |
| 330 | #else |
| 331 | pci_mem = hose->pci_mem; |
| 332 | pci_prefetch = hose->pci_prefetch; |
| 333 | pci_io = hose->pci_io; |
| 334 | #endif |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 335 | |
| 336 | /* Configure bus number registers */ |
Bin Meng | 95f3aa2 | 2015-07-19 00:20:03 +0800 | [diff] [blame] | 337 | #ifdef CONFIG_DM_PCI |
| 338 | pci_hose_write_config_byte(hose, dev, PCI_SUBORDINATE_BUS, sub_bus); |
| 339 | #else |
Ed Swarthout | e8b85f3 | 2007-07-11 14:52:08 -0500 | [diff] [blame] | 340 | pci_hose_write_config_byte(hose, dev, PCI_SUBORDINATE_BUS, |
| 341 | sub_bus - hose->first_busno); |
Bin Meng | 95f3aa2 | 2015-07-19 00:20:03 +0800 | [diff] [blame] | 342 | #endif |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 343 | |
wdenk | 3c74e32 | 2004-02-22 23:46:08 +0000 | [diff] [blame] | 344 | if (pci_mem) { |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 345 | /* Round memory allocator to 1MB boundary */ |
| 346 | pciauto_region_align(pci_mem, 0x100000); |
| 347 | |
| 348 | pci_hose_write_config_word(hose, dev, PCI_MEMORY_LIMIT, |
Andrew Sharp | cb2bf93 | 2012-08-29 14:16:29 +0000 | [diff] [blame] | 349 | (pci_mem->bus_lower - 1) >> 16); |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 350 | } |
| 351 | |
Kumar Gala | a179012 | 2006-01-11 13:24:15 -0600 | [diff] [blame] | 352 | if (pci_prefetch) { |
David Feng | 6eefd52 | 2015-02-02 16:53:13 +0800 | [diff] [blame] | 353 | u16 prefechable_64; |
| 354 | |
| 355 | pci_hose_read_config_word(hose, dev, |
| 356 | PCI_PREF_MEMORY_LIMIT, |
| 357 | &prefechable_64); |
| 358 | prefechable_64 &= PCI_PREF_RANGE_TYPE_MASK; |
| 359 | |
Kumar Gala | a179012 | 2006-01-11 13:24:15 -0600 | [diff] [blame] | 360 | /* Round memory allocator to 1MB boundary */ |
| 361 | pciauto_region_align(pci_prefetch, 0x100000); |
| 362 | |
| 363 | pci_hose_write_config_word(hose, dev, PCI_PREF_MEMORY_LIMIT, |
Andrew Sharp | cb2bf93 | 2012-08-29 14:16:29 +0000 | [diff] [blame] | 364 | (pci_prefetch->bus_lower - 1) >> 16); |
David Feng | 6eefd52 | 2015-02-02 16:53:13 +0800 | [diff] [blame] | 365 | if (prefechable_64 == PCI_PREF_RANGE_TYPE_64) |
| 366 | #ifdef CONFIG_SYS_PCI_64BIT |
| 367 | pci_hose_write_config_dword(hose, dev, |
| 368 | PCI_PREF_LIMIT_UPPER32, |
| 369 | (pci_prefetch->bus_lower - 1) >> 32); |
| 370 | #else |
| 371 | pci_hose_write_config_dword(hose, dev, |
| 372 | PCI_PREF_LIMIT_UPPER32, |
| 373 | 0x0); |
| 374 | #endif |
Kumar Gala | a179012 | 2006-01-11 13:24:15 -0600 | [diff] [blame] | 375 | } |
| 376 | |
wdenk | 3c74e32 | 2004-02-22 23:46:08 +0000 | [diff] [blame] | 377 | if (pci_io) { |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 378 | /* Round I/O allocator to 4KB boundary */ |
| 379 | pciauto_region_align(pci_io, 0x1000); |
| 380 | |
| 381 | pci_hose_write_config_byte(hose, dev, PCI_IO_LIMIT, |
Andrew Sharp | cb2bf93 | 2012-08-29 14:16:29 +0000 | [diff] [blame] | 382 | ((pci_io->bus_lower - 1) & 0x0000f000) >> 8); |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 383 | pci_hose_write_config_word(hose, dev, PCI_IO_LIMIT_UPPER16, |
Andrew Sharp | cb2bf93 | 2012-08-29 14:16:29 +0000 | [diff] [blame] | 384 | ((pci_io->bus_lower - 1) & 0xffff0000) >> 16); |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 385 | } |
| 386 | } |
| 387 | |
| 388 | /* |
| 389 | * |
| 390 | */ |
| 391 | |
| 392 | void pciauto_config_init(struct pci_controller *hose) |
| 393 | { |
| 394 | int i; |
| 395 | |
Thierry Reding | 010c480 | 2013-09-20 15:50:50 +0200 | [diff] [blame] | 396 | hose->pci_io = hose->pci_mem = hose->pci_prefetch = NULL; |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 397 | |
Andrew Sharp | cb2bf93 | 2012-08-29 14:16:29 +0000 | [diff] [blame] | 398 | for (i = 0; i < hose->region_count; i++) { |
wdenk | 3c74e32 | 2004-02-22 23:46:08 +0000 | [diff] [blame] | 399 | switch(hose->regions[i].flags) { |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 400 | case PCI_REGION_IO: |
| 401 | if (!hose->pci_io || |
| 402 | hose->pci_io->size < hose->regions[i].size) |
| 403 | hose->pci_io = hose->regions + i; |
| 404 | break; |
| 405 | case PCI_REGION_MEM: |
| 406 | if (!hose->pci_mem || |
| 407 | hose->pci_mem->size < hose->regions[i].size) |
| 408 | hose->pci_mem = hose->regions + i; |
| 409 | break; |
Kumar Gala | a179012 | 2006-01-11 13:24:15 -0600 | [diff] [blame] | 410 | case (PCI_REGION_MEM | PCI_REGION_PREFETCH): |
| 411 | if (!hose->pci_prefetch || |
| 412 | hose->pci_prefetch->size < hose->regions[i].size) |
| 413 | hose->pci_prefetch = hose->regions + i; |
| 414 | break; |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 415 | } |
| 416 | } |
| 417 | |
| 418 | |
wdenk | 3c74e32 | 2004-02-22 23:46:08 +0000 | [diff] [blame] | 419 | if (hose->pci_mem) { |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 420 | pciauto_region_init(hose->pci_mem); |
| 421 | |
Simon Glass | da4b159 | 2015-07-31 09:31:33 -0600 | [diff] [blame] | 422 | debug("PCI Autoconfig: Bus Memory region: [0x%llx-0x%llx],\n" |
Kumar Gala | 30e76d5 | 2008-10-21 08:36:08 -0500 | [diff] [blame] | 423 | "\t\tPhysical Memory [%llx-%llxx]\n", |
| 424 | (u64)hose->pci_mem->bus_start, |
| 425 | (u64)(hose->pci_mem->bus_start + hose->pci_mem->size - 1), |
| 426 | (u64)hose->pci_mem->phys_start, |
| 427 | (u64)(hose->pci_mem->phys_start + hose->pci_mem->size - 1)); |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 428 | } |
| 429 | |
Kumar Gala | a179012 | 2006-01-11 13:24:15 -0600 | [diff] [blame] | 430 | if (hose->pci_prefetch) { |
| 431 | pciauto_region_init(hose->pci_prefetch); |
| 432 | |
Simon Glass | da4b159 | 2015-07-31 09:31:33 -0600 | [diff] [blame] | 433 | debug("PCI Autoconfig: Bus Prefetchable Mem: [0x%llx-0x%llx],\n" |
Kumar Gala | 30e76d5 | 2008-10-21 08:36:08 -0500 | [diff] [blame] | 434 | "\t\tPhysical Memory [%llx-%llx]\n", |
| 435 | (u64)hose->pci_prefetch->bus_start, |
| 436 | (u64)(hose->pci_prefetch->bus_start + |
| 437 | hose->pci_prefetch->size - 1), |
| 438 | (u64)hose->pci_prefetch->phys_start, |
| 439 | (u64)(hose->pci_prefetch->phys_start + |
| 440 | hose->pci_prefetch->size - 1)); |
Kumar Gala | a179012 | 2006-01-11 13:24:15 -0600 | [diff] [blame] | 441 | } |
| 442 | |
wdenk | 3c74e32 | 2004-02-22 23:46:08 +0000 | [diff] [blame] | 443 | if (hose->pci_io) { |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 444 | pciauto_region_init(hose->pci_io); |
| 445 | |
Simon Glass | da4b159 | 2015-07-31 09:31:33 -0600 | [diff] [blame] | 446 | debug("PCI Autoconfig: Bus I/O region: [0x%llx-0x%llx],\n" |
Kumar Gala | 30e76d5 | 2008-10-21 08:36:08 -0500 | [diff] [blame] | 447 | "\t\tPhysical Memory: [%llx-%llx]\n", |
| 448 | (u64)hose->pci_io->bus_start, |
| 449 | (u64)(hose->pci_io->bus_start + hose->pci_io->size - 1), |
| 450 | (u64)hose->pci_io->phys_start, |
| 451 | (u64)(hose->pci_io->phys_start + hose->pci_io->size - 1)); |
Ed Swarthout | ba5feb1 | 2007-07-11 14:51:48 -0500 | [diff] [blame] | 452 | |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 453 | } |
| 454 | } |
| 455 | |
Andrew Sharp | cb2bf93 | 2012-08-29 14:16:29 +0000 | [diff] [blame] | 456 | /* |
| 457 | * HJF: Changed this to return int. I think this is required |
wdenk | c7de829 | 2002-11-19 11:04:11 +0000 | [diff] [blame] | 458 | * to get the correct result when scanning bridges |
| 459 | */ |
| 460 | int pciauto_config_device(struct pci_controller *hose, pci_dev_t dev) |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 461 | { |
Bin Meng | d11d9ef | 2015-07-19 00:20:06 +0800 | [diff] [blame] | 462 | struct pci_region *pci_mem; |
| 463 | struct pci_region *pci_prefetch; |
| 464 | struct pci_region *pci_io; |
wdenk | c7de829 | 2002-11-19 11:04:11 +0000 | [diff] [blame] | 465 | unsigned int sub_bus = PCI_BUS(dev); |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 466 | unsigned short class; |
wdenk | 5653fc3 | 2004-02-08 22:55:38 +0000 | [diff] [blame] | 467 | int n; |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 468 | |
Bin Meng | d11d9ef | 2015-07-19 00:20:06 +0800 | [diff] [blame] | 469 | #ifdef CONFIG_DM_PCI |
| 470 | /* The root controller has the region information */ |
| 471 | struct pci_controller *ctlr_hose = pci_bus_to_hose(0); |
| 472 | |
| 473 | pci_mem = ctlr_hose->pci_mem; |
| 474 | pci_prefetch = ctlr_hose->pci_prefetch; |
| 475 | pci_io = ctlr_hose->pci_io; |
| 476 | #else |
| 477 | pci_mem = hose->pci_mem; |
| 478 | pci_prefetch = hose->pci_prefetch; |
| 479 | pci_io = hose->pci_io; |
| 480 | #endif |
| 481 | |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 482 | pci_hose_read_config_word(hose, dev, PCI_CLASS_DEVICE, &class); |
| 483 | |
Andrew Sharp | cb2bf93 | 2012-08-29 14:16:29 +0000 | [diff] [blame] | 484 | switch (class) { |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 485 | case PCI_CLASS_BRIDGE_PCI: |
Simon Glass | da4b159 | 2015-07-31 09:31:33 -0600 | [diff] [blame] | 486 | debug("PCI Autoconfig: Found P2P bridge, device %d\n", |
| 487 | PCI_DEV(dev)); |
Simon Glass | ff3e077 | 2015-03-05 12:25:25 -0700 | [diff] [blame] | 488 | |
Bin Meng | d11d9ef | 2015-07-19 00:20:06 +0800 | [diff] [blame] | 489 | pciauto_setup_device(hose, dev, 2, pci_mem, |
| 490 | pci_prefetch, pci_io); |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 491 | |
Simon Glass | ff3e077 | 2015-03-05 12:25:25 -0700 | [diff] [blame] | 492 | #ifdef CONFIG_DM_PCI |
| 493 | n = dm_pci_hose_probe_bus(hose, dev); |
| 494 | if (n < 0) |
| 495 | return n; |
| 496 | sub_bus = (unsigned int)n; |
| 497 | #else |
wdenk | 3c74e32 | 2004-02-22 23:46:08 +0000 | [diff] [blame] | 498 | /* Passing in current_busno allows for sibling P2P bridges */ |
Simon Glass | ff3e077 | 2015-03-05 12:25:25 -0700 | [diff] [blame] | 499 | hose->current_busno++; |
wdenk | 5653fc3 | 2004-02-08 22:55:38 +0000 | [diff] [blame] | 500 | pciauto_prescan_setup_bridge(hose, dev, hose->current_busno); |
wdenk | cd37d9e | 2004-02-10 00:03:41 +0000 | [diff] [blame] | 501 | /* |
wdenk | 3c74e32 | 2004-02-22 23:46:08 +0000 | [diff] [blame] | 502 | * need to figure out if this is a subordinate bridge on the bus |
wdenk | 5653fc3 | 2004-02-08 22:55:38 +0000 | [diff] [blame] | 503 | * to be able to properly set the pri/sec/sub bridge registers. |
| 504 | */ |
| 505 | n = pci_hose_scan_bus(hose, hose->current_busno); |
wdenk | 8bde7f7 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 506 | |
wdenk | 3c74e32 | 2004-02-22 23:46:08 +0000 | [diff] [blame] | 507 | /* figure out the deepest we've gone for this leg */ |
Masahiro Yamada | b414119 | 2014-11-07 03:03:31 +0900 | [diff] [blame] | 508 | sub_bus = max((unsigned int)n, sub_bus); |
wdenk | db2f721f | 2003-03-06 00:58:30 +0000 | [diff] [blame] | 509 | pciauto_postscan_setup_bridge(hose, dev, sub_bus); |
wdenk | 5653fc3 | 2004-02-08 22:55:38 +0000 | [diff] [blame] | 510 | |
wdenk | db2f721f | 2003-03-06 00:58:30 +0000 | [diff] [blame] | 511 | sub_bus = hose->current_busno; |
Simon Glass | ff3e077 | 2015-03-05 12:25:25 -0700 | [diff] [blame] | 512 | #endif |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 513 | break; |
| 514 | |
wdenk | 1cb8e98 | 2003-03-06 21:55:29 +0000 | [diff] [blame] | 515 | case PCI_CLASS_BRIDGE_CARDBUS: |
Andrew Sharp | cb2bf93 | 2012-08-29 14:16:29 +0000 | [diff] [blame] | 516 | /* |
| 517 | * just do a minimal setup of the bridge, |
| 518 | * let the OS take care of the rest |
| 519 | */ |
Bin Meng | d11d9ef | 2015-07-19 00:20:06 +0800 | [diff] [blame] | 520 | pciauto_setup_device(hose, dev, 0, pci_mem, |
| 521 | pci_prefetch, pci_io); |
wdenk | 1cb8e98 | 2003-03-06 21:55:29 +0000 | [diff] [blame] | 522 | |
Simon Glass | da4b159 | 2015-07-31 09:31:33 -0600 | [diff] [blame] | 523 | debug("PCI Autoconfig: Found P2CardBus bridge, device %d\n", |
| 524 | PCI_DEV(dev)); |
wdenk | 1cb8e98 | 2003-03-06 21:55:29 +0000 | [diff] [blame] | 525 | |
Simon Glass | ff3e077 | 2015-03-05 12:25:25 -0700 | [diff] [blame] | 526 | #ifndef CONFIG_DM_PCI |
wdenk | 1cb8e98 | 2003-03-06 21:55:29 +0000 | [diff] [blame] | 527 | hose->current_busno++; |
Simon Glass | ff3e077 | 2015-03-05 12:25:25 -0700 | [diff] [blame] | 528 | #endif |
wdenk | 1cb8e98 | 2003-03-06 21:55:29 +0000 | [diff] [blame] | 529 | break; |
| 530 | |
TsiChung Liew | f33fca2 | 2008-03-30 01:19:06 -0500 | [diff] [blame] | 531 | #if defined(CONFIG_PCIAUTO_SKIP_HOST_BRIDGE) |
wdenk | e0ac62d | 2003-08-17 18:55:18 +0000 | [diff] [blame] | 532 | case PCI_CLASS_BRIDGE_OTHER: |
Simon Glass | da4b159 | 2015-07-31 09:31:33 -0600 | [diff] [blame] | 533 | debug("PCI Autoconfig: Skipping bridge device %d\n", |
| 534 | PCI_DEV(dev)); |
wdenk | e0ac62d | 2003-08-17 18:55:18 +0000 | [diff] [blame] | 535 | break; |
| 536 | #endif |
Reinhard Arlt | c2e49f7 | 2009-07-25 06:19:12 +0200 | [diff] [blame] | 537 | #if defined(CONFIG_MPC834x) && !defined(CONFIG_VME8349) |
Rafal Jaworowski | 6902df5 | 2005-10-17 02:39:53 +0200 | [diff] [blame] | 538 | case PCI_CLASS_BRIDGE_OTHER: |
| 539 | /* |
| 540 | * The host/PCI bridge 1 seems broken in 8349 - it presents |
| 541 | * itself as 'PCI_CLASS_BRIDGE_OTHER' and appears as an _agent_ |
| 542 | * device claiming resources io/mem/irq.. we only allow for |
| 543 | * the PIMMR window to be allocated (BAR0 - 1MB size) |
| 544 | */ |
Simon Glass | da4b159 | 2015-07-31 09:31:33 -0600 | [diff] [blame] | 545 | debug("PCI Autoconfig: Broken bridge found, only minimal config\n"); |
Andrew Sharp | cb2bf93 | 2012-08-29 14:16:29 +0000 | [diff] [blame] | 546 | pciauto_setup_device(hose, dev, 0, hose->pci_mem, |
| 547 | hose->pci_prefetch, hose->pci_io); |
Rafal Jaworowski | 6902df5 | 2005-10-17 02:39:53 +0200 | [diff] [blame] | 548 | break; |
| 549 | #endif |
Andrew Sharp | 69fd2d3 | 2012-08-29 14:16:32 +0000 | [diff] [blame] | 550 | |
| 551 | case PCI_CLASS_PROCESSOR_POWERPC: /* an agent or end-point */ |
Simon Glass | da4b159 | 2015-07-31 09:31:33 -0600 | [diff] [blame] | 552 | debug("PCI AutoConfig: Found PowerPC device\n"); |
Andrew Sharp | 69fd2d3 | 2012-08-29 14:16:32 +0000 | [diff] [blame] | 553 | |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 554 | default: |
Bin Meng | d11d9ef | 2015-07-19 00:20:06 +0800 | [diff] [blame] | 555 | pciauto_setup_device(hose, dev, 6, pci_mem, |
| 556 | pci_prefetch, pci_io); |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 557 | break; |
| 558 | } |
wdenk | c7de829 | 2002-11-19 11:04:11 +0000 | [diff] [blame] | 559 | |
| 560 | return sub_bus; |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 561 | } |