diff options
author | vojo <joris.van.vossen@sintecs.nl> | 2018-02-07 12:36:58 (GMT) |
---|---|---|
committer | vojo <joris.van.vossen@sintecs.nl> | 2018-02-07 12:36:58 (GMT) |
commit | f3420047e97980b83d6549184d159a0a901881dc (patch) | |
tree | d098c20e2f60891b52e0961ad858b93e202f9bb4 /board/scalys | |
parent | 9ca9f1eaaa6de0bd7684764cf46ca62a7be02abf (diff) | |
parent | f6b76fd828c6311dec9a84c2658033d98dd75eee (diff) | |
download | u-boot-f3420047e97980b83d6549184d159a0a901881dc.tar.xz |
Merge commit 'f6b76fd828c6311dec9a84c2658033d98dd75eee' into grapeboard
Diffstat (limited to 'board/scalys')
-rw-r--r-- | board/scalys/grapeboard/board_configuration_data.c | 136 | ||||
-rw-r--r-- | board/scalys/grapeboard/board_configuration_data.h | 2 | ||||
-rw-r--r-- | board/scalys/grapeboard/eth.c | 11 | ||||
-rw-r--r-- | board/scalys/grapeboard/grapeboard.c | 30 | ||||
-rw-r--r-- | board/scalys/grapeboard/usb_grapeboard.c | 20 |
5 files changed, 102 insertions, 97 deletions
diff --git a/board/scalys/grapeboard/board_configuration_data.c b/board/scalys/grapeboard/board_configuration_data.c index bd6a04e..a730c11 100644 --- a/board/scalys/grapeboard/board_configuration_data.c +++ b/board/scalys/grapeboard/board_configuration_data.c @@ -58,8 +58,6 @@ int add_mac_addressess_to_env(const void* blob) memcpy(mac_address, value, 6); - /* ret = fdtdec_get_byte_array( blob, prop_offset, propname, mac_address, 6 ); */ - if (count) { snprintf(eth_string, sizeof(eth_string), "eth%iaddr", count); } @@ -85,66 +83,63 @@ int add_mac_addressess_to_env(const void* blob) return 0; } -const void* get_boardinfo_rescue_flash(void) -{ +struct udevice* sel_rescue_qspi_flash(bool sel_rescue) { struct ccsr_gpio *pgpio = (void *)(CONFIG_SYS_GPIO2); - struct spi_flash *flash; - - uint32_t bcd_data_lenght; - uint8_t *bcd_data = NULL; - uint32_t calculated_crc, received_crc; - int dtb_length; + struct udevice *rescue_flash_dev,*bus_dev; int ret = 0; - unsigned int bus = 0; unsigned int cs = 0; - unsigned int speed = 10000000; - unsigned int mode = SPI_MODE_0; - -#ifdef CONFIG_DM_SPI_FLASH - struct udevice *new, *bus_dev; - /* In DM mode defaults will be taken from DT */ - speed = 0, mode = 0; -#else - struct spi_flash *new; -#endif + unsigned int speed = 0; + unsigned int mode = 0; - /* Change chip select to rescue QSPI NOR flash */ - setbits_be32(&pgpio->gpdir, QSPI_MUX_N_MASK); - setbits_be32(&pgpio->gpdat, QSPI_MUX_N_MASK); - -#ifdef CONFIG_DM_SPI_FLASH - /* Remove the old device, otherwise probe will just be a nop */ - ret = spi_find_bus_and_cs(bus, cs, &bus_dev, &new); + /* Remove previous DM device */ + ret = spi_find_bus_and_cs(bus, cs, &bus_dev, &rescue_flash_dev); if (!ret) { - device_remove(new, DM_REMOVE_NORMAL); + device_remove(rescue_flash_dev, DM_REMOVE_NORMAL); } - flash = NULL; - ret = spi_flash_probe_bus_cs(bus, cs, speed, mode, &new); - if (ret) { - printf("Failed to initialize SPI flash at %u:%u (error %d)\n", - bus, cs, ret); + + setbits_be32(&pgpio->gpdir, QSPI_MUX_N_MASK); + if (sel_rescue == true) { + /* Change chip select to rescue QSPI NOR flash */ + setbits_be32(&pgpio->gpdat, QSPI_MUX_N_MASK); + } else { + /* Revert chip select muxing to standard QSPI flash */ + clrbits_be32(&pgpio->gpdat, QSPI_MUX_N_MASK); + /* Delay required (to meet RC time for button debouncing) before probing flash again. + * May be removed but the primary flash is only available after delay */ + udelay(75000); + } + + /* Probe new flash */ + ret = spi_flash_probe_bus_cs(bus, cs, speed, mode, &rescue_flash_dev); + if (ret != 0) { + printf("probe failed\n"); return NULL; } - flash = dev_get_uclass_priv(new); -#else - if (flash) - spi_flash_free(flash); + return rescue_flash_dev; - new = spi_flash_probe(bus, cs, speed, mode); - flash = new; +} - if (!new) { - printf("Failed to initialize SPI flash at %u:%u\n", bus, cs); - return NULL; - } - flash = new; -#endif + +const void* get_boardinfo_rescue_flash(void) +{ + struct udevice *rescue_flash_dev; + uint32_t bcd_data_length; + uint8_t *bcd_data = NULL; + uint32_t calculated_crc, received_crc; + int dtb_length; + int ret = 0; + + /* Select and probe rescue flash */ + rescue_flash_dev = sel_rescue_qspi_flash(true); + + if (rescue_flash_dev == NULL) + goto err_no_free; /* Read the last 4 bytes to determine the length of the DTB data */ - ret = spi_flash_read(flash, (BCD_FLASH_SIZE-4), 4, (uint8_t*) &bcd_data_lenght); + ret = spi_flash_read_dm(rescue_flash_dev, (BCD_FLASH_SIZE-4), 4, (uint8_t*) &bcd_data_length); if (ret != 0) { printf("Error reading bcd length\n"); errno = -ENODEV; @@ -152,54 +147,57 @@ const void* get_boardinfo_rescue_flash(void) } /* Convert length from big endianess to architecture endianess */ - bcd_data_lenght = ntohl(bcd_data_lenght); - printf("bcd_data_lenght = %i\n", bcd_data_lenght ); + bcd_data_length = ntohl(bcd_data_length); + printf("bcd_data_length = %i\n", bcd_data_length ); - if (bcd_data_lenght > BCD_FLASH_SIZE ) { - printf("BCD data length error %02x %02x %02x %02x\n", - ( (uint8_t*) &bcd_data_lenght)[0], - ( (uint8_t*) &bcd_data_lenght)[1], - ( (uint8_t*) &bcd_data_lenght)[2], - ( (uint8_t*) &bcd_data_lenght)[3] ); + if (bcd_data_length > BCD_FLASH_SIZE ) { + debug("BCD data length error %02x %02x %02x %02x\n", + ( (uint8_t*) &bcd_data_length)[0], + ( (uint8_t*) &bcd_data_length)[1], + ( (uint8_t*) &bcd_data_length)[2], + ( (uint8_t*) &bcd_data_length)[3] ); errno = -EMSGSIZE; goto err_no_free; } - + /* Allocate, and verify memory for the BCD data */ - bcd_data = (uint8_t*) malloc(bcd_data_lenght); + bcd_data = (uint8_t*) malloc(bcd_data_length); if (bcd_data == NULL) { printf("Error locating memory for BCD data\n"); goto err_no_free; } - printf("Allocated memory for BCD data\n"); - + debug("Allocated memory for BCD data\n"); + /* Read the DTB BCD data to memory */ - ret = spi_flash_read(flash, (BCD_FLASH_SIZE-bcd_data_lenght), bcd_data_lenght, (uint8_t*) &bcd_data); - printf("Read data from I2C bus\n"); + ret = spi_flash_read_dm(rescue_flash_dev, (BCD_FLASH_SIZE-bcd_data_length), bcd_data_length, (uint8_t*) bcd_data); + debug("Read data from QSPI bus\n"); if (ret != 0) { printf("Error reading complete BCD data from EEPROM\n"); errno = -ENOMEM; goto err_free; } - dtb_length = bcd_data_lenght - BCD_LENGTH_SIZE - BCD_HASH_SIZE; - + dtb_length = bcd_data_length - BCD_LENGTH_SIZE - BCD_HASH_SIZE; + /* Calculate CRC on read DTB data */ calculated_crc = crc32( 0, bcd_data, dtb_length); - + /* Received CRC is packed after the DTB data */ received_crc = *((uint32_t*) &bcd_data[dtb_length]); - + /* Convert CRC from big endianess to architecture endianess */ received_crc = ntohl(received_crc); - + if (calculated_crc != received_crc) { printf("Checksum error. expected %08x, got %08x\n", calculated_crc, received_crc); errno = -EBADMSG; goto err_free; } - + + /* Select and probe normal flash */ + rescue_flash_dev = sel_rescue_qspi_flash(false); + /* Everything checked out, return the BCD data. * The caller is expected to free this data */ return bcd_data; @@ -209,9 +207,9 @@ err_free: free(bcd_data); err_no_free: - /* Revert chip select for standard QSPI flash */ - clrbits_be32(&pgpio->gpdat, QSPI_MUX_N_MASK); + /* Select and probe normal flash */ + rescue_flash_dev = sel_rescue_qspi_flash(false); return NULL; } diff --git a/board/scalys/grapeboard/board_configuration_data.h b/board/scalys/grapeboard/board_configuration_data.h index 5424bf0..f6e253c 100644 --- a/board/scalys/grapeboard/board_configuration_data.h +++ b/board/scalys/grapeboard/board_configuration_data.h @@ -3,7 +3,7 @@ #define BCD_LENGTH_SIZE 4 -#define BCD_FLASH_SIZE 0x800000 /* 8 MBytes */ +#define BCD_FLASH_SIZE 0x100000 /* 1 MBytes */ #define BCD_HASH_SIZE 4 diff --git a/board/scalys/grapeboard/eth.c b/board/scalys/grapeboard/eth.c index 256f996..16885cc 100644 --- a/board/scalys/grapeboard/eth.c +++ b/board/scalys/grapeboard/eth.c @@ -70,9 +70,14 @@ int board_eth_init(bd_t *bis) ls1012a_set_mdio(1, miiphy_get_dev_by_name(DEFAULT_PFE_MDIO_NAME)); ls1012a_set_phy_address_mode(1, EMAC2_PHY_ADDR, PHY_INTERFACE_MODE_SGMII); - /* Initialize TI83867CS PHY LEDs */ - miiphy_write(DEFAULT_PFE_MDIO_NAME,EMAC1_PHY_ADDR,0x18,0x61B6); - miiphy_write(DEFAULT_PFE_MDIO_NAME,EMAC2_PHY_ADDR,0x18,0x61B6); + /* Initialize TI83867CS PHY LEDs as: + * LED_3 = 0x0: Link established (not connected) + * LED_2 = 0x0: Link established (not connected) + * LED_1 = 0xB: Link established, blink for activity (green LED) + * LED_0 = 0x8: 10/100BT link established (orange LED) + */ + miiphy_write(DEFAULT_PFE_MDIO_NAME,EMAC1_PHY_ADDR,0x18,0x00B8); + miiphy_write(DEFAULT_PFE_MDIO_NAME,EMAC2_PHY_ADDR,0x18,0x00B8); cpu_eth_init(bis); #endif diff --git a/board/scalys/grapeboard/grapeboard.c b/board/scalys/grapeboard/grapeboard.c index 78c5502..bd5e640 100644 --- a/board/scalys/grapeboard/grapeboard.c +++ b/board/scalys/grapeboard/grapeboard.c @@ -31,16 +31,14 @@ #include <../../../include/generated/autoconf.h> #include <usb.h> #include "gpio_grapeboard.h" +#include "board_configuration_data.h" DECLARE_GLOBAL_DATA_PTR; int checkboard(void) { struct ccsr_gpio *pgpio = (void *)(CONFIG_SYS_GPIO2); -#if 0 - const void* bcd_dtc_blob; - int ret; -#endif + int m2_config = 0; int serdes_cfg = get_serdes_protocol(); @@ -50,17 +48,6 @@ int checkboard(void) setbits_be32(&pgpio->gpdir, QSPI_MUX_N_MASK); clrbits_be32(&pgpio->gpdat, QSPI_MUX_N_MASK); -#if 0 /* todo: test */ - bcd_dtc_blob = get_boardinfo_rescue_flash(); - if (bcd_dtc_blob != NULL) { - /* Board Configuration Data is intact, ready for parsing */ - ret = add_mac_addressess_to_env(bcd_dtc_blob); - if (ret != 0) { - printf("Error adding BCD data to environment\n"); - } - } -#endif - /* Configure USB hub */ usb_hx3_hub_init(); @@ -92,6 +79,18 @@ int checkboard(void) int misc_init_r(void) { + const void* bcd_dtc_blob; + int ret; + + bcd_dtc_blob = get_boardinfo_rescue_flash(); + if (bcd_dtc_blob != NULL) { + /* Board Configuration Data is intact, ready for parsing */ + ret = add_mac_addressess_to_env(bcd_dtc_blob); + if (ret != 0) { + printf("Error adding BCD data to environment\n"); + } + } + return 0; } @@ -177,3 +176,4 @@ int ft_board_setup(void *blob, bd_t *bd) return 0; } + diff --git a/board/scalys/grapeboard/usb_grapeboard.c b/board/scalys/grapeboard/usb_grapeboard.c index 6a2ba36..f8fbd59 100644 --- a/board/scalys/grapeboard/usb_grapeboard.c +++ b/board/scalys/grapeboard/usb_grapeboard.c @@ -35,7 +35,7 @@ const uint8_t hx3_settings[5 + HX3_SETTINGS_SIZE] = { 0xf0, /* cdp enabled */ 0x78, /* overcurrent input is active high */ 0x00, /* reserved */ - 0x00, /* USB String descriptors enabled */ + 0x08, /* USB String descriptors enabled (0x08) / disabled (0x00) */ 0x00, 0x00, 0x12, 0x00, 0x2c, 0x66, 0x66, /* USB3.0 TX driver de-emphasis */ @@ -93,14 +93,6 @@ int usb_hx3_hub_init(void) { data += length; } - /* Suspend USB2.0 PHY */ - /*unsigned int val; - - val = in_be32(0x2f0c200); - setbits_be32(0x2f0c200, val & (64 << 24)); - mdelay(10);*/ - - puts("Done!\n"); return 0; } @@ -109,3 +101,13 @@ int usb_hx3_hub_reset(void) { /* USB hub cannot be reset in software without resetting the ls1012a */ return 1; } + +void usb_hub_reset_devices(int port) +{ + /* Todo: fix issue and remove this message and temporary code added in drivers/usb/host/xhci.c at line 777*/ + static bool warning_shown = false; + if (!warning_shown) + printf("Warning: Currently Grapeboard does not support USB 2.0 devices under U-boot until xhci hub configuration error is fixed!\n"); + warning_shown = true; + return; +} |