diff options
Diffstat (limited to 'board/scalys/grapeboard')
-rw-r--r-- | board/scalys/grapeboard/board_configuration_data.c | 92 | ||||
-rw-r--r-- | board/scalys/grapeboard/board_configuration_data.h | 2 | ||||
-rw-r--r-- | board/scalys/grapeboard/grapeboard.c | 30 | ||||
-rw-r--r-- | board/scalys/grapeboard/usb_grapeboard.c | 20 |
4 files changed, 59 insertions, 85 deletions
diff --git a/board/scalys/grapeboard/board_configuration_data.c b/board/scalys/grapeboard/board_configuration_data.c index bd6a04e..4daff4f 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); } @@ -88,63 +86,34 @@ int add_mac_addressess_to_env(const void* blob) const void* get_boardinfo_rescue_flash(void) { struct ccsr_gpio *pgpio = (void *)(CONFIG_SYS_GPIO2); - struct spi_flash *flash; - uint32_t bcd_data_lenght; + uint32_t bcd_data_length; uint8_t *bcd_data = NULL; uint32_t calculated_crc, received_crc; int dtb_length; int ret = 0; + struct udevice *rescue_flash_dev,*bus_dev; 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); + 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); - return NULL; - } - - flash = dev_get_uclass_priv(new); -#else - if (flash) - spi_flash_free(flash); - - 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; + ret = spi_flash_probe_bus_cs(bus, cs, speed, mode, &rescue_flash_dev); + if (ret != 0) { + printf("probe failed\n"); } - flash = new; -#endif - /* 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 +121,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_lenght = %i\n", bcd_data_length ); - if (bcd_data_lenght > BCD_FLASH_SIZE ) { + if (bcd_data_length > 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] ); + ( (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"); - + /* 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); + printf("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; } - + + /* Revert chip select muxing to standard QSPI flash */ + clrbits_be32(&pgpio->gpdat, QSPI_MUX_N_MASK); + /* Everything checked out, return the BCD data. * The caller is expected to free this data */ return bcd_data; @@ -209,7 +181,7 @@ err_free: free(bcd_data); err_no_free: - /* Revert chip select for standard QSPI flash */ + /* Revert chip select muxing to standard QSPI flash */ clrbits_be32(&pgpio->gpdat, QSPI_MUX_N_MASK); 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/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; +} |