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