2 * Copyright (C) 2016 David Lechner <david@lechnology.com>
6 * Copyright (C) 2010 Texas Instruments Incorporated - http://www.ti.com/
8 * Based on da830evm.c. Original Copyrights follow:
10 * Copyright (C) 2009 Nick Thompson, GE Fanuc, Ltd. <nick.thompson@gefanuc.com>
11 * Copyright (C) 2007 Sergey Kubushyn <ksi@koi8.net>
13 * SPDX-License-Identifier: GPL-2.0+
21 #include <spi_flash.h>
22 #include <asm/arch/hardware.h>
23 #include <asm/arch/pinmux_defs.h>
25 #include <asm/arch/davinci_misc.h>
26 #include <linux/errno.h>
28 #include <asm/mach-types.h>
29 #include <asm/setup.h>
31 #ifdef CONFIG_MMC_DAVINCI
33 #include <asm/arch/sdmmc_defs.h>
36 DECLARE_GLOBAL_DATA_PTR;
40 #define EEPROM_I2C_ADDR 0x50
41 #define EEPROM_REV_OFFSET 0x3F00
42 #define EEPROM_MAC_OFFSET 0x3F06
44 #ifdef CONFIG_MMC_DAVINCI
45 static struct davinci_mmc mmc_sd0 = {
46 .reg_base = (struct davinci_mmc_regs *)DAVINCI_MMC_SD0_BASE,
47 .host_caps = MMC_MODE_4BIT, /* DA850 supports only 4-bit SD/MMC */
48 .voltages = MMC_VDD_32_33 | MMC_VDD_33_34,
49 .version = MMC_CTLR_VERSION_2,
52 int board_mmc_init(bd_t *bis)
54 mmc_sd0.input_clk = clk_get(DAVINCI_MMCSD_CLKID);
56 /* Add slot-0 to mmc subsystem */
57 return davinci_mmc_init(bis, &mmc_sd0);
61 const struct pinmux_resource pinmuxes[] = {
62 PINMUX_ITEM(spi0_pins_base),
63 PINMUX_ITEM(spi0_pins_scs0),
64 PINMUX_ITEM(uart1_pins_txrx),
65 PINMUX_ITEM(i2c0_pins),
66 PINMUX_ITEM(mmc0_pins),
69 const int pinmuxes_size = ARRAY_SIZE(pinmuxes);
71 const struct lpsc_resource lpsc[] = {
72 { DAVINCI_LPSC_SPI0 }, /* Serial Flash */
73 { DAVINCI_LPSC_UART1 }, /* console */
74 { DAVINCI_LPSC_MMC_SD },
77 const int lpsc_size = ARRAY_SIZE(lpsc);
79 u32 get_board_rev(void)
84 if (i2c_read(EEPROM_I2C_ADDR, EEPROM_REV_OFFSET, 2, buf, 2)) {
85 printf("\nBoard revision read failed!\n");
88 * Board rev 3 has MAC address at EEPROM_REV_OFFSET.
89 * Other revisions have checksum at EEPROM_REV_OFFSET+1
92 if ((buf[0] ^ buf[1]) == 0xFF)
103 * The Bluetooth MAC address serves as the board serial number.
105 void get_board_serial(struct tag_serialnr *serialnr)
111 board_rev = get_board_rev();
113 /* Board rev 3 has MAC address where rev should be */
114 offset = (board_rev == 3) ? EEPROM_REV_OFFSET : EEPROM_MAC_OFFSET;
116 if (i2c_read(EEPROM_I2C_ADDR, offset, 2, buf, 6)) {
117 printf("\nBoard serial read failed!\n");
121 nr = (u8 *)&serialnr->low;
126 nr = (u8 *)&serialnr->high;
134 int board_early_init_f(void)
137 * Power on required peripherals
138 * ARM does not have access by default to PSC0 and PSC1
139 * assuming here that the DSP bootloader has set the IOPU
140 * such that PSC access is available to ARM
142 if (da8xx_configure_lpsc_items(lpsc, ARRAY_SIZE(lpsc)))
152 /* arch number of the board */
153 /* LEGO didn't register for a unique number and uses da850evm */
154 gd->bd->bi_arch_number = MACH_TYPE_DAVINCI_DA850_EVM;
156 /* address of boot parameters */
157 gd->bd->bi_boot_params = LINUX_BOOT_PARAM_ADDR;
159 /* setup the SUSPSRC for ARM to control emulation suspend */
160 writel(readl(&davinci_syscfg_regs->suspsrc) &
161 ~(DAVINCI_SYSCFG_SUSPSRC_EMAC | DAVINCI_SYSCFG_SUSPSRC_I2C |
162 DAVINCI_SYSCFG_SUSPSRC_SPI0 | DAVINCI_SYSCFG_SUSPSRC_TIMER0 |
163 DAVINCI_SYSCFG_SUSPSRC_UART1),
164 &davinci_syscfg_regs->suspsrc);
166 /* configure pinmux settings */
167 if (davinci_configure_pin_mux_items(pinmuxes, ARRAY_SIZE(pinmuxes)))
170 /* enable the console UART */
171 writel((DAVINCI_UART_PWREMU_MGMT_FREE | DAVINCI_UART_PWREMU_MGMT_URRST |
172 DAVINCI_UART_PWREMU_MGMT_UTRST),
173 &davinci_uart1_ctrl_regs->pwremu_mgmt);