Tom Rini | 83d290c | 2018-05-06 17:58:06 -0400 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0+ |
Reinhard Arlt | c2e49f7 | 2009-07-25 06:19:12 +0200 | [diff] [blame] | 2 | /* |
| 3 | * pci.c -- esd VME8349 PCI board support. |
| 4 | * Copyright (c) 2006 Wind River Systems, Inc. |
| 5 | * Copyright (C) 2006-2009 Freescale Semiconductor, Inc. |
Reinhard Arlt | a0daa2e | 2009-12-08 09:21:41 +0100 | [diff] [blame] | 6 | * Copyright (c) 2009 esd gmbh. |
| 7 | * |
| 8 | * Reinhard Arlt <reinhard.arlt@esd-electronics.com> |
Reinhard Arlt | c2e49f7 | 2009-07-25 06:19:12 +0200 | [diff] [blame] | 9 | * |
| 10 | * Based on MPC8349 PCI support but w/o PIB related code. |
Reinhard Arlt | c2e49f7 | 2009-07-25 06:19:12 +0200 | [diff] [blame] | 11 | */ |
| 12 | |
Simon Glass | 2cf431c | 2019-11-14 12:57:47 -0700 | [diff] [blame] | 13 | #include <init.h> |
Reinhard Arlt | c2e49f7 | 2009-07-25 06:19:12 +0200 | [diff] [blame] | 14 | #include <asm/mmu.h> |
| 15 | #include <asm/io.h> |
| 16 | #include <common.h> |
| 17 | #include <mpc83xx.h> |
| 18 | #include <pci.h> |
| 19 | #include <i2c.h> |
| 20 | #include <asm/fsl_i2c.h> |
Simon Glass | c05ed00 | 2020-05-10 11:40:11 -0600 | [diff] [blame] | 21 | #include <linux/delay.h> |
Reinhard Arlt | a0daa2e | 2009-12-08 09:21:41 +0100 | [diff] [blame] | 22 | #include "vme8349pin.h" |
Reinhard Arlt | c2e49f7 | 2009-07-25 06:19:12 +0200 | [diff] [blame] | 23 | |
Reinhard Arlt | c2e49f7 | 2009-07-25 06:19:12 +0200 | [diff] [blame] | 24 | static struct pci_region pci1_regions[] = { |
| 25 | { |
| 26 | bus_start: CONFIG_SYS_PCI1_MEM_BASE, |
| 27 | phys_start: CONFIG_SYS_PCI1_MEM_PHYS, |
| 28 | size: CONFIG_SYS_PCI1_MEM_SIZE, |
| 29 | flags: PCI_REGION_MEM | PCI_REGION_PREFETCH |
| 30 | }, |
| 31 | { |
| 32 | bus_start: CONFIG_SYS_PCI1_IO_BASE, |
| 33 | phys_start: CONFIG_SYS_PCI1_IO_PHYS, |
| 34 | size: CONFIG_SYS_PCI1_IO_SIZE, |
| 35 | flags: PCI_REGION_IO |
| 36 | }, |
| 37 | { |
| 38 | bus_start: CONFIG_SYS_PCI1_MMIO_BASE, |
| 39 | phys_start: CONFIG_SYS_PCI1_MMIO_PHYS, |
| 40 | size: CONFIG_SYS_PCI1_MMIO_SIZE, |
| 41 | flags: PCI_REGION_MEM |
| 42 | }, |
| 43 | }; |
| 44 | |
| 45 | /* |
| 46 | * pci_init_board() |
| 47 | * |
| 48 | * NOTICE: PCI2 is not supported. There is only one |
| 49 | * physical PCI slot on the board. |
| 50 | * |
| 51 | */ |
| 52 | void |
| 53 | pci_init_board(void) |
| 54 | { |
| 55 | volatile immap_t *immr = (volatile immap_t *)CONFIG_SYS_IMMR; |
| 56 | volatile clk83xx_t *clk = (volatile clk83xx_t *)&immr->clk; |
| 57 | volatile law83xx_t *pci_law = immr->sysconf.pcilaw; |
| 58 | struct pci_region *reg[] = { pci1_regions }; |
| 59 | u8 reg8; |
| 60 | int monarch = 0; |
| 61 | |
| 62 | i2c_set_bus_num(1); |
| 63 | /* Read the PCI_M66EN jumper setting */ |
| 64 | if ((i2c_read(CONFIG_SYS_I2C_8574_ADDR2, 0, 0, ®8, 1) == 0) || |
| 65 | (i2c_read(0x38 , 0, 0, ®8, 1) == 0)) { |
| 66 | if (reg8 & 0x40) { |
| 67 | clk->occr = 0xff000000; /* 66 MHz PCI */ |
| 68 | printf("PCI: 66MHz\n"); |
| 69 | } else { |
| 70 | clk->occr = 0xffff0003; /* 33 MHz PCI */ |
| 71 | printf("PCI: 33MHz\n"); |
| 72 | } |
| 73 | if (((reg8 & 0x01) == 0) || ((reg8 & 0x02) == 0)) |
| 74 | monarch = 1; |
| 75 | } else { |
| 76 | clk->occr = 0xffff0003; /* 33 MHz PCI */ |
| 77 | printf("PCI: 33MHz (I2C read failed)\n"); |
| 78 | } |
| 79 | udelay(2000); |
| 80 | |
| 81 | /* |
Reinhard Arlt | a0daa2e | 2009-12-08 09:21:41 +0100 | [diff] [blame] | 82 | * Assert/deassert VME reset |
Reinhard Arlt | c2e49f7 | 2009-07-25 06:19:12 +0200 | [diff] [blame] | 83 | */ |
Reinhard Arlt | a0daa2e | 2009-12-08 09:21:41 +0100 | [diff] [blame] | 84 | clrsetbits_be32(&immr->gpio[1].dat, |
| 85 | GPIO2_TSI_POWERUP_RESET_N | GPIO2_TSI_PLL_RESET_N, |
| 86 | GPIO2_VME_RESET_N | GPIO2_L_RESET_EN_N); |
| 87 | setbits_be32(&immr->gpio[1].dir, GPIO2_TSI_PLL_RESET_N | |
| 88 | GPIO2_TSI_POWERUP_RESET_N | |
| 89 | GPIO2_VME_RESET_N | |
| 90 | GPIO2_L_RESET_EN_N); |
| 91 | clrbits_be32(&immr->gpio[1].dir, GPIO2_V_SCON); |
Reinhard Arlt | c2e49f7 | 2009-07-25 06:19:12 +0200 | [diff] [blame] | 92 | udelay(200); |
Reinhard Arlt | a0daa2e | 2009-12-08 09:21:41 +0100 | [diff] [blame] | 93 | setbits_be32(&immr->gpio[1].dat, GPIO2_TSI_PLL_RESET_N); |
Reinhard Arlt | c2e49f7 | 2009-07-25 06:19:12 +0200 | [diff] [blame] | 94 | udelay(200); |
Reinhard Arlt | a0daa2e | 2009-12-08 09:21:41 +0100 | [diff] [blame] | 95 | setbits_be32(&immr->gpio[1].dat, GPIO2_TSI_POWERUP_RESET_N); |
Reinhard Arlt | c2e49f7 | 2009-07-25 06:19:12 +0200 | [diff] [blame] | 96 | udelay(600000); |
Reinhard Arlt | a0daa2e | 2009-12-08 09:21:41 +0100 | [diff] [blame] | 97 | clrbits_be32(&immr->gpio[1].dat, GPIO2_L_RESET_EN_N); |
Reinhard Arlt | c2e49f7 | 2009-07-25 06:19:12 +0200 | [diff] [blame] | 98 | |
| 99 | /* Configure PCI Local Access Windows */ |
| 100 | pci_law[0].bar = CONFIG_SYS_PCI1_MEM_PHYS & LAWBAR_BAR; |
| 101 | pci_law[0].ar = LAWAR_EN | LAWAR_SIZE_1G; |
| 102 | |
| 103 | pci_law[1].bar = CONFIG_SYS_PCI1_IO_PHYS & LAWBAR_BAR; |
| 104 | pci_law[1].ar = LAWAR_EN | LAWAR_SIZE_4M; |
| 105 | |
| 106 | udelay(2000); |
| 107 | |
Reinhard Arlt | a0daa2e | 2009-12-08 09:21:41 +0100 | [diff] [blame] | 108 | if (monarch == 0) { |
Peter Tyser | 6aa3d3b | 2010-09-14 19:13:50 -0500 | [diff] [blame] | 109 | mpc83xx_pci_init(1, reg); |
Reinhard Arlt | a0daa2e | 2009-12-08 09:21:41 +0100 | [diff] [blame] | 110 | } else { |
| 111 | /* |
| 112 | * Release PCI RST Output signal |
| 113 | */ |
| 114 | out_be32(&immr->pci_ctrl[0].gcr, 0); |
| 115 | udelay(2000); |
| 116 | out_be32(&immr->pci_ctrl[0].gcr, 1); |
| 117 | } |
Reinhard Arlt | c2e49f7 | 2009-07-25 06:19:12 +0200 | [diff] [blame] | 118 | } |