wdenk | 21136db | 2003-07-16 21:53:01 +0000 | [diff] [blame] | 1 | /* |
| 2 | * (C) Copyright 2000-2002 |
| 3 | * Wolfgang Denk, DENX Software Engineering, wd@denx.de. |
| 4 | * |
Wolfgang Denk | d79de1d | 2013-07-08 09:37:19 +0200 | [diff] [blame] | 5 | * SPDX-License-Identifier: GPL-2.0+ |
wdenk | 21136db | 2003-07-16 21:53:01 +0000 | [diff] [blame] | 6 | */ |
| 7 | |
| 8 | #include <common.h> |
| 9 | #include <mpc5xxx.h> |
| 10 | #include <asm/processor.h> |
| 11 | |
Wolfgang Denk | 6405a15 | 2006-03-31 18:32:53 +0200 | [diff] [blame] | 12 | DECLARE_GLOBAL_DATA_PTR; |
| 13 | |
wdenk | 21136db | 2003-07-16 21:53:01 +0000 | [diff] [blame] | 14 | /* ------------------------------------------------------------------------- */ |
| 15 | |
| 16 | /* Bus-to-Core Multipliers */ |
| 17 | |
| 18 | static int bus2core[] = { |
wdenk | 67f1336 | 2003-12-27 19:24:54 +0000 | [diff] [blame] | 19 | 3, 2, 2, 2, 4, 4, 5, 9, |
| 20 | 6, 11, 8, 10, 3, 12, 7, 0, |
| 21 | 6, 5, 13, 2, 14, 4, 15, 9, |
| 22 | 0, 11, 8, 10, 16, 12, 7, 0 |
wdenk | 21136db | 2003-07-16 21:53:01 +0000 | [diff] [blame] | 23 | }; |
| 24 | /* ------------------------------------------------------------------------- */ |
| 25 | |
| 26 | /* |
| 27 | * |
| 28 | */ |
| 29 | |
| 30 | int get_clocks (void) |
| 31 | { |
wdenk | 21136db | 2003-07-16 21:53:01 +0000 | [diff] [blame] | 32 | ulong val, vco; |
| 33 | |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 34 | #if !defined(CONFIG_SYS_MPC5XXX_CLKIN) |
| 35 | #error clock measuring not implemented yet - define CONFIG_SYS_MPC5XXX_CLKIN |
wdenk | 21136db | 2003-07-16 21:53:01 +0000 | [diff] [blame] | 36 | #endif |
| 37 | |
| 38 | val = *(vu_long *)MPC5XXX_CDM_PORCFG; |
| 39 | if (val & (1 << 6)) { |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 40 | vco = CONFIG_SYS_MPC5XXX_CLKIN * 12; |
wdenk | 21136db | 2003-07-16 21:53:01 +0000 | [diff] [blame] | 41 | } else { |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 42 | vco = CONFIG_SYS_MPC5XXX_CLKIN * 16; |
wdenk | 21136db | 2003-07-16 21:53:01 +0000 | [diff] [blame] | 43 | } |
| 44 | if (val & (1 << 5)) { |
| 45 | gd->bus_clk = vco / 8; |
| 46 | } else { |
| 47 | gd->bus_clk = vco / 4; |
| 48 | } |
wdenk | 67f1336 | 2003-12-27 19:24:54 +0000 | [diff] [blame] | 49 | gd->cpu_clk = gd->bus_clk * bus2core[val & 0x1f] / 2; |
wdenk | 21136db | 2003-07-16 21:53:01 +0000 | [diff] [blame] | 50 | |
| 51 | val = *(vu_long *)MPC5XXX_CDM_CFG; |
| 52 | if (val & (1 << 8)) { |
Simon Glass | 4f8c5f0 | 2012-12-13 20:48:53 +0000 | [diff] [blame] | 53 | gd->arch.ipb_clk = gd->bus_clk / 2; |
wdenk | 21136db | 2003-07-16 21:53:01 +0000 | [diff] [blame] | 54 | } else { |
Simon Glass | 4f8c5f0 | 2012-12-13 20:48:53 +0000 | [diff] [blame] | 55 | gd->arch.ipb_clk = gd->bus_clk; |
wdenk | 21136db | 2003-07-16 21:53:01 +0000 | [diff] [blame] | 56 | } |
| 57 | switch (val & 3) { |
Simon Glass | 4f8c5f0 | 2012-12-13 20:48:53 +0000 | [diff] [blame] | 58 | case 0: |
| 59 | gd->pci_clk = gd->arch.ipb_clk; |
| 60 | break; |
| 61 | case 1: |
| 62 | gd->pci_clk = gd->arch.ipb_clk / 2; |
| 63 | break; |
| 64 | default: |
| 65 | gd->pci_clk = gd->bus_clk / 4; |
| 66 | break; |
wdenk | 21136db | 2003-07-16 21:53:01 +0000 | [diff] [blame] | 67 | } |
| 68 | |
| 69 | return (0); |
| 70 | } |
| 71 | |
Simon Glass | ab051bb | 2017-01-23 13:31:26 -0700 | [diff] [blame] | 72 | int print_cpuinfo(void) |
wdenk | 21136db | 2003-07-16 21:53:01 +0000 | [diff] [blame] | 73 | { |
Wolfgang Denk | 2059104 | 2008-10-19 02:35:49 +0200 | [diff] [blame] | 74 | char buf1[32], buf2[32], buf3[32]; |
wdenk | 21136db | 2003-07-16 21:53:01 +0000 | [diff] [blame] | 75 | |
Wolfgang Denk | 2059104 | 2008-10-19 02:35:49 +0200 | [diff] [blame] | 76 | printf (" Bus %s MHz, IPB %s MHz, PCI %s MHz\n", |
| 77 | strmhz(buf1, gd->bus_clk), |
Simon Glass | 4f8c5f0 | 2012-12-13 20:48:53 +0000 | [diff] [blame] | 78 | strmhz(buf2, gd->arch.ipb_clk), |
Wolfgang Denk | 2059104 | 2008-10-19 02:35:49 +0200 | [diff] [blame] | 79 | strmhz(buf3, gd->pci_clk) |
| 80 | ); |
wdenk | 21136db | 2003-07-16 21:53:01 +0000 | [diff] [blame] | 81 | return (0); |
| 82 | } |
| 83 | |
| 84 | /* ------------------------------------------------------------------------- */ |