Merge tag 'u-boot-atmel-fixes-2020.07-a' of https://gitlab.denx.de/u-boot/custodians...
[oweals/u-boot.git] / arch / powerpc / cpu / mpc86xx / mp.c
index b4a0faacde0c8bcc11914e49492603e07ec911d2..08d11ad4f2e5857cbcf6878eb789da6ba94b91d4 100644 (file)
@@ -1,26 +1,10 @@
+// SPDX-License-Identifier: GPL-2.0+
 /*
  * Copyright 2008-2010 Freescale Semiconductor, Inc.
- *
- * 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 <cpu_func.h>
 #include <asm/processor.h>
 #include <asm/mmu.h>
 #include <ioports.h>
@@ -30,7 +14,7 @@
 
 DECLARE_GLOBAL_DATA_PTR;
 
-int cpu_reset(int nr)
+int cpu_reset(u32 nr)
 {
        /* dummy function so common/cmd_mp.c will build
         * should be implemented in the future, when cpu_release()
@@ -40,13 +24,13 @@ int cpu_reset(int nr)
        return 1;
 }
 
-int cpu_status(int nr)
+int cpu_status(u32 nr)
 {
        /* dummy function so common/cmd_mp.c will build */
        return 0;
 }
 
-int cpu_disable(int nr)
+int cpu_disable(u32 nr)
 {
        volatile immap_t *immap = (immap_t *) CONFIG_SYS_CCSRBAR;
        volatile ccsr_gur_t *gur = &immap->im_gur;
@@ -66,15 +50,35 @@ int cpu_disable(int nr)
        return 0;
 }
 
-int cpu_release(int nr, int argc, char *argv[])
+int is_core_disabled(int nr) {
+       immap_t *immap = (immap_t *) CONFIG_SYS_CCSRBAR;
+       ccsr_gur_t *gur = &immap->im_gur;
+       u32 devdisr = in_be32(&gur->devdisr);
+
+       switch (nr) {
+       case 0:
+               return (devdisr & MPC86xx_DEVDISR_CPU0);
+       case 1:
+               return (devdisr & MPC86xx_DEVDISR_CPU1);
+       default:
+               printf("Invalid cpu number for disable %d\n", nr);
+       }
+
+       return 0;
+}
+
+int cpu_release(u32 nr, int argc, char *const argv[])
 {
        /* dummy function so common/cmd_mp.c will build
         * should be implemented in the future */
        return 1;
 }
 
-u32 determine_mp_bootpg(void)
+u32 determine_mp_bootpg(unsigned int *pagesize)
 {
+       if (pagesize)
+               *pagesize = 4096;
+
        /* if we have 4G or more of memory, put the boot page at 4Gb-1M */
        if ((u64)gd->ram_size > 0xfffff000)
                return (0xfff00000);
@@ -84,7 +88,7 @@ u32 determine_mp_bootpg(void)
 
 void cpu_mp_lmb_reserve(struct lmb *lmb)
 {
-       u32 bootpg = determine_mp_bootpg();
+       u32 bootpg = determine_mp_bootpg(NULL);
 
        /* tell u-boot we stole a page */
        lmb_reserve(lmb, bootpg, 4096);
@@ -98,7 +102,7 @@ void setup_mp(void)
 {
        extern ulong __secondary_start_page;
        ulong fixup = (ulong)&__secondary_start_page;
-       u32 bootpg = determine_mp_bootpg();
+       u32 bootpg = determine_mp_bootpg(NULL);
        u32 bootpg_va;
 
        if (bootpg >= CONFIG_SYS_MAX_DDR_BAT_SIZE) {