blob: 3a04a9f691c5b58a30a7160c97f2a435a30304a3 [file] [log] [blame]
Tom Rini83d290c2018-05-06 17:58:06 -04001// SPDX-License-Identifier: GPL-2.0+
Rafal Jaworowski500856e2008-01-09 19:39:36 +01002/*
3 * (C) Copyright 2007 Semihalf
4 *
5 * Written by: Rafal Jaworowski <raj@semihalf.com>
6 *
Rafal Jaworowski500856e2008-01-09 19:39:36 +01007 * This file contains routines that fetch data from PowerPC-dependent sources
8 * (bd_info etc.)
Rafal Jaworowski500856e2008-01-09 19:39:36 +01009 */
10
11#include <config.h>
Rafal Jaworowski500856e2008-01-09 19:39:36 +010012#include <linux/types.h>
13#include <api_public.h>
14
Rafal Jaworowski500856e2008-01-09 19:39:36 +010015#include <asm/global_data.h>
16
17#include "api_private.h"
18
19DECLARE_GLOBAL_DATA_PTR;
20
21/*
22 * Important notice: handling of individual fields MUST be kept in sync with
23 * include/asm-ppc/u-boot.h and include/asm-ppc/global_data.h, so any changes
24 * need to reflect their current state and layout of structures involved!
25 */
26int platform_sys_info(struct sys_info *si)
27{
28 si->clk_bus = gd->bus_clk;
29 si->clk_cpu = gd->cpu_clk;
30
Christophe Leroyee1e6002018-03-16 17:20:41 +010031#if defined(CONFIG_MPC8xx) || defined(CONFIG_E500) || defined(CONFIG_MPC86xx)
Rafal Jaworowski500856e2008-01-09 19:39:36 +010032#define bi_bar bi_immr_base
Peter Tyser0f898602009-05-22 17:23:24 -050033#elif defined(CONFIG_MPC83xx)
Rafal Jaworowski500856e2008-01-09 19:39:36 +010034#define bi_bar bi_immrbar
Rafal Jaworowski500856e2008-01-09 19:39:36 +010035#endif
36
37#if defined(bi_bar)
38 si->bar = gd->bd->bi_bar;
39#undef bi_bar
40#else
Matthias Fuchs12c66702008-10-04 19:26:16 +020041 si->bar = 0;
Rafal Jaworowski500856e2008-01-09 19:39:36 +010042#endif
43
Stefan Roesee207f222020-08-12 13:16:36 +020044 platform_set_mr(si, gd->ram_base, gd->ram_size, MR_ATTR_DRAM);
Rafal Jaworowski500856e2008-01-09 19:39:36 +010045 platform_set_mr(si, gd->bd->bi_flashstart, gd->bd->bi_flashsize, MR_ATTR_FLASH);
46 platform_set_mr(si, gd->bd->bi_sramstart, gd->bd->bi_sramsize, MR_ATTR_SRAM);
47
48 return 1;
49}