Poonam Aggrwal | f857ed9 | 2009-08-21 07:29:58 +0530 | [diff] [blame] | 1 | /* |
Kumar Gala | d0f27d3 | 2010-07-08 22:37:44 -0500 | [diff] [blame] | 2 | * Copyright 2009-2010 Freescale Semiconductor, Inc. |
Poonam Aggrwal | f857ed9 | 2009-08-21 07:29:58 +0530 | [diff] [blame] | 3 | * |
| 4 | * See file CREDITS for list of people who contributed to this |
| 5 | * project. |
| 6 | * |
| 7 | * This program is free software; you can redistribute it and/or |
| 8 | * modify it under the terms of the GNU General Public License as |
| 9 | * published by the Free Software Foundation; either version 2 of |
| 10 | * the License, or (at your option) any later version. |
| 11 | * |
| 12 | * This program is distributed in the hope that it will be useful, |
| 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 15 | * GNU General Public License for more details. |
| 16 | * |
| 17 | * You should have received a copy of the GNU General Public License |
| 18 | * along with this program; if not, write to the Free Software |
| 19 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, |
| 20 | * MA 02111-1307 USA |
| 21 | */ |
| 22 | |
| 23 | #include <common.h> |
| 24 | #include <command.h> |
| 25 | #include <pci.h> |
| 26 | #include <asm/immap_85xx.h> |
Kumar Gala | 3d02038 | 2010-12-15 04:55:20 -0600 | [diff] [blame^] | 27 | #include <asm/fsl_serdes.h> |
Poonam Aggrwal | f857ed9 | 2009-08-21 07:29:58 +0530 | [diff] [blame] | 28 | #include <asm/io.h> |
| 29 | #include <asm/fsl_pci.h> |
| 30 | #include <libfdt.h> |
| 31 | #include <fdt_support.h> |
| 32 | |
| 33 | DECLARE_GLOBAL_DATA_PTR; |
| 34 | |
| 35 | #ifdef CONFIG_PCIE1 |
| 36 | static struct pci_controller pcie1_hose; |
| 37 | #endif |
| 38 | |
| 39 | #ifdef CONFIG_PCIE2 |
| 40 | static struct pci_controller pcie2_hose; |
| 41 | #endif |
| 42 | |
| 43 | void pci_init_board(void) |
| 44 | { |
Poonam Aggrwal | f857ed9 | 2009-08-21 07:29:58 +0530 | [diff] [blame] | 45 | volatile ccsr_gur_t *gur = (void *)(CONFIG_SYS_MPC85xx_GUTS_ADDR); |
Kumar Gala | 584fae5 | 2009-09-03 10:09:04 -0500 | [diff] [blame] | 46 | struct fsl_pci_info pci_info[2]; |
Kumar Gala | 3d02038 | 2010-12-15 04:55:20 -0600 | [diff] [blame^] | 47 | u32 devdisr, pordevsr; |
Poonam Aggrwal | f857ed9 | 2009-08-21 07:29:58 +0530 | [diff] [blame] | 48 | int first_free_busno = 0; |
Kumar Gala | 584fae5 | 2009-09-03 10:09:04 -0500 | [diff] [blame] | 49 | int num = 0; |
Poonam Aggrwal | f857ed9 | 2009-08-21 07:29:58 +0530 | [diff] [blame] | 50 | |
| 51 | int pcie_ep, pcie_configured; |
| 52 | |
Kumar Gala | 584fae5 | 2009-09-03 10:09:04 -0500 | [diff] [blame] | 53 | devdisr = in_be32(&gur->devdisr); |
| 54 | pordevsr = in_be32(&gur->pordevsr); |
Poonam Aggrwal | f857ed9 | 2009-08-21 07:29:58 +0530 | [diff] [blame] | 55 | |
Kumar Gala | 584fae5 | 2009-09-03 10:09:04 -0500 | [diff] [blame] | 56 | if (!(pordevsr & MPC85xx_PORDEVSR_SGMII2_DIS)) |
Peter Tyser | 8e9134c | 2010-10-29 17:59:25 -0500 | [diff] [blame] | 57 | printf("eTSEC2 is in sgmii mode.\n"); |
Poonam Aggrwal | f857ed9 | 2009-08-21 07:29:58 +0530 | [diff] [blame] | 58 | |
Kumar Gala | 584fae5 | 2009-09-03 10:09:04 -0500 | [diff] [blame] | 59 | puts("\n"); |
Poonam Aggrwal | f857ed9 | 2009-08-21 07:29:58 +0530 | [diff] [blame] | 60 | #ifdef CONFIG_PCIE2 |
Kumar Gala | 3d02038 | 2010-12-15 04:55:20 -0600 | [diff] [blame^] | 61 | pcie_configured = is_serdes_configured(PCIE2); |
Poonam Aggrwal | f857ed9 | 2009-08-21 07:29:58 +0530 | [diff] [blame] | 62 | |
| 63 | if (pcie_configured && !(devdisr & MPC85xx_DEVDISR_PCIE)){ |
Kumar Gala | 584fae5 | 2009-09-03 10:09:04 -0500 | [diff] [blame] | 64 | SET_STD_PCIE_INFO(pci_info[num], 2); |
Kumar Gala | 5a0b9bd | 2009-11-04 13:01:38 -0600 | [diff] [blame] | 65 | pcie_ep = fsl_setup_hose(&pcie2_hose, pci_info[num].regs); |
Peter Tyser | 2b91f71 | 2010-10-29 17:59:24 -0500 | [diff] [blame] | 66 | printf("PCIE2: connected to Slot 1 as %s (base addr %lx)\n", |
| 67 | pcie_ep ? "Endpoint" : "Root Complex", |
| 68 | pci_info[num].regs); |
Kumar Gala | 584fae5 | 2009-09-03 10:09:04 -0500 | [diff] [blame] | 69 | first_free_busno = fsl_pci_init_port(&pci_info[num++], |
Kumar Gala | b83ff07 | 2009-11-04 01:29:04 -0600 | [diff] [blame] | 70 | &pcie2_hose, first_free_busno); |
Poonam Aggrwal | f857ed9 | 2009-08-21 07:29:58 +0530 | [diff] [blame] | 71 | } else { |
Peter Tyser | 2b91f71 | 2010-10-29 17:59:24 -0500 | [diff] [blame] | 72 | printf("PCIE2: disabled\n"); |
Poonam Aggrwal | f857ed9 | 2009-08-21 07:29:58 +0530 | [diff] [blame] | 73 | } |
Kumar Gala | 584fae5 | 2009-09-03 10:09:04 -0500 | [diff] [blame] | 74 | puts("\n"); |
Poonam Aggrwal | f857ed9 | 2009-08-21 07:29:58 +0530 | [diff] [blame] | 75 | #else |
Kumar Gala | 584fae5 | 2009-09-03 10:09:04 -0500 | [diff] [blame] | 76 | setbits_be32(&gur->devdisr, MPC85xx_DEVDISR_PCIE2); /* disable */ |
Poonam Aggrwal | f857ed9 | 2009-08-21 07:29:58 +0530 | [diff] [blame] | 77 | #endif |
| 78 | |
| 79 | #ifdef CONFIG_PCIE1 |
Kumar Gala | 3d02038 | 2010-12-15 04:55:20 -0600 | [diff] [blame^] | 80 | pcie_configured = is_serdes_configured(PCIE1); |
Poonam Aggrwal | f857ed9 | 2009-08-21 07:29:58 +0530 | [diff] [blame] | 81 | |
| 82 | if (pcie_configured && !(devdisr & MPC85xx_DEVDISR_PCIE)){ |
Kumar Gala | 584fae5 | 2009-09-03 10:09:04 -0500 | [diff] [blame] | 83 | SET_STD_PCIE_INFO(pci_info[num], 1); |
Kumar Gala | 5a0b9bd | 2009-11-04 13:01:38 -0600 | [diff] [blame] | 84 | pcie_ep = fsl_setup_hose(&pcie1_hose, pci_info[num].regs); |
Peter Tyser | 2b91f71 | 2010-10-29 17:59:24 -0500 | [diff] [blame] | 85 | printf("PCIE1: connected to Slot 2 as %s (base addr %lx)\n", |
| 86 | pcie_ep ? "Endpoint" : "Root Complex", |
| 87 | pci_info[num].regs); |
Kumar Gala | 584fae5 | 2009-09-03 10:09:04 -0500 | [diff] [blame] | 88 | first_free_busno = fsl_pci_init_port(&pci_info[num++], |
Kumar Gala | b83ff07 | 2009-11-04 01:29:04 -0600 | [diff] [blame] | 89 | &pcie1_hose, first_free_busno); |
Poonam Aggrwal | f857ed9 | 2009-08-21 07:29:58 +0530 | [diff] [blame] | 90 | } else { |
Peter Tyser | 2b91f71 | 2010-10-29 17:59:24 -0500 | [diff] [blame] | 91 | printf("PCIE1: disabled\n"); |
Poonam Aggrwal | f857ed9 | 2009-08-21 07:29:58 +0530 | [diff] [blame] | 92 | } |
Kumar Gala | 584fae5 | 2009-09-03 10:09:04 -0500 | [diff] [blame] | 93 | puts("\n"); |
Poonam Aggrwal | f857ed9 | 2009-08-21 07:29:58 +0530 | [diff] [blame] | 94 | #else |
Kumar Gala | 584fae5 | 2009-09-03 10:09:04 -0500 | [diff] [blame] | 95 | setbits_be32(&gur->devdisr, MPC85xx_DEVDISR_PCIE); /* disable */ |
Poonam Aggrwal | f857ed9 | 2009-08-21 07:29:58 +0530 | [diff] [blame] | 96 | #endif |
| 97 | } |
| 98 | |
| 99 | void ft_pci_board_setup(void *blob) |
| 100 | { |
Kumar Gala | d0f27d3 | 2010-07-08 22:37:44 -0500 | [diff] [blame] | 101 | FT_FSL_PCI_SETUP; |
Poonam Aggrwal | f857ed9 | 2009-08-21 07:29:58 +0530 | [diff] [blame] | 102 | } |