Skip to content

Commit 5808b4c

Browse files
dgarskedanielinux
authored andcommitted
Fix for T1024 CPU core clock calculation.
1 parent 349231b commit 5808b4c

2 files changed

Lines changed: 27 additions & 8 deletions

File tree

docs/Targets.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1381,6 +1381,7 @@ Default NOR Flash Memory Layout (64MB) (128KB block, 1K page)
13811381
| Swap Sector | 0xEC0F0000 | 0x00010000 ( 64 KB) |
13821382
| Free | 0xEC100000 | 0x00100000 ( 1 MB) |
13831383
| Update (OS) | 0xEC200000 | 0x01E00000 ( 30 MB) |
1384+
| Ethenet Config | 0xED0E0000 | 0x00000400 ( 1 KB) |
13841385
| Application (OS) | 0xEE000000 | 0x01E00000 ( 30 MB) |
13851386
| QUICC | 0xEFE00000 | 0x00100000 ( 1 MB) |
13861387
| DPAA (FMAN) | 0xEFF00000 | 0x00020000 (128 KB) |

hal/nxp_t1024.c

Lines changed: 26 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -192,8 +192,16 @@ static void hal_flash_unlock_sector(uint32_t sector);
192192

193193

194194
/* T1024RM: 4.6.5 */
195-
#define CLOCKING_BASE (CCSRBAR + 0xE1000)
196-
#define CLOCKING_PLLPGSR ((volatile uint32_t*)(CLOCKING_BASE + 0xC00UL)) /* Platform PLL general status register */
195+
#define CLOCKING_BASE (CCSRBAR + 0xE1000)
196+
#define CLOCKING_CLKCCSR(n) ((volatile uint32_t*)(CLOCKING_BASE + 0x000UL + ((n) * 0x20))) /* Core cluster n clock control/status register */
197+
#define CLOCKING_CLKCGHWACSR(n) ((volatile uint32_t*)(CLOCKING_BASE + 0x010UL + ((n) * 0x20))) /* Clock generator n hardware accelerator control/status */
198+
#define CLOCKING_PLLCNGSR(n) ((volatile uint32_t*)(CLOCKING_BASE + 0x800UL + ((n) * 0x20))) /* PLL cluster n general status register */
199+
#define CLOCKING_CLKPCSR ((volatile uint32_t*)(CLOCKING_BASE + 0xA00UL)) /* Platform clock domain control/status register */
200+
#define CLOCKING_PLLPGSR ((volatile uint32_t*)(CLOCKING_BASE + 0xC00UL)) /* Platform PLL general status register */
201+
#define CLOCKING_PLLDGSR ((volatile uint32_t*)(CLOCKING_BASE + 0xC20UL)) /* DDR PLL general status register */
202+
203+
#define CLKC0CSR_CLKSEL(n) (((n) >> 27) & 0xF) /* 0000=Cluster PLL1 Output, 0001=Cluster PKK1 divide-by-2 */
204+
#define PLLCGSR_CGF(n) (((n) >> 1) & 0x3F) /* Reflects the current PLL multiplier configuration. Indicates the frequency for this PLL */
197205

198206
#define RCPM_BASE (CCSRBAR + 0xE2000)
199207
#define RCPM_PCTBENR ((volatile uint32_t*)(RCPM_BASE + 0x1A0)) /* Physical Core Time Base Enable Bit 0=Core 0 */
@@ -749,26 +757,36 @@ enum ifc_amask_sizes {
749757

750758

751759
#ifdef ENABLE_BUS_CLK_CALC
760+
static uint32_t hal_get_core_clk(void)
761+
{
762+
/* compute core clock (system input * ratio) */
763+
uint32_t core_clk;
764+
uint32_t core_ratio = get32(CLOCKING_PLLCNGSR(0)); /* see CGA_PLL1_RAT in RCW */
765+
/* shift by 1 and mask */
766+
core_ratio = ((core_ratio >> 1) & 0x3F);
767+
core_clk = SYS_CLK * core_ratio;
768+
return core_clk;
769+
}
752770
static uint32_t hal_get_plat_clk(void)
753771
{
754-
/* compute platform clock (system input * ratio) */
772+
/* compute core clock (system input * ratio) */
755773
uint32_t plat_clk;
756774
uint32_t plat_ratio = get32(CLOCKING_PLLPGSR); /* see SYS_PLL_RAT in RCW */
757-
/* mask and shift by 1 to get platform ratio */
758-
plat_ratio = ((plat_ratio & 0x3E) >> 1); /* default is 4 (4:1) */
775+
/* shift by 1 and mask */
776+
plat_ratio = ((plat_ratio >> 1) & 0x1F);
759777
plat_clk = SYS_CLK * plat_ratio;
760778
return plat_clk;
761779
}
762-
763780
static uint32_t hal_get_bus_clk(void)
764781
{
765782
/* compute bus clock (platform clock / 2) */
766783
uint32_t bus_clk = hal_get_plat_clk() / 2;
767784
return bus_clk;
768785
}
769786
#else
787+
#define hal_get_core_clk() (uint32_t)(SYS_CLK * 14)
770788
#define hal_get_plat_clk() (uint32_t)(SYS_CLK * 4)
771-
#define hal_get_bus_clk() (uint32_t)(hal_get_plat_clk() / 2)
789+
#define hal_get_bus_clk() (uint32_t)(hal_get_plat_clk() / 2)
772790
#endif
773791

774792
#define TIMEBASE_CLK_DIV 16
@@ -2319,7 +2337,7 @@ int hal_dts_fixup(void* dts_addr)
23192337
fdt_fixup_val64(fdt, off, "cpu", "cpu-release-addr", core_spin_table);
23202338
fdt_fixup_str(fdt, off, "cpu", "enable-method", "spin-table");
23212339
fdt_fixup_val(fdt, off, "cpu", "timebase-frequency", TIMEBASE_HZ);
2322-
fdt_fixup_val(fdt, off, "cpu", "clock-frequency", hal_get_plat_clk());
2340+
fdt_fixup_val(fdt, off, "cpu", "clock-frequency", hal_get_core_clk());
23232341
fdt_fixup_val(fdt, off, "cpu", "bus-frequency", hal_get_plat_clk());
23242342

23252343
off = fdt_find_devtype(fdt, off, "cpu");

0 commit comments

Comments
 (0)