Skip to contentSkip to conversation

Tegra: clk: always use find_best_divider() for periph clocks

PATCH New Allen Martin 3 participants 6 messages May 11, 2013 – May 14, 2013

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Tegra: clk: always use find_best_divider() for periph clocks

When adjusting peripheral clocks always use find_best_divider() instead of clk_get_divider() even when a secondary divider is not available. In the case where is requested clock is too slow to be derived from the parent clock this allows a best effort to get close to the requested clock.

This comes up for commands like "sf" where the user can pass a clock speed on the command line or "sspi" where the clock is hardcoded to 1MHz, but the Tegra114 SPI controller can't go that low.

---
 arch/arm/cpu/tegra-common/clock.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)
arch/arm/cpu/tegra-common/clock.c +5 -5
index 9156d00..268fb91 100644
@@ -321,17 +321,17 @@ unsigned clock_adjust_periph_pll_div(enum periph_id periph_id,
 	unsigned effective_rate;
 	int mux_bits, divider_bits, source;
 	int divider;
+	int xdiv = 0;
 
 	/* work out the source clock and set it */
 	source = get_periph_clock_source(periph_id, parent, &mux_bits,
 					 &divider_bits);
 
+	divider = find_best_divider(divider_bits, pll_rate[parent],
+				    rate, &xdiv);
 	if (extra_div)
-		divider = find_best_divider(divider_bits, pll_rate[parent],
-						rate, extra_div);
-	else
-		divider = clk_get_divider(divider_bits, pll_rate[parent],
-					  rate);
+		*extra_div = xdiv;
+
 	assert(divider >= 0);
 	if (adjust_periph_pll(periph_id, source, mux_bits, divider))
 		return -1U;
Signature · 1 line
1.8.1.2
#1 lore raw

PATCH 1/1 Tegra: clk: always use find_best_divider() for periph clocks

Quoted 11 lines · Allen Martin

When adjusting peripheral clocks always use find_best_divider() instead of clk_get_divider() even when a secondary divider is not available. In the case where is requested clock is too slow to be derived from the parent clock this allows a best effort to get close to the requested clock.

This comes up for commands like "sf" where the user can pass a clock speed on the command line or "sspi" where the clock is hardcoded to 1MHz, but the Tegra114 SPI controller can't go that low.

Seems right to me,

#2 lore raw

PATCH 1/1 Tegra: clk: always use find_best_divider() for periph clocks

Allen,

Quoted 8 lines

-----Original Message-----
From: sjg at google.com [mailto:sjg at google.com] On Behalf Of Simon Glass
Sent: Friday, May 10, 2013 8:06 PM
To: Allen Martin
Cc: Tom Warren; Stephen Warren; U-Boot Mailing List
Subject: Re: [PATCH] Tegra: clk: always use find_best_divider() for periph clocks

Quoted 10 lines
Quoted 9 lines · Allen Martin

When adjusting peripheral clocks always use find_best_divider() instead of clk_get_divider() even when a secondary divider is not available. In the case where is requested clock is too slow to be derived from the parent clock this allows a best effort to get close to the requested clock.

This comes up for commands like "sf" where the user can pass a clock speed on the command line or "sspi" where the clock is hardcoded to 1MHz, but the Tegra114 SPI controller can't go that low.

Did you test all other periphs and check their config'd clocks to make sure this doesn't affect anything else negatively? This proc is pretty universal (called by clock_start_periph_pll, which is used by MMC/I2C/USB/display drivers).

Tom

Quoted 6 lines
Quoted 2 lines

Seems right to me,

--
nvpublic

#3 lore raw

PATCH 1/1 Tegra: clk: always use find_best_divider() for periph clocks

Quoted 17 lines · Tom Warren

Allen,

Quoted 15 lines

-----Original Message-----
From: sjg at google.com [mailto:sjg at google.com] On Behalf Of Simon Glass
Sent: Friday, May 10, 2013 8:06 PM
To: Allen Martin
Cc: Tom Warren; Stephen Warren; U-Boot Mailing List
Subject: Re: [PATCH] Tegra: clk: always use find_best_divider() for periph clocks

Quoted 6 lines · Allen Martin

When adjusting peripheral clocks always use find_best_divider() instead of clk_get_divider() even when a secondary divider is not available. In the case where is requested clock is too slow to be derived from the parent clock this allows a best effort to get close to the requested clock.

Quoted 6 lines
Quoted 3 lines
Quoted 3 lines

This comes up for commands like "sf" where the user can pass a clock speed on the command line or "sspi" where the clock is hardcoded to 1MHz, but the Tegra114 SPI controller can't go that low.

Did you test all other periphs and check their config'd clocks to make sure this doesn't affect anything else negatively? This proc is pretty universal (called by clock_start_periph_pll, which is used by MMC/I2C/USB/display drivers).

I tested a handful of peripherals on dalmore, but you're right this is generic enough that it warrants a more thorough test scrubbing. I'll try to hit all the peripherals I can across all chipsets and report back.

-Allen

Signature · 1 line
nvpublic
#4 lore raw

PATCH 1/1 Tegra: clk: always use find_best_divider() for periph clocks

In reply to Tom Warren
Quoted 17 lines · Tom Warren

Allen,

Quoted 15 lines

-----Original Message-----
From: sjg at google.com [mailto:sjg at google.com] On Behalf Of Simon Glass
Sent: Friday, May 10, 2013 8:06 PM
To: Allen Martin
Cc: Tom Warren; Stephen Warren; U-Boot Mailing List
Subject: Re: [PATCH] Tegra: clk: always use find_best_divider() for periph clocks

Quoted 6 lines · Allen Martin

When adjusting peripheral clocks always use find_best_divider() instead of clk_get_divider() even when a secondary divider is not available. In the case where is requested clock is too slow to be derived from the parent clock this allows a best effort to get close to the requested clock.

Quoted 6 lines
Quoted 3 lines
Quoted 3 lines

This comes up for commands like "sf" where the user can pass a clock speed on the command line or "sspi" where the clock is hardcoded to 1MHz, but the Tegra114 SPI controller can't go that low.

Did you test all other periphs and check their config'd clocks to make sure this doesn't affect anything else negatively? This proc is pretty universal (called by clock_start_periph_pll, which is used by MMC/I2C/USB/display drivers).

Testing done:

tegra20 seaboard:
usb read/write
i2c read
emmc read
sdcard read/write
lcd
uart read/write

tegra20 trimslice:
spi read
uart read/write

tegra30 cardhu:
spi read/write
uart read/write
i2c read
sdcard read/write
emmc read

tegra114 dalmore:
iwc read
sdcard read/write
emmc read
uart read/write

-Allen

Signature · 1 line
nvpublic
#5 lore raw

PATCH 1/1 Tegra: clk: always use find_best_divider() for periph clocks

Allen,

Quoted 59 lines

-----Original Message-----
From: Allen Martin [mailto:amartin at nvidia.com]
Sent: Monday, May 13, 2013 7:12 PM
To: Tom Warren
Cc: Simon Glass; Stephen Warren; U-Boot Mailing List
Subject: Re: [PATCH] Tegra: clk: always use find_best_divider() for periph clocks

Quoted 12 lines · Tom Warren

Allen,

Quoted 10 lines

-----Original Message-----
From: sjg at google.com [mailto:sjg at google.com] On Behalf Of Simon Glass
Sent: Friday, May 10, 2013 8:06 PM
To: Allen Martin
Cc: Tom Warren; Stephen Warren; U-Boot Mailing List
Subject: Re: [PATCH] Tegra: clk: always use find_best_divider() for periph clocks

On Fri, May 10, 2013 at 8:56 PM, Allen Martin <[email protected]>

Quoted 11 lines · wrote:
Quoted 9 lines
Quoted 9 lines

When adjusting peripheral clocks always use find_best_divider() instead of clk_get_divider() even when a secondary divider is not available. In the case where is requested clock is too slow to be derived from the parent clock this allows a best effort to get close to the requested clock.

This comes up for commands like "sf" where the user can pass a clock speed on the command line or "sspi" where the clock is hardcoded to 1MHz, but the Tegra114 SPI controller can't go that low.

Did you test all other periphs and check their config'd clocks to make sure

this doesn't affect anything else negatively? This proc is pretty universal (called by clock_start_periph_pll, which is used by MMC/I2C/USB/display drivers).

Quoted 1 line

Testing done:

tegra20 seaboard:
usb read/write
i2c read
emmc read
sdcard read/write
lcd
uart read/write

tegra20 trimslice:
spi read
uart read/write

tegra30 cardhu:
spi read/write
uart read/write
i2c read
sdcard read/write
emmc read

Quoted 5 lines

tegra114 dalmore:
iwc read
sdcard read/write
emmc read
uart read/write

Nice. Thanks. I'll add it to u-boot-tegra/next tomorrow or Weds.

Tom

Quoted 2 lines

-Allen

--
nvpublic