blob: 4197e88fb6ff2a7f3a555f52bf07973b42b4741f [file] [log] [blame]
Tom Rini10e47792018-05-06 17:58:06 -04001// SPDX-License-Identifier: GPL-2.0+
Stefan Roese2a0b94c2016-03-16 08:48:21 +01002/*
3 * Copyright (C) 2016 Stefan Roese <sr@denx.de>
Stefan Roese2a0b94c2016-03-16 08:48:21 +01004 */
5
Stefan Roese9a111ce2016-06-28 15:45:13 +02006#include <i2c.h>
Simon Glassa7b51302019-11-14 12:57:46 -07007#include <init.h>
Stefan Roese2a0b94c2016-03-16 08:48:21 +01008#include <winbond_w83627.h>
9#include <asm/gpio.h>
10#include <asm/ibmpc.h>
11#include <asm/pnp_def.h>
12
13int board_early_init_f(void)
14{
Stefan Roeseb1f21472016-06-15 14:15:25 +020015#ifndef CONFIG_INTERNAL_UART
Stefan Roese2a0b94c2016-03-16 08:48:21 +010016 /*
17 * The FSP enables the BayTrail internal legacy UART (again).
18 * Disable it again, so that the Winbond one can be used.
19 */
20 setup_internal_uart(0);
21
22 /* Enable the legacy UART in the Winbond W83627 Super IO chip */
23 winbond_enable_serial(PNP_DEV(WINBOND_IO_PORT, W83627DHG_SP1),
24 UART0_BASE, UART0_IRQ);
Stefan Roeseb1f21472016-06-15 14:15:25 +020025#endif
Stefan Roese2a0b94c2016-03-16 08:48:21 +010026
27 return 0;
28}
29
Stefan Roese9a111ce2016-06-28 15:45:13 +020030int board_late_init(void)
31{
32 struct udevice *dev;
33 u8 buf[8];
34 int ret;
35
36 /* Configure SMSC USB2513 USB Hub: 7bit address 0x2c */
37 ret = i2c_get_chip_for_busnum(0, 0x2c, 1, &dev);
38 if (ret) {
39 printf("Cannot find USB2513: %d\n", ret);
40 return 0;
41 }
42
43 /*
44 * The first access to the USB Hub fails sometimes, so lets read
45 * a dummy byte to be sure here
46 */
47 dm_i2c_read(dev, 0x00, buf, 1);
48
49 /*
50 * The SMSC hub is not visible on the I2C bus after the first
51 * configuration at power-up. The following code deliberately
52 * does not report upon failure of these I2C write calls.
53 */
54 buf[0] = 0x93;
55 dm_i2c_write(dev, 0x06, buf, 1);
56
57 buf[0] = 0xaa;
58 dm_i2c_write(dev, 0xf8, buf, 1);
59
60 buf[0] = 0x0f;
61 dm_i2c_write(dev, 0xfa, buf, 1);
62
63 buf[0] = 0x01;
64 dm_i2c_write(dev, 0xff, buf, 1);
65
66 return 0;
67}