/*1* Support for MicroBlaze PVR (processor version register)2*3* Copyright (C) 2007-2009 Michal Simek <[email protected]>4* Copyright (C) 2007-2009 PetaLogix5* Copyright (C) 2007 John Williams <[email protected]>6*7* This file is subject to the terms and conditions of the GNU General Public8* License. See the file "COPYING" in the main directory of this archive9* for more details.10*/1112#include <linux/kernel.h>13#include <linux/compiler.h>14#include <asm/exceptions.h>15#include <asm/pvr.h>16#include <linux/irqflags.h>1718/*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, rpvrNN22*/2324#define get_single_pvr(pvrid, val) \25{ \26register unsigned tmp __asm__("r3"); \27tmp = 0x0; /* Prevent warning about unused */ \28__asm__ __volatile__ ( \29"mfs %0, rpvr" #pvrid ";" \30: "=r" (tmp) : : "memory"); \31val = tmp; \32}3334/*35* Does the CPU support the PVR register?36* return value:37* 0: no PVR38* 1: simple PVR39* 2: full PVR40*41* This must work on all CPU versions, including those before the42* PVR was even an option.43*/4445int cpu_has_pvr(void)46{47unsigned long flags;48unsigned pvr0;4950local_save_flags(flags);5152/* PVR bit in MSR tells us if there is any support */53if (!(flags & PVR_MSR_BIT))54return 0;5556get_single_pvr(0, pvr0);57pr_debug("%s: pvr0 is 0x%08x\n", __func__, pvr0);5859if (pvr0 & PVR0_PVR_FULL_MASK)60return 1;6162/* for partial PVR use static cpuinfo */63return 2;64}6566void get_pvr(struct pvr_s *p)67{68get_single_pvr(0, p->pvr[0]);69get_single_pvr(1, p->pvr[1]);70get_single_pvr(2, p->pvr[2]);71get_single_pvr(3, p->pvr[3]);72get_single_pvr(4, p->pvr[4]);73get_single_pvr(5, p->pvr[5]);74get_single_pvr(6, p->pvr[6]);75get_single_pvr(7, p->pvr[7]);76get_single_pvr(8, p->pvr[8]);77get_single_pvr(9, p->pvr[9]);78get_single_pvr(10, p->pvr[10]);79get_single_pvr(11, p->pvr[11]);80}818283