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