3 * Corscience GmbH & Co. KG, <www.corscience.de>
4 * Thomas Weber <weber@corscience.de>
5 * Sunil Kumar <sunilsaini05@gmail.com>
6 * Shashi Ranjan <shashiranjanmca05@gmail.com>
8 * Derived from Devkit8000 code by
9 * Frederik Kriewitz <frederik@kriewitz.eu>
11 * SPDX-License-Identifier: GPL-2.0+
17 #include <asm/arch/mmc_host_def.h>
18 #include <asm/arch/mux.h>
19 #include <asm/arch/sys_proto.h>
20 #include <asm/arch/mem.h>
21 #include "tricorder.h"
22 #include "tricorder-eeprom.h"
24 DECLARE_GLOBAL_DATA_PTR;
28 * Description: Early hardware init.
32 gpmc_init(); /* in SRAM or SDRAM, finish GPMC */
34 gd->bd->bi_boot_params = (OMAP34XX_SDRC_CS0 + 0x100);
40 * get_eeprom - read the eeprom
42 * @eeprom - pointer to a eeprom struct to fill
44 * This function will panic() on wrong EEPROM content
46 static void get_eeprom(struct tricorder_eeprom *eeprom)
51 panic("No eeprom given!\n");
53 ret = gpio_request(7, "BMS");
55 panic("gpio: requesting BMS pin failed\n");
57 ret = gpio_direction_input(7);
59 panic("gpio: set BMS as input failed\n");
61 ret = gpio_get_value(7);
63 panic("gpio: get BMS pin state failed\n");
68 /* BMS is _not_ set, do the EEPROM check */
69 ret = tricorder_get_eeprom(0x51, eeprom);
71 if (strncmp(eeprom->board_name, "CS10411", 7) != 0)
72 panic("Wrong board name '%.*s'\n",
73 sizeof(eeprom->board_name),
75 if (eeprom->board_version[0] < 'D')
76 panic("Wrong board version '%.*s'\n",
77 sizeof(eeprom->board_version),
78 eeprom->board_version);
80 panic("Could not get board revision\n");
86 * print_hwversion - print out a HW version string
88 * @eeprom - pointer to the eeprom
90 static void print_hwversion(struct tricorder_eeprom *eeprom)
94 panic("No eeprom given!");
96 printf("Board %.*s:%.*s serial %.*s",
97 sizeof(eeprom->board_name), eeprom->board_name,
98 sizeof(eeprom->board_version), eeprom->board_version,
99 sizeof(eeprom->board_serial), eeprom->board_serial);
101 len = strnlen(eeprom->interface_version,
102 sizeof(eeprom->interface_version));
104 printf(" HW interface version %.*s",
105 sizeof(eeprom->interface_version),
106 eeprom->interface_version);
111 * Routine: misc_init_r
112 * Description: Configure board specific parts
114 int misc_init_r(void)
116 struct tricorder_eeprom eeprom;
118 print_hwversion(&eeprom);
120 twl4030_power_init();
121 status_led_set(0, STATUS_LED_ON);
122 status_led_set(1, STATUS_LED_ON);
123 status_led_set(2, STATUS_LED_ON);
131 * Routine: set_muxconf_regs
132 * Description: Setting up the configuration Mux registers specific to the
133 * hardware. Many pins need to be moved from protect to primary
136 void set_muxconf_regs(void)
141 #if defined(CONFIG_GENERIC_MMC) && !(defined(CONFIG_SPL_BUILD))
142 int board_mmc_init(bd_t *bis)
144 return omap_mmc_init(0, 0, 0, -1, -1);
149 * Routine: get_board_mem_timings
150 * Description: If we use SPL then there is no x-loader nor config header
151 * so we have to setup the DDR timings ourself on the first bank. This
152 * provides the timing values back to the function that configures
153 * the memory. We have either one or two banks of 128MB DDR.
155 void get_board_mem_timings(struct board_sdrc_timings *timings)
157 /* General SDRC config */
158 timings->mcfg = MICRON_V_MCFG_165(128 << 20);
159 timings->rfr_ctrl = SDP_3430_SDRC_RFR_CTRL_165MHz;
162 timings->ctrla = MICRON_V_ACTIMA_165;
163 timings->ctrlb = MICRON_V_ACTIMB_165;
164 timings->mr = MICRON_V_MR_165;