common: Drop linux/delay.h from common header
[platform/kernel/u-boot.git] / drivers / video / mb862xx.c
index edf34aa..04e435f 100644 (file)
@@ -1,24 +1,7 @@
+// SPDX-License-Identifier: GPL-2.0+
 /*
  * (C) Copyright 2007
  * DENX Software Engineering, Anatolij Gustschin, agust@denx.de
- *
- * 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
  */
 
 /*
  */
 
 #include <common.h>
+#include <linux/delay.h>
 
 #include <asm/io.h>
+#include <env.h>
 #include <pci.h>
 #include <video_fb.h>
 #include "videomodes.h"
@@ -95,7 +80,7 @@ static void gdc_sw_reset (void)
        GraphicDevice *dev = &mb862xx;
 
        HOST_WR_REG (GC_SRST, 0x1);
-       udelay (500);
+       udelay(500);
        video_hw_init ();
 }
 
@@ -189,13 +174,22 @@ static void de_init (void)
 }
 
 #if defined(CONFIG_VIDEO_CORALP)
+/* use CCF and MMR parameters for Coral-P Eval. Board as default */
+#ifndef CONFIG_SYS_MB862xx_CCF
+#define CONFIG_SYS_MB862xx_CCF 0x00090000
+#endif
+#ifndef CONFIG_SYS_MB862xx_MMR
+#define CONFIG_SYS_MB862xx_MMR 0x11d7fa13
+#endif
+
 unsigned int pci_video_init (void)
 {
        GraphicDevice *dev = &mb862xx;
        pci_dev_t devbusfn;
+       u16 device;
 
        if ((devbusfn = pci_find_devices (supported, 0)) < 0) {
-               puts ("PCI video controller not found!\n");
+               puts("controller not present\n");
                return 0;
        }
 
@@ -212,11 +206,26 @@ unsigned int pci_video_init (void)
 
        dev->pciBase = dev->frameAdrs;
 
-       /* Setup clocks and memory mode for Coral-P Eval. Board */
-       HOST_WR_REG (GC_CCF, 0x00090000);
-       udelay (200);
-       HOST_WR_REG (GC_MMR, 0x11d7fa13);
-       udelay (100);
+       puts("Coral-");
+
+       pci_read_config_word(devbusfn, PCI_DEVICE_ID, &device);
+       switch (device) {
+       case PCI_DEVICE_ID_CORAL_P:
+               puts("P\n");
+               break;
+       case PCI_DEVICE_ID_CORAL_PA:
+               puts("PA\n");
+               break;
+       default:
+               puts("Unknown\n");
+               return 0;
+       }
+
+       /* Setup clocks and memory mode for Coral-P(A) */
+       HOST_WR_REG(GC_CCF, CONFIG_SYS_MB862xx_CCF);
+       udelay(200);
+       HOST_WR_REG(GC_MMR, CONFIG_SYS_MB862xx_MMR);
+       udelay(100);
        return dev->frameAdrs;
 }
 
@@ -235,12 +244,11 @@ unsigned int card_init (void)
        if (!pci_video_init ())
                return 0;
 
-       puts ("CoralP\n");
-
        tmp = 0;
        videomode = 0x310;
        /* get video mode via environment */
-       if ((penv = getenv ("videomode")) != NULL) {
+       penv = env_get("videomode");
+       if (penv) {
                /* decide if it is a string */
                if (penv[0] <= '9') {
                        videomode = (int) simple_strtoul (penv, NULL, 16);