From 0c521ff1a651585741317b4b4dfe99fd242dace2 Mon Sep 17 00:00:00 2001 From: vojo Date: Mon, 29 Jan 2018 15:56:18 +0100 Subject: BCD data reading implemented diff --git a/arch/arm/cpu/armv8/fsl-layerscape/ls1012a_serdes.c b/arch/arm/cpu/armv8/fsl-layerscape/ls1012a_serdes.c index ff0903c..56f1174 100644 --- a/arch/arm/cpu/armv8/fsl-layerscape/ls1012a_serdes.c +++ b/arch/arm/cpu/armv8/fsl-layerscape/ls1012a_serdes.c @@ -18,6 +18,7 @@ static struct serdes_config serdes1_cfg_tbl[] = { {0x0008, {NONE, NONE, NONE, SATA1} }, {0x3508, {SGMII_FM1_DTSEC1, PCIE1, NONE, SATA1} }, {0x3305, {SGMII_FM1_DTSEC1, SGMII_FM1_DTSEC2, NONE, PCIE1} }, + {0x3308, {SGMII_FM1_DTSEC1, SGMII_FM1_DTSEC2, NONE, SATA1} }, {0x2205, {SGMII_2500_FM1_DTSEC1, SGMII_2500_FM1_DTSEC2, NONE, PCIE1} }, {0x2305, {SGMII_2500_FM1_DTSEC1, SGMII_FM1_DTSEC2, NONE, PCIE1} }, {0x9508, {TX_CLK, PCIE1, NONE, SATA1} }, 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 #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; +} diff --git a/configs/grapeboard_qspi_rescue_defconfig b/configs/grapeboard_qspi_rescue_defconfig new file mode 100644 index 0000000..5649f3f --- /dev/null +++ b/configs/grapeboard_qspi_rescue_defconfig @@ -0,0 +1,59 @@ +CONFIG_ARM=y +CONFIG_TARGET_GRAPEBOARD=y +CONFIG_FSL_LS_PPA=y +CONFIG_QSPI_AHB_INIT=y +CONFIG_DEFAULT_DEVICE_TREE="grapeboard" +CONFIG_RESCUE_UBOOT_CONFIG=y +CONFICONFIG_SYS_LS_PPA_FW_ADDR=0x400a0000 +CONFIG_SYS_LS_PFE_FW_ADDR=0x400c0000 +CONFIG_PBL_BINARY_SRC="board/scalys/grapeboard/PBL_0x33_0x05_800_250_1000.bin" + +# CONFIG_SYS_MALLOC_F is not set +CONFIG_FIT_VERBOSE=y +CONFIG_OF_BOARD_SETUP=y +CONFIG_OF_STDOUT_VIA_ALIAS=y +CONFIG_SYS_EXTRA_OPTIONS="QSPI_BOOT" +CONFIG_QSPI_BOOT=y +CONFIG_BOOTDELAY=10 +# CONFIG_DISPLAY_BOARDINFO is not set +CONFIG_HUSH_PARSER=y +CONFIG_CMD_GREPENV=y +CONFIG_CMD_GPT=y +CONFIG_CMD_MMC=y +CONFIG_CMD_SF=y +CONFIG_CMD_I2C=y +CONFIG_CMD_USB=y +# CONFIG_CMD_SETEXPR is not set +CONFIG_CMD_DHCP=y +CONFIG_CMD_MII=y +CONFIG_CMD_PING=y +CONFIG_CMD_CACHE=y +CONFIG_CMD_EXT2=y +CONFIG_CMD_FAT=y +CONFIG_OF_CONTROL=y +CONFIG_NET_RANDOM_ETHADDR=y +CONFIG_DM=y +# CONFIG_BLK is not set +CONFIG_DM_MMC=y +# CONFIG_DM_MMC_OPS is not set +CONFIG_DM_SPI_FLASH=y +CONFIG_SPI_FLASH=y +CONFIG_NETDEVICES=y +CONFIG_E1000=y +CONFIG_FSL_PFE=y +CONFIG_PHYLIB=y +CONFIG_PHY_TI=y +CONFIG_PCI=y +CONFIG_DM_PCI=y +CONFIG_DM_PCI_COMPAT=y +CONFIG_PCIE_LAYERSCAPE=y +CONFIG_SYS_NS16550=y +CONFIG_DM_SPI=y +CONFIG_FSL_DSPI=y +CONFIG_USB=y +CONFIG_DM_USB=y +CONFIG_USB_XHCI_HCD=y +CONFIG_USB_XHCI_DWC3=y +CONFIG_USB_STORAGE=y +CONFIG_DISTRO_DEFAULTS=y + diff --git a/drivers/usb/host/xhci.c b/drivers/usb/host/xhci.c index e64637b..67e29d9 100644 --- a/drivers/usb/host/xhci.c +++ b/drivers/usb/host/xhci.c @@ -773,6 +773,13 @@ static int xhci_submit_root(struct usb_device *udev, unsigned long pipe, tmpbuf[1] |= USB_PORT_STAT_SUPER_SPEED >> 8; break; } + +/* TODO: fix issue and remove the following code. Do not push upstream! */ +#if defined(CONFIG_TARGET_GRAPEBOARD) + if(!(tmpbuf[1] & (USB_PORT_STAT_SUPER_SPEED >> 8))) { + goto unknown; + } +#endif } if (reg & PORT_PE) tmpbuf[0] |= USB_PORT_STAT_ENABLE; diff --git a/include/configs/grapeboard.h b/include/configs/grapeboard.h index 509395f..3a252b6 100644 --- a/include/configs/grapeboard.h +++ b/include/configs/grapeboard.h @@ -22,6 +22,7 @@ #define CONFIG_BOARD_LATE_INIT #define CONFIG_DISPLAY_BOARDINFO_LATE +#define CONFIG_MISC_INIT_R /* Match the following u-boot offsets with the value in the PBI instructions! */ #define CONFIG_U_BOOT_PAD_TO 0x1000 @@ -71,17 +72,21 @@ #define CONFIG_FSL_QSPI #define QSPI0_AMBA_BASE 0x40000000 #define CONFIG_SPI_FLASH_SPANSION +#define CONFIG_SPI_FLASH_SST /* Standard flash */ #define FSL_QSPI_FLASH_SIZE SZ_64M #define FSL_QSPI_FLASH_NUM 1 /* QSPI Environment */ +#define CONFIG_ENV_SIZE 0x40000 /* 256KB */ + #if CONFIG_RESCUE_UBOOT_CONFIG +/* Rescue flash size is at minimum 1MBytes. + * I.e. PBL/U-boot/PPA/PFE/BCD must fit within 0x100000. */ #define CONFIG_ENV_IS_NOWHERE #else #define CONFIG_ENV_OVERWRITE #define CONFIG_ENV_IS_IN_SPI_FLASH -#define CONFIG_ENV_SIZE 0x40000 /* 256KB */ #define CONFIG_ENV_OFFSET 0x200000 /* 2MB */ #define CONFIG_ENV_SECT_SIZE 0x40000 #endif @@ -140,27 +145,11 @@ #define EMAC2_PHY_ADDR 0x2 #endif -/* -* USB -*/ -/* EHCI Support - disbaled by default */ -/*#define CONFIG_HAS_FSL_DR_USB*/ - -#ifdef CONFIG_HAS_FSL_DR_USB -#define CONFIG_USB_EHCI_FSL -#define CONFIG_USB_ULPI -#define CONFIG_USB_ULPI_VIEWPORT -#define CONFIG_USB_EHCI_HCD -#define CONFIG_EHCI_HCD_INIT_AFTER_RESET -#endif - /* USB XHCI */ -/* todo: fix hx3 hub configuration errors */ #define CONFIG_HAS_FSL_XHCI_USB #ifdef CONFIG_HAS_FSL_XHCI_USB #define CONFIG_USB_XHCI_FSL -/*#define CONFIG_USB_XHCI_PCI*/ #define CONFIG_USB_MAX_CONTROLLER_COUNT 1 #endif @@ -232,22 +221,7 @@ "eth1addr=02:00:00:ba:be:02\0" \ "tftp_path=.\0" \ "autoload=no\0" \ - -/* Default flash specific environment variables */ -#if CONFIG_RESCUE_UBOOT_CONFIG -#define CONFIG_EXTRA_ENV_SETTINGS \ - COMMON_UBOOT_CONFIG - /* todo: add recovery variables */ -#undef CONFIG_BOOTCOMMAND -#if defined(CONFIG_QSPI_BOOT) || defined(CONFIG_SD_BOOT_QSPI) -/* recover from sd card */ -#define CONFIG_BOOTCOMMAND "test" -#endif - -#else /* if CONFIG_STANDARD_UBOOT_CONFIG */ -#define CONFIG_EXTRA_ENV_SETTINGS \ - COMMON_UBOOT_CONFIG \ - "tftp_update_pbl_uboot_qspi_nor=" \ + "update_tftp_uboot_pbl_qspi_nor=" \ "dhcp;" \ "tftp $load_addr $tftp_path/u-boot-pbl.bin;" \ "if test $? = \"0\"; then " \ @@ -255,7 +229,7 @@ "sf erase 0 200000;" \ "sf write $load_addr 0 $filesize;" \ "fi\0" \ - "tftp_update_ppa_qspi_nor=" \ + "update_tftp_ppa_qspi_nor=" \ "dhcp;" \ "tftp $load_addr $tftp_path/ppa.itb;" \ "if test $? = \"0\"; then " \ @@ -263,7 +237,7 @@ "sf erase 240000 40000;" \ "sf write $load_addr 240000 $filesize;" \ "fi\0" \ - "tftp_update_pfe_qspi_nor=" \ + "update_tftp_pfe_qspi_nor=" \ "dhcp;" \ "tftp $load_addr $tftp_path/pfe_fw_sbl.itb;" \ "if test $? = \"0\"; then " \ @@ -271,6 +245,68 @@ "sf erase 280000 40000;" \ "sf write $load_addr 280000 $filesize;" \ "fi\0" \ + "update_usb_uboot_pbl_qspi_nor=" \ + "usb start;" \ + "fatload usb 0:1 $load_addr u-boot-pbl.bin;" \ + "if test $? = \"0\"; then " \ + "sf probe 0:0;" \ + "sf erase 0 200000;" \ + "sf write $load_addr 0 $filesize;" \ + "fi\0" \ + "update_usb_ppa_qspi_nor=" \ + "usb start;" \ + "fatload usb 0:1 $load_addr ppa.itb;" \ + "if test $? = \"0\"; then " \ + "sf probe 0:0;" \ + "sf erase 240000 40000;" \ + "sf write $load_addr 240000 $filesize;" \ + "fi\0" \ + "update_usb_pfe_qspi_nor=" \ + "usb start;" \ + "fatload usb 0:1 $load_addr pfe_fw_sbl.itb;" \ + "if test $? = \"0\"; then " \ + "sf probe 0:0;" \ + "sf erase 280000 40000;" \ + "sf write $load_addr 280000 $filesize;" \ + "fi\0" \ + "update_mmc_uboot_pbl_qspi_nor=" \ + "mmc rescan;" \ + "ext4load mmc 0:1 $load_addr /boot/u-boot-pbl.bin;" \ + "if test $? = \"0\"; then " \ + "sf probe 0:0;" \ + "sf erase 0 200000;" \ + "sf write $load_addr 0 $filesize;" \ + "fi\0" \ + "update_mmc_ppa_qspi_nor=" \ + "mmc rescan;" \ + "ext4load mmc 0:1 $load_addr /boot/ppa.itb;" \ + "if test $? = \"0\"; then " \ + "sf probe 0:0;" \ + "sf erase 240000 40000;" \ + "sf write $load_addr 240000 $filesize;" \ + "fi\0" \ + "update_mmc_pfe_qspi_nor=" \ + "mmc rescan;" \ + "ext4load mmc 0:1 $load_addr /boot/pfe_fw_sbl.itb;" \ + "if test $? = \"0\"; then " \ + "sf probe 0:0;" \ + "sf erase 280000 40000;" \ + "sf write $load_addr 280000 $filesize;" \ + "fi\0" \ + +/* Default flash specific environment variables */ +#if CONFIG_RESCUE_UBOOT_CONFIG +#define CONFIG_EXTRA_ENV_SETTINGS \ + COMMON_UBOOT_CONFIG +#undef CONFIG_BOOTCOMMAND +#if defined(CONFIG_QSPI_BOOT) || defined(CONFIG_SD_BOOT_QSPI) +/* recover from sd card */ +#define CONFIG_BOOTCOMMAND "run update_mmc_uboot_pbl_qspi_nor; run update_mmc_pfe_qspi_nor; run update_mmc_ppa_qspi_nor" +#endif + +#else /* if CONFIG_STANDARD_UBOOT_CONFIG */ +#define CONFIG_EXTRA_ENV_SETTINGS \ + COMMON_UBOOT_CONFIG \ "mmcboot=" \ "ext4load mmc 0:1 $fdt_addr_r /boot/grapeboard.dtb;" \ "ext4load mmc 0:1 $kernel_addr_r /boot/uImage;" \ @@ -278,6 +314,13 @@ "pfe stop;" \ "bootm $kernel_addr_r - $fdt_addr_r;" \ "fi\0" \ + "scsiboot=" \ + "ext4load scsi 0:1 $fdt_addr_r /boot/grapeboard.dtb;" \ + "ext4load scsi 0:1 $kernel_addr_r /boot/uImage;" \ + "if test $? = \"0\"; then " \ + "pfe stop;" \ + "bootm $kernel_addr_r - $fdt_addr_r;" \ + "fi\0" \ "netboot=" \ "dhcp;" \ "tftp $fdt_addr_r $tftp_path/grapeboard.dtb;" \ @@ -291,8 +334,8 @@ #if defined(CONFIG_QSPI_BOOT) || defined(CONFIG_SD_BOOT_QSPI) #define CONFIG_BOOTCOMMAND "run mmcboot" #endif -#define CONFIG_BOOTARGS "console=ttyS0,115200 root=/dev/mmcblk0p1 rootfstype=ext4 rw rootwait" \ - "earlycon=uart8250,mmio,0x21c0500 quiet lpj=250000 noinitrd" +#define CONFIG_BOOTARGS "console=ttyS0,115200 earlycon=uart8250,mmio,0x21c0500 quiet lpj=250000 noinitrd " \ + "root=/dev/mmcblk0p1 rootfstype=ext4 rw rootwait" #endif #include -- cgit v0.10.2 From f6b76fd828c6311dec9a84c2658033d98dd75eee Mon Sep 17 00:00:00 2001 From: vojo Date: Wed, 7 Feb 2018 13:24:58 +0100 Subject: mtdparts support for qpsi nor diff --git a/board/scalys/grapeboard/board_configuration_data.c b/board/scalys/grapeboard/board_configuration_data.c index 4daff4f..a730c11 100644 --- a/board/scalys/grapeboard/board_configuration_data.c +++ b/board/scalys/grapeboard/board_configuration_data.c @@ -83,35 +83,61 @@ 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); - - 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; + int ret = 0; unsigned int bus = 0; unsigned int cs = 0; 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); - + /* Remove previous DM device */ ret = spi_find_bus_and_cs(bus, cs, &bus_dev, &rescue_flash_dev); if (!ret) { device_remove(rescue_flash_dev, DM_REMOVE_NORMAL); } + + 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; } + return rescue_flash_dev; + +} + + + +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_dm(rescue_flash_dev, (BCD_FLASH_SIZE-4), 4, (uint8_t*) &bcd_data_length); if (ret != 0) { @@ -122,10 +148,10 @@ const void* get_boardinfo_rescue_flash(void) /* Convert length from big endianess to architecture endianess */ bcd_data_length = ntohl(bcd_data_length); - printf("bcd_data_lenght = %i\n", bcd_data_length ); + printf("bcd_data_length = %i\n", bcd_data_length ); if (bcd_data_length > BCD_FLASH_SIZE ) { - printf("BCD data length error %02x %02x %02x %02x\n", + 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], @@ -140,11 +166,11 @@ const void* get_boardinfo_rescue_flash(void) 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_dm(rescue_flash_dev, (BCD_FLASH_SIZE-bcd_data_length), bcd_data_length, (uint8_t*) bcd_data); - printf("Read data from QSPI bus\n"); + debug("Read data from QSPI bus\n"); if (ret != 0) { printf("Error reading complete BCD data from EEPROM\n"); @@ -169,8 +195,8 @@ const void* get_boardinfo_rescue_flash(void) goto err_free; } - /* Revert chip select muxing to standard QSPI flash */ - clrbits_be32(&pgpio->gpdat, QSPI_MUX_N_MASK); + /* 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 */ @@ -181,9 +207,9 @@ err_free: free(bcd_data); err_no_free: - /* Revert chip select muxing to 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/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/include/configs/grapeboard.h b/include/configs/grapeboard.h index 3a252b6..cf83c8c 100644 --- a/include/configs/grapeboard.h +++ b/include/configs/grapeboard.h @@ -176,27 +176,23 @@ #define CONFIG_PCI_SCAN_SHOW #define CONFIG_CMD_PCI -#if 0 /* todo */ /* Mtdparts configuration */ #define CONFIG_MTD_DEVICE #define CONFIG_MTD_PARTITIONS -/*#define CONFIG_CMD_MTDPARTS*/ +#define CONFIG_CMD_MTDPARTS #define CONFIG_USE_SPIFLASH +#define CONFIG_SPI_FLASH_MTD #define MTDIDS_DEFAULT \ - "nor0=spi40000000.0" - -#define MTDPART_DEFAULT_PARTITIONS \ - "2M@0x0(u-boot)," \ - "256k(env)," \ - "256k(ppa)," \ - "256k(pfe_ucode)," + "nor0=qspi@40000000.0" #define MTDPARTS_DEFAULT \ - "mtdparts=spi40000000.0:" \ - MTDPART_DEFAULT_PARTITIONS \ + "mtdparts=qspi@40000000.0:" \ + "2M@0x0(u-boot)," \ + "256k(env)," \ + "256k(ppa)," \ + "256k(pfe_ucode)," \ "-(rootfs)" -#endif /* Default environment variables */ #define COMMON_UBOOT_CONFIG \ -- cgit v0.10.2