]> git.sur5r.net Git - u-boot/blobdiff - arch/m68k/cpu/mcf52x2/cpu.c
SPDX: Convert all of our single license tags to Linux Kernel style
[u-boot] / arch / m68k / cpu / mcf52x2 / cpu.c
index d43ef2a9a835995e5de49e43b1f3731fcefd5915..29a17c57fcea0f382415eb3cc7f2023cc6becec5 100644 (file)
@@ -1,3 +1,4 @@
+// SPDX-License-Identifier: GPL-2.0+
 /*
  * (C) Copyright 2003
  * Josef Baumgartner <josef.baumgartner@telex.de>
  * MCF5275 additions
  * Copyright (C) 2008 Arthur Shipkowski (art@videon-central.com)
  *
- * 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
+ * Copyright (C) 2012 Freescale Semiconductor, Inc. All Rights Reserved.
  */
 
 #include <common.h>
 #include <watchdog.h>
 #include <command.h>
 #include <asm/immap.h>
+#include <asm/io.h>
 #include <netdev.h>
 #include "cpu.h"
 
@@ -40,17 +26,18 @@ DECLARE_GLOBAL_DATA_PTR;
 #ifdef CONFIG_M5208
 int do_reset(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
 {
-       volatile rcm_t *rcm = (rcm_t *)(MMAP_RCM);
+       rcm_t *rcm = (rcm_t *)(MMAP_RCM);
 
        udelay(1000);
 
-       rcm->rcr = RCM_RCR_SOFTRST;
+       out_8(&rcm->rcr, RCM_RCR_SOFTRST);
 
        /* we don't return! */
        return 0;
 };
 
-int checkcpu(void)
+#if defined(CONFIG_DISPLAY_CPUINFO)
+int print_cpuinfo(void)
 {
        char buf1[32], buf2[32];
 
@@ -60,24 +47,27 @@ int checkcpu(void)
               strmhz(buf2, gd->bus_clk));
        return 0;
 };
+#endif /* CONFIG_DISPLAY_CPUINFO */
 
 #if defined(CONFIG_WATCHDOG)
 /* Called by macro WATCHDOG_RESET */
 void watchdog_reset(void)
 {
-       volatile wdog_t *wdt = (volatile wdog_t *)(MMAP_WDOG);
-       wdt->sr = 0x5555;
-       wdt->sr = 0xAAAA;
+       wdog_t *wdt = (wdog_t *)(MMAP_WDOG);
+
+       out_be16(&wdt->sr, 0x5555);
+       out_be16(&wdt->sr, 0xaaaa);
 }
 
 int watchdog_disable(void)
 {
-       volatile wdog_t *wdt = (volatile wdog_t *)(MMAP_WDOG);
+       wdog_t *wdt = (wdog_t *)(MMAP_WDOG);
 
-       wdt->sr = 0x5555; /* reset watchdog counteDECLARE_GLOBAL_DATA_PTR;
-r */
-       wdt->sr = 0xAAAA;
-       wdt->cr = 0;    /* disable watchdog timer */
+       /* reset watchdog counter */
+       out_be16(&wdt->sr, 0x5555);
+       out_be16(&wdt->sr, 0xaaaa);
+       /* disable watchdog timer */
+       out_be16(&wdt->cr, 0);
 
        puts("WATCHDOG:disabled\n");
        return (0);
@@ -85,15 +75,18 @@ r */
 
 int watchdog_init(void)
 {
-       volatile wdog_t *wdt = (volatile wdog_t *)(MMAP_WDOG);
+       wdog_t *wdt = (wdog_t *)(MMAP_WDOG);
 
-       wdt->cr = 0;    /* disable watchdog */
+       /* disable watchdog */
+       out_be16(&wdt->cr, 0);
 
        /* set timeout and enable watchdog */
-       wdt->mr =
-               ((CONFIG_WATCHDOG_TIMEOUT * CONFIG_SYS_HZ) / (32768 * 1000)) - 1;
-       wdt->sr = 0x5555; /* reset watchdog counter */
-       wdt->sr = 0xAAAA;
+       out_be16(&wdt->mr,
+               (CONFIG_WATCHDOG_TIMEOUT * CONFIG_SYS_HZ) / (32768 * 1000) - 1);
+
+       /* reset watchdog counter */
+       out_be16(&wdt->sr, 0x5555);
+       out_be16(&wdt->sr, 0xaaaa);
 
        puts("WATCHDOG:enabled\n");
        return (0);
@@ -102,12 +95,13 @@ int watchdog_init(void)
 #endif                         /* #ifdef CONFIG_M5208 */
 
 #ifdef  CONFIG_M5271
+#if defined(CONFIG_DISPLAY_CPUINFO)
 /*
  * Both MCF5270 and MCF5271 are members of the MPC5271 family. Try to
  * determine which one we are running on, based on the Chip Identification
  * Register (CIR).
  */
-int checkcpu(void)
+int print_cpuinfo(void)
 {
        char buf[32];
        unsigned short cir;     /* Chip Identification Register */
@@ -141,6 +135,7 @@ int checkcpu(void)
 
        return 0;
 }
+#endif /* CONFIG_DISPLAY_CPUINFO */
 
 int do_reset(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
 {
@@ -179,27 +174,28 @@ int watchdog_init(void)
 #ifdef CONFIG_M5272
 int do_reset(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
 {
-       volatile wdog_t *wdp = (wdog_t *) (MMAP_WDOG);
+       wdog_t *wdp = (wdog_t *) (MMAP_WDOG);
 
-       wdp->wdog_wrrr = 0;
+       out_be16(&wdp->wdog_wrrr, 0);
        udelay(1000);
 
        /* enable watchdog, set timeout to 0 and wait */
-       wdp->wdog_wrrr = 1;
+       out_be16(&wdp->wdog_wrrr, 1);
        while (1) ;
 
        /* we don't return! */
        return 0;
 };
 
-int checkcpu(void)
+#if defined(CONFIG_DISPLAY_CPUINFO)
+int print_cpuinfo(void)
 {
-       volatile sysctrl_t *sysctrl = (sysctrl_t *) (MMAP_CFG);
+       sysctrl_t *sysctrl = (sysctrl_t *) (MMAP_CFG);
        uchar msk;
        char *suf;
 
        puts("CPU:   ");
-       msk = (sysctrl->sc_dir > 28) & 0xf;
+       msk = (in_be32(&sysctrl->sc_dir) > 28) & 0xf;
        switch (msk) {
        case 0x2:
                suf = "1K75N";
@@ -217,22 +213,27 @@ int checkcpu(void)
                printf("Freescale MCF5272 %s\n", suf);
        return 0;
 };
+#endif /* CONFIG_DISPLAY_CPUINFO */
 
 #if defined(CONFIG_WATCHDOG)
 /* Called by macro WATCHDOG_RESET */
 void watchdog_reset(void)
 {
-       volatile wdog_t *wdt = (volatile wdog_t *)(MMAP_WDOG);
-       wdt->wdog_wcr = 0;
+       wdog_t *wdt = (wdog_t *)(MMAP_WDOG);
+
+       out_be16(&wdt->wdog_wcr, 0);
 }
 
 int watchdog_disable(void)
 {
-       volatile wdog_t *wdt = (volatile wdog_t *)(MMAP_WDOG);
+       wdog_t *wdt = (wdog_t *)(MMAP_WDOG);
 
-       wdt->wdog_wcr = 0;      /* reset watchdog counter */
-       wdt->wdog_wirr = 0;     /* disable watchdog interrupt */
-       wdt->wdog_wrrr = 0;     /* disable watchdog timer */
+       /* reset watchdog counter */
+       out_be16(&wdt->wdog_wcr, 0);
+       /* disable watchdog interrupt */
+       out_be16(&wdt->wdog_wirr, 0);
+       /* disable watchdog timer */
+       out_be16(&wdt->wdog_wrrr, 0);
 
        puts("WATCHDOG:disabled\n");
        return (0);
@@ -240,14 +241,17 @@ int watchdog_disable(void)
 
 int watchdog_init(void)
 {
-       volatile wdog_t *wdt = (volatile wdog_t *)(MMAP_WDOG);
+       wdog_t *wdt = (wdog_t *)(MMAP_WDOG);
 
-       wdt->wdog_wirr = 0;     /* disable watchdog interrupt */
+       /* disable watchdog interrupt */
+       out_be16(&wdt->wdog_wirr, 0);
 
        /* set timeout and enable watchdog */
-       wdt->wdog_wrrr =
-           ((CONFIG_WATCHDOG_TIMEOUT * CONFIG_SYS_HZ) / (32768 * 1000)) - 1;
-       wdt->wdog_wcr = 0;      /* reset watchdog counter */
+       out_be16(&wdt->wdog_wrrr,
+               (CONFIG_WATCHDOG_TIMEOUT * CONFIG_SYS_HZ) / (32768 * 1000) - 1);
+
+       /* reset watchdog counter */
+       out_be16(&wdt->wdog_wcr, 0);
 
        puts("WATCHDOG:enabled\n");
        return (0);
@@ -259,17 +263,18 @@ int watchdog_init(void)
 #ifdef CONFIG_M5275
 int do_reset(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
 {
-       volatile rcm_t *rcm = (rcm_t *)(MMAP_RCM);
+       rcm_t *rcm = (rcm_t *)(MMAP_RCM);
 
        udelay(1000);
 
-       rcm->rcr = RCM_RCR_SOFTRST;
+       out_8(&rcm->rcr, RCM_RCR_SOFTRST);
 
        /* we don't return! */
        return 0;
 };
 
-int checkcpu(void)
+#if defined(CONFIG_DISPLAY_CPUINFO)
+int print_cpuinfo(void)
 {
        char buf[32];
 
@@ -277,24 +282,28 @@ int checkcpu(void)
                        strmhz(buf, CONFIG_SYS_CLK));
        return 0;
 };
-
+#endif /* CONFIG_DISPLAY_CPUINFO */
 
 #if defined(CONFIG_WATCHDOG)
 /* Called by macro WATCHDOG_RESET */
 void watchdog_reset(void)
 {
-       volatile wdog_t *wdt = (volatile wdog_t *)(MMAP_WDOG);
-       wdt->wsr = 0x5555;
-       wdt->wsr = 0xAAAA;
+       wdog_t *wdt = (wdog_t *)(MMAP_WDOG);
+
+       out_be16(&wdt->wsr, 0x5555);
+       out_be16(&wdt->wsr, 0xaaaa);
 }
 
 int watchdog_disable(void)
 {
-       volatile wdog_t *wdt = (volatile wdog_t *)(MMAP_WDOG);
+       wdog_t *wdt = (wdog_t *)(MMAP_WDOG);
 
-       wdt->wsr = 0x5555; /* reset watchdog counter */
-       wdt->wsr = 0xAAAA;
-       wdt->wcr = 0;   /* disable watchdog timer */
+       /* reset watchdog counter */
+       out_be16(&wdt->wsr, 0x5555);
+       out_be16(&wdt->wsr, 0xaaaa);
+
+       /* disable watchdog timer */
+       out_be16(&wdt->wcr, 0);
 
        puts("WATCHDOG:disabled\n");
        return (0);
@@ -302,15 +311,18 @@ int watchdog_disable(void)
 
 int watchdog_init(void)
 {
-       volatile wdog_t *wdt = (volatile wdog_t *)(MMAP_WDOG);
+       wdog_t *wdt = (wdog_t *)(MMAP_WDOG);
 
-       wdt->wcr = 0;   /* disable watchdog */
+       /* disable watchdog */
+       out_be16(&wdt->wcr, 0);
 
        /* set timeout and enable watchdog */
-       wdt->wmr =
-               ((CONFIG_WATCHDOG_TIMEOUT * CONFIG_SYS_HZ) / (32768 * 1000)) - 1;
-       wdt->wsr = 0x5555; /* reset watchdog counter */
-       wdt->wsr = 0xAAAA;
+       out_be16(&wdt->wmr,
+               (CONFIG_WATCHDOG_TIMEOUT * CONFIG_SYS_HZ) / (32768 * 1000) - 1);
+
+       /* reset watchdog counter */
+       out_be16(&wdt->wsr, 0x5555);
+       out_be16(&wdt->wsr, 0xaaaa);
 
        puts("WATCHDOG:enabled\n");
        return (0);
@@ -320,7 +332,8 @@ int watchdog_init(void)
 #endif                         /* #ifdef CONFIG_M5275 */
 
 #ifdef CONFIG_M5282
-int checkcpu(void)
+#if defined(CONFIG_DISPLAY_CPUINFO)
+int print_cpuinfo(void)
 {
        unsigned char resetsource = MCFRESET_RSR;
 
@@ -336,6 +349,7 @@ int checkcpu(void)
               (resetsource & MCFRESET_RSR_LVD) ? " Low Voltage" : "");
        return 0;
 }
+#endif /* CONFIG_DISPLAY_CPUINFO */
 
 int do_reset(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
 {
@@ -345,7 +359,8 @@ int do_reset(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
 #endif
 
 #ifdef CONFIG_M5249
-int checkcpu(void)
+#if defined(CONFIG_DISPLAY_CPUINFO)
+int print_cpuinfo(void)
 {
        char buf[32];
 
@@ -353,6 +368,7 @@ int checkcpu(void)
               strmhz(buf, CONFIG_SYS_CLK));
        return 0;
 }
+#endif /* CONFIG_DISPLAY_CPUINFO */
 
 int do_reset(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
 {
@@ -366,7 +382,8 @@ int do_reset(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
 #endif
 
 #ifdef CONFIG_M5253
-int checkcpu(void)
+#if defined(CONFIG_DISPLAY_CPUINFO)
+int print_cpuinfo(void)
 {
        char buf[32];
 
@@ -383,6 +400,7 @@ int checkcpu(void)
        }
        return 0;
 }
+#endif /* CONFIG_DISPLAY_CPUINFO */
 
 int do_reset(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
 {