Tom Rini | 83d290c | 2018-05-06 17:58:06 -0400 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0+ |
wdenk | 03f5c55 | 2004-10-10 21:21:55 +0000 | [diff] [blame] | 2 | /* |
chenhui zhao | 568336e | 2011-09-15 14:52:34 +0800 | [diff] [blame] | 3 | * Copyright 2004, 2011 Freescale Semiconductor. |
wdenk | 03f5c55 | 2004-10-10 21:21:55 +0000 | [diff] [blame] | 4 | */ |
| 5 | |
| 6 | |
| 7 | #include <common.h> |
Tom Rini | 2f8a6db | 2021-12-14 13:36:40 -0500 | [diff] [blame^] | 8 | #include <clock_legacy.h> |
wdenk | 03f5c55 | 2004-10-10 21:21:55 +0000 | [diff] [blame] | 9 | |
| 10 | /* |
| 11 | * CADMUS Board System Registers |
| 12 | */ |
Jean-Christophe PLAGNIOL-VILLARD | 6d0f6bc | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 13 | #ifndef CONFIG_SYS_CADMUS_BASE_REG |
| 14 | #define CONFIG_SYS_CADMUS_BASE_REG (CADMUS_BASE_ADDR + 0x4000) |
wdenk | 03f5c55 | 2004-10-10 21:21:55 +0000 | [diff] [blame] | 15 | #endif |
| 16 | |
| 17 | typedef struct cadmus_reg { |
| 18 | u_char cm_ver; /* Board version */ |
| 19 | u_char cm_csr; /* General control/status */ |
| 20 | u_char cm_rst; /* Reset control */ |
| 21 | u_char cm_hsclk; /* High speed clock */ |
| 22 | u_char cm_hsxclk; /* High speed clock extended */ |
| 23 | u_char cm_led; /* LED data */ |
| 24 | u_char cm_pci; /* PCI control/status */ |
| 25 | u_char cm_dma; /* DMA control */ |
| 26 | u_char cm_reserved[248]; /* Total 256 bytes */ |
| 27 | } cadmus_reg_t; |
| 28 | |
| 29 | |
| 30 | unsigned int |
| 31 | get_board_version(void) |
| 32 | { |
Jean-Christophe PLAGNIOL-VILLARD | 6d0f6bc | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 33 | volatile cadmus_reg_t *cadmus = (cadmus_reg_t *)CONFIG_SYS_CADMUS_BASE_REG; |
wdenk | 03f5c55 | 2004-10-10 21:21:55 +0000 | [diff] [blame] | 34 | |
| 35 | return cadmus->cm_ver; |
| 36 | } |
| 37 | |
| 38 | |
| 39 | unsigned long |
Tom Rini | e4c3ce7 | 2021-12-14 13:36:39 -0500 | [diff] [blame] | 40 | get_board_sys_clk(void) |
wdenk | 03f5c55 | 2004-10-10 21:21:55 +0000 | [diff] [blame] | 41 | { |
Jean-Christophe PLAGNIOL-VILLARD | 6d0f6bc | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 42 | volatile cadmus_reg_t *cadmus = (cadmus_reg_t *)CONFIG_SYS_CADMUS_BASE_REG; |
wdenk | 03f5c55 | 2004-10-10 21:21:55 +0000 | [diff] [blame] | 43 | |
| 44 | uint pci1_speed = (cadmus->cm_pci >> 2) & 0x3; /* PSPEED in [4:5] */ |
| 45 | |
| 46 | if (pci1_speed == 0) { |
chenhui zhao | 568336e | 2011-09-15 14:52:34 +0800 | [diff] [blame] | 47 | return 33333333; |
wdenk | 03f5c55 | 2004-10-10 21:21:55 +0000 | [diff] [blame] | 48 | } else if (pci1_speed == 1) { |
chenhui zhao | 568336e | 2011-09-15 14:52:34 +0800 | [diff] [blame] | 49 | return 66666666; |
wdenk | 03f5c55 | 2004-10-10 21:21:55 +0000 | [diff] [blame] | 50 | } else { |
| 51 | /* Really, unknown. Be safe? */ |
chenhui zhao | 568336e | 2011-09-15 14:52:34 +0800 | [diff] [blame] | 52 | return 33333333; |
wdenk | 03f5c55 | 2004-10-10 21:21:55 +0000 | [diff] [blame] | 53 | } |
| 54 | } |
| 55 | |
| 56 | |
| 57 | unsigned int |
| 58 | get_pci_slot(void) |
| 59 | { |
Jean-Christophe PLAGNIOL-VILLARD | 6d0f6bc | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 60 | volatile cadmus_reg_t *cadmus = (cadmus_reg_t *)CONFIG_SYS_CADMUS_BASE_REG; |
wdenk | 03f5c55 | 2004-10-10 21:21:55 +0000 | [diff] [blame] | 61 | |
| 62 | /* |
| 63 | * PCI slot in USER bits CSR[6:7] by convention. |
| 64 | */ |
| 65 | return ((cadmus->cm_csr >> 6) & 0x3) + 1; |
| 66 | } |
| 67 | |
| 68 | |
| 69 | unsigned int |
| 70 | get_pci_dual(void) |
| 71 | { |
Jean-Christophe PLAGNIOL-VILLARD | 6d0f6bc | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 72 | volatile cadmus_reg_t *cadmus = (cadmus_reg_t *)CONFIG_SYS_CADMUS_BASE_REG; |
wdenk | 03f5c55 | 2004-10-10 21:21:55 +0000 | [diff] [blame] | 73 | |
| 74 | /* |
| 75 | * PCI DUAL in CM_PCI[3] |
| 76 | */ |
| 77 | return cadmus->cm_pci & 0x10; |
| 78 | } |