summaryrefslogtreecommitdiff
path: root/board/scalys
diff options
context:
space:
mode:
Diffstat (limited to 'board/scalys')
-rw-r--r--board/scalys/grapeboard/Kconfig14
-rw-r--r--board/scalys/grapeboard/board_configuration_data.c73
-rw-r--r--board/scalys/grapeboard/board_configuration_data.h7
-rw-r--r--board/scalys/grapeboard/grapeboard.c50
4 files changed, 95 insertions, 49 deletions
diff --git a/board/scalys/grapeboard/Kconfig b/board/scalys/grapeboard/Kconfig
index 99ece55..6c2c92b 100644
--- a/board/scalys/grapeboard/Kconfig
+++ b/board/scalys/grapeboard/Kconfig
@@ -15,20 +15,6 @@ config SYS_CONFIG_NAME
menu "Grapeboard configuration options"
depends on TARGET_GRAPEBOARD
-choice
- prompt "U-boot environment configuration"
- default STANDARD_UBOOT_CONFIG
-
-config STANDARD_UBOOT_CONFIG
- bool
- prompt "Standard flash target"
-
-config RESCUE_UBOOT_CONFIG
- bool
- prompt "Rescue flash target"
-
-endchoice
-
config CONCAT_PBL_UBOOT_IMAGE
bool
default y
diff --git a/board/scalys/grapeboard/board_configuration_data.c b/board/scalys/grapeboard/board_configuration_data.c
index d277454..8d5cc9c 100644
--- a/board/scalys/grapeboard/board_configuration_data.c
+++ b/board/scalys/grapeboard/board_configuration_data.c
@@ -83,46 +83,77 @@ int add_mac_addressess_to_env(const void* blob)
return 0;
}
-struct udevice* sel_rescue_qspi_flash(bool sel_rescue) {
+const char* get_qspi_flash_name(void)
+{
+ struct udevice *flash_dev, *bus_dev;
+ struct spi_flash *flash;
+ int ret = 0;
+ unsigned int bus = CONFIG_SF_DEFAULT_BUS;
+ unsigned int cs = CONFIG_SF_DEFAULT_CS;
+ unsigned int speed = CONFIG_SF_DEFAULT_SPEED;
+ unsigned int mode = CONFIG_SF_DEFAULT_MODE;
+
+ /* Remove previous DM device */
+ ret = spi_find_bus_and_cs(bus, cs, &bus_dev, &flash_dev);
+ if (!ret) {
+ device_remove(flash_dev, DM_REMOVE_NORMAL);
+ }
+
+ /* Probe flash */
+ ret = spi_flash_probe_bus_cs(bus, cs, speed, mode, &flash_dev);
+ if (ret != 0) {
+ printf("probe failed\n");
+ return NULL;
+ }
+
+ flash = dev_get_uclass_priv(flash_dev);
+
+ return flash->name;
+}
+
+struct udevice* select_qspi_flash_device(enum grapeboard_flash_types flash_type)
+{
struct ccsr_gpio *pgpio = (void *)(CONFIG_SYS_GPIO2);
- struct udevice *rescue_flash_dev,*bus_dev;
+ struct udevice *flash_dev,*bus_dev;
int ret = 0;
- unsigned int bus = 0;
- unsigned int cs = 0;
- unsigned int speed = 0;
- unsigned int mode = 0;
+ unsigned int bus = CONFIG_SF_DEFAULT_BUS;
+ unsigned int cs = CONFIG_SF_DEFAULT_CS;
+ unsigned int speed = CONFIG_SF_DEFAULT_SPEED;
+ unsigned int mode = CONFIG_SF_DEFAULT_MODE;
/* Remove previous DM device */
- ret = spi_find_bus_and_cs(bus, cs, &bus_dev, &rescue_flash_dev);
+ ret = spi_find_bus_and_cs(bus, cs, &bus_dev, &flash_dev);
if (!ret) {
- device_remove(rescue_flash_dev, DM_REMOVE_NORMAL);
+ device_remove(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 {
+ switch (flash_type) {
+ case PRIMARY_FLASH_DEVICE:
/* 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 */
+ * Delay may be removed but the primary flash is only available after the delay */
udelay(75000);
+ break;
+ case RESCUE_FLASH_DEVICE:
+ /* Change chip select to rescue QSPI NOR flash */
+ setbits_be32(&pgpio->gpdat, QSPI_MUX_N_MASK);
+ break;
+ default:
+ break;
}
/* Probe new flash */
- ret = spi_flash_probe_bus_cs(bus, cs, speed, mode, &rescue_flash_dev);
+ ret = spi_flash_probe_bus_cs(bus, cs, speed, mode, &flash_dev);
if (ret != 0) {
printf("probe failed\n");
return NULL;
}
- return rescue_flash_dev;
-
+ return flash_dev;
}
-
-
const void* get_boardinfo_rescue_flash(void)
{
struct udevice *rescue_flash_dev;
@@ -133,7 +164,7 @@ const void* get_boardinfo_rescue_flash(void)
int ret = 0;
/* Select and probe rescue flash */
- rescue_flash_dev = sel_rescue_qspi_flash(true);
+ rescue_flash_dev = select_qspi_flash_device(true);
if (rescue_flash_dev == NULL)
goto err_no_free;
@@ -196,7 +227,7 @@ const void* get_boardinfo_rescue_flash(void)
}
/* Select and probe normal flash */
- rescue_flash_dev = sel_rescue_qspi_flash(false);
+ rescue_flash_dev = select_qspi_flash_device(false);
/* Everything checked out, return the BCD data.
* The caller is expected to free this data */
@@ -209,7 +240,7 @@ err_free:
err_no_free:
/* Select and probe normal flash */
- rescue_flash_dev = sel_rescue_qspi_flash(false);
+ rescue_flash_dev = select_qspi_flash_device(false);
return NULL;
}
diff --git a/board/scalys/grapeboard/board_configuration_data.h b/board/scalys/grapeboard/board_configuration_data.h
index f08eea8..4f65ce4 100644
--- a/board/scalys/grapeboard/board_configuration_data.h
+++ b/board/scalys/grapeboard/board_configuration_data.h
@@ -14,7 +14,14 @@
#define BCD_HASH_SIZE 4
+enum grapeboard_flash_types {
+ PRIMARY_FLASH_DEVICE,
+ RESCUE_FLASH_DEVICE,
+};
+
const void* get_boardinfo_rescue_flash(void);
+struct udevice* select_qspi_flash_device(enum grapeboard_flash_types);
+const char* get_qspi_flash_name(void);
int add_mac_addressess_to_env(const void* blob);
#endif /* _BCD_H */
diff --git a/board/scalys/grapeboard/grapeboard.c b/board/scalys/grapeboard/grapeboard.c
index 72d9510..6bb6f82 100644
--- a/board/scalys/grapeboard/grapeboard.c
+++ b/board/scalys/grapeboard/grapeboard.c
@@ -30,22 +30,42 @@
#include <usb.h>
#include "gpio_grapeboard.h"
#include "board_configuration_data.h"
+#include <dm.h>
+#include <spi.h>
+#include <dm/device-internal.h>
+
+#define RESCUE_FLASH_NAME "s25fs064s"
+
+static int recovery_mode_enabled = 0;
DECLARE_GLOBAL_DATA_PTR;
int checkboard(void)
{
struct ccsr_gpio *pgpio = (void *)(CONFIG_SYS_GPIO2);
+ const void* bcd_dtc_blob;
+ int ret;
int m2_config = 0;
int serdes_cfg = get_serdes_protocol();
- puts("Board: Grape board\n");
+ puts("Board: Grapeboard\n");
+
+ env_set_ulong("recoverymode", recovery_mode_enabled);
/* set QSPI chip select muxing to 0 */
setbits_be32(&pgpio->gpdir, QSPI_MUX_N_MASK);
clrbits_be32(&pgpio->gpdat, QSPI_MUX_N_MASK);
+ 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");
+ }
+ }
+
/* Configure USB hub */
usb_hx3_hub_init();
@@ -77,18 +97,6 @@ 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;
}
@@ -132,6 +140,8 @@ int board_init(void)
{
struct ccsr_cci400 *cci = (struct ccsr_cci400 *)(CONFIG_SYS_IMMR +
CONFIG_SYS_CCI400_OFFSET);
+ struct ccsr_gpio *pgpio = (void *)(CONFIG_SYS_GPIO2);
+
/*
* Set CCI-400 control override register to enable barrier
* transaction
@@ -146,6 +156,19 @@ int board_init(void)
gd->env_addr = (ulong)&default_environment[0];
#endif
+ /* Detect and handle grapeboard rescue mode */
+ if(strcmp(get_qspi_flash_name(), RESCUE_FLASH_NAME) == 0) {
+ /* Revert chip select muxing to standard QSPI flash */
+ setbits_be32(&pgpio->gpdir, QSPI_MUX_N_MASK);
+ clrbits_be32(&pgpio->gpdat, QSPI_MUX_N_MASK);
+ printf("Please release the rescue mode button (S2) to enter the recovery mode\n");
+ recovery_mode_enabled = 1;
+ while(strcmp(get_qspi_flash_name(), RESCUE_FLASH_NAME) == 0) {
+ udelay(500000);
+ puts("\033[1A"); /* Overwrite previous line */
+ }
+ }
+
#ifdef CONFIG_FSL_CAAM
sec_init();
#endif
@@ -178,4 +201,3 @@ int ft_board_setup(void *blob, bd_t *bd)
void scsi_init(void) {
printf("\r"); /* SCSI init already completed in board_late_init, so skip message */
}
-