arm-hdlcd-upgrade.py revision 11090
17506Stjones1@inf.ed.ac.uk# Copyright (c) 2015 ARM Limited
27506Stjones1@inf.ed.ac.uk# All rights reserved
37506Stjones1@inf.ed.ac.uk#
47506Stjones1@inf.ed.ac.uk# The license below extends only to copyright in the software and shall
57506Stjones1@inf.ed.ac.uk# not be construed as granting a license to any other intellectual
67506Stjones1@inf.ed.ac.uk# property including but not limited to intellectual property relating
77506Stjones1@inf.ed.ac.uk# to a hardware implementation of the functionality of the software
87506Stjones1@inf.ed.ac.uk# licensed hereunder.  You may use the software subject to the license
97506Stjones1@inf.ed.ac.uk# terms below provided that you ensure that this notice is replicated
107506Stjones1@inf.ed.ac.uk# unmodified and in its entirety in all distributions of the software,
117506Stjones1@inf.ed.ac.uk# modified or unmodified, in source code or in binary form.
127506Stjones1@inf.ed.ac.uk#
137506Stjones1@inf.ed.ac.uk# Redistribution and use in source and binary forms, with or without
147506Stjones1@inf.ed.ac.uk# modification, are permitted provided that the following conditions are
157506Stjones1@inf.ed.ac.uk# met: redistributions of source code must retain the above copyright
167506Stjones1@inf.ed.ac.uk# notice, this list of conditions and the following disclaimer;
177506Stjones1@inf.ed.ac.uk# redistributions in binary form must reproduce the above copyright
187506Stjones1@inf.ed.ac.uk# notice, this list of conditions and the following disclaimer in the
197506Stjones1@inf.ed.ac.uk# documentation and/or other materials provided with the distribution;
207506Stjones1@inf.ed.ac.uk# neither the name of the copyright holders nor the names of its
217506Stjones1@inf.ed.ac.uk# contributors may be used to endorse or promote products derived from
227506Stjones1@inf.ed.ac.uk# this software without specific prior written permission.
237506Stjones1@inf.ed.ac.uk#
247506Stjones1@inf.ed.ac.uk# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
257506Stjones1@inf.ed.ac.uk# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
267506Stjones1@inf.ed.ac.uk# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
277506Stjones1@inf.ed.ac.uk# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
287506Stjones1@inf.ed.ac.uk# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
297506Stjones1@inf.ed.ac.uk# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
307506Stjones1@inf.ed.ac.uk# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
317506Stjones1@inf.ed.ac.uk# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
327506Stjones1@inf.ed.ac.uk# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
337506Stjones1@inf.ed.ac.uk# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
347506Stjones1@inf.ed.ac.uk# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
357506Stjones1@inf.ed.ac.uk#
367698SAli.Saidi@ARM.com# Authors: Andreas Sandberg
377506Stjones1@inf.ed.ac.uk#
387506Stjones1@inf.ed.ac.uk
397506Stjones1@inf.ed.ac.ukdef upgrader(cpt):
407506Stjones1@inf.ed.ac.uk    """HDLCD controller rewrite. Converted checkpoints cause the HDLCD
417506Stjones1@inf.ed.ac.uk    model to start a new screen refresh and FIFO buffer fill immediately
427506Stjones1@inf.ed.ac.uk    after they are loaded. Expect some timing differences."""
437506Stjones1@inf.ed.ac.uk
447506Stjones1@inf.ed.ac.uk    import re
457506Stjones1@inf.ed.ac.uk    if cpt.get('root','isa') != 'arm':
467506Stjones1@inf.ed.ac.uk        return
477506Stjones1@inf.ed.ac.uk
487506Stjones1@inf.ed.ac.uk    option_names = {
497506Stjones1@inf.ed.ac.uk        "int_rawstat" : "int_rawstat_serial",
507506Stjones1@inf.ed.ac.uk        "int_mask" : "int_mask_serial",
517506Stjones1@inf.ed.ac.uk        "fb_base" : "fb_base",
527506Stjones1@inf.ed.ac.uk        "fb_line_length" : "fb_line_length",
537506Stjones1@inf.ed.ac.uk        "fb_line_count" : "fb_line_count_serial",
547506Stjones1@inf.ed.ac.uk        "fb_line_pitch" : "fb_line_pitch",
557720Sgblack@eecs.umich.edu        "bus_options" : "bus_options_serial",
567506Stjones1@inf.ed.ac.uk
577506Stjones1@inf.ed.ac.uk        "v_sync" : "v_sync_serial",
588787Sgblack@eecs.umich.edu        "v_back_porch" : "v_back_porch_serial",
598787Sgblack@eecs.umich.edu        "v_data" : "v_data_serial",
608787Sgblack@eecs.umich.edu        "v_front_porch" : "v_front_porch_serial",
618787Sgblack@eecs.umich.edu
628787Sgblack@eecs.umich.edu        "h_sync" : "h_sync_serial",
638787Sgblack@eecs.umich.edu        "h_back_porch" : "h_back_porch_serial",
648787Sgblack@eecs.umich.edu        "h_data" : "h_data_serial",
657693SAli.Saidi@ARM.com        "h_front_porch" : "h_front_porch_serial",
667693SAli.Saidi@ARM.com
677693SAli.Saidi@ARM.com        "polarities" : "polarities_serial",
687693SAli.Saidi@ARM.com
697693SAli.Saidi@ARM.com        "command" : "command_serial",
707693SAli.Saidi@ARM.com        "pixel_format" : "pixel_format_serial",
717693SAli.Saidi@ARM.com        "red_select" : "red_select_serial",
727811Ssteve.reinhardt@amd.com        "green_select" : "green_select_serial",
73        "blue_select" : "blue_select_serial",
74    }
75
76    for sec in cpt.sections():
77        if re.search('.*\.hdlcd$', sec):
78            options = {}
79            for new, old in option_names.items():
80                options[new] = cpt.get(sec, old)
81
82            cpt.remove_section(sec)
83            cpt.add_section(sec)
84            for key, value in options.items():
85                cpt.set(sec, key, value)
86
87            # Create a DMA engine section. The LCD controller will
88            # initialize the DMA it after the next VSync, so we don't
89            # care about the actual values
90            sec_dma = "%s.dmaEngine" % sec
91            cpt.add_section(sec_dma)
92            cpt.set(sec_dma, "nextLineAddr", "0")
93            cpt.set(sec_dma, "frameEnd", "0")
94            cpt.set(sec_dma, "startAddr", "0")
95            cpt.set(sec_dma, "endAddr", "0")
96            cpt.set(sec_dma, "nextAddr", "0")
97            cpt.set(sec_dma, "buffer", "")
98
99
100    print "Warning: Assuming that the HDLCD pixel clock and global frequency " \
101        "are still using their default values."
102    sec_osc = "system.realview.realview_io.osc_pxl"
103    global_tick = 1E12
104    pxl_freq = 137E6
105    pxl_ticks = global_tick / pxl_freq
106    if not cpt.has_section(sec_osc):
107        cpt.add_section(sec_osc)
108    cpt.set(sec_osc, "type", "RealViewOsc")
109    cpt.set(sec_osc, "_clockPeriod", "%i" % pxl_ticks)
110