blob: 92bda60765243991ce52d0ff703e70c8f3d716b3 [file] [log] [blame]
Tom Rini10e47792018-05-06 17:58:06 -04001// SPDX-License-Identifier: GPL-2.0+
Rafal Jaworowski384da5e2005-10-17 02:39:53 +02002/*
3 * (C) Copyright 2005
4 * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
Kim Phillips57a2af32009-07-18 18:42:13 -05005 * Copyright (C) 2006-2009 Freescale Semiconductor, Inc.
Rafal Jaworowski384da5e2005-10-17 02:39:53 +02006 */
7
Simon Glass18afe102019-11-14 12:57:47 -07008#include <init.h>
Rafal Jaworowski384da5e2005-10-17 02:39:53 +02009#include <asm/mmu.h>
Kim Phillips57a2af32009-07-18 18:42:13 -050010#include <asm/io.h>
Rafal Jaworowski384da5e2005-10-17 02:39:53 +020011#include <common.h>
Kim Phillips57a2af32009-07-18 18:42:13 -050012#include <mpc83xx.h>
Rafal Jaworowski384da5e2005-10-17 02:39:53 +020013#include <pci.h>
Kim Phillips57a2af32009-07-18 18:42:13 -050014#include <i2c.h>
15#include <asm/fsl_i2c.h>
Simon Glassdbd79542020-05-10 11:40:11 -060016#include <linux/delay.h>
Wolfgang Denk95593572009-05-14 23:18:34 +020017
Kim Phillips57a2af32009-07-18 18:42:13 -050018static struct pci_region pci1_regions[] = {
19 {
20 bus_start: CONFIG_SYS_PCI1_MEM_BASE,
21 phys_start: CONFIG_SYS_PCI1_MEM_PHYS,
22 size: CONFIG_SYS_PCI1_MEM_SIZE,
23 flags: PCI_REGION_MEM | PCI_REGION_PREFETCH
Rafal Jaworowski384da5e2005-10-17 02:39:53 +020024 },
Kim Phillips57a2af32009-07-18 18:42:13 -050025 {
26 bus_start: CONFIG_SYS_PCI1_IO_BASE,
27 phys_start: CONFIG_SYS_PCI1_IO_PHYS,
28 size: CONFIG_SYS_PCI1_IO_SIZE,
29 flags: PCI_REGION_IO
30 },
31 {
32 bus_start: CONFIG_SYS_PCI1_MMIO_BASE,
33 phys_start: CONFIG_SYS_PCI1_MMIO_PHYS,
34 size: CONFIG_SYS_PCI1_MMIO_SIZE,
35 flags: PCI_REGION_MEM
36 },
Rafal Jaworowski384da5e2005-10-17 02:39:53 +020037};
38
Kim Phillips57a2af32009-07-18 18:42:13 -050039/*
Rafal Jaworowski384da5e2005-10-17 02:39:53 +020040 * pci_init_board()
41 *
42 * NOTICE: MPC8349 internally has two PCI controllers (PCI1 and PCI2) but since
43 * per TQM834x design physical connections to external devices (PCI sockets)
44 * are routed only to the PCI1 we do not account for the second one - this code
45 * supports PCI1 module only. Should support for the PCI2 be required in the
46 * future it needs a separate pci_controller structure (above) and handling -
47 * please refer to other boards' implementation for dual PCI host controllers,
48 * for example board/Marvell/db64360/pci.c, pci_init_board()
49 *
50 */
51void
52pci_init_board(void)
53{
Kim Phillips57a2af32009-07-18 18:42:13 -050054 volatile immap_t *immr = (volatile immap_t *)CONFIG_SYS_IMMR;
55 volatile clk83xx_t *clk = (volatile clk83xx_t *)&immr->clk;
56 volatile law83xx_t *pci_law = immr->sysconf.pcilaw;
57 struct pci_region *reg[] = { pci1_regions };
Rafal Jaworowski384da5e2005-10-17 02:39:53 +020058 u32 reg32;
Wolfgang Denkf6a692b2005-12-04 00:40:34 +010059
Rafal Jaworowski384da5e2005-10-17 02:39:53 +020060 /*
Wolfgang Denkf6a692b2005-12-04 00:40:34 +010061 * Configure PCI controller and PCI_CLK_OUTPUT
Kim Phillips57a2af32009-07-18 18:42:13 -050062 *
Rafal Jaworowski384da5e2005-10-17 02:39:53 +020063 * WARNING! only PCI_CLK_OUTPUT1 is enabled here as this is the one
64 * line actually used for clocking all external PCI devices in TQM83xx.
Wolfgang Denkf6a692b2005-12-04 00:40:34 +010065 * Enabling other PCI_CLK_OUTPUT lines may lead to board's hang for
Rafal Jaworowski384da5e2005-10-17 02:39:53 +020066 * unknown reasons - particularly PCI_CLK_OUTPUT6 and PCI_CLK_OUTPUT7
Wolfgang Denkf6a692b2005-12-04 00:40:34 +010067 * are known to hang the board; this issue is under investigation
Rafal Jaworowski384da5e2005-10-17 02:39:53 +020068 * (13 oct 05)
69 */
70 reg32 = OCCR_PCICOE1;
Wolfgang Denkf6a692b2005-12-04 00:40:34 +010071#if 0
Rafal Jaworowski384da5e2005-10-17 02:39:53 +020072 /* enabling all PCI_CLK_OUTPUT lines HANGS the board... */
73 reg32 = 0xff000000;
Wolfgang Denkf6a692b2005-12-04 00:40:34 +010074#endif
Rafal Jaworowski384da5e2005-10-17 02:39:53 +020075 if (clk->spmr & SPMR_CKID) {
Mario Sixd10f3182019-01-21 09:17:53 +010076 /* PCI Clock is half CONFIG_SYS_CLK_FREQ so need to set up OCCR
Rafal Jaworowski384da5e2005-10-17 02:39:53 +020077 * fields accordingly */
78 reg32 |= (OCCR_PCI1CR | OCCR_PCI2CR);
Wolfgang Denkf6a692b2005-12-04 00:40:34 +010079
Rafal Jaworowski384da5e2005-10-17 02:39:53 +020080 reg32 |= (OCCR_PCICD0 | OCCR_PCICD1 | OCCR_PCICD2 \
81 | OCCR_PCICD3 | OCCR_PCICD4 | OCCR_PCICD5 \
82 | OCCR_PCICD6 | OCCR_PCICD7);
83 }
84
85 clk->occr = reg32;
86 udelay(2000);
87
Kim Phillips57a2af32009-07-18 18:42:13 -050088 /* Configure PCI Local Access Windows */
Jean-Christophe PLAGNIOL-VILLARD03836942008-10-16 15:01:15 +020089 pci_law[0].bar = CONFIG_SYS_PCI1_MEM_PHYS & LAWBAR_BAR;
Rafal Jaworowskice49c272005-11-17 00:26:18 +010090 pci_law[0].ar = LAWAR_EN | LAWAR_SIZE_512M;
Rafal Jaworowski384da5e2005-10-17 02:39:53 +020091
Jean-Christophe PLAGNIOL-VILLARD03836942008-10-16 15:01:15 +020092 pci_law[1].bar = CONFIG_SYS_PCI1_IO_PHYS & LAWBAR_BAR;
Rafal Jaworowskice49c272005-11-17 00:26:18 +010093 pci_law[1].ar = LAWAR_EN | LAWAR_SIZE_16M;
Rafal Jaworowski384da5e2005-10-17 02:39:53 +020094
Kim Phillips57a2af32009-07-18 18:42:13 -050095 udelay(2000);
Wolfgang Denk95593572009-05-14 23:18:34 +020096
Peter Tysere2283322010-09-14 19:13:50 -050097 mpc83xx_pci_init(1, reg);
Wolfgang Denk95593572009-05-14 23:18:34 +020098}