1 // SPDX-License-Identifier: GPL-2.0+
3 * Copyright (C) 2016 David Lechner <david@lechnology.com>
7 * Copyright (C) 2010 Texas Instruments Incorporated - http://www.ti.com/
9 * Based on da830evm.c. Original Copyrights follow:
11 * Copyright (C) 2009 Nick Thompson, GE Fanuc, Ltd. <nick.thompson@gefanuc.com>
12 * Copyright (C) 2007 Sergey Kubushyn <ksi@koi8.net>
18 #include <spi_flash.h>
19 #include <asm/arch/hardware.h>
20 #include <asm/arch/pinmux_defs.h>
22 #include <asm/arch/davinci_misc.h>
23 #include <linux/errno.h>
25 #include <asm/mach-types.h>
26 #include <asm/setup.h>
28 #ifdef CONFIG_MMC_DAVINCI
30 #include <asm/arch/sdmmc_defs.h>
33 DECLARE_GLOBAL_DATA_PTR;
37 #define EEPROM_I2C_ADDR 0x50
38 #define EEPROM_REV_OFFSET 0x3F00
39 #define EEPROM_MAC_OFFSET 0x3F06
41 #ifdef CONFIG_MMC_DAVINCI
42 static struct davinci_mmc mmc_sd0 = {
43 .reg_base = (struct davinci_mmc_regs *)DAVINCI_MMC_SD0_BASE,
44 .host_caps = MMC_MODE_4BIT, /* DA850 supports only 4-bit SD/MMC */
45 .voltages = MMC_VDD_32_33 | MMC_VDD_33_34,
46 .version = MMC_CTLR_VERSION_2,
49 int board_mmc_init(bd_t *bis)
51 mmc_sd0.input_clk = clk_get(DAVINCI_MMCSD_CLKID);
53 /* Add slot-0 to mmc subsystem */
54 return davinci_mmc_init(bis, &mmc_sd0);
58 const struct pinmux_resource pinmuxes[] = {
59 PINMUX_ITEM(spi0_pins_base),
60 PINMUX_ITEM(spi0_pins_scs0),
61 PINMUX_ITEM(uart1_pins_txrx),
62 PINMUX_ITEM(i2c0_pins),
63 PINMUX_ITEM(mmc0_pins),
66 const int pinmuxes_size = ARRAY_SIZE(pinmuxes);
68 const struct lpsc_resource lpsc[] = {
69 { DAVINCI_LPSC_SPI0 }, /* Serial Flash */
70 { DAVINCI_LPSC_UART1 }, /* console */
71 { DAVINCI_LPSC_MMC_SD },
74 const int lpsc_size = ARRAY_SIZE(lpsc);
76 u32 get_board_rev(void)
81 if (i2c_read(EEPROM_I2C_ADDR, EEPROM_REV_OFFSET, 2, buf, 2)) {
82 printf("\nBoard revision read failed!\n");
85 * Board rev 3 has MAC address at EEPROM_REV_OFFSET.
86 * Other revisions have checksum at EEPROM_REV_OFFSET+1
89 if ((buf[0] ^ buf[1]) == 0xFF)
100 * The Bluetooth MAC address serves as the board serial number.
102 void get_board_serial(struct tag_serialnr *serialnr)
108 board_rev = get_board_rev();
110 /* Board rev 3 has MAC address where rev should be */
111 offset = (board_rev == 3) ? EEPROM_REV_OFFSET : EEPROM_MAC_OFFSET;
113 if (i2c_read(EEPROM_I2C_ADDR, offset, 2, buf, 6)) {
114 printf("\nBoard serial read failed!\n");
118 nr = (u8 *)&serialnr->low;
123 nr = (u8 *)&serialnr->high;
131 int board_early_init_f(void)
133 /* enable the console UART */
134 writel((DAVINCI_UART_PWREMU_MGMT_FREE | DAVINCI_UART_PWREMU_MGMT_URRST |
135 DAVINCI_UART_PWREMU_MGMT_UTRST),
136 &davinci_uart1_ctrl_regs->pwremu_mgmt);
139 * Power on required peripherals
140 * ARM does not have access by default to PSC0 and PSC1
141 * assuming here that the DSP bootloader has set the IOPU
142 * such that PSC access is available to ARM
144 if (da8xx_configure_lpsc_items(lpsc, ARRAY_SIZE(lpsc)))
154 /* arch number of the board */
155 /* LEGO didn't register for a unique number and uses da850evm */
156 gd->bd->bi_arch_number = MACH_TYPE_DAVINCI_DA850_EVM;
158 /* address of boot parameters */
159 gd->bd->bi_boot_params = LINUX_BOOT_PARAM_ADDR;
161 /* setup the SUSPSRC for ARM to control emulation suspend */
162 writel(readl(&davinci_syscfg_regs->suspsrc) &
163 ~(DAVINCI_SYSCFG_SUSPSRC_I2C |
164 DAVINCI_SYSCFG_SUSPSRC_SPI0 | DAVINCI_SYSCFG_SUSPSRC_TIMER0 |
165 DAVINCI_SYSCFG_SUSPSRC_UART1),
166 &davinci_syscfg_regs->suspsrc);
168 /* configure pinmux settings */
169 if (davinci_configure_pin_mux_items(pinmuxes, ARRAY_SIZE(pinmuxes)))