mirror of
https://github.com/AsahiLinux/u-boot
synced 2024-11-17 10:18:38 +00:00
2f8a6db5d8
In order to finish moving this symbol to Kconfig for all platforms, we need to do a few more things. First, for all platforms that define this to a function, introduce CONFIG_DYNAMIC_SYS_CLK_FREQ, similar to CONFIG_DYNAMIC_DDR_CLK_FREQ and populate clock_legacy.h. This entails also switching all users from CONFIG_SYS_CLK_FREQ to get_board_sys_clk() and updating a few preprocessor tests. With that done, all platforms that define a value here can be converted to Kconfig, and a fall-back of zero is sufficiently safe to use (and what is used today in cases where code may or may not have this available). Make sure that code which calls this function includes <clock_legacy.h> to get the prototype. Signed-off-by: Tom Rini <trini@konsulko.com>
78 lines
1.6 KiB
C
78 lines
1.6 KiB
C
// SPDX-License-Identifier: GPL-2.0+
|
|
/*
|
|
* Copyright 2004, 2011 Freescale Semiconductor.
|
|
*/
|
|
|
|
|
|
#include <common.h>
|
|
#include <clock_legacy.h>
|
|
|
|
/*
|
|
* CADMUS Board System Registers
|
|
*/
|
|
#ifndef CONFIG_SYS_CADMUS_BASE_REG
|
|
#define CONFIG_SYS_CADMUS_BASE_REG (CADMUS_BASE_ADDR + 0x4000)
|
|
#endif
|
|
|
|
typedef struct cadmus_reg {
|
|
u_char cm_ver; /* Board version */
|
|
u_char cm_csr; /* General control/status */
|
|
u_char cm_rst; /* Reset control */
|
|
u_char cm_hsclk; /* High speed clock */
|
|
u_char cm_hsxclk; /* High speed clock extended */
|
|
u_char cm_led; /* LED data */
|
|
u_char cm_pci; /* PCI control/status */
|
|
u_char cm_dma; /* DMA control */
|
|
u_char cm_reserved[248]; /* Total 256 bytes */
|
|
} cadmus_reg_t;
|
|
|
|
|
|
unsigned int
|
|
get_board_version(void)
|
|
{
|
|
volatile cadmus_reg_t *cadmus = (cadmus_reg_t *)CONFIG_SYS_CADMUS_BASE_REG;
|
|
|
|
return cadmus->cm_ver;
|
|
}
|
|
|
|
|
|
unsigned long
|
|
get_board_sys_clk(void)
|
|
{
|
|
volatile cadmus_reg_t *cadmus = (cadmus_reg_t *)CONFIG_SYS_CADMUS_BASE_REG;
|
|
|
|
uint pci1_speed = (cadmus->cm_pci >> 2) & 0x3; /* PSPEED in [4:5] */
|
|
|
|
if (pci1_speed == 0) {
|
|
return 33333333;
|
|
} else if (pci1_speed == 1) {
|
|
return 66666666;
|
|
} else {
|
|
/* Really, unknown. Be safe? */
|
|
return 33333333;
|
|
}
|
|
}
|
|
|
|
|
|
unsigned int
|
|
get_pci_slot(void)
|
|
{
|
|
volatile cadmus_reg_t *cadmus = (cadmus_reg_t *)CONFIG_SYS_CADMUS_BASE_REG;
|
|
|
|
/*
|
|
* PCI slot in USER bits CSR[6:7] by convention.
|
|
*/
|
|
return ((cadmus->cm_csr >> 6) & 0x3) + 1;
|
|
}
|
|
|
|
|
|
unsigned int
|
|
get_pci_dual(void)
|
|
{
|
|
volatile cadmus_reg_t *cadmus = (cadmus_reg_t *)CONFIG_SYS_CADMUS_BASE_REG;
|
|
|
|
/*
|
|
* PCI DUAL in CM_PCI[3]
|
|
*/
|
|
return cadmus->cm_pci & 0x10;
|
|
}
|