RealView.py revision 9835
18870SAli.Saidi@ARM.com# Copyright (c) 2009-2012 ARM Limited
27090SN/A# All rights reserved.
37090SN/A#
47090SN/A# The license below extends only to copyright in the software and shall
57090SN/A# not be construed as granting a license to any other intellectual
67090SN/A# property including but not limited to intellectual property relating
77090SN/A# to a hardware implementation of the functionality of the software
87090SN/A# licensed hereunder.  You may use the software subject to the license
97090SN/A# terms below provided that you ensure that this notice is replicated
107090SN/A# unmodified and in its entirety in all distributions of the software,
117090SN/A# modified or unmodified, in source code or in binary form.
127090SN/A#
134486SN/A# Copyright (c) 2006-2007 The Regents of The University of Michigan
144486SN/A# All rights reserved.
154486SN/A#
164486SN/A# Redistribution and use in source and binary forms, with or without
174486SN/A# modification, are permitted provided that the following conditions are
184486SN/A# met: redistributions of source code must retain the above copyright
194486SN/A# notice, this list of conditions and the following disclaimer;
204486SN/A# redistributions in binary form must reproduce the above copyright
214486SN/A# notice, this list of conditions and the following disclaimer in the
224486SN/A# documentation and/or other materials provided with the distribution;
234486SN/A# neither the name of the copyright holders nor the names of its
244486SN/A# contributors may be used to endorse or promote products derived from
254486SN/A# this software without specific prior written permission.
264486SN/A#
274486SN/A# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
284486SN/A# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
294486SN/A# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
304486SN/A# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
314486SN/A# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
324486SN/A# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
334486SN/A# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
344486SN/A# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
354486SN/A# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
364486SN/A# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
374486SN/A# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
384486SN/A#
397584SAli.Saidi@arm.com# Authors: Ali Saidi
407584SAli.Saidi@arm.com#          Gabe Black
417754SWilliam.Wang@arm.com#          William Wang
424486SN/A
433630SN/Afrom m5.params import *
443630SN/Afrom m5.proxy import *
457587SAli.Saidi@arm.comfrom Device import BasicPioDevice, PioDevice, IsaFake, BadAddr, DmaDevice
468525SAli.Saidi@ARM.comfrom Pci import PciConfigAll
478525SAli.Saidi@ARM.comfrom Ethernet import NSGigE, IGbE_e1000, IGbE_igb
488212SAli.Saidi@ARM.comfrom Ide import *
495478SN/Afrom Platform import Platform
505478SN/Afrom Terminal import Terminal
517584SAli.Saidi@arm.comfrom Uart import Uart
528931Sandreas.hansson@arm.comfrom SimpleMemory import SimpleMemory
539525SAndreas.Sandberg@ARM.comfrom Gic import *
543630SN/A
559806Sstever@gmail.comclass AmbaPioDevice(BasicPioDevice):
569806Sstever@gmail.com    type = 'AmbaPioDevice'
577584SAli.Saidi@arm.com    abstract = True
589338SAndreas.Sandberg@arm.com    cxx_header = "dev/arm/amba_device.hh"
597584SAli.Saidi@arm.com    amba_id = Param.UInt32("ID of AMBA device for kernel detection")
603898SN/A
619806Sstever@gmail.comclass AmbaIntDevice(AmbaPioDevice):
627950SAli.Saidi@ARM.com    type = 'AmbaIntDevice'
637950SAli.Saidi@ARM.com    abstract = True
649338SAndreas.Sandberg@arm.com    cxx_header = "dev/arm/amba_device.hh"
659525SAndreas.Sandberg@ARM.com    gic = Param.BaseGic(Parent.any, "Gic to use for interrupting")
667950SAli.Saidi@ARM.com    int_num = Param.UInt32("Interrupt number that connects to GIC")
677950SAli.Saidi@ARM.com    int_delay = Param.Latency("100ns",
687950SAli.Saidi@ARM.com            "Time between action and interrupt generation by device")
697950SAli.Saidi@ARM.com
707587SAli.Saidi@arm.comclass AmbaDmaDevice(DmaDevice):
717587SAli.Saidi@arm.com    type = 'AmbaDmaDevice'
727587SAli.Saidi@arm.com    abstract = True
739338SAndreas.Sandberg@arm.com    cxx_header = "dev/arm/amba_device.hh"
747753SWilliam.Wang@arm.com    pio_addr = Param.Addr("Address for AMBA slave interface")
757753SWilliam.Wang@arm.com    pio_latency = Param.Latency("10ns", "Time between action and write/read result by AMBA DMA Device")
769525SAndreas.Sandberg@ARM.com    gic = Param.BaseGic(Parent.any, "Gic to use for interrupting")
777753SWilliam.Wang@arm.com    int_num = Param.UInt32("Interrupt number that connects to GIC")
787587SAli.Saidi@arm.com    amba_id = Param.UInt32("ID of AMBA device for kernel detection")
797587SAli.Saidi@arm.com
808282SAli.Saidi@ARM.comclass A9SCU(BasicPioDevice):
818282SAli.Saidi@ARM.com    type = 'A9SCU'
829338SAndreas.Sandberg@arm.com    cxx_header = "dev/arm/a9scu.hh"
838282SAli.Saidi@ARM.com
847584SAli.Saidi@arm.comclass RealViewCtrl(BasicPioDevice):
857584SAli.Saidi@arm.com    type = 'RealViewCtrl'
869338SAndreas.Sandberg@arm.com    cxx_header = "dev/arm/rv_ctrl.hh"
878524SAli.Saidi@ARM.com    proc_id0 = Param.UInt32(0x0C000000, "Processor ID, SYS_PROCID")
888524SAli.Saidi@ARM.com    proc_id1 = Param.UInt32(0x0C000222, "Processor ID, SYS_PROCID1")
898299Schander.sudanthi@arm.com    idreg = Param.UInt32(0x00000000, "ID Register, SYS_ID")
907584SAli.Saidi@arm.com
919806Sstever@gmail.comclass AmbaFake(AmbaPioDevice):
927584SAli.Saidi@arm.com    type = 'AmbaFake'
939338SAndreas.Sandberg@arm.com    cxx_header = "dev/arm/amba_fake.hh"
947584SAli.Saidi@arm.com    ignore_access = Param.Bool(False, "Ignore reads/writes to this device, (e.g. IsaFake + AMBA)")
957584SAli.Saidi@arm.com    amba_id = 0;
967584SAli.Saidi@arm.com
977584SAli.Saidi@arm.comclass Pl011(Uart):
987584SAli.Saidi@arm.com    type = 'Pl011'
999338SAndreas.Sandberg@arm.com    cxx_header = "dev/arm/pl011.hh"
1009525SAndreas.Sandberg@ARM.com    gic = Param.BaseGic(Parent.any, "Gic to use for interrupting")
1017584SAli.Saidi@arm.com    int_num = Param.UInt32("Interrupt number that connects to GIC")
1027584SAli.Saidi@arm.com    end_on_eot = Param.Bool(False, "End the simulation when a EOT is received on the UART")
1037584SAli.Saidi@arm.com    int_delay = Param.Latency("100ns", "Time between action and interrupt generation by UART")
1047584SAli.Saidi@arm.com
1059806Sstever@gmail.comclass Sp804(AmbaPioDevice):
1067584SAli.Saidi@arm.com    type = 'Sp804'
1079338SAndreas.Sandberg@arm.com    cxx_header = "dev/arm/timer_sp804.hh"
1089525SAndreas.Sandberg@ARM.com    gic = Param.BaseGic(Parent.any, "Gic to use for interrupting")
1097584SAli.Saidi@arm.com    int_num0 = Param.UInt32("Interrupt number that connects to GIC")
1107584SAli.Saidi@arm.com    clock0 = Param.Clock('1MHz', "Clock speed of the input")
1117584SAli.Saidi@arm.com    int_num1 = Param.UInt32("Interrupt number that connects to GIC")
1127584SAli.Saidi@arm.com    clock1 = Param.Clock('1MHz', "Clock speed of the input")
1137584SAli.Saidi@arm.com    amba_id = 0x00141804
1147584SAli.Saidi@arm.com
1158512Sgeoffrey.blake@arm.comclass CpuLocalTimer(BasicPioDevice):
1168512Sgeoffrey.blake@arm.com    type = 'CpuLocalTimer'
1179338SAndreas.Sandberg@arm.com    cxx_header = "dev/arm/timer_cpulocal.hh"
1189525SAndreas.Sandberg@ARM.com    gic = Param.BaseGic(Parent.any, "Gic to use for interrupting")
1198512Sgeoffrey.blake@arm.com    int_num_timer = Param.UInt32("Interrrupt number used per-cpu to GIC")
1208512Sgeoffrey.blake@arm.com    int_num_watchdog = Param.UInt32("Interrupt number for per-cpu watchdog to GIC")
1218512Sgeoffrey.blake@arm.com
1228870SAli.Saidi@ARM.comclass PL031(AmbaIntDevice):
1238870SAli.Saidi@ARM.com    type = 'PL031'
1249338SAndreas.Sandberg@arm.com    cxx_header = "dev/arm/rtc_pl031.hh"
1258870SAli.Saidi@ARM.com    time = Param.Time('01/01/2009', "System time to use ('Now' for actual time)")
1268870SAli.Saidi@ARM.com    amba_id = 0x00341031
1278870SAli.Saidi@ARM.com
1287950SAli.Saidi@ARM.comclass Pl050(AmbaIntDevice):
1297754SWilliam.Wang@arm.com    type = 'Pl050'
1309338SAndreas.Sandberg@arm.com    cxx_header = "dev/arm/kmi.hh"
1319330Schander.sudanthi@arm.com    vnc = Param.VncInput(Parent.any, "Vnc server for remote frame buffer display")
1327950SAli.Saidi@ARM.com    is_mouse = Param.Bool(False, "Is this interface a mouse, if not a keyboard")
1337950SAli.Saidi@ARM.com    int_delay = '1us'
1347754SWilliam.Wang@arm.com    amba_id = 0x00141050
1357754SWilliam.Wang@arm.com
1367753SWilliam.Wang@arm.comclass Pl111(AmbaDmaDevice):
1377753SWilliam.Wang@arm.com    type = 'Pl111'
1389338SAndreas.Sandberg@arm.com    cxx_header = "dev/arm/pl111.hh"
1399394Sandreas.hansson@arm.com    pixel_clock = Param.Clock('24MHz', "Pixel clock")
1409330Schander.sudanthi@arm.com    vnc   = Param.VncInput(Parent.any, "Vnc server for remote frame buffer display")
1417753SWilliam.Wang@arm.com    amba_id = 0x00141111
1427753SWilliam.Wang@arm.com
1439646SChris.Emmons@arm.comclass HDLcd(AmbaDmaDevice):
1449646SChris.Emmons@arm.com    type = 'HDLcd'
1459646SChris.Emmons@arm.com    cxx_header = "dev/arm/hdlcd.hh"
1469646SChris.Emmons@arm.com    pixel_clock = Param.Clock('65MHz', "Clock frequency of the pixel clock "
1479646SChris.Emmons@arm.com                                       "(i.e. PXLREFCLK / OSCCLK 5; 23.75MHz "
1489646SChris.Emmons@arm.com                                       "default up to 165MHz)")
1499646SChris.Emmons@arm.com    vnc = Param.VncInput(Parent.any, "Vnc server for remote frame buffer "
1509646SChris.Emmons@arm.com                                     "display")
1519646SChris.Emmons@arm.com    amba_id = 0x00141000
1529646SChris.Emmons@arm.com
1537584SAli.Saidi@arm.comclass RealView(Platform):
1547584SAli.Saidi@arm.com    type = 'RealView'
1559338SAndreas.Sandberg@arm.com    cxx_header = "dev/arm/realview.hh"
1563630SN/A    system = Param.System(Parent.any, "system")
1578525SAli.Saidi@ARM.com    pci_cfg_base = Param.Addr(0, "Base address of PCI Configuraiton Space")
1588870SAli.Saidi@ARM.com    mem_start_addr = Param.Addr(0, "Start address of main memory")
1598870SAli.Saidi@ARM.com    max_mem_size = Param.Addr('256MB', "Maximum amount of RAM supported by platform")
1608870SAli.Saidi@ARM.com
1618870SAli.Saidi@ARM.com    def setupBootLoader(self, mem_bus, cur_sys, loc):
1629835Sandreas.hansson@arm.com        self.nvmem = SimpleMemory(range = AddrRange('2GB', size = '64MB'),
1639835Sandreas.hansson@arm.com                                  conf_table_reported = False)
1648870SAli.Saidi@ARM.com        self.nvmem.port = mem_bus.master
1658870SAli.Saidi@ARM.com        cur_sys.boot_loader = loc('boot.arm')
1668870SAli.Saidi@ARM.com
1673630SN/A
1687753SWilliam.Wang@arm.com# Reference for memory map and interrupt number
1697753SWilliam.Wang@arm.com# RealView Platform Baseboard Explore for Cortex-A9 User Guide(ARM DUI 0440A)
1707753SWilliam.Wang@arm.com# Chapter 4: Programmer's Reference
1717584SAli.Saidi@arm.comclass RealViewPBX(RealView):
1727584SAli.Saidi@arm.com    uart = Pl011(pio_addr=0x10009000, int_num=44)
1737584SAli.Saidi@arm.com    realview_io = RealViewCtrl(pio_addr=0x10000000)
1749525SAndreas.Sandberg@ARM.com    gic = Pl390()
1757584SAli.Saidi@arm.com    timer0 = Sp804(int_num0=36, int_num1=36, pio_addr=0x10011000)
1767584SAli.Saidi@arm.com    timer1 = Sp804(int_num0=37, int_num1=37, pio_addr=0x10012000)
1778512Sgeoffrey.blake@arm.com    local_cpu_timer = CpuLocalTimer(int_num_timer=29, int_num_watchdog=30, pio_addr=0x1f000600)
1787753SWilliam.Wang@arm.com    clcd = Pl111(pio_addr=0x10020000, int_num=55)
1797754SWilliam.Wang@arm.com    kmi0   = Pl050(pio_addr=0x10006000, int_num=52)
1807950SAli.Saidi@ARM.com    kmi1   = Pl050(pio_addr=0x10007000, int_num=53, is_mouse=True)
1818282SAli.Saidi@ARM.com    a9scu  = A9SCU(pio_addr=0x1f000000)
1828525SAli.Saidi@ARM.com    cf_ctrl = IdeController(disks=[], pci_func=0, pci_dev=7, pci_bus=2,
1838212SAli.Saidi@ARM.com                            io_shift = 1, ctrl_offset = 2, Command = 0x1,
1848212SAli.Saidi@ARM.com                            BAR0 = 0x18000000, BAR0Size = '16B',
1858212SAli.Saidi@ARM.com                            BAR1 = 0x18000100, BAR1Size = '1B',
1868212SAli.Saidi@ARM.com                            BAR0LegacyIO = True, BAR1LegacyIO = True)
1878212SAli.Saidi@ARM.com
1887584SAli.Saidi@arm.com
1897731SAli.Saidi@ARM.com    l2x0_fake     = IsaFake(pio_addr=0x1f002000, pio_size=0xfff)
1908461SAli.Saidi@ARM.com    flash_fake    = IsaFake(pio_addr=0x40000000, pio_size=0x20000000,
1918461SAli.Saidi@ARM.com                            fake_mem=True)
1927696SAli.Saidi@ARM.com    dmac_fake     = AmbaFake(pio_addr=0x10030000)
1937696SAli.Saidi@ARM.com    uart1_fake    = AmbaFake(pio_addr=0x1000a000)
1947696SAli.Saidi@ARM.com    uart2_fake    = AmbaFake(pio_addr=0x1000b000)
1957696SAli.Saidi@ARM.com    uart3_fake    = AmbaFake(pio_addr=0x1000c000)
1967696SAli.Saidi@ARM.com    smc_fake      = AmbaFake(pio_addr=0x100e1000)
1977696SAli.Saidi@ARM.com    sp810_fake    = AmbaFake(pio_addr=0x10001000, ignore_access=True)
1987696SAli.Saidi@ARM.com    watchdog_fake = AmbaFake(pio_addr=0x10010000)
1997696SAli.Saidi@ARM.com    gpio0_fake    = AmbaFake(pio_addr=0x10013000)
2007696SAli.Saidi@ARM.com    gpio1_fake    = AmbaFake(pio_addr=0x10014000)
2017696SAli.Saidi@ARM.com    gpio2_fake    = AmbaFake(pio_addr=0x10015000)
2027696SAli.Saidi@ARM.com    ssp_fake      = AmbaFake(pio_addr=0x1000d000)
2037696SAli.Saidi@ARM.com    sci_fake      = AmbaFake(pio_addr=0x1000e000)
2047696SAli.Saidi@ARM.com    aaci_fake     = AmbaFake(pio_addr=0x10004000)
2057696SAli.Saidi@ARM.com    mmc_fake      = AmbaFake(pio_addr=0x10005000)
2068906Skoansin.tan@gmail.com    rtc           = PL031(pio_addr=0x10017000, int_num=42)
2077696SAli.Saidi@ARM.com
2087696SAli.Saidi@ARM.com
2098713Sandreas.hansson@arm.com    # Attach I/O devices that are on chip and also set the appropriate
2108713Sandreas.hansson@arm.com    # ranges for the bridge
2118713Sandreas.hansson@arm.com    def attachOnChipIO(self, bus, bridge):
2128839Sandreas.hansson@arm.com       self.gic.pio = bus.master
2138839Sandreas.hansson@arm.com       self.l2x0_fake.pio = bus.master
2148839Sandreas.hansson@arm.com       self.a9scu.pio = bus.master
2158839Sandreas.hansson@arm.com       self.local_cpu_timer.pio = bus.master
2168713Sandreas.hansson@arm.com       # Bridge ranges based on excluding what is part of on-chip I/O
2178713Sandreas.hansson@arm.com       # (gic, l2x0, a9scu, local_cpu_timer)
2188713Sandreas.hansson@arm.com       bridge.ranges = [AddrRange(self.realview_io.pio_addr,
2198713Sandreas.hansson@arm.com                                  self.a9scu.pio_addr - 1),
2208870SAli.Saidi@ARM.com                        AddrRange(self.flash_fake.pio_addr,
2218870SAli.Saidi@ARM.com                                  self.flash_fake.pio_addr + \
2228870SAli.Saidi@ARM.com                                  self.flash_fake.pio_size - 1)]
2237696SAli.Saidi@ARM.com
2247696SAli.Saidi@ARM.com    # Attach I/O devices to specified bus object.  Can't do this
2257696SAli.Saidi@ARM.com    # earlier, since the bus object itself is typically defined at the
2267696SAli.Saidi@ARM.com    # System level.
2277696SAli.Saidi@ARM.com    def attachIO(self, bus):
2288839Sandreas.hansson@arm.com       self.uart.pio          = bus.master
2298839Sandreas.hansson@arm.com       self.realview_io.pio   = bus.master
2308839Sandreas.hansson@arm.com       self.timer0.pio        = bus.master
2318839Sandreas.hansson@arm.com       self.timer1.pio        = bus.master
2328839Sandreas.hansson@arm.com       self.clcd.pio          = bus.master
2338839Sandreas.hansson@arm.com       self.clcd.dma          = bus.slave
2348839Sandreas.hansson@arm.com       self.kmi0.pio          = bus.master
2358839Sandreas.hansson@arm.com       self.kmi1.pio          = bus.master
2368839Sandreas.hansson@arm.com       self.cf_ctrl.pio       = bus.master
2378839Sandreas.hansson@arm.com       self.cf_ctrl.config    = bus.master
2388839Sandreas.hansson@arm.com       self.cf_ctrl.dma       = bus.slave
2398839Sandreas.hansson@arm.com       self.dmac_fake.pio     = bus.master
2408839Sandreas.hansson@arm.com       self.uart1_fake.pio    = bus.master
2418839Sandreas.hansson@arm.com       self.uart2_fake.pio    = bus.master
2428839Sandreas.hansson@arm.com       self.uart3_fake.pio    = bus.master
2438839Sandreas.hansson@arm.com       self.smc_fake.pio      = bus.master
2448839Sandreas.hansson@arm.com       self.sp810_fake.pio    = bus.master
2458839Sandreas.hansson@arm.com       self.watchdog_fake.pio = bus.master
2468839Sandreas.hansson@arm.com       self.gpio0_fake.pio    = bus.master
2478839Sandreas.hansson@arm.com       self.gpio1_fake.pio    = bus.master
2488839Sandreas.hansson@arm.com       self.gpio2_fake.pio    = bus.master
2498839Sandreas.hansson@arm.com       self.ssp_fake.pio      = bus.master
2508839Sandreas.hansson@arm.com       self.sci_fake.pio      = bus.master
2518839Sandreas.hansson@arm.com       self.aaci_fake.pio     = bus.master
2528839Sandreas.hansson@arm.com       self.mmc_fake.pio      = bus.master
2538906Skoansin.tan@gmail.com       self.rtc.pio           = bus.master
2548839Sandreas.hansson@arm.com       self.flash_fake.pio    = bus.master
2557696SAli.Saidi@ARM.com
2567754SWilliam.Wang@arm.com# Reference for memory map and interrupt number
2577754SWilliam.Wang@arm.com# RealView Emulation Baseboard User Guide (ARM DUI 0143B)
2587754SWilliam.Wang@arm.com# Chapter 4: Programmer's Reference
2597696SAli.Saidi@ARM.comclass RealViewEB(RealView):
2607696SAli.Saidi@ARM.com    uart = Pl011(pio_addr=0x10009000, int_num=44)
2617696SAli.Saidi@ARM.com    realview_io = RealViewCtrl(pio_addr=0x10000000)
2629525SAndreas.Sandberg@ARM.com    gic = Pl390(dist_addr=0x10041000, cpu_addr=0x10040000)
2637696SAli.Saidi@ARM.com    timer0 = Sp804(int_num0=36, int_num1=36, pio_addr=0x10011000)
2647696SAli.Saidi@ARM.com    timer1 = Sp804(int_num0=37, int_num1=37, pio_addr=0x10012000)
2657754SWilliam.Wang@arm.com    clcd   = Pl111(pio_addr=0x10020000, int_num=23)
2667754SWilliam.Wang@arm.com    kmi0   = Pl050(pio_addr=0x10006000, int_num=20)
2677950SAli.Saidi@ARM.com    kmi1   = Pl050(pio_addr=0x10007000, int_num=21, is_mouse=True)
2687696SAli.Saidi@ARM.com
2697696SAli.Saidi@ARM.com    l2x0_fake     = IsaFake(pio_addr=0x1f002000, pio_size=0xfff, warn_access="1")
2708461SAli.Saidi@ARM.com    flash_fake    = IsaFake(pio_addr=0x40000000, pio_size=0x20000000-1,
2718461SAli.Saidi@ARM.com                            fake_mem=True)
2727584SAli.Saidi@arm.com    dmac_fake     = AmbaFake(pio_addr=0x10030000)
2737584SAli.Saidi@arm.com    uart1_fake    = AmbaFake(pio_addr=0x1000a000)
2747584SAli.Saidi@arm.com    uart2_fake    = AmbaFake(pio_addr=0x1000b000)
2757584SAli.Saidi@arm.com    uart3_fake    = AmbaFake(pio_addr=0x1000c000)
2768299Schander.sudanthi@arm.com    smcreg_fake   = IsaFake(pio_addr=0x10080000, pio_size=0x10000-1)
2777584SAli.Saidi@arm.com    smc_fake      = AmbaFake(pio_addr=0x100e1000)
2787584SAli.Saidi@arm.com    sp810_fake    = AmbaFake(pio_addr=0x10001000, ignore_access=True)
2797584SAli.Saidi@arm.com    watchdog_fake = AmbaFake(pio_addr=0x10010000)
2807584SAli.Saidi@arm.com    gpio0_fake    = AmbaFake(pio_addr=0x10013000)
2817584SAli.Saidi@arm.com    gpio1_fake    = AmbaFake(pio_addr=0x10014000)
2827584SAli.Saidi@arm.com    gpio2_fake    = AmbaFake(pio_addr=0x10015000)
2837584SAli.Saidi@arm.com    ssp_fake      = AmbaFake(pio_addr=0x1000d000)
2847584SAli.Saidi@arm.com    sci_fake      = AmbaFake(pio_addr=0x1000e000)
2857584SAli.Saidi@arm.com    aaci_fake     = AmbaFake(pio_addr=0x10004000)
2867584SAli.Saidi@arm.com    mmc_fake      = AmbaFake(pio_addr=0x10005000)
2877584SAli.Saidi@arm.com    rtc_fake      = AmbaFake(pio_addr=0x10017000, amba_id=0x41031)
2887584SAli.Saidi@arm.com
2897584SAli.Saidi@arm.com
2907584SAli.Saidi@arm.com
2918713Sandreas.hansson@arm.com    # Attach I/O devices that are on chip and also set the appropriate
2928713Sandreas.hansson@arm.com    # ranges for the bridge
2938713Sandreas.hansson@arm.com    def attachOnChipIO(self, bus, bridge):
2948839Sandreas.hansson@arm.com       self.gic.pio = bus.master
2958839Sandreas.hansson@arm.com       self.l2x0_fake.pio = bus.master
2968713Sandreas.hansson@arm.com       # Bridge ranges based on excluding what is part of on-chip I/O
2978713Sandreas.hansson@arm.com       # (gic, l2x0)
2988713Sandreas.hansson@arm.com       bridge.ranges = [AddrRange(self.realview_io.pio_addr,
2998713Sandreas.hansson@arm.com                                  self.gic.cpu_addr - 1),
3008713Sandreas.hansson@arm.com                        AddrRange(self.flash_fake.pio_addr, Addr.max)]
3014104SN/A
3023630SN/A    # Attach I/O devices to specified bus object.  Can't do this
3033630SN/A    # earlier, since the bus object itself is typically defined at the
3043630SN/A    # System level.
3053630SN/A    def attachIO(self, bus):
3068839Sandreas.hansson@arm.com       self.uart.pio          = bus.master
3078839Sandreas.hansson@arm.com       self.realview_io.pio   = bus.master
3088839Sandreas.hansson@arm.com       self.timer0.pio        = bus.master
3098839Sandreas.hansson@arm.com       self.timer1.pio        = bus.master
3108839Sandreas.hansson@arm.com       self.clcd.pio          = bus.master
3118839Sandreas.hansson@arm.com       self.clcd.dma          = bus.slave
3128839Sandreas.hansson@arm.com       self.kmi0.pio          = bus.master
3138839Sandreas.hansson@arm.com       self.kmi1.pio          = bus.master
3148839Sandreas.hansson@arm.com       self.dmac_fake.pio     = bus.master
3158839Sandreas.hansson@arm.com       self.uart1_fake.pio    = bus.master
3168839Sandreas.hansson@arm.com       self.uart2_fake.pio    = bus.master
3178839Sandreas.hansson@arm.com       self.uart3_fake.pio    = bus.master
3188839Sandreas.hansson@arm.com       self.smc_fake.pio      = bus.master
3198839Sandreas.hansson@arm.com       self.sp810_fake.pio    = bus.master
3208839Sandreas.hansson@arm.com       self.watchdog_fake.pio = bus.master
3218839Sandreas.hansson@arm.com       self.gpio0_fake.pio    = bus.master
3228839Sandreas.hansson@arm.com       self.gpio1_fake.pio    = bus.master
3238839Sandreas.hansson@arm.com       self.gpio2_fake.pio    = bus.master
3248839Sandreas.hansson@arm.com       self.ssp_fake.pio      = bus.master
3258839Sandreas.hansson@arm.com       self.sci_fake.pio      = bus.master
3268839Sandreas.hansson@arm.com       self.aaci_fake.pio     = bus.master
3278839Sandreas.hansson@arm.com       self.mmc_fake.pio      = bus.master
3288839Sandreas.hansson@arm.com       self.rtc_fake.pio      = bus.master
3298839Sandreas.hansson@arm.com       self.flash_fake.pio    = bus.master
3308839Sandreas.hansson@arm.com       self.smcreg_fake.pio   = bus.master
3317584SAli.Saidi@arm.com
3328870SAli.Saidi@ARM.comclass VExpress_EMM(RealView):
3338870SAli.Saidi@ARM.com    mem_start_addr = '2GB'
3348870SAli.Saidi@ARM.com    max_mem_size = '2GB'
3359052Sgeoffrey.blake@arm.com    pci_cfg_base = 0x30000000
3368870SAli.Saidi@ARM.com    uart = Pl011(pio_addr=0x1c090000, int_num=37)
3378870SAli.Saidi@ARM.com    realview_io = RealViewCtrl(proc_id0=0x14000000, proc_id1=0x14000000, pio_addr=0x1C010000)
3389525SAndreas.Sandberg@ARM.com    gic = Pl390(dist_addr=0x2C001000, cpu_addr=0x2C002000)
3398870SAli.Saidi@ARM.com    local_cpu_timer = CpuLocalTimer(int_num_timer=29, int_num_watchdog=30, pio_addr=0x2C080000)
3409185SAli.Saidi@ARM.com    timer0 = Sp804(int_num0=34, int_num1=34, pio_addr=0x1C110000, clock0='1MHz', clock1='1MHz')
3419185SAli.Saidi@ARM.com    timer1 = Sp804(int_num0=35, int_num1=35, pio_addr=0x1C120000, clock0='1MHz', clock1='1MHz')
3428870SAli.Saidi@ARM.com    clcd   = Pl111(pio_addr=0x1c1f0000, int_num=46)
3439646SChris.Emmons@arm.com    hdlcd  = HDLcd(pio_addr=0x2b000000, int_num=117)
3448870SAli.Saidi@ARM.com    kmi0   = Pl050(pio_addr=0x1c060000, int_num=44)
3459387SChris.Emmons@arm.com    kmi1   = Pl050(pio_addr=0x1c070000, int_num=45, is_mouse=True)
3468870SAli.Saidi@ARM.com    cf_ctrl = IdeController(disks=[], pci_func=0, pci_dev=0, pci_bus=2,
3478870SAli.Saidi@ARM.com                            io_shift = 2, ctrl_offset = 2, Command = 0x1,
3488870SAli.Saidi@ARM.com                            BAR0 = 0x1C1A0000, BAR0Size = '256B',
3498870SAli.Saidi@ARM.com                            BAR1 = 0x1C1A0100, BAR1Size = '4096B',
3508870SAli.Saidi@ARM.com                            BAR0LegacyIO = True, BAR1LegacyIO = True)
3519052Sgeoffrey.blake@arm.com
3529052Sgeoffrey.blake@arm.com    pciconfig = PciConfigAll(size='256MB')
3539052Sgeoffrey.blake@arm.com    ethernet = IGbE_e1000(pci_bus=0, pci_dev=0, pci_func=0,
3549052Sgeoffrey.blake@arm.com                          InterruptLine=1, InterruptPin=1)
3559052Sgeoffrey.blake@arm.com
3569052Sgeoffrey.blake@arm.com    ide = IdeController(disks = [], pci_bus=0, pci_dev=1, pci_func=0,
3579052Sgeoffrey.blake@arm.com                        InterruptLine=2, InterruptPin=2)
3589052Sgeoffrey.blake@arm.com
3599052Sgeoffrey.blake@arm.com
3609835Sandreas.hansson@arm.com    vram           = SimpleMemory(range = AddrRange(0x18000000, size='32MB'),
3619835Sandreas.hansson@arm.com                                  conf_table_reported = False)
3628870SAli.Saidi@ARM.com    rtc            = PL031(pio_addr=0x1C170000, int_num=36)
3638870SAli.Saidi@ARM.com
3648870SAli.Saidi@ARM.com    l2x0_fake      = IsaFake(pio_addr=0x2C100000, pio_size=0xfff)
3658870SAli.Saidi@ARM.com    uart1_fake     = AmbaFake(pio_addr=0x1C0A0000)
3668870SAli.Saidi@ARM.com    uart2_fake     = AmbaFake(pio_addr=0x1C0B0000)
3678870SAli.Saidi@ARM.com    uart3_fake     = AmbaFake(pio_addr=0x1C0C0000)
3688870SAli.Saidi@ARM.com    sp810_fake     = AmbaFake(pio_addr=0x1C020000, ignore_access=True)
3698870SAli.Saidi@ARM.com    watchdog_fake  = AmbaFake(pio_addr=0x1C0F0000)
3708870SAli.Saidi@ARM.com    aaci_fake      = AmbaFake(pio_addr=0x1C040000)
3718870SAli.Saidi@ARM.com    lan_fake       = IsaFake(pio_addr=0x1A000000, pio_size=0xffff)
3728870SAli.Saidi@ARM.com    usb_fake       = IsaFake(pio_addr=0x1B000000, pio_size=0x1ffff)
3738870SAli.Saidi@ARM.com    mmc_fake       = AmbaFake(pio_addr=0x1c050000)
3748870SAli.Saidi@ARM.com
3758870SAli.Saidi@ARM.com    def setupBootLoader(self, mem_bus, cur_sys, loc):
3769835Sandreas.hansson@arm.com        self.nvmem = SimpleMemory(range = AddrRange('64MB'),
3779835Sandreas.hansson@arm.com                                  conf_table_reported = False)
3788870SAli.Saidi@ARM.com        self.nvmem.port = mem_bus.master
3798870SAli.Saidi@ARM.com        cur_sys.boot_loader = loc('boot_emm.arm')
3808870SAli.Saidi@ARM.com        cur_sys.atags_addr = 0x80000100
3818870SAli.Saidi@ARM.com
3828870SAli.Saidi@ARM.com    # Attach I/O devices that are on chip and also set the appropriate
3838870SAli.Saidi@ARM.com    # ranges for the bridge
3848870SAli.Saidi@ARM.com    def attachOnChipIO(self, bus, bridge):
3858870SAli.Saidi@ARM.com       self.gic.pio = bus.master
3868870SAli.Saidi@ARM.com       self.local_cpu_timer.pio = bus.master
3879646SChris.Emmons@arm.com       self.hdlcd.dma           = bus.slave
3888870SAli.Saidi@ARM.com       # Bridge ranges based on excluding what is part of on-chip I/O
3898870SAli.Saidi@ARM.com       # (gic, a9scu)
3908870SAli.Saidi@ARM.com       bridge.ranges = [AddrRange(0x2F000000, size='16MB'),
3919646SChris.Emmons@arm.com                        AddrRange(0x2B000000, size='4MB'),
3928870SAli.Saidi@ARM.com                        AddrRange(0x30000000, size='256MB'),
3939073SAli.Saidi@ARM.com                        AddrRange(0x40000000, size='512MB'),
3948870SAli.Saidi@ARM.com                        AddrRange(0x18000000, size='64MB'),
3958870SAli.Saidi@ARM.com                        AddrRange(0x1C000000, size='64MB')]
3968870SAli.Saidi@ARM.com
3978870SAli.Saidi@ARM.com    # Attach I/O devices to specified bus object.  Can't do this
3988870SAli.Saidi@ARM.com    # earlier, since the bus object itself is typically defined at the
3998870SAli.Saidi@ARM.com    # System level.
4008870SAli.Saidi@ARM.com    def attachIO(self, bus):
4018870SAli.Saidi@ARM.com       self.uart.pio            = bus.master
4028870SAli.Saidi@ARM.com       self.realview_io.pio     = bus.master
4038870SAli.Saidi@ARM.com       self.timer0.pio          = bus.master
4048870SAli.Saidi@ARM.com       self.timer1.pio          = bus.master
4058870SAli.Saidi@ARM.com       self.clcd.pio            = bus.master
4068870SAli.Saidi@ARM.com       self.clcd.dma            = bus.slave
4079646SChris.Emmons@arm.com       self.hdlcd.pio           = bus.master
4088870SAli.Saidi@ARM.com       self.kmi0.pio            = bus.master
4098870SAli.Saidi@ARM.com       self.kmi1.pio            = bus.master
4108870SAli.Saidi@ARM.com       self.cf_ctrl.pio         = bus.master
4118872Ssaidi@eecs.umich.edu       self.cf_ctrl.dma         = bus.slave
4128870SAli.Saidi@ARM.com       self.cf_ctrl.config      = bus.master
4138870SAli.Saidi@ARM.com       self.rtc.pio             = bus.master
4148870SAli.Saidi@ARM.com       bus.use_default_range    = True
4158870SAli.Saidi@ARM.com       self.vram.port           = bus.master
4169052Sgeoffrey.blake@arm.com       self.ide.pio             = bus.master
4179052Sgeoffrey.blake@arm.com       self.ide.config          = bus.master
4189052Sgeoffrey.blake@arm.com       self.ide.dma             = bus.slave
4199052Sgeoffrey.blake@arm.com       self.ethernet.pio        = bus.master
4209052Sgeoffrey.blake@arm.com       self.ethernet.config     = bus.master
4219052Sgeoffrey.blake@arm.com       self.ethernet.dma        = bus.slave
4229052Sgeoffrey.blake@arm.com       self.pciconfig.pio       = bus.default
4238870SAli.Saidi@ARM.com
4248870SAli.Saidi@ARM.com       self.l2x0_fake.pio       = bus.master
4258870SAli.Saidi@ARM.com       self.uart1_fake.pio      = bus.master
4268870SAli.Saidi@ARM.com       self.uart2_fake.pio      = bus.master
4278870SAli.Saidi@ARM.com       self.uart3_fake.pio      = bus.master
4288870SAli.Saidi@ARM.com       self.sp810_fake.pio      = bus.master
4298870SAli.Saidi@ARM.com       self.watchdog_fake.pio   = bus.master
4308870SAli.Saidi@ARM.com       self.aaci_fake.pio       = bus.master
4318870SAli.Saidi@ARM.com       self.lan_fake.pio        = bus.master
4328870SAli.Saidi@ARM.com       self.usb_fake.pio        = bus.master
4338870SAli.Saidi@ARM.com       self.mmc_fake.pio        = bus.master
4348870SAli.Saidi@ARM.com
435