xref: /OK3568_Linux_fs/u-boot/board/xes/common/fsl_8xxx_misc.c (revision 4882a59341e53eb6f0b4789bf948001014eff981)
1*4882a593Smuzhiyun /*
2*4882a593Smuzhiyun  * Copyright 2008 Extreme Engineering Solutions, Inc.
3*4882a593Smuzhiyun  *
4*4882a593Smuzhiyun  * SPDX-License-Identifier:	GPL-2.0+
5*4882a593Smuzhiyun  */
6*4882a593Smuzhiyun 
7*4882a593Smuzhiyun #include <common.h>
8*4882a593Smuzhiyun #include <asm/mmu.h>
9*4882a593Smuzhiyun #ifdef CONFIG_PCA953X
10*4882a593Smuzhiyun #include <pca953x.h>
11*4882a593Smuzhiyun 
12*4882a593Smuzhiyun /*
13*4882a593Smuzhiyun  * Determine if a board's flashes are write protected
14*4882a593Smuzhiyun  */
board_flash_wp_on(void)15*4882a593Smuzhiyun int board_flash_wp_on(void)
16*4882a593Smuzhiyun {
17*4882a593Smuzhiyun 	if (pca953x_get_val(CONFIG_SYS_I2C_PCA953X_ADDR0) &
18*4882a593Smuzhiyun 			CONFIG_SYS_PCA953X_NVM_WP)
19*4882a593Smuzhiyun 		return 1;
20*4882a593Smuzhiyun 
21*4882a593Smuzhiyun 	return 0;
22*4882a593Smuzhiyun }
23*4882a593Smuzhiyun #endif
24*4882a593Smuzhiyun 
25*4882a593Smuzhiyun /*
26*4882a593Smuzhiyun  * Return a board's derivative model number.  For example:
27*4882a593Smuzhiyun  * return 2 for the XPedite5372 and return 1 for the XPedite5201.
28*4882a593Smuzhiyun  */
get_board_derivative(void)29*4882a593Smuzhiyun uint get_board_derivative(void)
30*4882a593Smuzhiyun {
31*4882a593Smuzhiyun #if defined(CONFIG_MPC85xx)
32*4882a593Smuzhiyun        volatile ccsr_gur_t *gur = (void *)CONFIG_SYS_MPC85xx_GUTS_ADDR;
33*4882a593Smuzhiyun #elif defined(CONFIG_MPC86xx)
34*4882a593Smuzhiyun        volatile immap_t *immap = (immap_t *)CONFIG_SYS_CCSRBAR;
35*4882a593Smuzhiyun        volatile ccsr_gur_t *gur = &immap->im_gur;
36*4882a593Smuzhiyun #endif
37*4882a593Smuzhiyun 
38*4882a593Smuzhiyun        /*
39*4882a593Smuzhiyun 	* The top 4 lines of the local bus address are pulled low/high and
40*4882a593Smuzhiyun 	* can be read to determine the least significant digit of a board's
41*4882a593Smuzhiyun 	* model number.
42*4882a593Smuzhiyun 	*/
43*4882a593Smuzhiyun        return gur->gpporcr >> 28;
44*4882a593Smuzhiyun }
45