rv_ctrl.hh revision 11011
12810SN/A/* 212724Snikos.nikoleris@arm.com * Copyright (c) 2010,2013,2015 ARM Limited 38856Sandreas.hansson@arm.com * All rights reserved 48856Sandreas.hansson@arm.com * 58856Sandreas.hansson@arm.com * The license below extends only to copyright in the software and shall 68856Sandreas.hansson@arm.com * not be construed as granting a license to any other intellectual 78856Sandreas.hansson@arm.com * property including but not limited to intellectual property relating 88856Sandreas.hansson@arm.com * to a hardware implementation of the functionality of the software 98856Sandreas.hansson@arm.com * licensed hereunder. You may use the software subject to the license 108856Sandreas.hansson@arm.com * terms below provided that you ensure that this notice is replicated 118856Sandreas.hansson@arm.com * unmodified and in its entirety in all distributions of the software, 128856Sandreas.hansson@arm.com * modified or unmodified, in source code or in binary form. 138856Sandreas.hansson@arm.com * 142810SN/A * Redistribution and use in source and binary forms, with or without 152810SN/A * modification, are permitted provided that the following conditions are 162810SN/A * met: redistributions of source code must retain the above copyright 172810SN/A * notice, this list of conditions and the following disclaimer; 182810SN/A * redistributions in binary form must reproduce the above copyright 192810SN/A * notice, this list of conditions and the following disclaimer in the 202810SN/A * documentation and/or other materials provided with the distribution; 212810SN/A * neither the name of the copyright holders nor the names of its 222810SN/A * contributors may be used to endorse or promote products derived from 232810SN/A * this software without specific prior written permission. 242810SN/A * 252810SN/A * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 262810SN/A * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 272810SN/A * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 282810SN/A * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 292810SN/A * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 302810SN/A * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 312810SN/A * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 322810SN/A * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 332810SN/A * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 342810SN/A * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 352810SN/A * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 362810SN/A * 372810SN/A * Authors: Ali Saidi 382810SN/A */ 392810SN/A 402810SN/A#ifndef __DEV_ARM_RV_HH__ 414458SN/A#define __DEV_ARM_RV_HH__ 424458SN/A 4312724Snikos.nikoleris@arm.com#include "base/bitunion.hh" 4412724Snikos.nikoleris@arm.com#include "dev/io_device.hh" 452810SN/A#include "params/RealViewCtrl.hh" 462810SN/A#include "params/RealViewOsc.hh" 472810SN/A 482810SN/A/** @file 492810SN/A * This implements the simple real view registers on a PBXA9 502810SN/A */ 512810SN/A 5211051Sandreas.hansson@arm.comclass RealViewCtrl : public BasicPioDevice 5311051Sandreas.hansson@arm.com{ 542810SN/A public: 5512724Snikos.nikoleris@arm.com enum DeviceFunc { 5612724Snikos.nikoleris@arm.com FUNC_OSC = 1, 577676Snate@binkert.org FUNC_VOLT = 2, 582810SN/A FUNC_AMP = 3, 5912724Snikos.nikoleris@arm.com FUNC_TEMP = 4, 602810SN/A FUNC_RESET = 5, 612810SN/A FUNC_SCC = 6, 626215Snate@binkert.org FUNC_MUXFPGA = 7, 638232Snate@binkert.org FUNC_SHUTDOWN = 8, 648232Snate@binkert.org FUNC_REBOOT = 9, 6512724Snikos.nikoleris@arm.com FUNC_DVIMODE = 11, 6612724Snikos.nikoleris@arm.com FUNC_POWER = 12, 675338Sstever@gmail.com FUNC_ENERGY = 13, 6812724Snikos.nikoleris@arm.com }; 6911375Sandreas.hansson@arm.com 7012724Snikos.nikoleris@arm.com class Device 712810SN/A { 722810SN/A public: 7312724Snikos.nikoleris@arm.com Device(RealViewCtrl &parent, DeviceFunc func, 748914Sandreas.hansson@arm.com uint8_t site, uint8_t pos, uint8_t dcc, uint16_t dev) 758229Snate@binkert.org { 762811SN/A parent.registerDevice(func, site, pos, dcc, dev, this); 7712724Snikos.nikoleris@arm.com } 784626SN/A 798833Sdam.sunwoo@arm.com virtual ~Device() {} 802810SN/A 8112724Snikos.nikoleris@arm.com virtual uint32_t read() const = 0; 8212724Snikos.nikoleris@arm.com virtual void write(uint32_t value) = 0; 8312724Snikos.nikoleris@arm.com }; 8412724Snikos.nikoleris@arm.com 8512724Snikos.nikoleris@arm.com protected: 8612724Snikos.nikoleris@arm.com enum { 8712724Snikos.nikoleris@arm.com IdReg = 0x00, 8812724Snikos.nikoleris@arm.com SwReg = 0x04, 892810SN/A Led = 0x08, 902810SN/A Osc0 = 0x0C, 912810SN/A Osc1 = 0x10, 922810SN/A Osc2 = 0x14, 932810SN/A Osc3 = 0x18, 9411375Sandreas.hansson@arm.com Osc4 = 0x1C, 954628SN/A Lock = 0x20, 964628SN/A Clock100 = 0x24, 974628SN/A CfgData1 = 0x28, 984628SN/A CfgData2 = 0x2C, 994628SN/A Flags = 0x30, 1004628SN/A FlagsClr = 0x34, 1014628SN/A NvFlags = 0x38, 1024628SN/A NvFlagsClr = 0x3C, 1038737Skoansin.tan@gmail.com ResetCtl = 0x40, 1044628SN/A PciCtl = 0x44, 1054628SN/A MciCtl = 0x48, 1064628SN/A Flash = 0x4C, 1074628SN/A Clcd = 0x50, 1084628SN/A ClcdSer = 0x54, 1094628SN/A Bootcs = 0x58, 1104628SN/A Clock24 = 0x5C, 1114628SN/A Misc = 0x60, 1124628SN/A IoSel = 0x70, 1134628SN/A ProcId0 = 0x84, 1148737Skoansin.tan@gmail.com ProcId1 = 0x88, 1154628SN/A CfgData = 0xA0, 1168856Sandreas.hansson@arm.com CfgCtrl = 0xA4, 1178856Sandreas.hansson@arm.com CfgStat = 0xA8, 1188856Sandreas.hansson@arm.com TestOsc0 = 0xC0, 1198856Sandreas.hansson@arm.com TestOsc1 = 0xC4, 1208856Sandreas.hansson@arm.com TestOsc2 = 0xC8, 12110942Sandreas.hansson@arm.com TestOsc3 = 0xCC, 1228856Sandreas.hansson@arm.com TestOsc4 = 0xD0 1238856Sandreas.hansson@arm.com }; 1248856Sandreas.hansson@arm.com 1258922Swilliam.wang@arm.com // system lock value 1262810SN/A BitUnion32(SysLockReg) 1278856Sandreas.hansson@arm.com Bitfield<15,0> lockVal; 1282844SN/A Bitfield<16> locked; 1298856Sandreas.hansson@arm.com EndBitUnion(SysLockReg) 1308856Sandreas.hansson@arm.com 1318856Sandreas.hansson@arm.com BitUnion32(CfgCtrlReg) 13210713Sandreas.hansson@arm.com Bitfield<11, 0> dev; 1338856Sandreas.hansson@arm.com Bitfield<15, 12> pos; 13410942Sandreas.hansson@arm.com Bitfield<17, 16> site; 1358856Sandreas.hansson@arm.com Bitfield<25, 20> func; 13610942Sandreas.hansson@arm.com Bitfield<29, 26> dcc; 13710713Sandreas.hansson@arm.com Bitfield<30> wr; 1388856Sandreas.hansson@arm.com Bitfield<31> start; 1398856Sandreas.hansson@arm.com EndBitUnion(CfgCtrlReg) 1403738SN/A 1414458SN/A static const uint32_t CFG_CTRL_ADDR_MASK = 0x3fffffffUL; 1428856Sandreas.hansson@arm.com 14310713Sandreas.hansson@arm.com SysLockReg sysLock; 14410713Sandreas.hansson@arm.com 14510713Sandreas.hansson@arm.com /** This register is used for smp booting. 1468914Sandreas.hansson@arm.com * The primary cpu writes the secondary start address here before 1472810SN/A * sends it a soft interrupt. The secondary cpu reads this register and if 1488856Sandreas.hansson@arm.com * it's non-zero it jumps to the address 1498856Sandreas.hansson@arm.com */ 1508856Sandreas.hansson@arm.com uint32_t flags; 1518914Sandreas.hansson@arm.com 1528856Sandreas.hansson@arm.com /** This register contains the result from a system control reg access 1538922Swilliam.wang@arm.com */ 1548856Sandreas.hansson@arm.com uint32_t scData; 1553013SN/A 1568856Sandreas.hansson@arm.com public: 15712724Snikos.nikoleris@arm.com typedef RealViewCtrlParams Params; 15812724Snikos.nikoleris@arm.com const Params * 15912724Snikos.nikoleris@arm.com params() const 16012724Snikos.nikoleris@arm.com { 16112724Snikos.nikoleris@arm.com return dynamic_cast<const Params *>(_params); 16212724Snikos.nikoleris@arm.com } 16312724Snikos.nikoleris@arm.com /** 16412724Snikos.nikoleris@arm.com * The constructor for RealView just registers itself with the MMU. 16512724Snikos.nikoleris@arm.com * @param p params structure 16612724Snikos.nikoleris@arm.com */ 16712724Snikos.nikoleris@arm.com RealViewCtrl(Params *p); 16812724Snikos.nikoleris@arm.com 16912724Snikos.nikoleris@arm.com /** 17012724Snikos.nikoleris@arm.com * Handle a read to the device 17112724Snikos.nikoleris@arm.com * @param pkt The memory request. 17212724Snikos.nikoleris@arm.com * @param data Where to put the data. 17312724Snikos.nikoleris@arm.com */ 17412724Snikos.nikoleris@arm.com Tick read(PacketPtr pkt) M5_ATTR_OVERRIDE; 17512724Snikos.nikoleris@arm.com 17612724Snikos.nikoleris@arm.com /** 17712724Snikos.nikoleris@arm.com * All writes are simply ignored. 17812724Snikos.nikoleris@arm.com * @param pkt The memory request. 17912724Snikos.nikoleris@arm.com * @param data the data 18012724Snikos.nikoleris@arm.com */ 18112724Snikos.nikoleris@arm.com Tick write(PacketPtr pkt) M5_ATTR_OVERRIDE; 18212724Snikos.nikoleris@arm.com 18312724Snikos.nikoleris@arm.com void serialize(CheckpointOut &cp) const M5_ATTR_OVERRIDE; 18412724Snikos.nikoleris@arm.com void unserialize(CheckpointIn &cp) M5_ATTR_OVERRIDE; 18512724Snikos.nikoleris@arm.com 18612724Snikos.nikoleris@arm.com public: 18712724Snikos.nikoleris@arm.com void registerDevice(DeviceFunc func, uint8_t site, uint8_t pos, 18812724Snikos.nikoleris@arm.com uint8_t dcc, uint16_t dev, 18912724Snikos.nikoleris@arm.com Device *handler); 19012724Snikos.nikoleris@arm.com 19112724Snikos.nikoleris@arm.com protected: 19212724Snikos.nikoleris@arm.com std::map<uint32_t, Device *> devices; 19312724Snikos.nikoleris@arm.com}; 19412724Snikos.nikoleris@arm.com 19512724Snikos.nikoleris@arm.com/** 19612724Snikos.nikoleris@arm.com * This is an implementation of a programmable oscillator on the that 19712724Snikos.nikoleris@arm.com * can be configured through the RealView/Versatile Express 19812724Snikos.nikoleris@arm.com * configuration interface. 19912724Snikos.nikoleris@arm.com * 20012724Snikos.nikoleris@arm.com * See ARM DUI 0447J (ARM Motherboard Express uATX -- V2M-P1). 20112724Snikos.nikoleris@arm.com */ 20212724Snikos.nikoleris@arm.comclass RealViewOsc 20312724Snikos.nikoleris@arm.com : public ClockDomain, RealViewCtrl::Device 20412724Snikos.nikoleris@arm.com{ 20512724Snikos.nikoleris@arm.com public: 20612724Snikos.nikoleris@arm.com RealViewOsc(RealViewOscParams *p); 20712724Snikos.nikoleris@arm.com virtual ~RealViewOsc() {}; 20812724Snikos.nikoleris@arm.com 20912724Snikos.nikoleris@arm.com void startup() M5_ATTR_OVERRIDE; 21012724Snikos.nikoleris@arm.com 21112724Snikos.nikoleris@arm.com void serialize(CheckpointOut &cp) const M5_ATTR_OVERRIDE; 21212724Snikos.nikoleris@arm.com void unserialize(CheckpointIn &cp) M5_ATTR_OVERRIDE; 21312724Snikos.nikoleris@arm.com 21412724Snikos.nikoleris@arm.com public: // RealViewCtrl::Device interface 21512724Snikos.nikoleris@arm.com uint32_t read() const M5_ATTR_OVERRIDE; 21612724Snikos.nikoleris@arm.com void write(uint32_t freq) M5_ATTR_OVERRIDE; 21712724Snikos.nikoleris@arm.com 21812724Snikos.nikoleris@arm.com protected: 21912724Snikos.nikoleris@arm.com void clockPeriod(Tick clock_period); 22012724Snikos.nikoleris@arm.com}; 22112724Snikos.nikoleris@arm.com 22212724Snikos.nikoleris@arm.com 22312724Snikos.nikoleris@arm.com#endif // __DEV_ARM_RV_HH__ 22412724Snikos.nikoleris@arm.com