1*83d290c5STom Rini // SPDX-License-Identifier: GPL-2.0+
24677988cSWolfgang Grandegger /*
34677988cSWolfgang Grandegger * (C) Copyright 2005
44677988cSWolfgang Grandegger * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
59993e196SKim Phillips * Copyright (C) 2006-2009 Freescale Semiconductor, Inc.
64677988cSWolfgang Grandegger */
74677988cSWolfgang Grandegger
84677988cSWolfgang Grandegger #include <asm/mmu.h>
99993e196SKim Phillips #include <asm/io.h>
104677988cSWolfgang Grandegger #include <common.h>
119993e196SKim Phillips #include <mpc83xx.h>
124677988cSWolfgang Grandegger #include <pci.h>
139993e196SKim Phillips #include <i2c.h>
149993e196SKim Phillips #include <asm/fsl_i2c.h>
154681e673SWolfgang Denk
169993e196SKim Phillips static struct pci_region pci1_regions[] = {
179993e196SKim Phillips {
189993e196SKim Phillips bus_start: CONFIG_SYS_PCI1_MEM_BASE,
199993e196SKim Phillips phys_start: CONFIG_SYS_PCI1_MEM_PHYS,
209993e196SKim Phillips size: CONFIG_SYS_PCI1_MEM_SIZE,
219993e196SKim Phillips flags: PCI_REGION_MEM | PCI_REGION_PREFETCH
224677988cSWolfgang Grandegger },
239993e196SKim Phillips {
249993e196SKim Phillips bus_start: CONFIG_SYS_PCI1_IO_BASE,
259993e196SKim Phillips phys_start: CONFIG_SYS_PCI1_IO_PHYS,
269993e196SKim Phillips size: CONFIG_SYS_PCI1_IO_SIZE,
279993e196SKim Phillips flags: PCI_REGION_IO
289993e196SKim Phillips },
299993e196SKim Phillips {
309993e196SKim Phillips bus_start: CONFIG_SYS_PCI1_MMIO_BASE,
319993e196SKim Phillips phys_start: CONFIG_SYS_PCI1_MMIO_PHYS,
329993e196SKim Phillips size: CONFIG_SYS_PCI1_MMIO_SIZE,
339993e196SKim Phillips flags: PCI_REGION_MEM
349993e196SKim Phillips },
354677988cSWolfgang Grandegger };
364677988cSWolfgang Grandegger
379993e196SKim Phillips /*
384677988cSWolfgang Grandegger * pci_init_board()
394677988cSWolfgang Grandegger *
404677988cSWolfgang Grandegger * NOTICE: MPC8349 internally has two PCI controllers (PCI1 and PCI2) but since
414677988cSWolfgang Grandegger * per TQM834x design physical connections to external devices (PCI sockets)
424677988cSWolfgang Grandegger * are routed only to the PCI1 we do not account for the second one - this code
434677988cSWolfgang Grandegger * supports PCI1 module only. Should support for the PCI2 be required in the
444677988cSWolfgang Grandegger * future it needs a separate pci_controller structure (above) and handling -
454677988cSWolfgang Grandegger * please refer to other boards' implementation for dual PCI host controllers,
464677988cSWolfgang Grandegger * for example board/Marvell/db64360/pci.c, pci_init_board()
474677988cSWolfgang Grandegger *
484677988cSWolfgang Grandegger */
494677988cSWolfgang Grandegger void
pci_init_board(void)504677988cSWolfgang Grandegger pci_init_board(void)
514677988cSWolfgang Grandegger {
529993e196SKim Phillips volatile immap_t *immr = (volatile immap_t *)CONFIG_SYS_IMMR;
539993e196SKim Phillips volatile clk83xx_t *clk = (volatile clk83xx_t *)&immr->clk;
549993e196SKim Phillips volatile law83xx_t *pci_law = immr->sysconf.pcilaw;
559993e196SKim Phillips struct pci_region *reg[] = { pci1_regions };
564677988cSWolfgang Grandegger u32 reg32;
574677988cSWolfgang Grandegger
584677988cSWolfgang Grandegger /*
594677988cSWolfgang Grandegger * Configure PCI controller and PCI_CLK_OUTPUT
609993e196SKim Phillips *
614677988cSWolfgang Grandegger * WARNING! only PCI_CLK_OUTPUT1 is enabled here as this is the one
624677988cSWolfgang Grandegger * line actually used for clocking all external PCI devices in TQM83xx.
634677988cSWolfgang Grandegger * Enabling other PCI_CLK_OUTPUT lines may lead to board's hang for
644677988cSWolfgang Grandegger * unknown reasons - particularly PCI_CLK_OUTPUT6 and PCI_CLK_OUTPUT7
654677988cSWolfgang Grandegger * are known to hang the board; this issue is under investigation
664677988cSWolfgang Grandegger * (13 oct 05)
674677988cSWolfgang Grandegger */
684677988cSWolfgang Grandegger reg32 = OCCR_PCICOE1;
694677988cSWolfgang Grandegger #if 0
704677988cSWolfgang Grandegger /* enabling all PCI_CLK_OUTPUT lines HANGS the board... */
714677988cSWolfgang Grandegger reg32 = 0xff000000;
724677988cSWolfgang Grandegger #endif
734677988cSWolfgang Grandegger if (clk->spmr & SPMR_CKID) {
744677988cSWolfgang Grandegger /* PCI Clock is half CONFIG_83XX_CLKIN so need to set up OCCR
754677988cSWolfgang Grandegger * fields accordingly */
764677988cSWolfgang Grandegger reg32 |= (OCCR_PCI1CR | OCCR_PCI2CR);
774677988cSWolfgang Grandegger
784677988cSWolfgang Grandegger reg32 |= (OCCR_PCICD0 | OCCR_PCICD1 | OCCR_PCICD2 \
794677988cSWolfgang Grandegger | OCCR_PCICD3 | OCCR_PCICD4 | OCCR_PCICD5 \
804677988cSWolfgang Grandegger | OCCR_PCICD6 | OCCR_PCICD7);
814677988cSWolfgang Grandegger }
824677988cSWolfgang Grandegger
834677988cSWolfgang Grandegger clk->occr = reg32;
844677988cSWolfgang Grandegger udelay(2000);
854677988cSWolfgang Grandegger
869993e196SKim Phillips /* Configure PCI Local Access Windows */
876d0f6bcfSJean-Christophe PLAGNIOL-VILLARD pci_law[0].bar = CONFIG_SYS_PCI1_MEM_PHYS & LAWBAR_BAR;
884677988cSWolfgang Grandegger pci_law[0].ar = LAWAR_EN | LAWAR_SIZE_512M;
894677988cSWolfgang Grandegger
906d0f6bcfSJean-Christophe PLAGNIOL-VILLARD pci_law[1].bar = CONFIG_SYS_PCI1_IO_PHYS & LAWBAR_BAR;
914677988cSWolfgang Grandegger pci_law[1].ar = LAWAR_EN | LAWAR_SIZE_16M;
924677988cSWolfgang Grandegger
939993e196SKim Phillips udelay(2000);
944677988cSWolfgang Grandegger
956aa3d3bfSPeter Tyser mpc83xx_pci_init(1, reg);
964677988cSWolfgang Grandegger }
97