~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

TOMOYO Linux Cross Reference
Linux/arch/powerpc/boot/treeboot-currituck.c

Version: ~ [ linux-5.14-rc1 ] ~ [ linux-5.13.1 ] ~ [ linux-5.12.16 ] ~ [ linux-5.11.22 ] ~ [ linux-5.10.49 ] ~ [ linux-5.9.16 ] ~ [ linux-5.8.18 ] ~ [ linux-5.7.19 ] ~ [ linux-5.6.19 ] ~ [ linux-5.5.19 ] ~ [ linux-5.4.131 ] ~ [ linux-5.3.18 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.197 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.239 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.275 ] ~ [ linux-4.8.17 ] ~ [ linux-4.7.10 ] ~ [ linux-4.6.7 ] ~ [ linux-4.5.7 ] ~ [ linux-4.4.275 ] ~ [ linux-4.3.6 ] ~ [ linux-4.2.8 ] ~ [ linux-4.1.52 ] ~ [ linux-4.0.9 ] ~ [ linux-3.18.140 ] ~ [ linux-3.16.85 ] ~ [ linux-3.14.79 ] ~ [ linux-3.12.74 ] ~ [ linux-3.10.108 ] ~ [ linux-2.6.32.71 ] ~ [ linux-2.6.0 ] ~ [ linux-2.4.37.11 ] ~ [ unix-v6-master ] ~ [ ccs-tools-1.8.5 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

  1 /*
  2  * Copyright © 2011 Tony Breeds IBM Corporation
  3  *
  4  * Based on earlier code:
  5  *   Copyright (C) Paul Mackerras 1997.
  6  *
  7  *   Matt Porter <mporter@kernel.crashing.org>
  8  *   Copyright 2002-2005 MontaVista Software Inc.
  9  *
 10  *   Eugene Surovegin <eugene.surovegin@zultys.com> or <ebs@ebshome.net>
 11  *   Copyright (c) 2003, 2004 Zultys Technologies
 12  *
 13  *    Copyright 2007 David Gibson, IBM Corporation.
 14  *    Copyright 2010 Ben. Herrenschmidt, IBM Corporation.
 15  *    Copyright © 2011 David Kleikamp IBM Corporation
 16  *
 17  * This program is free software; you can redistribute it and/or
 18  * modify it under the terms of the GNU General Public License
 19  * as published by the Free Software Foundation; either version
 20  * 2 of the License, or (at your option) any later version.
 21  */
 22 #include <stdarg.h>
 23 #include <stddef.h>
 24 #include "types.h"
 25 #include "elf.h"
 26 #include "string.h"
 27 #include "stdio.h"
 28 #include "page.h"
 29 #include "ops.h"
 30 #include "reg.h"
 31 #include "io.h"
 32 #include "dcr.h"
 33 #include "4xx.h"
 34 #include "44x.h"
 35 #include "libfdt.h"
 36 
 37 BSS_STACK(4096);
 38 
 39 #define MAX_RANKS       0x4
 40 #define DDR3_MR0CF      0x80010011U
 41 
 42 static unsigned long long ibm_currituck_memsize;
 43 static unsigned long long ibm_currituck_detect_memsize(void)
 44 {
 45         u32 reg;
 46         unsigned i;
 47         unsigned long long memsize = 0;
 48 
 49         for(i = 0; i < MAX_RANKS; i++){
 50                 reg = mfdcrx(DDR3_MR0CF + i);
 51 
 52                 if (!(reg & 1))
 53                         continue;
 54 
 55                 reg &= 0x0000f000;
 56                 reg >>= 12;
 57                 memsize += (0x800000ULL << reg);
 58         }
 59 
 60         return memsize;
 61 }
 62 
 63 static void ibm_currituck_fixups(void)
 64 {
 65         void *devp = finddevice("/");
 66         u32 dma_ranges[7];
 67 
 68         dt_fixup_memory(0x0ULL,  ibm_currituck_memsize);
 69 
 70         while ((devp = find_node_by_devtype(devp, "pci"))) {
 71                 if (getprop(devp, "dma-ranges", dma_ranges, sizeof(dma_ranges)) < 0) {
 72                         printf("%s: Failed to get dma-ranges\r\n", __func__);
 73                         continue;
 74                 }
 75 
 76                 dma_ranges[5] = ibm_currituck_memsize >> 32;
 77                 dma_ranges[6] = ibm_currituck_memsize & 0xffffffffUL;
 78 
 79                 setprop(devp, "dma-ranges", dma_ranges, sizeof(dma_ranges));
 80         }
 81 }
 82 
 83 #define SPRN_PIR        0x11E   /* Processor Identification Register */
 84 void platform_init(void)
 85 {
 86         unsigned long end_of_ram, avail_ram;
 87         u32 pir_reg;
 88         int node, size;
 89         const u32 *timebase;
 90 
 91         ibm_currituck_memsize = ibm_currituck_detect_memsize();
 92         if (ibm_currituck_memsize >> 32)
 93                 end_of_ram = ~0UL;
 94         else
 95                 end_of_ram = ibm_currituck_memsize;
 96         avail_ram = end_of_ram - (unsigned long)_end;
 97 
 98         simple_alloc_init(_end, avail_ram, 128, 64);
 99         platform_ops.fixups = ibm_currituck_fixups;
100         platform_ops.exit = ibm44x_dbcr_reset;
101         pir_reg = mfspr(SPRN_PIR);
102 
103         /* Make sure FDT blob is sane */
104         if (fdt_check_header(_dtb_start) != 0)
105                 fatal("Invalid device tree blob\n");
106 
107         node = fdt_node_offset_by_prop_value(_dtb_start, -1, "device_type",
108                                              "cpu", sizeof("cpu"));
109         if (!node)
110                 fatal("Cannot find cpu node\n");
111         timebase = fdt_getprop(_dtb_start, node, "timebase-frequency", &size);
112         if (timebase && (size == 4))
113                 timebase_period_ns = 1000000000 / *timebase;
114 
115         fdt_set_boot_cpuid_phys(_dtb_start, pir_reg);
116         fdt_init(_dtb_start);
117 
118         serial_console_init();
119 }
120 

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

kernel.org | git.kernel.org | LWN.net | Project Home | Wiki (Japanese) | Wiki (English) | SVN repository | Mail admin

Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.

osdn.jp