blob: 7772f9f99cbcd42f101bb0e68143dd3a2c506b6b [file] [log] [blame]
wdenk03f5c552004-10-10 21:21:55 +00001/*
chenhui zhao568336e2011-09-15 14:52:34 +08002 * Copyright 2004, 2011 Freescale Semiconductor.
wdenk03f5c552004-10-10 21:21:55 +00003 *
Wolfgang Denk1a459662013-07-08 09:37:19 +02004 * SPDX-License-Identifier: GPL-2.0+
wdenk03f5c552004-10-10 21:21:55 +00005 */
6
7
8#include <common.h>
9
10
11/*
12 * CADMUS Board System Registers
13 */
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +020014#ifndef CONFIG_SYS_CADMUS_BASE_REG
15#define CONFIG_SYS_CADMUS_BASE_REG (CADMUS_BASE_ADDR + 0x4000)
wdenk03f5c552004-10-10 21:21:55 +000016#endif
17
18typedef struct cadmus_reg {
19 u_char cm_ver; /* Board version */
20 u_char cm_csr; /* General control/status */
21 u_char cm_rst; /* Reset control */
22 u_char cm_hsclk; /* High speed clock */
23 u_char cm_hsxclk; /* High speed clock extended */
24 u_char cm_led; /* LED data */
25 u_char cm_pci; /* PCI control/status */
26 u_char cm_dma; /* DMA control */
27 u_char cm_reserved[248]; /* Total 256 bytes */
28} cadmus_reg_t;
29
30
31unsigned int
32get_board_version(void)
33{
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +020034 volatile cadmus_reg_t *cadmus = (cadmus_reg_t *)CONFIG_SYS_CADMUS_BASE_REG;
wdenk03f5c552004-10-10 21:21:55 +000035
36 return cadmus->cm_ver;
37}
38
39
40unsigned long
41get_clock_freq(void)
42{
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +020043 volatile cadmus_reg_t *cadmus = (cadmus_reg_t *)CONFIG_SYS_CADMUS_BASE_REG;
wdenk03f5c552004-10-10 21:21:55 +000044
45 uint pci1_speed = (cadmus->cm_pci >> 2) & 0x3; /* PSPEED in [4:5] */
46
47 if (pci1_speed == 0) {
chenhui zhao568336e2011-09-15 14:52:34 +080048 return 33333333;
wdenk03f5c552004-10-10 21:21:55 +000049 } else if (pci1_speed == 1) {
chenhui zhao568336e2011-09-15 14:52:34 +080050 return 66666666;
wdenk03f5c552004-10-10 21:21:55 +000051 } else {
52 /* Really, unknown. Be safe? */
chenhui zhao568336e2011-09-15 14:52:34 +080053 return 33333333;
wdenk03f5c552004-10-10 21:21:55 +000054 }
55}
56
57
58unsigned int
59get_pci_slot(void)
60{
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +020061 volatile cadmus_reg_t *cadmus = (cadmus_reg_t *)CONFIG_SYS_CADMUS_BASE_REG;
wdenk03f5c552004-10-10 21:21:55 +000062
63 /*
64 * PCI slot in USER bits CSR[6:7] by convention.
65 */
66 return ((cadmus->cm_csr >> 6) & 0x3) + 1;
67}
68
69
70unsigned int
71get_pci_dual(void)
72{
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +020073 volatile cadmus_reg_t *cadmus = (cadmus_reg_t *)CONFIG_SYS_CADMUS_BASE_REG;
wdenk03f5c552004-10-10 21:21:55 +000074
75 /*
76 * PCI DUAL in CM_PCI[3]
77 */
78 return cadmus->cm_pci & 0x10;
79}