1 // SPDX-License-Identifier: GPL-2.0+
3 * Copyright (C) 2016 Stefan Roese <sr@denx.de>
10 #include <asm/global_data.h>
12 #include <asm/arch/cpu.h>
13 #include <asm/arch/soc.h>
14 #include <linux/delay.h>
16 DECLARE_GLOBAL_DATA_PTR;
19 * Information specific to the DB-88F7040 eval board. We strive to use
20 * DT for such platform specfic configurations. At some point, this
21 * might be removed here and implemented via DT.
23 /* IO expander I2C device */
24 #define I2C_IO_EXP_ADDR 0x21
25 #define I2C_IO_CFG_REG_0 0x6
26 #define I2C_IO_DATA_OUT_REG_0 0x2
28 #define I2C_IO_REG_0_USB_H0_OFF 0
29 #define I2C_IO_REG_0_USB_H1_OFF 1
30 #define I2C_IO_REG_VBUS ((1 << I2C_IO_REG_0_USB_H0_OFF) | \
31 (1 << I2C_IO_REG_0_USB_H1_OFF))
33 #define I2C_IO_REG_0_USB_H0_CL 4
34 #define I2C_IO_REG_0_USB_H1_CL 5
35 #define I2C_IO_REG_CL ((1 << I2C_IO_REG_0_USB_H0_CL) | \
36 (1 << I2C_IO_REG_0_USB_H1_CL))
39 * Information specific to the iEi Puzzle-M801 board.
42 /* Internal configuration registers */
43 #define CP1_CONF_REG_BASE 0xf4440000
44 #define CONF_REG_MPP0 0x0
45 #define CONF_REG_MPP1 0x4
46 #define CONF_REG_MPP2 0x8
47 #define CONF_REG_MPP3 0xC
49 static int usb_enabled = 0;
51 /* Board specific xHCI dis-/enable code */
54 * Set USB VBUS signals (via I2C IO expander/GPIO) as output and set
55 * output value as disabled
57 * Set USB Current Limit signals (via I2C IO expander/GPIO) as output
58 * and set output value as enabled
60 int board_xhci_config(void)
66 if (of_machine_is_compatible("marvell,armada7040-db")) {
67 /* Configure IO exander PCA9555: 7bit address 0x21 */
68 ret = i2c_get_chip_for_busnum(0, I2C_IO_EXP_ADDR, 1, &dev);
70 printf("Cannot find PCA9555: %d\n", ret);
75 * Read configuration (direction) and set VBUS pin as output
76 * (reset pin = output)
78 ret = dm_i2c_read(dev, I2C_IO_CFG_REG_0, buf, 1);
80 printf("Failed to read IO expander value via I2C\n");
83 buf[0] &= ~I2C_IO_REG_VBUS;
84 buf[0] &= ~I2C_IO_REG_CL;
85 ret = dm_i2c_write(dev, I2C_IO_CFG_REG_0, buf, 1);
87 printf("Failed to set IO expander via I2C\n");
91 /* Read output value and configure it */
92 ret = dm_i2c_read(dev, I2C_IO_DATA_OUT_REG_0, buf, 1);
94 printf("Failed to read IO expander value via I2C\n");
97 buf[0] &= ~I2C_IO_REG_VBUS;
98 buf[0] |= I2C_IO_REG_CL;
99 ret = dm_i2c_write(dev, I2C_IO_DATA_OUT_REG_0, buf, 1);
101 printf("Failed to set IO expander via I2C\n");
105 mdelay(500); /* required delay to let output value settle */
111 int board_xhci_enable(fdt_addr_t base)
117 if (of_machine_is_compatible("marvell,armada7040-db")) {
119 * This function enables all USB ports simultaniously,
120 * it only needs to get called once
125 /* Configure IO exander PCA9555: 7bit address 0x21 */
126 ret = i2c_get_chip_for_busnum(0, I2C_IO_EXP_ADDR, 1, &dev);
128 printf("Cannot find PCA9555: %d\n", ret);
132 /* Read VBUS output value */
133 ret = dm_i2c_read(dev, I2C_IO_DATA_OUT_REG_0, buf, 1);
135 printf("Failed to read IO expander value via I2C\n");
139 /* Enable VBUS power: Set output value of VBUS pin as enabled */
140 buf[0] |= I2C_IO_REG_VBUS;
141 ret = dm_i2c_write(dev, I2C_IO_DATA_OUT_REG_0, buf, 1);
143 printf("Failed to set IO expander via I2C\n");
147 mdelay(500); /* required delay to let output value settle */
154 int board_early_init_f(void)
156 /* Initialize some platform specific memory locations */
157 if (of_machine_is_compatible("marvell,armada8040-puzzle-m801")) {
159 writel(0x00444444, CP1_CONF_REG_BASE + CONF_REG_MPP0);
160 writel(0x00000000, CP1_CONF_REG_BASE + CONF_REG_MPP1);
161 writel(0x00000000, CP1_CONF_REG_BASE + CONF_REG_MPP2);
162 writel(0x08888000, CP1_CONF_REG_BASE + CONF_REG_MPP3);
170 /* adress of boot parameters */
171 gd->bd->bi_boot_params = CONFIG_SYS_SDRAM_BASE + 0x100;
176 int board_late_init(void)
178 /* Pre-configure the USB ports (overcurrent, VBus) */