Merge tag 'u-boot-atmel-fixes-2020.07-a' of https://gitlab.denx.de/u-boot/custodians...
[oweals/u-boot.git] / board / esd / vme8349 / pci.c
index d15203c145d7a53295572c8557899ad9e5d7f041..bf51d39b67c8869e6eb378e0f8a79b9d0b573f71 100644 (file)
@@ -1,30 +1,16 @@
+// SPDX-License-Identifier: GPL-2.0+
 /*
  * pci.c -- esd VME8349 PCI board support.
  * Copyright (c) 2006 Wind River Systems, Inc.
  * Copyright (C) 2006-2009 Freescale Semiconductor, Inc.
+ * Copyright (c) 2009 esd gmbh.
  *
- * Based on MPC8349 PCI support but w/o PIB related code.
- *
- * See file CREDITS for list of people who contributed to this
- * project.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License as
- * published by the Free Software Foundation; either version 2 of
- * the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
- * MA 02111-1307 USA
+ * Reinhard Arlt <reinhard.arlt@esd-electronics.com>
  *
+ * Based on MPC8349 PCI support but w/o PIB related code.
  */
 
+#include <init.h>
 #include <asm/mmu.h>
 #include <asm/io.h>
 #include <common.h>
@@ -32,8 +18,8 @@
 #include <pci.h>
 #include <i2c.h>
 #include <asm/fsl_i2c.h>
-
-DECLARE_GLOBAL_DATA_PTR;
+#include <linux/delay.h>
+#include "vme8349pin.h"
 
 static struct pci_region pci1_regions[] = {
        {
@@ -93,17 +79,22 @@ pci_init_board(void)
        udelay(2000);
 
        /*
-        * Assert/deassert PCI reset
+        * Assert/deassert VME reset
         */
-       setbits_be32(&immr->gpio[0].dat, 0x00800000);
-       setbits_be32(&immr->gpio[0].dir, 0x00800000);
-       setbits_be32(&immr->gpio[1].dir, 0x08800000);
+       clrsetbits_be32(&immr->gpio[1].dat,
+                       GPIO2_TSI_POWERUP_RESET_N | GPIO2_TSI_PLL_RESET_N,
+                       GPIO2_VME_RESET_N  | GPIO2_L_RESET_EN_N);
+       setbits_be32(&immr->gpio[1].dir, GPIO2_TSI_PLL_RESET_N |
+                    GPIO2_TSI_POWERUP_RESET_N |
+                    GPIO2_VME_RESET_N |
+                    GPIO2_L_RESET_EN_N);
+       clrbits_be32(&immr->gpio[1].dir, GPIO2_V_SCON);
        udelay(200);
-       setbits_be32(&immr->gpio[1].dat, 0x08000000);
+       setbits_be32(&immr->gpio[1].dat, GPIO2_TSI_PLL_RESET_N);
        udelay(200);
-       setbits_be32(&immr->gpio[1].dat, 0x08800000);
+       setbits_be32(&immr->gpio[1].dat, GPIO2_TSI_POWERUP_RESET_N);
        udelay(600000);
-       clrbits_be32(&immr->gpio[1].dat, 0x00100000);
+       clrbits_be32(&immr->gpio[1].dat, GPIO2_L_RESET_EN_N);
 
        /* Configure PCI Local Access Windows */
        pci_law[0].bar = CONFIG_SYS_PCI1_MEM_PHYS & LAWBAR_BAR;
@@ -114,6 +105,14 @@ pci_init_board(void)
 
        udelay(2000);
 
-       if (monarch == 0)
-               mpc83xx_pci_init(1, reg, 0);
+       if (monarch == 0) {
+               mpc83xx_pci_init(1, reg);
+       } else {
+               /*
+                * Release PCI RST Output signal
+                */
+               out_be32(&immr->pci_ctrl[0].gcr, 0);
+               udelay(2000);
+               out_be32(&immr->pci_ctrl[0].gcr, 1);
+       }
 }