i.MX: simplify CCM to only handle clock required by timers.
PATCH 2/6 i.MX: simplify CCM to only handle clock required by timers.
Various i.MX timers (GPT, EPIT, PWM, ...) are only requesting 4 clocks from the system.
* CLK_NONE,
* CLK_IPG,
* CLK_IPG_HIGH,
* CLK_32k
Other "clocks" are not required by the qemu framework so far.
--- hw/misc/imx25_ccm.c | 35 +++++------------------------------ hw/misc/imx31_ccm.c | 38 ++++---------------------------------- hw/timer/imx_epit.c | 8 ++++---- hw/timer/imx_gpt.c | 16 ++++++++-------- include/hw/misc/imx_ccm.h | 10 ++-------- 5 files changed, 23 insertions(+), 84 deletions(-)
hw/misc/imx25_ccm.c +5 -30
@@ -119,20 +119,6 @@ static uint32_t imx25_ccm_get_mpll_clk(IMXCCMState *dev)return freq; } -static uint32_t imx25_ccm_get_upll_clk (IMXCCMState *dev) -{ -uint32_t freq =0 ; -IMX25CCMState *s =IMX25_CCM (dev); - -if (!EXTRACT (s->reg[IMX25_CCM_CCTL_REG ],UPLL_DIS )) { - freq =imx_ccm_calc_pll (s->reg[IMX25_CCM_UPCTL_REG ],CKIH_FREQ ); - } - -DPRINTF ("freq = %d\n" , freq); - -return freq; -} -static uint32_t imx25_ccm_get_mcu_clk (IMXCCMState *dev) {uint32_t freq;
@@ -181,21 +167,10 @@ static uint32_t imx25_ccm_get_clock_frequency(IMXCCMState *dev, IMXClk clock)DPRINTF ("Clock = %d)\n" , clock);switch (clock) { -case NOCLK : -break ; -case CLK_MPLL : - freq =imx25_ccm_get_mpll_clk (dev); -break ; -case CLK_UPLL : - freq =imx25_ccm_get_upll_clk (dev); -break ; -case CLK_MCU : - freq =imx25_ccm_get_mcu_clk (dev); -break ; -case CLK_AHB : - freq =imx25_ccm_get_ahb_clk (dev); +case CLK_NONE :break ;case CLK_IPG : +case CLK_IPG_HIGH : freq =imx25_ccm_get_ipg_clk (dev);break ;case CLK_32k:
@@ -221,9 +196,9 @@ static void imx25_ccm_reset(DeviceState *dev)memset (s->reg,0 ,IMX25_CCM_MAX_REG *sizeof (uint32_t )); s->reg[IMX25_CCM_MPCTL_REG ] =0x800b2c01 ; s->reg[IMX25_CCM_UPCTL_REG ] =0x84042800 ; -/* +/* * The value below gives: -* CPU = 133 MHz, AHB = 66,5 MHz, IPG = 33 MHz. +* CPU = 133 MHz, AHB = 66,5 MHz, IPG = 33 MHz. */ s->reg[IMX25_CCM_CCTL_REG ] =0xd0030000 ; s->reg[IMX25_CCM_CGCR0_REG ] =0x028A0100 ;
@@ -240,7 +215,7 @@ static void imx25_ccm_reset(DeviceState *dev)/* * default boot will change the reset values to allow: -* CPU = 399 MHz, AHB = 133 MHz, IPG = 66,5 MHz. +* CPU = 399 MHz, AHB = 133 MHz, IPG = 66,5 MHz. * For some reason, this doesn't work. With the value below, linux * detects a 88 MHz IPG CLK instead of 66,5 MHz. s->reg[IMX25_CCM_CCTL_REG] = 0x20032000;
hw/misc/imx31_ccm.c +4 -34
@@ -111,7 +111,7 @@ static uint32_t imx31_ccm_get_pll_ref_clk(IMXCCMState *dev)if (s->reg[IMX31_CCM_CCMR_REG ] &CCMR_FPMF ) { freq *=1024 ; } - } + } }else { freq =CKIH_FREQ ; }
@@ -134,6 +134,7 @@ static uint32_t imx31_ccm_get_mpll_clk(IMXCCMState *dev)return freq; } +static uint32_t imx31_ccm_get_mcu_main_clk (IMXCCMState *dev) {uint32_t freq;
@@ -151,32 +152,6 @@ static uint32_t imx31_ccm_get_mcu_main_clk(IMXCCMState *dev)return freq; } -static uint32_t imx31_ccm_get_mcu_clk (IMXCCMState *dev) -{ -uint32_t freq; -IMX31CCMState *s =IMX31_CCM (dev); - - freq =imx31_ccm_get_mcu_main_clk (dev) - / (1 +EXTRACT (s->reg[IMX31_CCM_PDR0_REG ],MCU )); - -DPRINTF ("freq = %d\n" , freq); - -return freq; -} - -static uint32_t imx31_ccm_get_hsp_clk (IMXCCMState *dev) -{ -uint32_t freq; -IMX31CCMState *s =IMX31_CCM (dev); - - freq =imx31_ccm_get_mcu_main_clk (dev) - / (1 +EXTRACT (s->reg[IMX31_CCM_PDR0_REG ],HSP )); - -DPRINTF ("freq = %d\n" , freq); - -return freq; -} -static uint32_t imx31_ccm_get_hclk_clk (IMXCCMState *dev) {uint32_t freq;
@@ -208,15 +183,10 @@ static uint32_t imx31_ccm_get_clock_frequency(IMXCCMState *dev, IMXClk clock)uint32_t freq =0 ;switch (clock) { -case NOCLK : -break ; -case CLK_MCU : - freq =imx31_ccm_get_mcu_clk (dev); -break ; -case CLK_HSP : - freq =imx31_ccm_get_hsp_clk (dev); +case CLK_NONE :break ;case CLK_IPG : +case CLK_IPG_HIGH : freq =imx31_ccm_get_ipg_clk (dev);break ;case CLK_32k:
hw/timer/imx_epit.c +4 -4
@@ -51,10 +51,10 @@ static char const *imx_epit_reg_name(uint32_t reg)* These are typical. */ static const IMXClk imx_epit_clocks[] = { -NOCLK ,/* 00 disabled */ -CLK_IPG ,/* 01 ipg_clk, ~532MHz */ -CLK_IPG ,/* 10 ipg_clk_highfreq */ - CLK_32k,/* 11 ipg_clk_32k -- ~32kHz */ +CLK_NONE ,/* 00 disabled */ +CLK_IPG ,/* 01 ipg_clk, ~532MHz */ +CLK_IPG_HIGH ,/* 10 ipg_clk_highfreq */ + CLK_32k,/* 11 ipg_clk_32k -- ~32kHz */ };/*
hw/timer/imx_gpt.c +8 -8
@@ -80,14 +80,14 @@ static const VMStateDescription vmstate_imx_timer_gpt = { };static const IMXClk imx_gpt_clocks[] = { -NOCLK ,/* 000 No clock source */ -CLK_IPG ,/* 001 ipg_clk, 532MHz*/ -CLK_IPG ,/* 010 ipg_clk_highfreq */ -NOCLK ,/* 011 not defined */ - CLK_32k,/* 100 ipg_clk_32k */ -NOCLK ,/* 101 not defined */ -NOCLK ,/* 110 not defined */ -NOCLK ,/* 111 not defined */ +CLK_NONE ,/* 000 No clock source */ +CLK_IPG ,/* 001 ipg_clk, 532MHz*/ +CLK_IPG_HIGH ,/* 010 ipg_clk_highfreq */ +CLK_NONE ,/* 011 not defined */ + CLK_32k,/* 100 ipg_clk_32k */ +CLK_NONE ,/* 101 not defined */ +CLK_NONE ,/* 110 not defined */ +CLK_NONE ,/* 111 not defined */ };static void imx_gpt_set_freq (IMXGPTState *s)
include/hw/misc/imx_ccm.h +2 -8
@@ -43,15 +43,9 @@ typedef struct IMXCCMState { } IMXCCMState;typedef enum { -NOCLK , -CLK_MPLL , -CLK_UPLL , -CLK_MCU , -CLK_HSP , -CLK_MAX , -CLK_AHB , +CLK_NONE ,CLK_IPG , -CLK_PER , +CLK_IPG_HIGH , CLK_32k }IMXClk ;
Signature · 1 line
2.5.0
Quoted 8 lines · Jean-Christophe Dubois
Various i.MX timers (GPT, EPIT, PWM, ...) are only requesting 4 clocks from the system.
*CLK_NONE,
*CLK_IPG,
*CLK_IPG_HIGH,
*CLK_32kOther "clocks" are not required by the qemu framework so far.
This patch confuses me. You don't say why we're removing a bunch of code or why it's OK to do that.
Quoted 84 lines
Signed-off-by Jean-Christophe Dubois <[email protected]>--- hw/misc/imx25_ccm.c | 35 +++++------------------------------ hw/misc/imx31_ccm.c | 38 ++++---------------------------------- hw/timer/imx_epit.c | 8 ++++---- hw/timer/imx_gpt.c | 16 ++++++++-------- include/hw/misc/imx_ccm.h | 10 ++-------- 5 files changed, 23 insertions(+), 84 deletions(-)hw/misc/imx25_ccm.c +5
-30@@ -119,20 +119,6 @@ static uint32_t imx25_ccm_get_mpll_clk(IMXCCMState *dev)return freq; } -static uint32_t imx25_ccm_get_upll_clk (IMXCCMState *dev) -{ -uint32_t freq =0 ; -IMX25CCMState *s =IMX25_CCM (dev); - -if (!EXTRACT (s->reg[IMX25_CCM_CCTL_REG ],UPLL_DIS )) { - freq =imx_ccm_calc_pll (s->reg[IMX25_CCM_UPCTL_REG ],CKIH_FREQ ); - } - -DPRINTF ("freq = %d\n" , freq); - -return freq; -} -static uint32_t imx25_ccm_get_mcu_clk (IMXCCMState *dev) {uint32_t freq;@@ -181,21 +167,10 @@ static uint32_t imx25_ccm_get_clock_frequency(IMXCCMState *dev, IMXClk clock)DPRINTF ("Clock = %d)\n" , clock);switch (clock) { -case NOCLK : -break ; -case CLK_MPLL : - freq =imx25_ccm_get_mpll_clk (dev); -break ; -case CLK_UPLL : - freq =imx25_ccm_get_upll_clk (dev); -break ; -case CLK_MCU : - freq =imx25_ccm_get_mcu_clk (dev); -break ; -case CLK_AHB : - freq =imx25_ccm_get_ahb_clk (dev); +case CLK_NONE :break ;case CLK_IPG : +case CLK_IPG_HIGH : freq =imx25_ccm_get_ipg_clk (dev);break ;case CLK_32k:@@ -221,9 +196,9 @@ static void imx25_ccm_reset(DeviceState *dev)memset (s->reg,0 ,IMX25_CCM_MAX_REG *sizeof (uint32_t )); s->reg[IMX25_CCM_MPCTL_REG ] =0x800b2c01 ; s->reg[IMX25_CCM_UPCTL_REG ] =0x84042800 ; -/* +/* * The value below gives: -* CPU = 133 MHz, AHB = 66,5 MHz, IPG = 33 MHz. +* CPU = 133 MHz, AHB = 66,5 MHz, IPG = 33 MHz. */ s->reg[IMX25_CCM_CCTL_REG ] =0xd0030000 ; s->reg[IMX25_CCM_CGCR0_REG ] =0x028A0100 ;@@ -240,7 +215,7 @@ static void imx25_ccm_reset(DeviceState *dev)/* * default boot will change the reset values to allow: -* CPU = 399 MHz, AHB = 133 MHz, IPG = 66,5 MHz. +* CPU = 399 MHz, AHB = 133 MHz, IPG = 66,5 MHz. * For some reason, this doesn't work. With the value below, linux * detects a 88 MHz IPG CLK instead of 66,5 MHz. s->reg[IMX25_CCM_CCTL_REG] = 0x20032000; hw/misc/imx31_ccm.c +0
-0
hw/misc/imx31_ccm.c static uint32_t imx31_ccm_get_pll_ref_clk(IMXCCMState *dev) · line 114
Quoted 5 lines
hw/misc/imx31_ccm.c +1
-1@@ -111,7 +111,7 @@ static uint32_t imx31_ccm_get_pll_ref_clk(IMXCCMState *dev)if (s->reg[IMX31_CCM_CCMR_REG ] &CCMR_FPMF ) { freq *=1024 ; } - } + }
What are all these whitespace only changes? If you need to do a whitespace cleanup please put it in its own patch.
Quoted 35 lines
hw/misc/imx31_ccm.c +0
-0case CLK_32k:hw/timer/imx_epit.c +4
-4@@ -51,10 +51,10 @@ static char const *imx_epit_reg_name(uint32_t reg)* These are typical. */ static const IMXClk imx_epit_clocks[] = { -NOCLK ,/* 00 disabled */ -CLK_IPG ,/* 01 ipg_clk, ~532MHz */ -CLK_IPG ,/* 10 ipg_clk_highfreq */ - CLK_32k,/* 11 ipg_clk_32k -- ~32kHz */ +CLK_NONE ,/* 00 disabled */ +CLK_IPG ,/* 01 ipg_clk, ~532MHz */ +CLK_IPG_HIGH ,/* 10 ipg_clk_highfreq */ + CLK_32k,/* 11 ipg_clk_32k -- ~32kHz */ };/* hw/timer/imx_gpt.c +0
-7@@ -80,14 +80,14 @@ static const VMStateDescription vmstate_imx_timer_gpt = { };static const IMXClk imx_gpt_clocks[] = { -NOCLK ,/* 000 No clock source */ -CLK_IPG ,/* 001 ipg_clk, 532MHz*/ -CLK_IPG ,/* 010 ipg_clk_highfreq */ -NOCLK ,/* 011 not defined */ - CLK_32k,/* 100 ipg_clk_32k */ -NOCLK ,/* 101 not defined */ -NOCLK ,/* 110 not defined */
hw/timer/imx_gpt.c static const VMStateDescription vmstate_imx_timer_gpt = { · line 91
Quoted 10 lines
hw/timer/imx_gpt.c +8
-1- NOCLK, /* 111 not defined */ +CLK_NONE ,/* 000 No clock source */ +CLK_IPG ,/* 001 ipg_clk, 532MHz*/ +CLK_IPG_HIGH ,/* 010 ipg_clk_highfreq */ +CLK_NONE ,/* 011 not defined */ + CLK_32k,/* 100 ipg_clk_32k */ +CLK_NONE ,/* 101 not defined */ +CLK_NONE ,/* 110 not defined */ + CLK_NONE, /* 111 not defined */ };
These are just renaming NOCLK to CLK_NONE and fixing formatting? Again, please don't put that in the same patch as substantive code changes.
thanks
-- PMM
Quoted 11 lines · Peter Maydell
Quoted 8 lines · Jean-Christophe Dubois
Various i.MX timers (GPT, EPIT, PWM, ...) are only requesting 4 clocks from the system.
*CLK_NONE,
*CLK_IPG,
*CLK_IPG_HIGH,
*CLK_32kOther "clocks" are not required by the qemu framework so far.
This patch confuses me. You don't say why we're removing a bunch of code or why it's OK to do that.
I added these other clocks in a previous patch but I believe it was a mistake I made.
These additional clocks (MCU, AHB, PER, ...) will likely never be user inside QEMU. And each new version of SOC will just continue to add to this list of clocks making things always more confusing.
In fact, the only interesting clocks are the ones that are used by timer devices. And timer devices don't directly use SOC named clocks (PER, AHB, ...), but they use only (for now) the 4 abstract clocks listed above. Each SOC seems then free to map these abstract clocks (generally mostly IPG and IPG_HIGH) to any of its real clocks.
So I decided to just remove the useless code in relation with SOC clocks that are not otherwise used in the rest of the QEMU code.
I added this mess so I should clean it. And this is really what this patch is: A cleanup of something that should not have been added in the first place because it has no use.
Sorry about that.
Quoted 85 lines
Quoted 85 lines
Signed-off-by Jean-Christophe Dubois <[email protected]>--- hw/misc/imx25_ccm.c | 35 +++++------------------------------ hw/misc/imx31_ccm.c | 38 ++++---------------------------------- hw/timer/imx_epit.c | 8 ++++---- hw/timer/imx_gpt.c | 16 ++++++++-------- include/hw/misc/imx_ccm.h | 10 ++-------- 5 files changed, 23 insertions(+), 84 deletions(-)hw/misc/imx25_ccm.c +5
-30@@ -119,20 +119,6 @@ static uint32_t imx25_ccm_get_mpll_clk(IMXCCMState *dev)return freq; } -static uint32_t imx25_ccm_get_upll_clk (IMXCCMState *dev) -{ -uint32_t freq =0 ; -IMX25CCMState *s =IMX25_CCM (dev); - -if (!EXTRACT (s->reg[IMX25_CCM_CCTL_REG ],UPLL_DIS )) { - freq =imx_ccm_calc_pll (s->reg[IMX25_CCM_UPCTL_REG ],CKIH_FREQ ); - } - -DPRINTF ("freq = %d\n" , freq); - -return freq; -} -static uint32_t imx25_ccm_get_mcu_clk (IMXCCMState *dev) {uint32_t freq;@@ -181,21 +167,10 @@ static uint32_t imx25_ccm_get_clock_frequency(IMXCCMState *dev, IMXClk clock)DPRINTF ("Clock = %d)\n" , clock);switch (clock) { -case NOCLK : -break ; -case CLK_MPLL : - freq =imx25_ccm_get_mpll_clk (dev); -break ; -case CLK_UPLL : - freq =imx25_ccm_get_upll_clk (dev); -break ; -case CLK_MCU : - freq =imx25_ccm_get_mcu_clk (dev); -break ; -case CLK_AHB : - freq =imx25_ccm_get_ahb_clk (dev); +case CLK_NONE :break ;case CLK_IPG : +case CLK_IPG_HIGH : freq =imx25_ccm_get_ipg_clk (dev);break ;case CLK_32k:@@ -221,9 +196,9 @@ static void imx25_ccm_reset(DeviceState *dev)memset (s->reg,0 ,IMX25_CCM_MAX_REG *sizeof (uint32_t )); s->reg[IMX25_CCM_MPCTL_REG ] =0x800b2c01 ; s->reg[IMX25_CCM_UPCTL_REG ] =0x84042800 ; -/* +/* * The value below gives: -* CPU = 133 MHz, AHB = 66,5 MHz, IPG = 33 MHz. +* CPU = 133 MHz, AHB = 66,5 MHz, IPG = 33 MHz. */ s->reg[IMX25_CCM_CCTL_REG ] =0xd0030000 ; s->reg[IMX25_CCM_CGCR0_REG ] =0x028A0100 ;@@ -240,7 +215,7 @@ static void imx25_ccm_reset(DeviceState *dev)/* * default boot will change the reset values to allow: -* CPU = 399 MHz, AHB = 133 MHz, IPG = 66,5 MHz. +* CPU = 399 MHz, AHB = 133 MHz, IPG = 66,5 MHz. * For some reason, this doesn't work. With the value below, linux * detects a 88 MHz IPG CLK instead of 66,5 MHz. s->reg[IMX25_CCM_CCTL_REG] = 0x20032000; hw/misc/imx31_ccm.c +0
-0@@ -111,7 +111,7 @@ static uint32_t imx31_ccm_get_pll_ref_clk(IMXCCMState *dev)
Quoted 8 lines
hw/misc/imx31_ccm.c static uint32_t imx31_ccm_get_pll_ref_clk(IMXCCMState *dev) · line 114
Quoted 5 lines
hw/misc/imx31_ccm.c +1
-1if (s->reg[IMX31_CCM_CCMR_REG ] &CCMR_FPMF ) { freq *=1024 ; } - } + }What are all these whitespace only changes? If you need to do a whitespace cleanup please put it in its own patch.
OK
Quoted 41 lines
Quoted 41 lines
hw/misc/imx31_ccm.c +0
-0case CLK_32k:hw/timer/imx_epit.c +4
-4@@ -51,10 +51,10 @@ static char const *imx_epit_reg_name(uint32_t reg)* These are typical. */ static const IMXClk imx_epit_clocks[] = { -NOCLK ,/* 00 disabled */ -CLK_IPG ,/* 01 ipg_clk, ~532MHz */ -CLK_IPG ,/* 10 ipg_clk_highfreq */ - CLK_32k,/* 11 ipg_clk_32k -- ~32kHz */ +CLK_NONE ,/* 00 disabled */ +CLK_IPG ,/* 01 ipg_clk, ~532MHz */ +CLK_IPG_HIGH ,/* 10 ipg_clk_highfreq */ + CLK_32k,/* 11 ipg_clk_32k -- ~32kHz */ };/* hw/timer/imx_gpt.c +4
-8@@ -80,14 +80,14 @@ static const VMStateDescription vmstate_imx_timer_gpt = { };static const IMXClk imx_gpt_clocks[] = { -NOCLK ,/* 000 No clock source */ -CLK_IPG ,/* 001 ipg_clk, 532MHz*/ -CLK_IPG ,/* 010 ipg_clk_highfreq */ -NOCLK ,/* 011 not defined */ - CLK_32k,/* 100 ipg_clk_32k */ -NOCLK ,/* 101 not defined */ -NOCLK ,/* 110 not defined */ -NOCLK ,/* 111 not defined */ +CLK_NONE ,/* 000 No clock source */ +CLK_IPG ,/* 001 ipg_clk, 532MHz*/ +CLK_IPG_HIGH ,/* 010 ipg_clk_highfreq */ +CLK_NONE ,/* 011 not defined */
Quoted 8 lines
hw/timer/imx_gpt.c static const VMStateDescription vmstate_imx_timer_gpt = { · line 91
Quoted 5 lines
hw/timer/imx_gpt.c +4
-0+ CLK_32k,/* 100 ipg_clk_32k */ +CLK_NONE ,/* 101 not defined */ +CLK_NONE ,/* 110 not defined */ + CLK_NONE, /* 111 not defined */ };These are just renaming NOCLK to
CLK_NONEand fixing formatting? Again, please don't put that in the same patch as substantive code changes.
I just wanted to make things more coherent at the naming convention level.
But if you prefer NOCLK, I'll put it back.
Quoted 4 lines
thanks
-- PMM
Quoted 9 lines · Jean-Christophe DUBOIS
Quoted 3 lines · Peter Maydell
These are just renaming NOCLK to
CLK_NONEand fixing formatting? Again, please don't put that in the same patch as substantive code changes.I just wanted to make things more coherent at the naming convention level.
But if you prefer NOCLK, I'll put it back.
I have no preference either way about the name. It's just hard to review patches if they mix lots of cleanups in at once, and especially if they mix stylistic changes in with behaviour changes. It's probably sufficient just to split this patch up into logically distinct changes with suitable commit messages.
thanks
-- PMM