summaryrefslogtreecommitdiffstats
path: root/utils/regtools/qeditor/std_analysers.h
blob: 030e010f58474cf422cc5a01f4dd34022bab45a9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
/***************************************************************************
 *             __________               __   ___.
 *   Open      \______   \ ____   ____ |  | _\_ |__   _______  ___
 *   Source     |       _//  _ \_/ ___\|  |/ /| __ \ /  _ \  \/  /
 *   Jukebox    |    |   (  <_> )  \___|    < | \_\ (  <_> > <  <
 *   Firmware   |____|_  /\____/ \___  >__|_ \|___  /\____/__/\_ \
 *                     \/            \/     \/    \/            \/
 * $Id$
 *
 * Copyright (C) 2014 by Amaury Pouly
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
 * as published by the Free Software Foundation; either version 2
 * of the License, or (at your option) any later version.
 *
 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
 * KIND, either express or implied.
 *
 ****************************************************************************/
#ifndef _STDANALYSER_H_
#define _STDANALYSER_H_

#include "analyser.h"

#include <QGroupBox>
#include <QTreeWidget>
#include <QVBoxLayout>
#include <QHBoxLayout>
#include <QTableWidget>
#include <QHeaderView>
#include <QToolBox>
#include <QComboBox>
#include <QLabel>
#include <QLineEdit>
#include "analyser.h"

class AnalyserEx : public Analyser
{
public:
    AnalyserEx(const soc_desc::soc_ref_t& soc, IoBackend *backend);
protected:
    bool ReadRegister(const QString& path, soc_word_t& val);
    bool ReadRegisterOld(const QString& dev, const QString& reg, soc_word_t& val);
    bool ReadField(const QString& path, const QString& field, soc_word_t& val);
    bool ReadFieldOld(const QString& dev, const QString& reg, const QString& field,
        soc_word_t& val);

    BackendHelper m_helper;
};

/**
 * Clock analyser
 */

class ClockAnalyser : public AnalyserEx
{
public:
    ClockAnalyser(const soc_desc::soc_ref_t& soc, IoBackend *backend);
    virtual ~ClockAnalyser();
    virtual QWidget *GetWidget();
    static bool SupportSoc(const QString& soc_name);

private:
    QString GetFreq(unsigned freq);

    enum
    {
        DISABLED = 0,
        INVALID = -1,
        FROM_PARENT = -2,
    };

    QTreeWidgetItem *AddClock(QTreeWidgetItem *parent, const QString& name, int freq, int mul = 1, int div = 1);
    int GetClockFreq(QTreeWidgetItem *item);
    void FillTree();
    void FillTreeIMX233();
    void FillTreeRK27XX();
    void FillTreeATJ213X();

private:
    QGroupBox *m_group;
    QTreeWidget *m_tree_widget;
};

/**
 * EMI analyser
 */
class EmiAnalyser : public QObject, public AnalyserEx
{
    Q_OBJECT
public:
    EmiAnalyser(const soc_desc::soc_ref_t& soc, IoBackend *backend);
    virtual ~EmiAnalyser();
    virtual QWidget *GetWidget();

    static bool SupportSoc(const QString& soc_name);

private slots:
    void OnChangeDisplayMode(int index);

private:
    enum DisplayMode
    {
        DisplayCycles,
        DisplayRawHex,
        DisplayTime,
    };

    enum
    {
        NONE = -999999,
        INVALID = -1000000
    };

    void NewGroup(const QString& name);
    void AddLine(const QString& name, int value, const QString& unit, const QString& comment = "");
    void AddCycleLine(const QString& name, unsigned raw_val, float val, int digits, const QString& comment = "");
    void FillTable();

private:
    QGroupBox *m_group;
    QComboBox *m_display_selector;
    QToolBox *m_panel;
    DisplayMode m_display_mode;
    unsigned m_emi_freq;
    QLineEdit *m_emi_freq_label;
};

/**
 * PINCTRL analyzer
 */
class PinAnalyser : public AnalyserEx
{
public:
    PinAnalyser(const soc_desc::soc_ref_t& soc, IoBackend *backend);
    virtual ~PinAnalyser();
    virtual QWidget *GetWidget();

    static bool SupportSoc(const QString& soc_name);

private:
    void FillList();

private:
    QGroupBox *m_group;
    QLineEdit *m_package_edit;
    QToolBox *m_panel;
};

#endif /* _STDANALYSER_H_ */