From b888743cac9c0af26632672796934fe9eaaa471d Mon Sep 17 00:00:00 2001 From: Marcin Bukat Date: Thu, 18 Sep 2014 10:04:14 +0200 Subject: qeditor: Implement clock analyzer for rk27xx Change-Id: Ib8f53d32120893b6c1054299ed434a6650a0d7c2 Reviewed-on: http://gerrit.rockbox.org/971 Reviewed-by: Marcin Bukat --- utils/regtools/lib/soc_desc.cpp | 1 - utils/regtools/qeditor/std_analysers.cpp | 202 ++++++++++++++++++++++++++++++- utils/regtools/qeditor/std_analysers.h | 2 + 3 files changed, 200 insertions(+), 5 deletions(-) diff --git a/utils/regtools/lib/soc_desc.cpp b/utils/regtools/lib/soc_desc.cpp index 3904f6a77e..1b1cd61edc 100644 --- a/utils/regtools/lib/soc_desc.cpp +++ b/utils/regtools/lib/soc_desc.cpp @@ -982,4 +982,3 @@ public: }; xml_parser_init __xml_parser_init; -} diff --git a/utils/regtools/qeditor/std_analysers.cpp b/utils/regtools/qeditor/std_analysers.cpp index f278c2a526..8aae007093 100644 --- a/utils/regtools/qeditor/std_analysers.cpp +++ b/utils/regtools/qeditor/std_analysers.cpp @@ -33,7 +33,7 @@ QWidget *ClockAnalyser::GetWidget() bool ClockAnalyser::SupportSoc(const QString& soc_name) { - return soc_name == "imx233"; + return soc_name == "imx233" || soc_name == "rk27xx"; } QString ClockAnalyser::GetFreq(unsigned freq) @@ -82,6 +82,203 @@ int ClockAnalyser::GetClockFreq(QTreeWidgetItem *item) void ClockAnalyser::FillTree() { m_tree_widget->clear(); + if(m_soc.GetSoc().name == "imx233") FillTreeIMX233(); + else if(m_soc.GetSoc().name == "rk27xx") FillTreeRK27XX(); + m_tree_widget->expandAll(); + m_tree_widget->resizeColumnToContents(0); +} + +void ClockAnalyser::FillTreeRK27XX() +{ + soc_word_t value, value2, value3, value4; + soc_word_t bypass, clkr, clkf, clkod, pll_off; + + BackendHelper helper(m_io_backend, m_soc); + + QTreeWidgetItem *xtal_clk = AddClock(0, "xtal clk", 24000000); + + // F = (Fref*F)/R/OD = (Fref*F)/R/OD + QTreeWidgetItem *arm_pll = 0; + if (helper.ReadRegisterField("SCU", "PLLCON1", "ARM_PLL_BYPASS", bypass) && + helper.ReadRegisterField("SCU", "PLLCON1", "ARM_PLL_CLKR", clkr) && + helper.ReadRegisterField("SCU", "PLLCON1", "ARM_PLL_CLKF", clkf) && + helper.ReadRegisterField("SCU", "PLLCON1", "ARM_PLL_CLKOD", clkod) && + helper.ReadRegisterField("SCU", "PLLCON1", "ARM_PLL_POWERDOWN", pll_off)) + { + arm_pll = AddClock(xtal_clk, "arm pll", pll_off ? DISABLED : FROM_PARENT, + bypass ? 1 : clkf+1, bypass ? 1 : (clkr+1)*(clkod+1)); + } + else + { + arm_pll = AddClock(xtal_clk, "arm pll", INVALID); + } + + QTreeWidgetItem *arm_clk = 0; + QTreeWidgetItem *hclk = 0; + QTreeWidgetItem *pclk = 0; + if(helper.ReadRegisterField("SCU", "DIVCON1", "ARM_SLOW_MODE", value) && + helper.ReadRegisterField("SCU", "DIVCON1", "ARM_CLK_DIV", value2) && + helper.ReadRegisterField("SCU", "DIVCON1", "PCLK_CLK_DIV", value3)) + { + arm_clk = AddClock(value ? xtal_clk : arm_pll, "arm clk", FROM_PARENT, 1, value2 ? 2 : 1); + hclk = AddClock(arm_clk, "hclk", FROM_PARENT, 1, value2 ? 1 : 2); + pclk = AddClock(hclk, "pclk", FROM_PARENT, 1, (1<expandAll(); - m_tree_widget->resizeColumnToContents(0); } static TmplAnalyserFactory< ClockAnalyser > g_clock_factory(true, "Clock Analyser"); diff --git a/utils/regtools/qeditor/std_analysers.h b/utils/regtools/qeditor/std_analysers.h index cca8b12b99..a9b3022b41 100644 --- a/utils/regtools/qeditor/std_analysers.h +++ b/utils/regtools/qeditor/std_analysers.h @@ -40,6 +40,8 @@ private: 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(); private: QGroupBox *m_group; -- cgit v1.2.3