blob: e3793c1125c3d82d5cf3db8ae4f225fbbfa0bbe1 [file] [log] [blame]
Tom Rini83d290c2018-05-06 17:58:06 -04001// SPDX-License-Identifier: GPL-2.0+
Jean-Christophe PLAGNIOL-VILLARD86baa082009-05-17 00:58:36 +02002/*
3 * (C) Copyright 2002
4 * Sysgo Real-Time Solutions, GmbH <www.elinos.com>
5 * Marius Groeger <mgroeger@sysgo.de>
6 *
7 * (C) Copyright 2002
8 * David Mueller, ELSOFT AG, <d.mueller@elsoft.ch>
9 *
10 * (C) Copyright 2003
11 * Texas Instruments, <www.ti.com>
12 * Kshitij Gupta <Kshitij@ti.com>
13 *
14 * (C) Copyright 2004
15 * ARM Ltd.
16 * Philippe Robin, <philippe.robin@arm.com>
17 *
Linus Walleij24587162012-01-30 13:49:34 +000018 * (C) Copyright 2011
19 * Linaro
20 * Linus Walleij <linus.walleij@linaro.org>
Jean-Christophe PLAGNIOL-VILLARD86baa082009-05-17 00:58:36 +020021 */
Jean-Christophe PLAGNIOL-VILLARD86baa082009-05-17 00:58:36 +020022#include <common.h>
Simon Glass2cf431c2019-11-14 12:57:47 -070023#include <init.h>
Simon Glassf7ae49f2020-05-10 11:40:05 -060024#include <log.h>
Jean-Christophe PLAGNIOL-VILLARD86baa082009-05-17 00:58:36 +020025#include <pci.h>
Linus Walleij24587162012-01-30 13:49:34 +000026#include <asm/io.h>
27#include "integrator-sc.h"
28#include "pci_v3.h"
29
30#define INTEGRATOR_BOOT_ROM_BASE 0x20000000
31#define INTEGRATOR_HDR0_SDRAM_BASE 0x80000000
32
33/*
34 * These are in the physical addresses on the CPU side, i.e.
35 * where we read and write stuff - you don't want to try to
36 * move these around
37 */
38#define PHYS_PCI_MEM_BASE 0x40000000
39#define PHYS_PCI_IO_BASE 0x60000000 /* PCI I/O space base */
40#define PHYS_PCI_CONFIG_BASE 0x61000000
41#define PHYS_PCI_V3_BASE 0x62000000 /* V360EPC registers */
42#define SZ_256M 0x10000000
43
44/*
45 * These are in the PCI BUS address space
46 * Set to 0x00000000 in the Linux kernel, 0x40000000 in Boot monitor
47 * we follow the example of the kernel, because that is the address
48 * range that devices actually use - what would they be doing at
49 * 0x40000000?
50 */
51#define PCI_BUS_NONMEM_START 0x00000000
52#define PCI_BUS_NONMEM_SIZE SZ_256M
53
54#define PCI_BUS_PREMEM_START (PCI_BUS_NONMEM_START + PCI_BUS_NONMEM_SIZE)
55#define PCI_BUS_PREMEM_SIZE SZ_256M
56
57#if PCI_BUS_NONMEM_START & 0x000fffff
58#error PCI_BUS_NONMEM_START must be megabyte aligned
59#endif
60#if PCI_BUS_PREMEM_START & 0x000fffff
61#error PCI_BUS_PREMEM_START must be megabyte aligned
62#endif
Jean-Christophe PLAGNIOL-VILLARD86baa082009-05-17 00:58:36 +020063
64/*
65 * Initialize PCI Devices, report devices found.
66 */
67
68#ifndef CONFIG_PCI_PNP
Linus Walleij24587162012-01-30 13:49:34 +000069#define PCI_ENET0_IOADDR 0x60000000 /* First card in PCI I/O space */
70#define PCI_ENET0_MEMADDR 0x40000000 /* First card in PCI memory space */
Jean-Christophe PLAGNIOL-VILLARD86baa082009-05-17 00:58:36 +020071static struct pci_config_table pci_integrator_config_table[] = {
72 { PCI_ANY_ID, PCI_ANY_ID, PCI_ANY_ID, PCI_ANY_ID, 0x0f, PCI_ANY_ID,
73 pci_cfgfunc_config_device, { PCI_ENET0_IOADDR,
74 PCI_ENET0_MEMADDR,
75 PCI_COMMAND_MEMORY | PCI_COMMAND_MASTER }},
76 { }
77};
78#endif /* CONFIG_PCI_PNP */
79
80/* V3 access routines */
Linus Walleij24587162012-01-30 13:49:34 +000081#define v3_writeb(o, v) __raw_writeb(v, PHYS_PCI_V3_BASE + (unsigned int)(o))
82#define v3_readb(o) (__raw_readb(PHYS_PCI_V3_BASE + (unsigned int)(o)))
Jean-Christophe PLAGNIOL-VILLARD86baa082009-05-17 00:58:36 +020083
Linus Walleij24587162012-01-30 13:49:34 +000084#define v3_writew(o, v) __raw_writew(v, PHYS_PCI_V3_BASE + (unsigned int)(o))
85#define v3_readw(o) (__raw_readw(PHYS_PCI_V3_BASE + (unsigned int)(o)))
Jean-Christophe PLAGNIOL-VILLARD86baa082009-05-17 00:58:36 +020086
Linus Walleij24587162012-01-30 13:49:34 +000087#define v3_writel(o, v) __raw_writel(v, PHYS_PCI_V3_BASE + (unsigned int)(o))
88#define v3_readl(o) (__raw_readl(PHYS_PCI_V3_BASE + (unsigned int)(o)))
Jean-Christophe PLAGNIOL-VILLARD86baa082009-05-17 00:58:36 +020089
Linus Walleij24587162012-01-30 13:49:34 +000090static unsigned long v3_open_config_window(pci_dev_t bdf, int offset)
Jean-Christophe PLAGNIOL-VILLARD86baa082009-05-17 00:58:36 +020091{
Linus Walleij24587162012-01-30 13:49:34 +000092 unsigned int address, mapaddress;
93 unsigned int busnr = PCI_BUS(bdf);
94 unsigned int devfn = PCI_FUNC(bdf);
Jean-Christophe PLAGNIOL-VILLARD86baa082009-05-17 00:58:36 +020095
Linus Walleij24587162012-01-30 13:49:34 +000096 /*
97 * Trap out illegal values
98 */
99 if (offset > 255)
100 BUG();
101 if (busnr > 255)
102 BUG();
103 if (devfn > 255)
104 BUG();
105
106 if (busnr == 0) {
107 /*
108 * Linux calls the thing U-Boot calls "DEV" "SLOT"
109 * instead, but it's the same 5 bits
110 */
111 int slot = PCI_DEV(bdf);
112
113 /*
114 * local bus segment so need a type 0 config cycle
115 *
116 * build the PCI configuration "address" with one-hot in
117 * A31-A11
118 *
119 * mapaddress:
120 * 3:1 = config cycle (101)
121 * 0 = PCI A1 & A0 are 0 (0)
122 */
123 address = PCI_FUNC(bdf) << 8;
124 mapaddress = V3_LB_MAP_TYPE_CONFIG;
125
126 if (slot > 12)
127 /*
128 * high order bits are handled by the MAP register
129 */
130 mapaddress |= 1 << (slot - 5);
131 else
132 /*
133 * low order bits handled directly in the address
134 */
135 address |= 1 << (slot + 11);
136 } else {
137 /*
138 * not the local bus segment so need a type 1 config cycle
139 *
140 * address:
141 * 23:16 = bus number
142 * 15:11 = slot number (7:3 of devfn)
143 * 10:8 = func number (2:0 of devfn)
144 *
145 * mapaddress:
146 * 3:1 = config cycle (101)
147 * 0 = PCI A1 & A0 from host bus (1)
148 */
149 mapaddress = V3_LB_MAP_TYPE_CONFIG | V3_LB_MAP_AD_LOW_EN;
150 address = (busnr << 16) | (devfn << 8);
151 }
152
153 /*
154 * Set up base0 to see all 512Mbytes of memory space (not
155 * prefetchable), this frees up base1 for re-use by
156 * configuration memory
157 */
158 v3_writel(V3_LB_BASE0, v3_addr_to_lb_base(PHYS_PCI_MEM_BASE) |
159 V3_LB_BASE_ADR_SIZE_512MB | V3_LB_BASE_ENABLE);
160
161 /*
162 * Set up base1/map1 to point into configuration space.
163 */
164 v3_writel(V3_LB_BASE1, v3_addr_to_lb_base(PHYS_PCI_CONFIG_BASE) |
165 V3_LB_BASE_ADR_SIZE_16MB | V3_LB_BASE_ENABLE);
166 v3_writew(V3_LB_MAP1, mapaddress);
167
168 return PHYS_PCI_CONFIG_BASE + address + offset;
169}
170
171static void v3_close_config_window(void)
172{
173 /*
174 * Reassign base1 for use by prefetchable PCI memory
175 */
176 v3_writel(V3_LB_BASE1, v3_addr_to_lb_base(PHYS_PCI_MEM_BASE + SZ_256M) |
177 V3_LB_BASE_ADR_SIZE_256MB | V3_LB_BASE_PREFETCH |
178 V3_LB_BASE_ENABLE);
179 v3_writew(V3_LB_MAP1, v3_addr_to_lb_map(PCI_BUS_PREMEM_START) |
180 V3_LB_MAP_TYPE_MEM_MULTIPLE);
181
182 /*
183 * And shrink base0 back to a 256M window (NOTE: MAP0 already correct)
184 */
185 v3_writel(V3_LB_BASE0, v3_addr_to_lb_base(PHYS_PCI_MEM_BASE) |
186 V3_LB_BASE_ADR_SIZE_256MB | V3_LB_BASE_ENABLE);
187}
188
189static int pci_integrator_read_byte(struct pci_controller *hose, pci_dev_t bdf,
190 int offset, unsigned char *val)
191{
192 unsigned long addr;
193
194 addr = v3_open_config_window(bdf, offset);
195 *val = __raw_readb(addr);
196 v3_close_config_window();
Jean-Christophe PLAGNIOL-VILLARD86baa082009-05-17 00:58:36 +0200197 return 0;
198}
199
Linus Walleij24587162012-01-30 13:49:34 +0000200static int pci_integrator_read__word(struct pci_controller *hose,
201 pci_dev_t bdf, int offset,
202 unsigned short *val)
Jean-Christophe PLAGNIOL-VILLARD86baa082009-05-17 00:58:36 +0200203{
Linus Walleij24587162012-01-30 13:49:34 +0000204 unsigned long addr;
Jean-Christophe PLAGNIOL-VILLARD86baa082009-05-17 00:58:36 +0200205
Linus Walleij24587162012-01-30 13:49:34 +0000206 addr = v3_open_config_window(bdf, offset);
207 *val = __raw_readw(addr);
208 v3_close_config_window();
Jean-Christophe PLAGNIOL-VILLARD86baa082009-05-17 00:58:36 +0200209 return 0;
210}
211
Linus Walleij24587162012-01-30 13:49:34 +0000212static int pci_integrator_read_dword(struct pci_controller *hose,
213 pci_dev_t bdf, int offset,
214 unsigned int *val)
Jean-Christophe PLAGNIOL-VILLARD86baa082009-05-17 00:58:36 +0200215{
Linus Walleij24587162012-01-30 13:49:34 +0000216 unsigned long addr;
Jean-Christophe PLAGNIOL-VILLARD86baa082009-05-17 00:58:36 +0200217
Linus Walleij24587162012-01-30 13:49:34 +0000218 addr = v3_open_config_window(bdf, offset);
219 *val = __raw_readl(addr);
220 v3_close_config_window();
Jean-Christophe PLAGNIOL-VILLARD86baa082009-05-17 00:58:36 +0200221 return 0;
222}
223
Linus Walleij24587162012-01-30 13:49:34 +0000224static int pci_integrator_write_byte(struct pci_controller *hose,
225 pci_dev_t bdf, int offset,
226 unsigned char val)
Jean-Christophe PLAGNIOL-VILLARD86baa082009-05-17 00:58:36 +0200227{
Linus Walleij24587162012-01-30 13:49:34 +0000228 unsigned long addr;
Jean-Christophe PLAGNIOL-VILLARD86baa082009-05-17 00:58:36 +0200229
Linus Walleij24587162012-01-30 13:49:34 +0000230 addr = v3_open_config_window(bdf, offset);
231 __raw_writeb((u8)val, addr);
232 __raw_readb(addr);
233 v3_close_config_window();
Jean-Christophe PLAGNIOL-VILLARD86baa082009-05-17 00:58:36 +0200234 return 0;
235}
236
Linus Walleij24587162012-01-30 13:49:34 +0000237static int pci_integrator_write_word(struct pci_controller *hose,
238 pci_dev_t bdf, int offset,
239 unsigned short val)
Jean-Christophe PLAGNIOL-VILLARD86baa082009-05-17 00:58:36 +0200240{
Linus Walleij24587162012-01-30 13:49:34 +0000241 unsigned long addr;
Jean-Christophe PLAGNIOL-VILLARD86baa082009-05-17 00:58:36 +0200242
Linus Walleij24587162012-01-30 13:49:34 +0000243 addr = v3_open_config_window(bdf, offset);
244 __raw_writew((u8)val, addr);
245 __raw_readw(addr);
246 v3_close_config_window();
Jean-Christophe PLAGNIOL-VILLARD86baa082009-05-17 00:58:36 +0200247 return 0;
248}
249
Linus Walleij24587162012-01-30 13:49:34 +0000250static int pci_integrator_write_dword(struct pci_controller *hose,
251 pci_dev_t bdf, int offset,
252 unsigned int val)
Jean-Christophe PLAGNIOL-VILLARD86baa082009-05-17 00:58:36 +0200253{
Linus Walleij24587162012-01-30 13:49:34 +0000254 unsigned long addr;
Jean-Christophe PLAGNIOL-VILLARD86baa082009-05-17 00:58:36 +0200255
Linus Walleij24587162012-01-30 13:49:34 +0000256 addr = v3_open_config_window(bdf, offset);
257 __raw_writel((u8)val, addr);
258 __raw_readl(addr);
259 v3_close_config_window();
Jean-Christophe PLAGNIOL-VILLARD86baa082009-05-17 00:58:36 +0200260 return 0;
261}
Jean-Christophe PLAGNIOL-VILLARD86baa082009-05-17 00:58:36 +0200262
263struct pci_controller integrator_hose = {
264#ifndef CONFIG_PCI_PNP
265 config_table: pci_integrator_config_table,
266#endif
267};
268
Linus Walleij24587162012-01-30 13:49:34 +0000269void pci_init_board(void)
Jean-Christophe PLAGNIOL-VILLARD86baa082009-05-17 00:58:36 +0200270{
Jean-Christophe PLAGNIOL-VILLARD86baa082009-05-17 00:58:36 +0200271 struct pci_controller *hose = &integrator_hose;
Linus Walleij24587162012-01-30 13:49:34 +0000272 u16 val;
Jean-Christophe PLAGNIOL-VILLARD86baa082009-05-17 00:58:36 +0200273
274 /* setting this register will take the V3 out of reset */
Linus Walleij24587162012-01-30 13:49:34 +0000275 __raw_writel(SC_PCI_PCIEN, SC_PCI);
Jean-Christophe PLAGNIOL-VILLARD86baa082009-05-17 00:58:36 +0200276
Linus Walleijfca94c32012-03-03 21:21:13 +0100277 /* Wait for 230 ms (from spec) before accessing any V3 registers */
278 mdelay(230);
Jean-Christophe PLAGNIOL-VILLARD86baa082009-05-17 00:58:36 +0200279
Linus Walleij24587162012-01-30 13:49:34 +0000280 /* Now write the Base I/O Address Word to PHYS_PCI_V3_BASE + 0x6E */
281 v3_writew(V3_LB_IO_BASE, (PHYS_PCI_V3_BASE >> 16));
Jean-Christophe PLAGNIOL-VILLARD86baa082009-05-17 00:58:36 +0200282
Linus Walleij24587162012-01-30 13:49:34 +0000283 /* Wait for the mailbox to settle */
Jean-Christophe PLAGNIOL-VILLARD86baa082009-05-17 00:58:36 +0200284 do {
Linus Walleij24587162012-01-30 13:49:34 +0000285 v3_writeb(V3_MAIL_DATA, 0xAA);
286 v3_writeb(V3_MAIL_DATA + 4, 0x55);
287 } while (v3_readb(V3_MAIL_DATA) != 0xAA ||
288 v3_readb(V3_MAIL_DATA + 4) != 0x55);
Jean-Christophe PLAGNIOL-VILLARD86baa082009-05-17 00:58:36 +0200289
290 /* Make sure that V3 register access is not locked, if it is, unlock it */
Linus Walleij24587162012-01-30 13:49:34 +0000291 if (v3_readw(V3_SYSTEM) & V3_SYSTEM_M_LOCK)
292 v3_writew(V3_SYSTEM, 0xA05F);
Jean-Christophe PLAGNIOL-VILLARD86baa082009-05-17 00:58:36 +0200293
Linus Walleij24587162012-01-30 13:49:34 +0000294 /*
295 * Ensure that the slave accesses from PCI are disabled while we
296 * setup memory windows
297 */
298 val = v3_readw(V3_PCI_CMD);
299 val &= ~(V3_COMMAND_M_MEM_EN | V3_COMMAND_M_IO_EN);
300 v3_writew(V3_PCI_CMD, val);
Jean-Christophe PLAGNIOL-VILLARD86baa082009-05-17 00:58:36 +0200301
302 /* Clear RST_OUT to 0; keep the PCI bus in reset until we've finished */
Linus Walleij24587162012-01-30 13:49:34 +0000303 val = v3_readw(V3_SYSTEM);
304 val &= ~V3_SYSTEM_M_RST_OUT;
305 v3_writew(V3_SYSTEM, val);
Jean-Christophe PLAGNIOL-VILLARD86baa082009-05-17 00:58:36 +0200306
307 /* Make all accesses from PCI space retry until we're ready for them */
Linus Walleij24587162012-01-30 13:49:34 +0000308 val = v3_readw(V3_PCI_CFG);
309 val |= V3_PCI_CFG_M_RETRY_EN;
310 v3_writew(V3_PCI_CFG, val);
Jean-Christophe PLAGNIOL-VILLARD86baa082009-05-17 00:58:36 +0200311
Linus Walleij24587162012-01-30 13:49:34 +0000312 /*
313 * Set up any V3 PCI Configuration Registers that we absolutely have to.
314 * LB_CFG controls Local Bus protocol.
315 * Enable LocalBus byte strobes for READ accesses too.
316 * set bit 7 BE_IMODE and bit 6 BE_OMODE
317 */
318 val = v3_readw(V3_LB_CFG);
319 val |= 0x0C0;
320 v3_writew(V3_LB_CFG, val);
Jean-Christophe PLAGNIOL-VILLARD86baa082009-05-17 00:58:36 +0200321
Linus Walleij24587162012-01-30 13:49:34 +0000322 /* PCI_CMD controls overall PCI operation. Enable PCI bus master. */
323 val = v3_readw(V3_PCI_CMD);
324 val |= V3_COMMAND_M_MASTER_EN;
325 v3_writew(V3_PCI_CMD, val);
Jean-Christophe PLAGNIOL-VILLARD86baa082009-05-17 00:58:36 +0200326
Linus Walleij24587162012-01-30 13:49:34 +0000327 /*
328 * PCI_MAP0 controls where the PCI to CPU memory window is on
329 * Local Bus
330 */
331 v3_writel(V3_PCI_MAP0,
332 (INTEGRATOR_BOOT_ROM_BASE) | (V3_PCI_MAP_M_ADR_SIZE_512MB |
333 V3_PCI_MAP_M_REG_EN |
334 V3_PCI_MAP_M_ENABLE));
Jean-Christophe PLAGNIOL-VILLARD86baa082009-05-17 00:58:36 +0200335
336 /* PCI_BASE0 is the PCI address of the start of the window */
Linus Walleij24587162012-01-30 13:49:34 +0000337 v3_writel(V3_PCI_BASE0, INTEGRATOR_BOOT_ROM_BASE);
Jean-Christophe PLAGNIOL-VILLARD86baa082009-05-17 00:58:36 +0200338
339 /* PCI_MAP1 is LOCAL address of the start of the window */
Linus Walleij24587162012-01-30 13:49:34 +0000340 v3_writel(V3_PCI_MAP1,
341 (INTEGRATOR_HDR0_SDRAM_BASE) | (V3_PCI_MAP_M_ADR_SIZE_1GB |
342 V3_PCI_MAP_M_REG_EN |
343 V3_PCI_MAP_M_ENABLE));
Jean-Christophe PLAGNIOL-VILLARD86baa082009-05-17 00:58:36 +0200344
345 /* PCI_BASE1 is the PCI address of the start of the window */
Linus Walleij24587162012-01-30 13:49:34 +0000346 v3_writel(V3_PCI_BASE1, INTEGRATOR_HDR0_SDRAM_BASE);
Jean-Christophe PLAGNIOL-VILLARD86baa082009-05-17 00:58:36 +0200347
Linus Walleij24587162012-01-30 13:49:34 +0000348 /*
349 * Set up memory the windows from local bus memory into PCI
350 * configuration, I/O and Memory regions.
351 * PCI I/O, LB_BASE2 and LB_MAP2 are used exclusively for this.
352 */
353 v3_writew(V3_LB_BASE2,
354 v3_addr_to_lb_map(PHYS_PCI_IO_BASE) | V3_LB_BASE_ENABLE);
355 v3_writew(V3_LB_MAP2, 0);
Jean-Christophe PLAGNIOL-VILLARD86baa082009-05-17 00:58:36 +0200356
357 /* PCI Configuration, use LB_BASE1/LB_MAP1. */
358
Linus Walleij24587162012-01-30 13:49:34 +0000359 /*
360 * PCI Memory use LB_BASE0/LB_MAP0 and LB_BASE1/LB_MAP1
361 * Map first 256Mbytes as non-prefetchable via BASE0/MAP0
362 */
363 v3_writel(V3_LB_BASE0, v3_addr_to_lb_base(PHYS_PCI_MEM_BASE) |
364 V3_LB_BASE_ADR_SIZE_256MB | V3_LB_BASE_ENABLE);
365 v3_writew(V3_LB_MAP0,
366 v3_addr_to_lb_map(PCI_BUS_NONMEM_START) | V3_LB_MAP_TYPE_MEM);
Jean-Christophe PLAGNIOL-VILLARD86baa082009-05-17 00:58:36 +0200367
368 /* Map second 256 Mbytes as prefetchable via BASE1/MAP1 */
Linus Walleij24587162012-01-30 13:49:34 +0000369 v3_writel(V3_LB_BASE1, v3_addr_to_lb_base(PHYS_PCI_MEM_BASE + SZ_256M) |
370 V3_LB_BASE_ADR_SIZE_256MB | V3_LB_BASE_PREFETCH |
371 V3_LB_BASE_ENABLE);
372 v3_writew(V3_LB_MAP1, v3_addr_to_lb_map(PCI_BUS_PREMEM_START) |
373 V3_LB_MAP_TYPE_MEM_MULTIPLE);
Jean-Christophe PLAGNIOL-VILLARD86baa082009-05-17 00:58:36 +0200374
Linus Walleij24587162012-01-30 13:49:34 +0000375 /* Dump PCI to local address space mappings */
376 debug("LB_BASE0 = %08x\n", v3_readl(V3_LB_BASE0));
377 debug("LB_MAP0 = %04x\n", v3_readw(V3_LB_MAP0));
378 debug("LB_BASE1 = %08x\n", v3_readl(V3_LB_BASE1));
379 debug("LB_MAP1 = %04x\n", v3_readw(V3_LB_MAP1));
380 debug("LB_BASE2 = %04x\n", v3_readw(V3_LB_BASE2));
381 debug("LB_MAP2 = %04x\n", v3_readw(V3_LB_MAP2));
382 debug("LB_IO_BASE = %04x\n", v3_readw(V3_LB_IO_BASE));
Jean-Christophe PLAGNIOL-VILLARD86baa082009-05-17 00:58:36 +0200383
384 /*
Linus Walleij24587162012-01-30 13:49:34 +0000385 * Allow accesses to PCI Configuration space and set up A1, A0 for
386 * type 1 config cycles
387 */
388 val = v3_readw(V3_PCI_CFG);
389 val &= ~(V3_PCI_CFG_M_RETRY_EN | V3_PCI_CFG_M_AD_LOW1);
390 val |= V3_PCI_CFG_M_AD_LOW0;
391 v3_writew(V3_PCI_CFG, val);
392
393 /* now we can allow incoming PCI MEMORY accesses */
394 val = v3_readw(V3_PCI_CMD);
395 val |= V3_COMMAND_M_MEM_EN;
396 v3_writew(V3_PCI_CMD, val);
397
398 /*
399 * Set RST_OUT to take the PCI bus is out of reset, PCI devices can
400 * now initialise.
401 */
402 val = v3_readw(V3_SYSTEM);
403 val |= V3_SYSTEM_M_RST_OUT;
404 v3_writew(V3_SYSTEM, val);
405
406 /* Lock the V3 system register so that no one else can play with it */
407 val = v3_readw(V3_SYSTEM);
408 val |= V3_SYSTEM_M_LOCK;
409 v3_writew(V3_SYSTEM, val);
410
411 /*
412 * Configure and register the PCI hose
Jean-Christophe PLAGNIOL-VILLARD86baa082009-05-17 00:58:36 +0200413 */
414 hose->first_busno = 0;
415 hose->last_busno = 0xff;
416
Linus Walleij24587162012-01-30 13:49:34 +0000417 /* System memory space, window 0 256 MB non-prefetchable */
418 pci_set_region(hose->regions + 0,
419 PCI_BUS_NONMEM_START, PHYS_PCI_MEM_BASE,
420 SZ_256M,
421 PCI_REGION_MEM);
Jean-Christophe PLAGNIOL-VILLARD86baa082009-05-17 00:58:36 +0200422
Linus Walleij24587162012-01-30 13:49:34 +0000423 /* System memory space, window 1 256 MB prefetchable */
424 pci_set_region(hose->regions + 1,
425 PCI_BUS_PREMEM_START, PHYS_PCI_MEM_BASE + SZ_256M,
426 SZ_256M,
427 PCI_REGION_MEM |
428 PCI_REGION_PREFETCH);
Jean-Christophe PLAGNIOL-VILLARD86baa082009-05-17 00:58:36 +0200429
430 /* PCI I/O space */
Linus Walleij24587162012-01-30 13:49:34 +0000431 pci_set_region(hose->regions + 2,
432 0x00000000, PHYS_PCI_IO_BASE, 0x01000000,
433 PCI_REGION_IO);
Jean-Christophe PLAGNIOL-VILLARD86baa082009-05-17 00:58:36 +0200434
Linus Walleij24587162012-01-30 13:49:34 +0000435 /* PCI Memory - config space */
436 pci_set_region(hose->regions + 3,
437 0x00000000, PHYS_PCI_CONFIG_BASE, 0x01000000,
438 PCI_REGION_MEM);
439 /* PCI V3 regs */
440 pci_set_region(hose->regions + 4,
441 0x00000000, PHYS_PCI_V3_BASE, 0x01000000,
442 PCI_REGION_MEM);
Jean-Christophe PLAGNIOL-VILLARD86baa082009-05-17 00:58:36 +0200443
Linus Walleij24587162012-01-30 13:49:34 +0000444 hose->region_count = 5;
Jean-Christophe PLAGNIOL-VILLARD86baa082009-05-17 00:58:36 +0200445
Linus Walleij24587162012-01-30 13:49:34 +0000446 pci_set_ops(hose,
447 pci_integrator_read_byte,
448 pci_integrator_read__word,
449 pci_integrator_read_dword,
450 pci_integrator_write_byte,
451 pci_integrator_write_word,
452 pci_integrator_write_dword);
Jean-Christophe PLAGNIOL-VILLARD86baa082009-05-17 00:58:36 +0200453
Linus Walleij24587162012-01-30 13:49:34 +0000454 pci_register_hose(hose);
Jean-Christophe PLAGNIOL-VILLARD86baa082009-05-17 00:58:36 +0200455
Linus Walleij24587162012-01-30 13:49:34 +0000456 pciauto_config_init(hose);
457 pciauto_config_device(hose, 0);
458
459 hose->last_busno = pci_hose_scan(hose);
Jean-Christophe PLAGNIOL-VILLARD86baa082009-05-17 00:58:36 +0200460}