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