1 // SPDX-License-Identifier: GPL-2.0+
3 * Copyright (C) 2016 Stefan Roese <sr@denx.de>
10 #include <asm/arch/cpu.h>
11 #include <asm/arch/soc.h>
13 DECLARE_GLOBAL_DATA_PTR;
16 * Information specific to the DB-88F7040 eval board. We strive to use
17 * DT for such platform specfic configurations. At some point, this
18 * might be removed here and implemented via DT.
20 /* IO expander I2C device */
21 #define I2C_IO_EXP_ADDR 0x21
22 #define I2C_IO_CFG_REG_0 0x6
23 #define I2C_IO_DATA_OUT_REG_0 0x2
25 #define I2C_IO_REG_0_USB_H0_OFF 0
26 #define I2C_IO_REG_0_USB_H1_OFF 1
27 #define I2C_IO_REG_VBUS ((1 << I2C_IO_REG_0_USB_H0_OFF) | \
28 (1 << I2C_IO_REG_0_USB_H1_OFF))
30 #define I2C_IO_REG_0_USB_H0_CL 4
31 #define I2C_IO_REG_0_USB_H1_CL 5
32 #define I2C_IO_REG_CL ((1 << I2C_IO_REG_0_USB_H0_CL) | \
33 (1 << I2C_IO_REG_0_USB_H1_CL))
35 static int usb_enabled = 0;
37 /* Board specific xHCI dis-/enable code */
40 * Set USB VBUS signals (via I2C IO expander/GPIO) as output and set
41 * output value as disabled
43 * Set USB Current Limit signals (via I2C IO expander/GPIO) as output
44 * and set output value as enabled
46 int board_xhci_config(void)
52 if (of_machine_is_compatible("marvell,armada7040-db")) {
53 /* Configure IO exander PCA9555: 7bit address 0x21 */
54 ret = i2c_get_chip_for_busnum(0, I2C_IO_EXP_ADDR, 1, &dev);
56 printf("Cannot find PCA9555: %d\n", ret);
61 * Read configuration (direction) and set VBUS pin as output
62 * (reset pin = output)
64 ret = dm_i2c_read(dev, I2C_IO_CFG_REG_0, buf, 1);
66 printf("Failed to read IO expander value via I2C\n");
69 buf[0] &= ~I2C_IO_REG_VBUS;
70 buf[0] &= ~I2C_IO_REG_CL;
71 ret = dm_i2c_write(dev, I2C_IO_CFG_REG_0, buf, 1);
73 printf("Failed to set IO expander via I2C\n");
77 /* Read output value and configure it */
78 ret = dm_i2c_read(dev, I2C_IO_DATA_OUT_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_DATA_OUT_REG_0, buf, 1);
87 printf("Failed to set IO expander via I2C\n");
91 mdelay(500); /* required delay to let output value settle */
97 int board_xhci_enable(fdt_addr_t base)
103 if (of_machine_is_compatible("marvell,armada7040-db")) {
105 * This function enables all USB ports simultaniously,
106 * it only needs to get called once
111 /* Configure IO exander PCA9555: 7bit address 0x21 */
112 ret = i2c_get_chip_for_busnum(0, I2C_IO_EXP_ADDR, 1, &dev);
114 printf("Cannot find PCA9555: %d\n", ret);
118 /* Read VBUS output value */
119 ret = dm_i2c_read(dev, I2C_IO_DATA_OUT_REG_0, buf, 1);
121 printf("Failed to read IO expander value via I2C\n");
125 /* Enable VBUS power: Set output value of VBUS pin as enabled */
126 buf[0] |= I2C_IO_REG_VBUS;
127 ret = dm_i2c_write(dev, I2C_IO_DATA_OUT_REG_0, buf, 1);
129 printf("Failed to set IO expander via I2C\n");
133 mdelay(500); /* required delay to let output value settle */
140 int board_early_init_f(void)
142 /* Nothing to do (yet), perhaps later some pin-muxing etc */
149 /* adress of boot parameters */
150 gd->bd->bi_boot_params = CONFIG_SYS_SDRAM_BASE + 0x100;
155 int board_late_init(void)
157 /* Pre-configure the USB ports (overcurrent, VBus) */