xref: /rk3399_rockchip-uboot/api/api_platform-powerpc.c (revision a47a12becf66f02a56da91c161e2edb625e9f20c)
1*a47a12beSStefan Roese /*
2*a47a12beSStefan Roese  * (C) Copyright 2007 Semihalf
3*a47a12beSStefan Roese  *
4*a47a12beSStefan Roese  * Written by: Rafal Jaworowski <raj@semihalf.com>
5*a47a12beSStefan Roese  *
6*a47a12beSStefan Roese  * See file CREDITS for list of people who contributed to this
7*a47a12beSStefan Roese  * project.
8*a47a12beSStefan Roese  *
9*a47a12beSStefan Roese  * This program is free software; you can redistribute it and/or
10*a47a12beSStefan Roese  * modify it under the terms of the GNU General Public License as
11*a47a12beSStefan Roese  * published by the Free Software Foundation; either version 2 of
12*a47a12beSStefan Roese  * the License, or (at your option) any later version.
13*a47a12beSStefan Roese  *
14*a47a12beSStefan Roese  * This program is distributed in the hope that it will be useful,
15*a47a12beSStefan Roese  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16*a47a12beSStefan Roese  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17*a47a12beSStefan Roese  * GNU General Public License for more details.
18*a47a12beSStefan Roese  *
19*a47a12beSStefan Roese  * You should have received a copy of the GNU General Public License
20*a47a12beSStefan Roese  * along with this program; if not, write to the Free Software
21*a47a12beSStefan Roese  * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
22*a47a12beSStefan Roese  * MA 02111-1307 USA
23*a47a12beSStefan Roese  *
24*a47a12beSStefan Roese  *
25*a47a12beSStefan Roese  * This file contains routines that fetch data from PowerPC-dependent sources
26*a47a12beSStefan Roese  * (bd_info etc.)
27*a47a12beSStefan Roese  *
28*a47a12beSStefan Roese  */
29*a47a12beSStefan Roese 
30*a47a12beSStefan Roese #include <config.h>
31*a47a12beSStefan Roese #include <linux/types.h>
32*a47a12beSStefan Roese #include <api_public.h>
33*a47a12beSStefan Roese 
34*a47a12beSStefan Roese #include <asm/u-boot.h>
35*a47a12beSStefan Roese #include <asm/global_data.h>
36*a47a12beSStefan Roese 
37*a47a12beSStefan Roese #include "api_private.h"
38*a47a12beSStefan Roese 
39*a47a12beSStefan Roese DECLARE_GLOBAL_DATA_PTR;
40*a47a12beSStefan Roese 
41*a47a12beSStefan Roese /*
42*a47a12beSStefan Roese  * Important notice: handling of individual fields MUST be kept in sync with
43*a47a12beSStefan Roese  * include/asm-ppc/u-boot.h and include/asm-ppc/global_data.h, so any changes
44*a47a12beSStefan Roese  * need to reflect their current state and layout of structures involved!
45*a47a12beSStefan Roese  */
46*a47a12beSStefan Roese int platform_sys_info(struct sys_info *si)
47*a47a12beSStefan Roese {
48*a47a12beSStefan Roese 	si->clk_bus = gd->bus_clk;
49*a47a12beSStefan Roese 	si->clk_cpu = gd->cpu_clk;
50*a47a12beSStefan Roese 
51*a47a12beSStefan Roese #if defined(CONFIG_5xx) || defined(CONFIG_8xx) || defined(CONFIG_8260) || \
52*a47a12beSStefan Roese     defined(CONFIG_E500) || defined(CONFIG_MPC86xx)
53*a47a12beSStefan Roese #define bi_bar	bi_immr_base
54*a47a12beSStefan Roese #elif defined(CONFIG_MPC5xxx)
55*a47a12beSStefan Roese #define bi_bar	bi_mbar_base
56*a47a12beSStefan Roese #elif defined(CONFIG_MPC83xx)
57*a47a12beSStefan Roese #define bi_bar	bi_immrbar
58*a47a12beSStefan Roese #elif defined(CONFIG_MPC8220)
59*a47a12beSStefan Roese #define bi_bar	bi_mbar_base
60*a47a12beSStefan Roese #endif
61*a47a12beSStefan Roese 
62*a47a12beSStefan Roese #if defined(bi_bar)
63*a47a12beSStefan Roese 	si->bar = gd->bd->bi_bar;
64*a47a12beSStefan Roese #undef bi_bar
65*a47a12beSStefan Roese #else
66*a47a12beSStefan Roese 	si->bar = 0;
67*a47a12beSStefan Roese #endif
68*a47a12beSStefan Roese 
69*a47a12beSStefan Roese 	platform_set_mr(si, gd->bd->bi_memstart, gd->bd->bi_memsize, MR_ATTR_DRAM);
70*a47a12beSStefan Roese 	platform_set_mr(si, gd->bd->bi_flashstart, gd->bd->bi_flashsize, MR_ATTR_FLASH);
71*a47a12beSStefan Roese 	platform_set_mr(si, gd->bd->bi_sramstart, gd->bd->bi_sramsize, MR_ATTR_SRAM);
72*a47a12beSStefan Roese 
73*a47a12beSStefan Roese 	return 1;
74*a47a12beSStefan Roese }
75