Path: blob/master/arch/mips/cavium-octeon/executive/cvmx-sysinfo.c
10818 views
/***********************license start***************1* Author: Cavium Networks2*3* Contact: [email protected]4* This file is part of the OCTEON SDK5*6* Copyright (c) 2003-2008 Cavium Networks7*8* This file is free software; you can redistribute it and/or modify9* it under the terms of the GNU General Public License, Version 2, as10* published by the Free Software Foundation.11*12* This file is distributed in the hope that it will be useful, but13* AS-IS and WITHOUT ANY WARRANTY; without even the implied warranty14* of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE, TITLE, or15* NONINFRINGEMENT. See the GNU General Public License for more16* details.17*18* You should have received a copy of the GNU General Public License19* along with this file; if not, write to the Free Software20* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA21* or visit http://www.gnu.org/licenses/.22*23* This file may also be available under a different license from Cavium.24* Contact Cavium Networks for more information25***********************license end**************************************/2627/*28* This module provides system/board/application information obtained29* by the bootloader.30*/31#include <linux/module.h>3233#include <asm/octeon/cvmx.h>34#include <asm/octeon/cvmx-spinlock.h>35#include <asm/octeon/cvmx-sysinfo.h>3637/**38* This structure defines the private state maintained by sysinfo module.39*40*/41static struct {42struct cvmx_sysinfo sysinfo; /* system information */43cvmx_spinlock_t lock; /* mutex spinlock */4445} state = {46.lock = CVMX_SPINLOCK_UNLOCKED_INITIALIZER47};484950/*51* Global variables that define the min/max of the memory region set52* up for 32 bit userspace access.53*/54uint64_t linux_mem32_min;55uint64_t linux_mem32_max;56uint64_t linux_mem32_wired;57uint64_t linux_mem32_offset;5859/**60* This function returns the application information as obtained61* by the bootloader. This provides the core mask of the cores62* running the same application image, as well as the physical63* memory regions available to the core.64*65* Returns Pointer to the boot information structure66*67*/68struct cvmx_sysinfo *cvmx_sysinfo_get(void)69{70return &(state.sysinfo);71}72EXPORT_SYMBOL(cvmx_sysinfo_get);7374/**75* This function is used in non-simple executive environments (such as76* Linux kernel, u-boot, etc.) to configure the minimal fields that77* are required to use simple executive files directly.78*79* Locking (if required) must be handled outside of this80* function81*82* @phy_mem_desc_ptr:83* Pointer to global physical memory descriptor84* (bootmem descriptor) @board_type: Octeon board85* type enumeration86*87* @board_rev_major:88* Board major revision89* @board_rev_minor:90* Board minor revision91* @cpu_clock_hz:92* CPU clock freqency in hertz93*94* Returns 0: Failure95* 1: success96*/97int cvmx_sysinfo_minimal_initialize(void *phy_mem_desc_ptr,98uint16_t board_type,99uint8_t board_rev_major,100uint8_t board_rev_minor,101uint32_t cpu_clock_hz)102{103104/* The sysinfo structure was already initialized */105if (state.sysinfo.board_type)106return 0;107108memset(&(state.sysinfo), 0x0, sizeof(state.sysinfo));109state.sysinfo.phy_mem_desc_ptr = phy_mem_desc_ptr;110state.sysinfo.board_type = board_type;111state.sysinfo.board_rev_major = board_rev_major;112state.sysinfo.board_rev_minor = board_rev_minor;113state.sysinfo.cpu_clock_hz = cpu_clock_hz;114115return 1;116}117118119