1 /* 2 * board.c 3 * 4 * Board functions for TI AM43XX based boards 5 * 6 * Copyright (C) 2013, Texas Instruments, Incorporated - http://www.ti.com/ 7 * 8 * SPDX-License-Identifier: GPL-2.0+ 9 */ 10 11 #include <common.h> 12 #include <i2c.h> 13 #include <asm/errno.h> 14 #include <spl.h> 15 #include <asm/arch/clock.h> 16 #include <asm/arch/sys_proto.h> 17 #include <asm/arch/mux.h> 18 #include "board.h" 19 20 DECLARE_GLOBAL_DATA_PTR; 21 22 /* 23 * Read header information from EEPROM into global structure. 24 */ 25 static int read_eeprom(struct am43xx_board_id *header) 26 { 27 /* Check if baseboard eeprom is available */ 28 if (i2c_probe(CONFIG_SYS_I2C_EEPROM_ADDR)) { 29 printf("Could not probe the EEPROM at 0x%x\n", 30 CONFIG_SYS_I2C_EEPROM_ADDR); 31 return -ENODEV; 32 } 33 34 /* read the eeprom using i2c */ 35 if (i2c_read(CONFIG_SYS_I2C_EEPROM_ADDR, 0, 2, (uchar *)header, 36 sizeof(struct am43xx_board_id))) { 37 printf("Could not read the EEPROM\n"); 38 return -EIO; 39 } 40 41 if (header->magic != 0xEE3355AA) { 42 /* 43 * read the eeprom using i2c again, 44 * but use only a 1 byte address 45 */ 46 if (i2c_read(CONFIG_SYS_I2C_EEPROM_ADDR, 0, 1, (uchar *)header, 47 sizeof(struct am43xx_board_id))) { 48 printf("Could not read the EEPROM at 0x%x\n", 49 CONFIG_SYS_I2C_EEPROM_ADDR); 50 return -EIO; 51 } 52 53 if (header->magic != 0xEE3355AA) { 54 printf("Incorrect magic number (0x%x) in EEPROM\n", 55 header->magic); 56 return -EINVAL; 57 } 58 } 59 60 strncpy(am43xx_board_name, (char *)header->name, sizeof(header->name)); 61 am43xx_board_name[sizeof(header->name)] = 0; 62 63 return 0; 64 } 65 66 #ifdef CONFIG_SPL_BUILD 67 68 const struct dpll_params dpll_ddr = { 69 -1, -1, -1, -1, -1, -1, -1}; 70 71 const struct dpll_params *get_dpll_ddr_params(void) 72 { 73 return &dpll_ddr; 74 } 75 76 void set_uart_mux_conf(void) 77 { 78 enable_uart0_pin_mux(); 79 } 80 81 void set_mux_conf_regs(void) 82 { 83 enable_board_pin_mux(); 84 } 85 86 void sdram_init(void) 87 { 88 } 89 #endif 90 91 int board_init(void) 92 { 93 gd->bd->bi_boot_params = CONFIG_SYS_SDRAM_BASE + 0x100; 94 95 return 0; 96 } 97 98 #ifdef CONFIG_BOARD_LATE_INIT 99 int board_late_init(void) 100 { 101 return 0; 102 } 103 #endif 104