blob: bc7e5c5764f8c2183a0cb9ef65ae648a9f22be3c [file] [log] [blame]
Tom Rini10e47792018-05-06 17:58:06 -04001// SPDX-License-Identifier: GPL-2.0+
John Schmollerd9c2dd52010-10-22 00:20:24 -05002/*
3 * Copyright 2008 Extreme Engineering Solutions, Inc.
John Schmollerd9c2dd52010-10-22 00:20:24 -05004 */
5
6#include <common.h>
7#include <asm/mmu.h>
John Schmoller876e9912010-10-22 00:20:25 -05008#ifdef CONFIG_PCA953X
9#include <pca953x.h>
10
11/*
12 * Determine if a board's flashes are write protected
13 */
14int board_flash_wp_on(void)
15{
Tom Rini6a5dccc2022-11-16 13:10:41 -050016 if (pca953x_get_val(CFG_SYS_I2C_PCA953X_ADDR0) &
John Schmoller876e9912010-10-22 00:20:25 -050017 CONFIG_SYS_PCA953X_NVM_WP)
18 return 1;
19
20 return 0;
21}
22#endif
John Schmollerd9c2dd52010-10-22 00:20:24 -050023
24/*
25 * Return a board's derivative model number. For example:
26 * return 2 for the XPedite5372 and return 1 for the XPedite5201.
27 */
28uint get_board_derivative(void)
29{
30#if defined(CONFIG_MPC85xx)
Tom Rinid5c3bf22022-10-28 20:27:12 -040031 volatile ccsr_gur_t *gur = (void *)CFG_SYS_MPC85xx_GUTS_ADDR;
John Schmollerd9c2dd52010-10-22 00:20:24 -050032#elif defined(CONFIG_MPC86xx)
Tom Rini6a5dccc2022-11-16 13:10:41 -050033 volatile immap_t *immap = (immap_t *)CFG_SYS_CCSRBAR;
John Schmollerd9c2dd52010-10-22 00:20:24 -050034 volatile ccsr_gur_t *gur = &immap->im_gur;
35#endif
36
37 /*
Wolfgang Denk1136f692010-10-27 22:48:30 +020038 * 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 */
John Schmollerd9c2dd52010-10-22 00:20:24 -050042 return gur->gpporcr >> 28;
43}