2 * MPC85XX common board code
4 * Maintainer: Kumar Gala <galak@kernel.crashing.org>
6 * Copyright 2004 Freescale Semiconductor Inc.
8 * This program is free software; you can redistribute it and/or modify it
9 * under the terms of the GNU General Public License as published by the
10 * Free Software Foundation; either version 2 of the License, or (at your
11 * option) any later version.
14 #include <linux/config.h>
15 #include <linux/types.h>
16 #include <linux/module.h>
17 #include <linux/init.h>
18 #include <linux/pci.h>
19 #include <linux/serial.h>
20 #include <linux/tty.h> /* for linux/serial_core.h */
21 #include <linux/serial_core.h>
22 #include <linux/serial_8250.h>
25 #include <asm/mpc85xx.h>
26 #include <asm/immap_85xx.h>
28 #include <asm/ppc_sys.h>
30 #include <asm/machdep.h>
32 #include <syslib/ppc85xx_setup.h>
34 extern void abort(void);
36 /* Return the amount of memory */
38 mpc85xx_find_end_of_memory(void)
42 binfo
= (bd_t
*) __res
;
44 return binfo
->bi_memsize
;
47 /* The decrementer counts at the system (internal) clock freq divided by 8 */
49 mpc85xx_calibrate_decr(void)
51 bd_t
*binfo
= (bd_t
*) __res
;
52 unsigned int freq
, divisor
;
54 /* get the core frequency */
55 freq
= binfo
->bi_busfreq
;
57 /* The timebase is updated every 8 bus clocks, HID0[SEL_TBCLK] = 0 */
59 tb_ticks_per_jiffy
= freq
/ divisor
/ HZ
;
60 tb_to_us
= mulhwu_scale_factor(freq
/ divisor
, 1000000);
62 /* Set the time base to zero */
66 /* Clear any pending timer interrupts */
67 mtspr(SPRN_TSR
, TSR_ENW
| TSR_WIS
| TSR_DIS
| TSR_FIS
);
69 /* Enable decrementer interrupt */
70 mtspr(SPRN_TCR
, TCR_DIE
);
73 #ifdef CONFIG_SERIAL_8250
75 mpc85xx_early_serial_map(void)
77 #if defined(CONFIG_SERIAL_TEXT_DEBUG) || defined(CONFIG_KGDB)
78 struct uart_port serial_req
;
80 struct plat_serial8250_port
*pdata
;
81 bd_t
*binfo
= (bd_t
*) __res
;
82 pdata
= (struct plat_serial8250_port
*) ppc_sys_get_pdata(MPC85xx_DUART
);
84 /* Setup serial port access */
85 pdata
[0].uartclk
= binfo
->bi_busfreq
;
86 pdata
[0].mapbase
+= binfo
->bi_immr_base
;
87 pdata
[0].membase
= ioremap(pdata
[0].mapbase
, MPC85xx_UART0_SIZE
);
89 #if defined(CONFIG_SERIAL_TEXT_DEBUG) || defined(CONFIG_KGDB)
90 memset(&serial_req
, 0, sizeof (serial_req
));
91 serial_req
.iotype
= UPIO_MEM
;
92 serial_req
.mapbase
= pdata
[0].mapbase
;
93 serial_req
.membase
= pdata
[0].membase
;
94 serial_req
.regshift
= 0;
96 gen550_init(0, &serial_req
);
99 pdata
[1].uartclk
= binfo
->bi_busfreq
;
100 pdata
[1].mapbase
+= binfo
->bi_immr_base
;
101 pdata
[1].membase
= ioremap(pdata
[1].mapbase
, MPC85xx_UART0_SIZE
);
103 #if defined(CONFIG_SERIAL_TEXT_DEBUG) || defined(CONFIG_KGDB)
104 /* Assume gen550_init() doesn't modify serial_req */
105 serial_req
.mapbase
= pdata
[1].mapbase
;
106 serial_req
.membase
= pdata
[1].membase
;
108 gen550_init(1, &serial_req
);
114 mpc85xx_restart(char *cmd
)
121 mpc85xx_power_off(void)
136 #if defined(CONFIG_MPC8555_CDS) || defined(CONFIG_MPC8548_CDS)
137 extern void mpc85xx_cds_enable_via(struct pci_controller
*hose
);
138 extern void mpc85xx_cds_fixup_via(struct pci_controller
*hose
);
142 mpc85xx_setup_pci1(struct pci_controller
*hose
)
144 volatile struct ccsr_pci
*pci
;
145 volatile struct ccsr_guts
*guts
;
146 unsigned short temps
;
147 bd_t
*binfo
= (bd_t
*) __res
;
149 pci
= ioremap(binfo
->bi_immr_base
+ MPC85xx_PCI1_OFFSET
,
152 guts
= ioremap(binfo
->bi_immr_base
+ MPC85xx_GUTS_OFFSET
,
155 early_read_config_word(hose
, 0, 0, PCI_COMMAND
, &temps
);
156 temps
|= PCI_COMMAND_SERR
| PCI_COMMAND_MASTER
| PCI_COMMAND_MEMORY
;
157 early_write_config_word(hose
, 0, 0, PCI_COMMAND
, temps
);
159 #define PORDEVSR_PCI (0x00800000) /* PCI Mode */
160 if (guts
->pordevsr
& PORDEVSR_PCI
) {
161 early_write_config_byte(hose
, 0, 0, PCI_LATENCY_TIMER
, 0x80);
164 temps
= PCI_X_CMD_MAX_SPLIT
| PCI_X_CMD_MAX_READ
165 | PCI_X_CMD_ERO
| PCI_X_CMD_DPERR_E
;
166 early_write_config_word(hose
, 0, 0, PCIX_COMMAND
, temps
);
169 /* Disable all windows (except powar0 since its ignored) */
178 /* Setup Phys:PCI 1:1 outbound mem window @ MPC85XX_PCI1_LOWER_MEM */
179 pci
->potar1
= (MPC85XX_PCI1_LOWER_MEM
>> 12) & 0x000fffff;
180 pci
->potear1
= 0x00000000;
181 pci
->powbar1
= (MPC85XX_PCI1_LOWER_MEM
>> 12) & 0x000fffff;
182 /* Enable, Mem R/W */
183 pci
->powar1
= 0x80044000 |
184 (__ilog2(MPC85XX_PCI1_UPPER_MEM
- MPC85XX_PCI1_LOWER_MEM
+ 1) - 1);
186 /* Setup outbound IO windows @ MPC85XX_PCI1_IO_BASE */
187 pci
->potar2
= (MPC85XX_PCI1_LOWER_IO
>> 12) & 0x000fffff;
188 pci
->potear2
= 0x00000000;
189 pci
->powbar2
= (MPC85XX_PCI1_IO_BASE
>> 12) & 0x000fffff;
191 pci
->powar2
= 0x80088000 | (__ilog2(MPC85XX_PCI1_IO_SIZE
) - 1);
193 /* Setup 2G inbound Memory Window @ 0 */
194 pci
->pitar1
= 0x00000000;
195 pci
->piwbar1
= 0x00000000;
196 pci
->piwar1
= 0xa0f5501e; /* Enable, Prefetch, Local
197 Mem, Snoop R/W, 2G */
201 extern int mpc85xx_map_irq(struct pci_dev
*dev
, unsigned char idsel
, unsigned char pin
);
202 extern int mpc85xx_exclude_device(u_char bus
, u_char devfn
);
204 #ifdef CONFIG_85xx_PCI2
206 mpc85xx_setup_pci2(struct pci_controller
*hose
)
208 volatile struct ccsr_pci
*pci
;
209 unsigned short temps
;
210 bd_t
*binfo
= (bd_t
*) __res
;
212 pci
= ioremap(binfo
->bi_immr_base
+ MPC85xx_PCI2_OFFSET
,
215 early_read_config_word(hose
, hose
->bus_offset
, 0, PCI_COMMAND
, &temps
);
216 temps
|= PCI_COMMAND_SERR
| PCI_COMMAND_MASTER
| PCI_COMMAND_MEMORY
;
217 early_write_config_word(hose
, hose
->bus_offset
, 0, PCI_COMMAND
, temps
);
218 early_write_config_byte(hose
, hose
->bus_offset
, 0, PCI_LATENCY_TIMER
, 0x80);
220 /* Disable all windows (except powar0 since its ignored) */
229 /* Setup Phys:PCI 1:1 outbound mem window @ MPC85XX_PCI2_LOWER_MEM */
230 pci
->potar1
= (MPC85XX_PCI2_LOWER_MEM
>> 12) & 0x000fffff;
231 pci
->potear1
= 0x00000000;
232 pci
->powbar1
= (MPC85XX_PCI2_LOWER_MEM
>> 12) & 0x000fffff;
233 /* Enable, Mem R/W */
234 pci
->powar1
= 0x80044000 |
235 (__ilog2(MPC85XX_PCI2_UPPER_MEM
- MPC85XX_PCI2_LOWER_MEM
+ 1) - 1);
237 /* Setup outbound IO windows @ MPC85XX_PCI2_IO_BASE */
238 pci
->potar2
= (MPC85XX_PCI2_LOWER_IO
>> 12) & 0x000fffff;
239 pci
->potear2
= 0x00000000;
240 pci
->powbar2
= (MPC85XX_PCI2_IO_BASE
>> 12) & 0x000fffff;
242 pci
->powar2
= 0x80088000 | (__ilog2(MPC85XX_PCI2_IO_SIZE
) - 1);
244 /* Setup 2G inbound Memory Window @ 0 */
245 pci
->pitar1
= 0x00000000;
246 pci
->piwbar1
= 0x00000000;
247 pci
->piwar1
= 0xa0f5501e; /* Enable, Prefetch, Local
248 Mem, Snoop R/W, 2G */
250 #endif /* CONFIG_85xx_PCI2 */
252 int mpc85xx_pci1_last_busno
= 0;
255 mpc85xx_setup_hose(void)
257 struct pci_controller
*hose_a
;
258 #ifdef CONFIG_85xx_PCI2
259 struct pci_controller
*hose_b
;
261 bd_t
*binfo
= (bd_t
*) __res
;
263 hose_a
= pcibios_alloc_controller();
268 ppc_md
.pci_swizzle
= common_swizzle
;
269 ppc_md
.pci_map_irq
= mpc85xx_map_irq
;
271 hose_a
->first_busno
= 0;
272 hose_a
->bus_offset
= 0;
273 hose_a
->last_busno
= 0xff;
275 setup_indirect_pci(hose_a
, binfo
->bi_immr_base
+ PCI1_CFG_ADDR_OFFSET
,
276 binfo
->bi_immr_base
+ PCI1_CFG_DATA_OFFSET
);
277 hose_a
->set_cfg_type
= 1;
279 mpc85xx_setup_pci1(hose_a
);
281 hose_a
->pci_mem_offset
= MPC85XX_PCI1_MEM_OFFSET
;
282 hose_a
->mem_space
.start
= MPC85XX_PCI1_LOWER_MEM
;
283 hose_a
->mem_space
.end
= MPC85XX_PCI1_UPPER_MEM
;
285 hose_a
->io_space
.start
= MPC85XX_PCI1_LOWER_IO
;
286 hose_a
->io_space
.end
= MPC85XX_PCI1_UPPER_IO
;
287 hose_a
->io_base_phys
= MPC85XX_PCI1_IO_BASE
;
288 #ifdef CONFIG_85xx_PCI2
289 hose_a
->io_base_virt
= ioremap(MPC85XX_PCI1_IO_BASE
,
290 MPC85XX_PCI1_IO_SIZE
+
291 MPC85XX_PCI2_IO_SIZE
);
293 hose_a
->io_base_virt
= ioremap(MPC85XX_PCI1_IO_BASE
,
294 MPC85XX_PCI1_IO_SIZE
);
296 isa_io_base
= (unsigned long)hose_a
->io_base_virt
;
298 /* setup resources */
299 pci_init_resource(&hose_a
->mem_resources
[0],
300 MPC85XX_PCI1_LOWER_MEM
,
301 MPC85XX_PCI1_UPPER_MEM
,
302 IORESOURCE_MEM
, "PCI1 host bridge");
304 pci_init_resource(&hose_a
->io_resource
,
305 MPC85XX_PCI1_LOWER_IO
,
306 MPC85XX_PCI1_UPPER_IO
,
307 IORESOURCE_IO
, "PCI1 host bridge");
309 ppc_md
.pci_exclude_device
= mpc85xx_exclude_device
;
311 #if defined(CONFIG_MPC8555_CDS) || defined(CONFIG_MPC8548_CDS)
312 /* Pre pciauto_bus_scan VIA init */
313 mpc85xx_cds_enable_via(hose_a
);
316 hose_a
->last_busno
= pciauto_bus_scan(hose_a
, hose_a
->first_busno
);
318 #if defined(CONFIG_MPC8555_CDS) || defined(CONFIG_MPC8548_CDS)
319 /* Post pciauto_bus_scan VIA fixup */
320 mpc85xx_cds_fixup_via(hose_a
);
323 #ifdef CONFIG_85xx_PCI2
324 hose_b
= pcibios_alloc_controller();
329 hose_b
->bus_offset
= hose_a
->last_busno
+ 1;
330 hose_b
->first_busno
= hose_a
->last_busno
+ 1;
331 hose_b
->last_busno
= 0xff;
333 setup_indirect_pci(hose_b
, binfo
->bi_immr_base
+ PCI2_CFG_ADDR_OFFSET
,
334 binfo
->bi_immr_base
+ PCI2_CFG_DATA_OFFSET
);
335 hose_b
->set_cfg_type
= 1;
337 mpc85xx_setup_pci2(hose_b
);
339 hose_b
->pci_mem_offset
= MPC85XX_PCI2_MEM_OFFSET
;
340 hose_b
->mem_space
.start
= MPC85XX_PCI2_LOWER_MEM
;
341 hose_b
->mem_space
.end
= MPC85XX_PCI2_UPPER_MEM
;
343 hose_b
->io_space
.start
= MPC85XX_PCI2_LOWER_IO
;
344 hose_b
->io_space
.end
= MPC85XX_PCI2_UPPER_IO
;
345 hose_b
->io_base_phys
= MPC85XX_PCI2_IO_BASE
;
346 hose_b
->io_base_virt
= hose_a
->io_base_virt
+ MPC85XX_PCI1_IO_SIZE
;
348 /* setup resources */
349 pci_init_resource(&hose_b
->mem_resources
[0],
350 MPC85XX_PCI2_LOWER_MEM
,
351 MPC85XX_PCI2_UPPER_MEM
,
352 IORESOURCE_MEM
, "PCI2 host bridge");
354 pci_init_resource(&hose_b
->io_resource
,
355 MPC85XX_PCI2_LOWER_IO
,
356 MPC85XX_PCI2_UPPER_IO
,
357 IORESOURCE_IO
, "PCI2 host bridge");
359 hose_b
->last_busno
= pciauto_bus_scan(hose_b
, hose_b
->first_busno
);
361 /* let board code know what the last bus number was on PCI1 */
362 mpc85xx_pci1_last_busno
= hose_a
->last_busno
;
366 #endif /* CONFIG_PCI */
This page took 0.045585 seconds and 5 git commands to generate.