Tom Rini | 10e4779 | 2018-05-06 17:58:06 -0400 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0+ |
Peter Tyser | 1c2b329 | 2008-12-17 16:36:23 -0600 | [diff] [blame] | 2 | /* |
| 3 | * Copyright 2008 Extreme Engineering Solutions, Inc. |
| 4 | * Copyright 2007-2008 Freescale Semiconductor, Inc. |
Peter Tyser | 1c2b329 | 2008-12-17 16:36:23 -0600 | [diff] [blame] | 5 | */ |
| 6 | |
| 7 | #include <common.h> |
| 8 | #include <pci.h> |
Kumar Gala | 9bbd643 | 2009-04-02 13:22:48 -0500 | [diff] [blame] | 9 | #include <asm/fsl_pci.h> |
Kumar Gala | 3d02038 | 2010-12-15 04:55:20 -0600 | [diff] [blame] | 10 | #include <asm/fsl_serdes.h> |
Peter Tyser | 2b1a48d | 2009-08-07 13:16:34 -0500 | [diff] [blame] | 11 | #include <asm/io.h> |
Peter Tyser | 5194477 | 2010-10-22 00:20:22 -0500 | [diff] [blame] | 12 | #include <linux/compiler.h> |
Masahiro Yamada | 75f82d0 | 2018-03-05 01:20:11 +0900 | [diff] [blame] | 13 | #include <linux/libfdt.h> |
Peter Tyser | 1c2b329 | 2008-12-17 16:36:23 -0600 | [diff] [blame] | 14 | #include <fdt_support.h> |
| 15 | |
Peter Tyser | 1c2b329 | 2008-12-17 16:36:23 -0600 | [diff] [blame] | 16 | |
Peter Tyser | 59b5fdf | 2008-12-01 13:47:13 -0600 | [diff] [blame] | 17 | #ifdef CONFIG_PCI1 |
| 18 | static struct pci_controller pci1_hose; |
| 19 | #endif |
Peter Tyser | 7537982 | 2009-05-22 10:26:35 -0500 | [diff] [blame] | 20 | |
Peter Tyser | 1c2b329 | 2008-12-17 16:36:23 -0600 | [diff] [blame] | 21 | void pci_init_board(void) |
| 22 | { |
Peter Tyser | 5194477 | 2010-10-22 00:20:22 -0500 | [diff] [blame] | 23 | int first_free_busno = 0; |
Peter Tyser | 5194477 | 2010-10-22 00:20:22 -0500 | [diff] [blame] | 24 | |
Kumar Gala | f330c6b | 2010-12-17 10:23:03 -0600 | [diff] [blame] | 25 | #ifdef CONFIG_PCI1 |
| 26 | int pcie_ep; |
| 27 | struct fsl_pci_info pci_info; |
Peter Tyser | 1c2b329 | 2008-12-17 16:36:23 -0600 | [diff] [blame] | 28 | volatile ccsr_gur_t *gur = (void *)(CONFIG_SYS_MPC85xx_GUTS_ADDR); |
Peter Tyser | 5194477 | 2010-10-22 00:20:22 -0500 | [diff] [blame] | 29 | u32 devdisr = in_be32(&gur->devdisr); |
Peter Tyser | 2b1a48d | 2009-08-07 13:16:34 -0500 | [diff] [blame] | 30 | uint pci_spd_norm = in_be32(&gur->pordevsr) & MPC85xx_PORDEVSR_PCI1_SPD; |
| 31 | uint pci_32 = in_be32(&gur->pordevsr) & MPC85xx_PORDEVSR_PCI1_PCI32; |
| 32 | uint pci_arb = in_be32(&gur->pordevsr) & MPC85xx_PORDEVSR_PCI1_ARB; |
| 33 | uint pcix = in_be32(&gur->pordevsr) & MPC85xx_PORDEVSR_PCI1; |
Peter Tyser | 59b5fdf | 2008-12-01 13:47:13 -0600 | [diff] [blame] | 34 | uint freq = CONFIG_SYS_CLK_FREQ / 1000 / 1000; |
| 35 | |
Peter Tyser | 59b5fdf | 2008-12-01 13:47:13 -0600 | [diff] [blame] | 36 | if (!(devdisr & MPC85xx_DEVDISR_PCI1)) { |
Kumar Gala | f330c6b | 2010-12-17 10:23:03 -0600 | [diff] [blame] | 37 | SET_STD_PCI_INFO(pci_info, 1); |
| 38 | set_next_law(pci_info.mem_phys, |
| 39 | law_size_bits(pci_info.mem_size), pci_info.law); |
| 40 | set_next_law(pci_info.io_phys, |
| 41 | law_size_bits(pci_info.io_size), pci_info.law); |
| 42 | |
| 43 | pcie_ep = fsl_setup_hose(&pci1_hose, pci_info.regs); |
Peter Tyser | 2b91f71 | 2010-10-29 17:59:24 -0500 | [diff] [blame] | 44 | printf("PCI1: %d bit %s, %s %d MHz, %s, %s\n", |
Peter Tyser | 59b5fdf | 2008-12-01 13:47:13 -0600 | [diff] [blame] | 45 | pci_32 ? 32 : 64, |
| 46 | pcix ? "PCIX" : "PCI", |
Peter Tyser | 2b1a48d | 2009-08-07 13:16:34 -0500 | [diff] [blame] | 47 | pci_spd_norm ? ">=" : "<=", |
Peter Tyser | 59b5fdf | 2008-12-01 13:47:13 -0600 | [diff] [blame] | 48 | pcix ? freq * 2 : freq, |
Peter Tyser | 5194477 | 2010-10-22 00:20:22 -0500 | [diff] [blame] | 49 | pcie_ep ? "agent" : "host", |
Peter Tyser | 59b5fdf | 2008-12-01 13:47:13 -0600 | [diff] [blame] | 50 | pci_arb ? "arbiter" : "external-arbiter"); |
| 51 | |
Kumar Gala | f330c6b | 2010-12-17 10:23:03 -0600 | [diff] [blame] | 52 | first_free_busno = fsl_pci_init_port(&pci_info, |
Peter Tyser | 5194477 | 2010-10-22 00:20:22 -0500 | [diff] [blame] | 53 | &pci1_hose, first_free_busno); |
Peter Tyser | 59b5fdf | 2008-12-01 13:47:13 -0600 | [diff] [blame] | 54 | } else { |
Peter Tyser | 2b91f71 | 2010-10-29 17:59:24 -0500 | [diff] [blame] | 55 | printf("PCI1: disabled\n"); |
Peter Tyser | 59b5fdf | 2008-12-01 13:47:13 -0600 | [diff] [blame] | 56 | } |
York Sun | efc49e0 | 2016-11-15 13:52:34 -0800 | [diff] [blame] | 57 | #elif defined CONFIG_ARCH_MPC8548 |
Kumar Gala | f330c6b | 2010-12-17 10:23:03 -0600 | [diff] [blame] | 58 | volatile ccsr_gur_t *gur = (void *)(CONFIG_SYS_MPC85xx_GUTS_ADDR); |
Peter Tyser | 59b5fdf | 2008-12-01 13:47:13 -0600 | [diff] [blame] | 59 | /* PCI1 not present on MPC8572 */ |
Peter Tyser | 2b1a48d | 2009-08-07 13:16:34 -0500 | [diff] [blame] | 60 | setbits_be32(&gur->devdisr, MPC85xx_DEVDISR_PCI1); |
Peter Tyser | 59b5fdf | 2008-12-01 13:47:13 -0600 | [diff] [blame] | 61 | #endif |
Peter Tyser | 1c2b329 | 2008-12-17 16:36:23 -0600 | [diff] [blame] | 62 | |
Kumar Gala | f330c6b | 2010-12-17 10:23:03 -0600 | [diff] [blame] | 63 | fsl_pcie_init_board(first_free_busno); |
Peter Tyser | 1c2b329 | 2008-12-17 16:36:23 -0600 | [diff] [blame] | 64 | } |
| 65 | |
| 66 | #if defined(CONFIG_OF_BOARD_SETUP) |
Peter Tyser | 1c2b329 | 2008-12-17 16:36:23 -0600 | [diff] [blame] | 67 | void ft_board_pci_setup(void *blob, bd_t *bd) |
| 68 | { |
Kumar Gala | d0f27d3 | 2010-07-08 22:37:44 -0500 | [diff] [blame] | 69 | FT_FSL_PCI_SETUP; |
Peter Tyser | 1c2b329 | 2008-12-17 16:36:23 -0600 | [diff] [blame] | 70 | } |
| 71 | #endif /* CONFIG_OF_BOARD_SETUP */ |