root/arch/microblaze/kernel/cpu/pvr.c

/* [<][>][^][v][top][bottom][index][help] */

DEFINITIONS

This source file includes following definitions.
  1. cpu_has_pvr
  2. get_pvr

   1 /*
   2  * Support for MicroBlaze PVR (processor version register)
   3  *
   4  * Copyright (C) 2007-2009 Michal Simek <monstr@monstr.eu>
   5  * Copyright (C) 2007-2009 PetaLogix
   6  * Copyright (C) 2007 John Williams <john.williams@petalogix.com>
   7  *
   8  * This file is subject to the terms and conditions of the GNU General Public
   9  * License. See the file "COPYING" in the main directory of this archive
  10  * for more details.
  11  */
  12 
  13 #include <linux/kernel.h>
  14 #include <linux/compiler.h>
  15 #include <asm/exceptions.h>
  16 #include <asm/pvr.h>
  17 
  18 /*
  19  * Until we get an assembler that knows about the pvr registers,
  20  * this horrible cruft will have to do.
  21  * That hardcoded opcode is mfs r3, rpvrNN
  22  */
  23 
  24 #define get_single_pvr(pvrid, val)                              \
  25 {                                                               \
  26         register unsigned tmp __asm__("r3");                    \
  27         tmp = 0x0;      /* Prevent warning about unused */      \
  28         __asm__ __volatile__ (                                  \
  29                         "mfs    %0, rpvr" #pvrid ";"            \
  30                         : "=r" (tmp) : : "memory");             \
  31         val = tmp;                                              \
  32 }
  33 
  34 /*
  35  * Does the CPU support the PVR register?
  36  * return value:
  37  * 0: no PVR
  38  * 1: simple PVR
  39  * 2: full PVR
  40  *
  41  * This must work on all CPU versions, including those before the
  42  * PVR was even an option.
  43  */
  44 
  45 int cpu_has_pvr(void)
  46 {
  47         unsigned long flags;
  48         unsigned pvr0;
  49 
  50         local_save_flags(flags);
  51 
  52         /* PVR bit in MSR tells us if there is any support */
  53         if (!(flags & PVR_MSR_BIT))
  54                 return 0;
  55 
  56         get_single_pvr(0, pvr0);
  57         pr_debug("%s: pvr0 is 0x%08x\n", __func__, pvr0);
  58 
  59         if (pvr0 & PVR0_PVR_FULL_MASK)
  60                 return 1;
  61 
  62         /* for partial PVR use static cpuinfo */
  63         return 2;
  64 }
  65 
  66 void get_pvr(struct pvr_s *p)
  67 {
  68         get_single_pvr(0, p->pvr[0]);
  69         get_single_pvr(1, p->pvr[1]);
  70         get_single_pvr(2, p->pvr[2]);
  71         get_single_pvr(3, p->pvr[3]);
  72         get_single_pvr(4, p->pvr[4]);
  73         get_single_pvr(5, p->pvr[5]);
  74         get_single_pvr(6, p->pvr[6]);
  75         get_single_pvr(7, p->pvr[7]);
  76         get_single_pvr(8, p->pvr[8]);
  77         get_single_pvr(9, p->pvr[9]);
  78         get_single_pvr(10, p->pvr[10]);
  79         get_single_pvr(11, p->pvr[11]);
  80 }

/* [<][>][^][v][top][bottom][index][help] */