1 // SPDX-License-Identifier: GPL-2.0+
3 * Copyright (C) 2016 Stefan Roese <sr@denx.de>
11 #include <asm/arch/cpu.h>
12 #include <asm/arch/soc.h>
13 #include <linux/delay.h>
15 DECLARE_GLOBAL_DATA_PTR;
18 * Information specific to the DB-88F7040 eval board. We strive to use
19 * DT for such platform specfic configurations. At some point, this
20 * might be removed here and implemented via DT.
22 /* IO expander I2C device */
23 #define I2C_IO_EXP_ADDR 0x21
24 #define I2C_IO_CFG_REG_0 0x6
25 #define I2C_IO_DATA_OUT_REG_0 0x2
27 #define I2C_IO_REG_0_USB_H0_OFF 0
28 #define I2C_IO_REG_0_USB_H1_OFF 1
29 #define I2C_IO_REG_VBUS ((1 << I2C_IO_REG_0_USB_H0_OFF) | \
30 (1 << I2C_IO_REG_0_USB_H1_OFF))
32 #define I2C_IO_REG_0_USB_H0_CL 4
33 #define I2C_IO_REG_0_USB_H1_CL 5
34 #define I2C_IO_REG_CL ((1 << I2C_IO_REG_0_USB_H0_CL) | \
35 (1 << I2C_IO_REG_0_USB_H1_CL))
37 static int usb_enabled = 0;
39 /* Board specific xHCI dis-/enable code */
42 * Set USB VBUS signals (via I2C IO expander/GPIO) as output and set
43 * output value as disabled
45 * Set USB Current Limit signals (via I2C IO expander/GPIO) as output
46 * and set output value as enabled
48 int board_xhci_config(void)
54 if (of_machine_is_compatible("marvell,armada7040-db")) {
55 /* Configure IO exander PCA9555: 7bit address 0x21 */
56 ret = i2c_get_chip_for_busnum(0, I2C_IO_EXP_ADDR, 1, &dev);
58 printf("Cannot find PCA9555: %d\n", ret);
63 * Read configuration (direction) and set VBUS pin as output
64 * (reset pin = output)
66 ret = dm_i2c_read(dev, I2C_IO_CFG_REG_0, buf, 1);
68 printf("Failed to read IO expander value via I2C\n");
71 buf[0] &= ~I2C_IO_REG_VBUS;
72 buf[0] &= ~I2C_IO_REG_CL;
73 ret = dm_i2c_write(dev, I2C_IO_CFG_REG_0, buf, 1);
75 printf("Failed to set IO expander via I2C\n");
79 /* Read output value and configure it */
80 ret = dm_i2c_read(dev, I2C_IO_DATA_OUT_REG_0, buf, 1);
82 printf("Failed to read IO expander value via I2C\n");
85 buf[0] &= ~I2C_IO_REG_VBUS;
86 buf[0] |= I2C_IO_REG_CL;
87 ret = dm_i2c_write(dev, I2C_IO_DATA_OUT_REG_0, buf, 1);
89 printf("Failed to set IO expander via I2C\n");
93 mdelay(500); /* required delay to let output value settle */
99 int board_xhci_enable(fdt_addr_t base)
105 if (of_machine_is_compatible("marvell,armada7040-db")) {
107 * This function enables all USB ports simultaniously,
108 * it only needs to get called once
113 /* Configure IO exander PCA9555: 7bit address 0x21 */
114 ret = i2c_get_chip_for_busnum(0, I2C_IO_EXP_ADDR, 1, &dev);
116 printf("Cannot find PCA9555: %d\n", ret);
120 /* Read VBUS output value */
121 ret = dm_i2c_read(dev, I2C_IO_DATA_OUT_REG_0, buf, 1);
123 printf("Failed to read IO expander value via I2C\n");
127 /* Enable VBUS power: Set output value of VBUS pin as enabled */
128 buf[0] |= I2C_IO_REG_VBUS;
129 ret = dm_i2c_write(dev, I2C_IO_DATA_OUT_REG_0, buf, 1);
131 printf("Failed to set IO expander via I2C\n");
135 mdelay(500); /* required delay to let output value settle */
142 int board_early_init_f(void)
144 /* Nothing to do (yet), perhaps later some pin-muxing etc */
151 /* adress of boot parameters */
152 gd->bd->bi_boot_params = CONFIG_SYS_SDRAM_BASE + 0x100;
157 int board_late_init(void)
159 /* Pre-configure the USB ports (overcurrent, VBus) */