public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
From: Vitaly Andrianov <vitalya@ti.com>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH 6/8] ARM: keystone2: Cleanup init_pll definition
Date: Thu, 23 Jul 2015 14:01:27 -0400	[thread overview]
Message-ID: <55B12BF7.8040801@ti.com> (raw)
In-Reply-To: <1437579558-26579-7-git-send-email-lokeshvutla@ti.com>



On 07/22/2015 11:39 AM, Lokesh Vutla wrote:
> This is just a cosmetic change that makes
> the calling of pll init code looks much cleaner.
>
> Signed-off-by: Lokesh Vutla <lokeshvutla@ti.com>
> ---
>   arch/arm/mach-keystone/clock.c              | 12 ++++++---
>   arch/arm/mach-keystone/include/mach/clock.h |  3 ++-
>   board/ti/ks2_evm/board_k2e.c                | 33 +++++++++++++++--------
>   board/ti/ks2_evm/board_k2hk.c               | 41 ++++++++++++++++++-----------
>   board/ti/ks2_evm/board_k2l.c                | 41 ++++++++++++++++++-----------
>   5 files changed, 84 insertions(+), 46 deletions(-)
>
> diff --git a/arch/arm/mach-keystone/clock.c b/arch/arm/mach-keystone/clock.c
> index f60a0b8..824a6ce 100644
> --- a/arch/arm/mach-keystone/clock.c
> +++ b/arch/arm/mach-keystone/clock.c
> @@ -191,12 +191,16 @@ void init_pll(const struct pll_init_data *data)
>   		configure_secondary_pll(data);
>   }
>
> -void init_plls(int num_pll, struct pll_init_data *config)
> +void init_plls(void)
>   {
> -	int i;
> +	struct pll_init_data *data;
> +	int pll;
>
> -	for (i = 0; i < num_pll; i++)
> -		init_pll(&config[i]);
> +	for (pll = MAIN_PLL; pll < MAX_PLL_COUNT; pll++) {
> +		data = get_pll_init_data(pll);
> +		if (data)
> +			init_pll(data);
> +	}
>   }
>
Does the MAX_PLL_COUNT represent all PLLs on board?
If that is true, I think the patch is incorrect.
If you look at the history of the PLL configuration code you will find
that we had this cod in the past and changed it.

The currently working code doesn't configure all PLLs an advance.
For example DDR3a PLLs is configured later, after getting information
about required DDR3 speed. Also the current version of code doesn't 
configure DDR3B at all. And I don't see any reason why do we need to 
change it.




>   static int get_max_speed(u32 val, u32 speed_supported)
> diff --git a/arch/arm/mach-keystone/include/mach/clock.h b/arch/arm/mach-keystone/include/mach/clock.h
> index dc3c56a..ea7d8bc 100644
> --- a/arch/arm/mach-keystone/include/mach/clock.h
> +++ b/arch/arm/mach-keystone/include/mach/clock.h
> @@ -73,8 +73,9 @@ extern const struct keystone_pll_regs keystone_pll_regs[];
>   extern int dev_speeds[];
>   extern int arm_speeds[];
>
> -void init_plls(int num_pll, struct pll_init_data *config);
> +void init_plls(void);
>   void init_pll(const struct pll_init_data *data);
> +struct pll_init_data *get_pll_init_data(int pll);
>   unsigned long clk_get_rate(unsigned int clk);
>   unsigned long clk_round_rate(unsigned int clk, unsigned long hz);
>   int clk_set_rate(unsigned int clk, unsigned long hz);
> diff --git a/board/ti/ks2_evm/board_k2e.c b/board/ti/ks2_evm/board_k2e.c
> index 6d98b2a..82792ef 100644
> --- a/board/ti/ks2_evm/board_k2e.c
> +++ b/board/ti/ks2_evm/board_k2e.c
> @@ -38,6 +38,26 @@ static struct pll_init_data core_pll_config[] = {
>   static struct pll_init_data pa_pll_config =
>   	PASS_PLL_1000;
>
> +struct pll_init_data *get_pll_init_data(int pll)
> +{
> +	int speed;
> +	struct pll_init_data *data;
> +
> +	switch (pll) {
> +	case MAIN_PLL:
> +		speed = get_max_dev_speed();
> +		data = &core_pll_config[speed];
> +		break;
> +	case PASS_PLL:
> +		data = &pa_pll_config;
> +		break;
> +	default:
> +		data = NULL;
> +	}
> +
> +	return data;
> +}
> +
>   #ifdef CONFIG_DRIVER_TI_KEYSTONE_NET
>   struct eth_priv_t eth_priv_cfg[] = {
>   	{
> @@ -107,24 +127,15 @@ int get_num_eth_ports(void)
>   #if defined(CONFIG_BOARD_EARLY_INIT_F)
>   int board_early_init_f(void)
>   {
> -	int speed;
> -
> -	speed = get_max_dev_speed();
> -	init_pll(&core_pll_config[speed]);
> -
> -	init_pll(&pa_pll_config);
> +	init_plls();
>
>   	return 0;
>   }
>   #endif
>
>   #ifdef CONFIG_SPL_BUILD
> -static struct pll_init_data spl_pll_config[] = {
> -	CORE_PLL_800,
> -};
> -
>   void spl_init_keystone_plls(void)
>   {
> -	init_plls(ARRAY_SIZE(spl_pll_config), spl_pll_config);
> +	init_plls();
>   }
>   #endif
> diff --git a/board/ti/ks2_evm/board_k2hk.c b/board/ti/ks2_evm/board_k2hk.c
> index ed181f4..cec6c02 100644
> --- a/board/ti/ks2_evm/board_k2hk.c
> +++ b/board/ti/ks2_evm/board_k2hk.c
> @@ -46,6 +46,30 @@ static struct pll_init_data tetris_pll_config[] = {
>   static struct pll_init_data pa_pll_config =
>   	PASS_PLL_983;
>
> +struct pll_init_data *get_pll_init_data(int pll)
> +{
> +	int speed;
> +	struct pll_init_data *data;
> +
> +	switch (pll) {
> +	case MAIN_PLL:
> +		speed = get_max_dev_speed();
> +		data = &core_pll_config[speed];
> +		break;
> +	case TETRIS_PLL:
> +		speed = get_max_arm_speed();
> +		data = &tetris_pll_config[speed];
> +		break;
> +	case PASS_PLL:
> +		data = &pa_pll_config;
> +		break;
> +	default:
> +		data = NULL;
> +	}
> +
> +	return data;
> +}
> +
>   #ifdef CONFIG_DRIVER_TI_KEYSTONE_NET
>   struct eth_priv_t eth_priv_cfg[] = {
>   	{
> @@ -87,28 +111,15 @@ int get_num_eth_ports(void)
>   #ifdef CONFIG_BOARD_EARLY_INIT_F
>   int board_early_init_f(void)
>   {
> -	int speed;
> -
> -	speed = get_max_dev_speed();
> -	init_pll(&core_pll_config[speed]);
> -
> -	init_pll(&pa_pll_config);
> -
> -	speed = get_max_arm_speed();
> -	init_pll(&tetris_pll_config[speed]);
> +	init_plls();
>
>   	return 0;
>   }
>   #endif
>
>   #ifdef CONFIG_SPL_BUILD
> -static struct pll_init_data spl_pll_config[] = {
> -	CORE_PLL_799,
> -	TETRIS_PLL_500,
> -};
> -
>   void spl_init_keystone_plls(void)
>   {
> -	init_plls(ARRAY_SIZE(spl_pll_config), spl_pll_config);
> +	init_plls();
>   }
>   #endif
> diff --git a/board/ti/ks2_evm/board_k2l.c b/board/ti/ks2_evm/board_k2l.c
> index 729a193..1b4d086 100644
> --- a/board/ti/ks2_evm/board_k2l.c
> +++ b/board/ti/ks2_evm/board_k2l.c
> @@ -42,6 +42,30 @@ static struct pll_init_data tetris_pll_config[] = {
>   static struct pll_init_data pa_pll_config =
>   	PASS_PLL_983;
>
> +struct pll_init_data *get_pll_init_data(int pll)
> +{
> +	int speed;
> +	struct pll_init_data *data;
> +
> +	switch (pll) {
> +	case MAIN_PLL:
> +		speed = get_max_dev_speed();
> +		data = &core_pll_config[speed];
> +		break;
> +	case TETRIS_PLL:
> +		speed = get_max_arm_speed();
> +		data = &tetris_pll_config[speed];
> +		break;
> +	case PASS_PLL:
> +		data = &pa_pll_config;
> +		break;
> +	default:
> +		data = NULL;
> +	}
> +
> +	return data;
> +}
> +
>   #ifdef CONFIG_DRIVER_TI_KEYSTONE_NET
>   struct eth_priv_t eth_priv_cfg[] = {
>   	{
> @@ -83,28 +107,15 @@ int get_num_eth_ports(void)
>   #ifdef CONFIG_BOARD_EARLY_INIT_F
>   int board_early_init_f(void)
>   {
> -	int speed;
> -
> -	speed = get_max_dev_speed();
> -	init_pll(&core_pll_config[speed]);
> -
> -	init_pll(&pa_pll_config);
> -
> -	speed = get_max_arm_speed();
> -	init_pll(&tetris_pll_config[speed]);
> +	init_plls();
>
>   	return 0;
>   }
>   #endif
>
>   #ifdef CONFIG_SPL_BUILD
> -static struct pll_init_data spl_pll_config[] = {
> -	CORE_PLL_799,
> -	TETRIS_PLL_491,
> -};
> -
>   void spl_init_keystone_plls(void)
>   {
> -	init_plls(ARRAY_SIZE(spl_pll_config), spl_pll_config);
> +	init_plls();
>   }
>   #endif
>

  reply	other threads:[~2015-07-23 18:01 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-07-22 15:39 [U-Boot] [PATCH 0/8] ARM: keystone2: Clocls and PLLs cleanup Lokesh Vutla
2015-07-22 15:39 ` [U-Boot] [PATCH 1/8] ARM: keystone2: Cleanup SoC detection Lokesh Vutla
2015-07-22 15:54   ` Vitaly Andrianov
2015-07-23 19:29   ` Tom Rini
2015-07-24 11:50     ` Lokesh Vutla
2015-07-22 15:39 ` [U-Boot] [PATCH 2/8] ARM: keystone2: Enable CONFIG_DISPLAY_CPUINFO Lokesh Vutla
2015-07-22 15:56   ` Vitaly Andrianov
2015-07-23 19:29   ` Tom Rini
2015-07-22 15:39 ` [U-Boot] [PATCH 3/8] ARM: keystone2: Cleanup PLL init code Lokesh Vutla
2015-07-23 19:29   ` Tom Rini
2015-07-22 15:39 ` [U-Boot] [PATCH 4/8] ARM: keystone2: Fix dev and arm speed detection Lokesh Vutla
2015-07-23 19:29   ` Tom Rini
2015-07-22 15:39 ` [U-Boot] [PATCH 5/8] ARM: keystone2: Use common structure for PLLs Lokesh Vutla
2015-07-23 19:30   ` Tom Rini
2015-07-22 15:39 ` [U-Boot] [PATCH 6/8] ARM: keystone2: Cleanup init_pll definition Lokesh Vutla
2015-07-23 18:01   ` Vitaly Andrianov [this message]
2015-07-24  4:20     ` Lokesh Vutla
2015-07-24 11:48       ` Vitaly Andrianov
2015-07-23 19:30   ` Tom Rini
2015-07-22 15:39 ` [U-Boot] [PATCH 7/8] ARM: keystone2: Remove unsed external clocks Lokesh Vutla
2015-07-23 19:30   ` Tom Rini
2015-07-22 15:39 ` [U-Boot] [PATCH 8/8] ARM: keystone2: Use common definition for clk_get_rate Lokesh Vutla
2015-07-23 19:30   ` Tom Rini
2015-07-22 15:45 ` [U-Boot] [PATCH 0/8] ARM: keystone2: Clocls and PLLs cleanup Lokesh Vutla

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=55B12BF7.8040801@ti.com \
    --to=vitalya@ti.com \
    --cc=u-boot@lists.denx.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox