From cc67f4a63ff3c6ed0b8fab35ce4af6e683296e47 Mon Sep 17 00:00:00 2001 From: Nikita Kiryanov Date: Wed, 14 Jan 2015 10:42:42 +0200 Subject: arm: mx6: cm-fx6: change dtb node for ethaddr When passing eth address to Linux via dtb, the "local-mac-address" property should be set for "/soc/aips-bus@02100000/ethernet@02188000", not "/fec". Signed-off-by: Nikita Kiryanov Cc: Stefano Babic Cc: Igor Grinberg Acked-by: Igor Grinberg --- board/compulab/cm_fx6/cm_fx6.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'board/compulab') diff --git a/board/compulab/cm_fx6/cm_fx6.c b/board/compulab/cm_fx6/cm_fx6.c index 84e3643..5ddf8c6 100644 --- a/board/compulab/cm_fx6/cm_fx6.c +++ b/board/compulab/cm_fx6/cm_fx6.c @@ -464,8 +464,9 @@ int ft_board_setup(void *blob, bd_t *bd) /* MAC addr */ if (eth_getenv_enetaddr("ethaddr", enetaddr)) { - fdt_find_and_setprop(blob, "/fec", "local-mac-address", - enetaddr, 6, 1); + fdt_find_and_setprop(blob, + "/soc/aips-bus@02100000/ethernet@02188000", + "local-mac-address", enetaddr, 6, 1); } return 0; -- cgit v1.1 From e7a2447ba2d8483b7d029e77c59b0ee26eeabe88 Mon Sep 17 00:00:00 2001 From: Nikita Kiryanov Date: Wed, 14 Jan 2015 10:42:43 +0200 Subject: compulab: eeprom: allow reading mac address from multiple eeproms Implement the option to select the eeprom i2c bus when reading mac address. Signed-off-by: Nikita Kiryanov Cc: Stefano Babic Cc: Igor Grinberg Cc: Ilya Ledvich Cc: Dmitry Lifshitz Acked-by: Igor Grinberg --- board/compulab/cm_fx6/cm_fx6.c | 2 +- board/compulab/cm_t335/cm_t335.c | 2 +- board/compulab/cm_t35/cm_t35.c | 2 +- board/compulab/cm_t3517/cm_t3517.c | 2 +- board/compulab/cm_t54/cm_t54.c | 2 +- board/compulab/common/eeprom.c | 20 +++++++++++++------- board/compulab/common/eeprom.h | 4 ++-- 7 files changed, 20 insertions(+), 14 deletions(-) (limited to 'board/compulab') diff --git a/board/compulab/cm_fx6/cm_fx6.c b/board/compulab/cm_fx6/cm_fx6.c index 5ddf8c6..32f4434 100644 --- a/board/compulab/cm_fx6/cm_fx6.c +++ b/board/compulab/cm_fx6/cm_fx6.c @@ -354,7 +354,7 @@ static int handle_mac_address(void) if (rc) return 0; - rc = cl_eeprom_read_mac_addr(enetaddr); + rc = cl_eeprom_read_mac_addr(enetaddr, CONFIG_SYS_I2C_EEPROM_BUS); if (rc) return rc; diff --git a/board/compulab/cm_t335/cm_t335.c b/board/compulab/cm_t335/cm_t335.c index 9583149..592ef3d 100644 --- a/board/compulab/cm_t335/cm_t335.c +++ b/board/compulab/cm_t335/cm_t335.c @@ -110,7 +110,7 @@ static int handle_mac_address(void) if (rv) return 0; - rv = cl_eeprom_read_mac_addr(enetaddr); + rv = cl_eeprom_read_mac_addr(enetaddr, CONFIG_SYS_I2C_EEPROM_BUS); if (rv) get_efuse_mac_addr(enetaddr); diff --git a/board/compulab/cm_t35/cm_t35.c b/board/compulab/cm_t35/cm_t35.c index 43463d5..9a3b2ee 100644 --- a/board/compulab/cm_t35/cm_t35.c +++ b/board/compulab/cm_t35/cm_t35.c @@ -429,7 +429,7 @@ static int handle_mac_address(void) if (rc) return 0; - rc = cl_eeprom_read_mac_addr(enetaddr); + rc = cl_eeprom_read_mac_addr(enetaddr, CONFIG_SYS_I2C_EEPROM_BUS); if (rc) return rc; diff --git a/board/compulab/cm_t3517/cm_t3517.c b/board/compulab/cm_t3517/cm_t3517.c index cac1ad9..624cf4c 100644 --- a/board/compulab/cm_t3517/cm_t3517.c +++ b/board/compulab/cm_t3517/cm_t3517.c @@ -163,7 +163,7 @@ static int cm_t3517_handle_mac_address(void) if (ret) return 0; - ret = cl_eeprom_read_mac_addr(enetaddr); + ret = cl_eeprom_read_mac_addr(enetaddr, CONFIG_SYS_I2C_EEPROM_BUS); if (ret) { ret = am3517_get_efuse_enetaddr(enetaddr); if (ret) diff --git a/board/compulab/cm_t54/cm_t54.c b/board/compulab/cm_t54/cm_t54.c index 2c2530a..fdea909 100644 --- a/board/compulab/cm_t54/cm_t54.c +++ b/board/compulab/cm_t54/cm_t54.c @@ -165,7 +165,7 @@ static int handle_mac_address(void) if (ret) return 0; - ret = cl_eeprom_read_mac_addr(enetaddr); + ret = cl_eeprom_read_mac_addr(enetaddr, CONFIG_SYS_I2C_EEPROM_BUS); if (ret || !is_valid_ether_addr(enetaddr)) generate_mac_addr(enetaddr); diff --git a/board/compulab/common/eeprom.c b/board/compulab/common/eeprom.c index a45e7be..77bcea4 100644 --- a/board/compulab/common/eeprom.c +++ b/board/compulab/common/eeprom.c @@ -31,6 +31,7 @@ #define LAYOUT_INVALID 0 #define LAYOUT_LEGACY 0xff +static int cl_eeprom_bus; static int cl_eeprom_layout; /* Implicitly LAYOUT_INVALID */ static int cl_eeprom_read(uint offset, uchar *buf, int len) @@ -38,7 +39,7 @@ static int cl_eeprom_read(uint offset, uchar *buf, int len) int res; unsigned int current_i2c_bus = i2c_get_bus_num(); - res = i2c_set_bus_num(CONFIG_SYS_I2C_EEPROM_BUS); + res = i2c_set_bus_num(cl_eeprom_bus); if (res < 0) return res; @@ -50,13 +51,18 @@ static int cl_eeprom_read(uint offset, uchar *buf, int len) return res; } -static int cl_eeprom_setup_layout(void) +static int cl_eeprom_setup(uint eeprom_bus) { int res; - if (cl_eeprom_layout != LAYOUT_INVALID) + /* + * We know the setup was already done when the layout is set to a valid + * value and we're using the same bus as before. + */ + if (cl_eeprom_layout != LAYOUT_INVALID && eeprom_bus == cl_eeprom_bus) return 0; + cl_eeprom_bus = eeprom_bus; res = cl_eeprom_read(EEPROM_LAYOUT_VER_OFFSET, (uchar *)&cl_eeprom_layout, 1); if (res) { @@ -77,7 +83,7 @@ void get_board_serial(struct tag_serialnr *serialnr) memset(serialnr, 0, sizeof(*serialnr)); - if (cl_eeprom_setup_layout()) + if (cl_eeprom_setup(CONFIG_SYS_I2C_EEPROM_BUS)) return; offset = (cl_eeprom_layout != LAYOUT_LEGACY) ? @@ -96,11 +102,11 @@ void get_board_serial(struct tag_serialnr *serialnr) * Routine: cl_eeprom_read_mac_addr * Description: read mac address and store it in buf. */ -int cl_eeprom_read_mac_addr(uchar *buf) +int cl_eeprom_read_mac_addr(uchar *buf, uint eeprom_bus) { uint offset; - if (cl_eeprom_setup_layout()) + if (cl_eeprom_setup(eeprom_bus)) return 0; offset = (cl_eeprom_layout != LAYOUT_LEGACY) ? @@ -123,7 +129,7 @@ u32 cl_eeprom_get_board_rev(void) if (board_rev) return board_rev; - if (cl_eeprom_setup_layout()) + if (cl_eeprom_setup(CONFIG_SYS_I2C_EEPROM_BUS)) return 0; if (cl_eeprom_layout != LAYOUT_LEGACY) diff --git a/board/compulab/common/eeprom.h b/board/compulab/common/eeprom.h index 85d5bf0..50c6b02 100644 --- a/board/compulab/common/eeprom.h +++ b/board/compulab/common/eeprom.h @@ -11,10 +11,10 @@ #define _EEPROM_ #ifdef CONFIG_SYS_I2C -int cl_eeprom_read_mac_addr(uchar *buf); +int cl_eeprom_read_mac_addr(uchar *buf, uint eeprom_bus); u32 cl_eeprom_get_board_rev(void); #else -static inline int cl_eeprom_read_mac_addr(uchar *buf) +static inline int cl_eeprom_read_mac_addr(uchar *buf, uint eeprom_bus) { return 1; } -- cgit v1.1 From eab29802d6211aeb9cd521a51d22a43c8fb4f94d Mon Sep 17 00:00:00 2001 From: Nikita Kiryanov Date: Wed, 14 Jan 2015 10:42:44 +0200 Subject: arm: mx6: cm-fx6: pass 2nd nic mac addr to Linux Obtain 2nd NIC MAC address from baseboard EEPROM and pass it to Linux. Signed-off-by: Nikita Kiryanov Cc: Stefano Babic Cc: Igor Grinberg Acked-by: Igor Grinberg --- board/compulab/cm_fx6/cm_fx6.c | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) (limited to 'board/compulab') diff --git a/board/compulab/cm_fx6/cm_fx6.c b/board/compulab/cm_fx6/cm_fx6.c index 32f4434..eb18dfc 100644 --- a/board/compulab/cm_fx6/cm_fx6.c +++ b/board/compulab/cm_fx6/cm_fx6.c @@ -345,32 +345,36 @@ static iomux_v3_cfg_t const enet_pads[] = { MUX_PAD_CTRL(ENET_PAD_CTRL)), }; -static int handle_mac_address(void) +static int handle_mac_address(char *env_var, uint eeprom_bus) { unsigned char enetaddr[6]; int rc; - rc = eth_getenv_enetaddr("ethaddr", enetaddr); + rc = eth_getenv_enetaddr(env_var, enetaddr); if (rc) return 0; - rc = cl_eeprom_read_mac_addr(enetaddr, CONFIG_SYS_I2C_EEPROM_BUS); + rc = cl_eeprom_read_mac_addr(enetaddr, eeprom_bus); if (rc) return rc; if (!is_valid_ether_addr(enetaddr)) return -1; - return eth_setenv_enetaddr("ethaddr", enetaddr); + return eth_setenv_enetaddr(env_var, enetaddr); } +#define SB_FX6_I2C_EEPROM_BUS 0 +#define NO_MAC_ADDR "No MAC address found for %s\n" int board_eth_init(bd_t *bis) { int err; - err = handle_mac_address(); - if (err) - puts("No MAC address found\n"); + if (handle_mac_address("ethaddr", CONFIG_SYS_I2C_EEPROM_BUS)) + printf(NO_MAC_ADDR, "primary NIC"); + + if (handle_mac_address("eth1addr", SB_FX6_I2C_EEPROM_BUS)) + printf(NO_MAC_ADDR, "secondary NIC"); SETUP_IOMUX_PADS(enet_pads); /* phy reset */ @@ -469,6 +473,11 @@ int ft_board_setup(void *blob, bd_t *bd) "local-mac-address", enetaddr, 6, 1); } + if (eth_getenv_enetaddr("eth1addr", enetaddr)) { + fdt_find_and_setprop(blob, "/eth@pcie", "local-mac-address", + enetaddr, 6, 1); + } + return 0; } #endif -- cgit v1.1 From deb94d6192e7507d743aefa69a86954c0c26be82 Mon Sep 17 00:00:00 2001 From: Nikita Kiryanov Date: Wed, 14 Jan 2015 10:42:46 +0200 Subject: arm: mx6: cm-fx6: add hdmi console support Add support for hdmi console. Signed-off-by: Nikita Kiryanov Cc: Stefano Babic Cc: Igor Grinberg Acked-by: Igor Grinberg --- board/compulab/cm_fx6/cm_fx6.c | 51 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) (limited to 'board/compulab') diff --git a/board/compulab/cm_fx6/cm_fx6.c b/board/compulab/cm_fx6/cm_fx6.c index eb18dfc..b31e1f5 100644 --- a/board/compulab/cm_fx6/cm_fx6.c +++ b/board/compulab/cm_fx6/cm_fx6.c @@ -18,8 +18,10 @@ #include #include #include +#include #include #include +#include #include #include #include @@ -28,6 +30,53 @@ DECLARE_GLOBAL_DATA_PTR; +#ifdef CONFIG_IMX_HDMI +static void cm_fx6_enable_hdmi(struct display_info_t const *dev) +{ + imx_enable_hdmi_phy(); +} + +struct display_info_t const displays[] = { + { + .bus = -1, + .addr = 0, + .pixfmt = IPU_PIX_FMT_RGB24, + .detect = detect_hdmi, + .enable = cm_fx6_enable_hdmi, + .mode = { + .name = "HDMI", + .refresh = 60, + .xres = 1024, + .yres = 768, + .pixclock = 40385, + .left_margin = 220, + .right_margin = 40, + .upper_margin = 21, + .lower_margin = 7, + .hsync_len = 60, + .vsync_len = 10, + .sync = FB_SYNC_EXT, + .vmode = FB_VMODE_NONINTERLACED, + } + }, +}; +size_t display_count = ARRAY_SIZE(displays); + +static void cm_fx6_setup_display(void) +{ + struct mxc_ccm_reg *mxc_ccm = (struct mxc_ccm_reg *)CCM_BASE_ADDR; + int reg; + + enable_ipu_clock(); + imx_setup_hdmi(); + reg = __raw_readl(&mxc_ccm->CCGR3); + reg |= MXC_CCM_CCGR3_IPU1_IPU_DI0_MASK; + writel(reg, &mxc_ccm->CCGR3); +} +#else +static inline void cm_fx6_setup_display(void) {} +#endif /* CONFIG_VIDEO_IPUV3 */ + #ifdef CONFIG_DWC_AHSATA static int cm_fx6_issd_gpios[] = { /* The order of the GPIOs in the array is important! */ @@ -516,6 +565,8 @@ int board_init(void) if (ret) printf("Warning: I2C setup failed: %d\n", ret); + cm_fx6_setup_display(); + return 0; } -- cgit v1.1 From 6947e3f56f265c9bb1f3832c74630adf6286987d Mon Sep 17 00:00:00 2001 From: Nikita Kiryanov Date: Wed, 14 Jan 2015 10:42:49 +0200 Subject: compulab: splash: use errno values Use errno values to improve return reporting. Signed-off-by: Nikita Kiryanov Cc: Stefano Babic Cc: Igor Grinberg Acked-by: Igor Grinberg --- board/compulab/common/splash.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'board/compulab') diff --git a/board/compulab/common/splash.c b/board/compulab/common/splash.c index 49ed49b..33b2f9f 100644 --- a/board/compulab/common/splash.c +++ b/board/compulab/common/splash.c @@ -8,6 +8,7 @@ #include #include +#include #include DECLARE_GLOBAL_DATA_PTR; @@ -44,12 +45,12 @@ splash_address_too_high: printf("Error: splashimage address too high. Data overwrites U-Boot " "and/or placed beyond DRAM boundaries.\n"); - return -1; + return -EFAULT; } #else static inline int splash_load_from_nand(u32 bmp_load_addr, int nand_offset) { - return -1; + return -ENOSYS; } #endif /* CONFIG_CMD_NAND */ @@ -60,12 +61,12 @@ int cl_splash_screen_prepare(int nand_offset) env_splashimage_value = getenv("splashimage"); if (env_splashimage_value == NULL) - return -1; + return -ENOENT; bmp_load_addr = simple_strtoul(env_splashimage_value, 0, 16); if (bmp_load_addr == 0) { printf("Error: bad splashimage address specified\n"); - return -1; + return -EFAULT; } return splash_load_from_nand(bmp_load_addr, nand_offset); -- cgit v1.1 From 7be4cd2cc54fc494dd550b9893e784bf1f9a31b5 Mon Sep 17 00:00:00 2001 From: Nikita Kiryanov Date: Wed, 14 Jan 2015 10:42:50 +0200 Subject: compulab: splash: refactor splash.c Move storage device specific code into its own function instead of calling it directly from an otherwise storage device independent function (cl_splash_screen_prepare). This is a preparation for supporting multiple splash locations. Signed-off-by: Nikita Kiryanov Cc: Stefano Babic Cc: Igor Grinberg Acked-by: Igor Grinberg --- board/compulab/common/common.h | 4 ++-- board/compulab/common/splash.c | 43 +++++++++++++++++++++++++----------------- 2 files changed, 28 insertions(+), 19 deletions(-) (limited to 'board/compulab') diff --git a/board/compulab/common/common.h b/board/compulab/common/common.h index 68ffb11..80753b4 100644 --- a/board/compulab/common/common.h +++ b/board/compulab/common/common.h @@ -25,9 +25,9 @@ static inline void cl_usb_hub_deinit(int gpio) {} #endif /* CONFIG_CMD_USB */ #ifdef CONFIG_SPLASH_SCREEN -int cl_splash_screen_prepare(int nand_offset); +int cl_splash_screen_prepare(int offset); #else /* !CONFIG_SPLASH_SCREEN */ -static inline int cl_splash_screen_prepare(int nand_offset) +static inline int cl_splash_screen_prepare(int offset) { return -ENOSYS; } diff --git a/board/compulab/common/splash.c b/board/compulab/common/splash.c index 33b2f9f..09a0755 100644 --- a/board/compulab/common/splash.c +++ b/board/compulab/common/splash.c @@ -10,11 +10,32 @@ #include #include #include +#include "common.h" DECLARE_GLOBAL_DATA_PTR; #ifdef CONFIG_CMD_NAND -static int splash_load_from_nand(u32 bmp_load_addr, int nand_offset) +static int splash_nand_read(u32 bmp_load_addr, int offset, size_t read_size) +{ + return nand_read_skip_bad(&nand_info[nand_curr_device], offset, + &read_size, NULL, + nand_info[nand_curr_device].size, + (u_char *)bmp_load_addr); +} +#else +static int splash_nand_read(u32 bmp_load_addr, int offset, size_t read_size) +{ + debug("%s: nand support not available\n", __func__); + return -ENOSYS; +} +#endif + +static int splash_storage_read(u32 bmp_load_addr, int offset, size_t read_size) +{ + return splash_nand_read(bmp_load_addr, offset, read_size); +} + +static int splash_load_raw(u32 bmp_load_addr, int offset) { struct bmp_header *bmp_hdr; int res; @@ -23,10 +44,7 @@ static int splash_load_from_nand(u32 bmp_load_addr, int nand_offset) if (bmp_load_addr + bmp_header_size >= gd->start_addr_sp) goto splash_address_too_high; - res = nand_read_skip_bad(&nand_info[nand_curr_device], - nand_offset, &bmp_header_size, - NULL, nand_info[nand_curr_device].size, - (u_char *)bmp_load_addr); + res = splash_storage_read(bmp_load_addr, offset, bmp_header_size); if (res < 0) return res; @@ -36,10 +54,7 @@ static int splash_load_from_nand(u32 bmp_load_addr, int nand_offset) if (bmp_load_addr + bmp_size >= gd->start_addr_sp) goto splash_address_too_high; - return nand_read_skip_bad(&nand_info[nand_curr_device], - nand_offset, &bmp_size, - NULL, nand_info[nand_curr_device].size, - (u_char *)bmp_load_addr); + return splash_storage_read(bmp_load_addr, offset, bmp_size); splash_address_too_high: printf("Error: splashimage address too high. Data overwrites U-Boot " @@ -47,14 +62,8 @@ splash_address_too_high: return -EFAULT; } -#else -static inline int splash_load_from_nand(u32 bmp_load_addr, int nand_offset) -{ - return -ENOSYS; -} -#endif /* CONFIG_CMD_NAND */ -int cl_splash_screen_prepare(int nand_offset) +int cl_splash_screen_prepare(int offset) { char *env_splashimage_value; u32 bmp_load_addr; @@ -69,5 +78,5 @@ int cl_splash_screen_prepare(int nand_offset) return -EFAULT; } - return splash_load_from_nand(bmp_load_addr, nand_offset); + return splash_load_raw(bmp_load_addr, offset); } -- cgit v1.1 From fd29dd554af6e88ff6d794886e5ab7ba176ace17 Mon Sep 17 00:00:00 2001 From: Nikita Kiryanov Date: Wed, 14 Jan 2015 10:42:51 +0200 Subject: compulab: splash: support multiple splash sources Define a generic way for boards to define splash image locations: - introduce struct splash_location - introduce enum splash_storage - update cl_splash_screen_prepare() to take an array of above struct and select the appropriate one based on the splashsource environment variable (if it is not defined- use the first splash location as default). cm-t35 is updated to work with the new interface. Signed-off-by: Nikita Kiryanov Cc: Stefano Babic Cc: Igor Grinberg Acked-by: Igor Grinberg --- board/compulab/cm_t35/cm_t35.c | 11 +++++-- board/compulab/common/common.h | 15 +++++++-- board/compulab/common/splash.c | 70 +++++++++++++++++++++++++++++++++++++----- 3 files changed, 85 insertions(+), 11 deletions(-) (limited to 'board/compulab') diff --git a/board/compulab/cm_t35/cm_t35.c b/board/compulab/cm_t35/cm_t35.c index 9a3b2ee..8143c05 100644 --- a/board/compulab/cm_t35/cm_t35.c +++ b/board/compulab/cm_t35/cm_t35.c @@ -59,11 +59,18 @@ void get_board_mem_timings(struct board_sdrc_timings *timings) } #endif -#define CM_T35_SPLASH_NAND_OFFSET 0x100000 +struct splash_location splash_locations[] = { + { + .name = "nand", + .storage = SPLASH_STORAGE_NAND, + .offset = 0x100000, + }, +}; int splash_screen_prepare(void) { - return cl_splash_screen_prepare(CM_T35_SPLASH_NAND_OFFSET); + return cl_splash_screen_prepare(splash_locations, + ARRAY_SIZE(splash_locations)); } /* diff --git a/board/compulab/common/common.h b/board/compulab/common/common.h index 80753b4..09b4de6 100644 --- a/board/compulab/common/common.h +++ b/board/compulab/common/common.h @@ -24,10 +24,21 @@ static inline int cl_usb_hub_init(int gpio, const char *label) static inline void cl_usb_hub_deinit(int gpio) {} #endif /* CONFIG_CMD_USB */ +enum splash_storage { + SPLASH_STORAGE_NAND, +}; + +struct splash_location { + char *name; + enum splash_storage storage; + u32 offset; /* offset from start of storage */ +}; + #ifdef CONFIG_SPLASH_SCREEN -int cl_splash_screen_prepare(int offset); +int cl_splash_screen_prepare(struct splash_location *locations, uint size); #else /* !CONFIG_SPLASH_SCREEN */ -static inline int cl_splash_screen_prepare(int offset) +static inline int cl_splash_screen_prepare(struct splash_location *locations, + uint size) { return -ENOSYS; } diff --git a/board/compulab/common/splash.c b/board/compulab/common/splash.c index 09a0755..f230d6d 100644 --- a/board/compulab/common/splash.c +++ b/board/compulab/common/splash.c @@ -30,12 +30,26 @@ static int splash_nand_read(u32 bmp_load_addr, int offset, size_t read_size) } #endif -static int splash_storage_read(u32 bmp_load_addr, int offset, size_t read_size) +static int splash_storage_read(struct splash_location *location, + u32 bmp_load_addr, size_t read_size) { - return splash_nand_read(bmp_load_addr, offset, read_size); + u32 offset; + + if (!location) + return -EINVAL; + + offset = location->offset; + switch (location->storage) { + case SPLASH_STORAGE_NAND: + return splash_nand_read(bmp_load_addr, offset, read_size); + default: + printf("Unknown splash location\n"); + } + + return -EINVAL; } -static int splash_load_raw(u32 bmp_load_addr, int offset) +static int splash_load_raw(struct splash_location *location, u32 bmp_load_addr) { struct bmp_header *bmp_hdr; int res; @@ -44,7 +58,7 @@ static int splash_load_raw(u32 bmp_load_addr, int offset) if (bmp_load_addr + bmp_header_size >= gd->start_addr_sp) goto splash_address_too_high; - res = splash_storage_read(bmp_load_addr, offset, bmp_header_size); + res = splash_storage_read(location, bmp_load_addr, bmp_header_size); if (res < 0) return res; @@ -54,7 +68,7 @@ static int splash_load_raw(u32 bmp_load_addr, int offset) if (bmp_load_addr + bmp_size >= gd->start_addr_sp) goto splash_address_too_high; - return splash_storage_read(bmp_load_addr, offset, bmp_size); + return splash_storage_read(location, bmp_load_addr, bmp_size); splash_address_too_high: printf("Error: splashimage address too high. Data overwrites U-Boot " @@ -63,8 +77,46 @@ splash_address_too_high: return -EFAULT; } -int cl_splash_screen_prepare(int offset) +/** + * select_splash_location - return the splash location based on board support + * and env variable "splashsource". + * + * @locations: An array of supported splash locations. + * @size: Size of splash_locations array. + * + * @return: If a null set of splash locations is given, or + * splashsource env variable is set to unsupported value + * return NULL. + * If splashsource env variable is not defined + * return the first entry in splash_locations as default. + * If splashsource env variable contains a supported value + * return the location selected by splashsource. + */ +static struct splash_location *select_splash_location( + struct splash_location *locations, uint size) +{ + int i; + char *env_splashsource; + + if (!locations || size == 0) + return NULL; + + env_splashsource = getenv("splashsource"); + if (env_splashsource == NULL) + return &locations[0]; + + for (i = 0; i < size; i++) { + if (!strcmp(locations[i].name, env_splashsource)) + return &locations[i]; + } + + printf("splashsource env variable set to unsupported value\n"); + return NULL; +} + +int cl_splash_screen_prepare(struct splash_location *locations, uint size) { + struct splash_location *splash_location; char *env_splashimage_value; u32 bmp_load_addr; @@ -78,5 +130,9 @@ int cl_splash_screen_prepare(int offset) return -EFAULT; } - return splash_load_raw(bmp_load_addr, offset); + splash_location = select_splash_location(locations, size); + if (!splash_location) + return -EINVAL; + + return splash_load_raw(splash_location, bmp_load_addr); } -- cgit v1.1 From 7e8d7f2ac2035efa04382bbeede1b4fbe1c66987 Mon Sep 17 00:00:00 2001 From: Nikita Kiryanov Date: Wed, 14 Jan 2015 10:42:52 +0200 Subject: compulab: splash: support loading splash from sf Add support for loading splash from sf. Signed-off-by: Nikita Kiryanov [grinberg@compulab.co.il: staticize the sf global variable] Signed-off-by: Igor Grinberg Cc: Stefano Babic Cc: Igor Grinberg --- board/compulab/common/common.h | 1 + board/compulab/common/splash.c | 27 +++++++++++++++++++++++++++ 2 files changed, 28 insertions(+) (limited to 'board/compulab') diff --git a/board/compulab/common/common.h b/board/compulab/common/common.h index 09b4de6..b992965 100644 --- a/board/compulab/common/common.h +++ b/board/compulab/common/common.h @@ -26,6 +26,7 @@ static inline void cl_usb_hub_deinit(int gpio) {} enum splash_storage { SPLASH_STORAGE_NAND, + SPLASH_STORAGE_SF, }; struct splash_location { diff --git a/board/compulab/common/splash.c b/board/compulab/common/splash.c index f230d6d..16c315c 100644 --- a/board/compulab/common/splash.c +++ b/board/compulab/common/splash.c @@ -9,11 +9,36 @@ #include #include #include +#include +#include #include #include "common.h" DECLARE_GLOBAL_DATA_PTR; +#ifdef CONFIG_SPI_FLASH +static struct spi_flash *sf; +static int splash_sf_read(u32 bmp_load_addr, int offset, size_t read_size) +{ + if (!sf) { + sf = spi_flash_probe(CONFIG_SF_DEFAULT_BUS, + CONFIG_SF_DEFAULT_CS, + CONFIG_SF_DEFAULT_SPEED, + CONFIG_SF_DEFAULT_MODE); + if (!sf) + return -ENODEV; + } + + return spi_flash_read(sf, offset, read_size, (void *)bmp_load_addr); +} +#else +static int splash_sf_read(u32 bmp_load_addr, int offset, size_t read_size) +{ + debug("%s: sf support not available\n", __func__); + return -ENOSYS; +} +#endif + #ifdef CONFIG_CMD_NAND static int splash_nand_read(u32 bmp_load_addr, int offset, size_t read_size) { @@ -42,6 +67,8 @@ static int splash_storage_read(struct splash_location *location, switch (location->storage) { case SPLASH_STORAGE_NAND: return splash_nand_read(bmp_load_addr, offset, read_size); + case SPLASH_STORAGE_SF: + return splash_sf_read(bmp_load_addr, offset, read_size); default: printf("Unknown splash location\n"); } -- cgit v1.1 From 3a236a356397449bf3ad1e72221053b5a3d87b80 Mon Sep 17 00:00:00 2001 From: Nikita Kiryanov Date: Wed, 14 Jan 2015 10:42:53 +0200 Subject: arm: mx6: cm-fx6: add splash screen support Add support for splash screen. The splash screen is loaded from the SPI flash and is displayed on the HDMI display. Signed-off-by: Nikita Kiryanov [grinberg@compulab.co.il: minor code and commit message updates] Signed-off-by: Igor Grinberg Cc: Stefano Babic Cc: Igor Grinberg --- board/compulab/cm_fx6/cm_fx6.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'board/compulab') diff --git a/board/compulab/cm_fx6/cm_fx6.c b/board/compulab/cm_fx6/cm_fx6.c index b31e1f5..b5c3ea1 100644 --- a/board/compulab/cm_fx6/cm_fx6.c +++ b/board/compulab/cm_fx6/cm_fx6.c @@ -27,9 +27,26 @@ #include #include "common.h" #include "../common/eeprom.h" +#include "../common/common.h" DECLARE_GLOBAL_DATA_PTR; +#ifdef CONFIG_SPLASH_SCREEN +static struct splash_location cm_fx6_splash_locations[] = { + { + .name = "sf", + .storage = SPLASH_STORAGE_SF, + .offset = 0x100000, + }, +}; + +int splash_screen_prepare(void) +{ + return cl_splash_screen_prepare(cm_fx6_splash_locations, + ARRAY_SIZE(cm_fx6_splash_locations)); +} +#endif + #ifdef CONFIG_IMX_HDMI static void cm_fx6_enable_hdmi(struct display_info_t const *dev) { -- cgit v1.1 From f82eb2fa5df86b7180ea355a3cb98482f7c27269 Mon Sep 17 00:00:00 2001 From: Nikita Kiryanov Date: Wed, 14 Jan 2015 10:42:54 +0200 Subject: common: convert compulab splash load code to common code Move board/compulab/common/splash.c code to common/splash_source.c to make it available for everybody. This move renames cl_splash_screen_prepare() to splash_source_load(), and the compilation of this code is conditional on CONFIG_SPLASH_SOURCE. splash_source features: * Provide a standardized way for declaring board specific splash screen locations * Provide existing routines for auto loading the splash image from the locations as declared by the board * Introduce the "splashsource" environment variable, which makes it possible to select the splash image source. cm-t35 and cm-fx6 are updated to use the modified version. Signed-off-by: Nikita Kiryanov Cc: Stefano Babic Cc: Tom Rini Cc: Igor Grinberg Cc: Anatolij Gustschin Reviewed-by: Tom Rini Acked-by: Igor Grinberg --- board/compulab/cm_fx6/cm_fx6.c | 5 +- board/compulab/cm_t35/cm_t35.c | 5 +- board/compulab/common/Makefile | 1 - board/compulab/common/common.h | 21 ------ board/compulab/common/splash.c | 165 ----------------------------------------- 5 files changed, 6 insertions(+), 191 deletions(-) delete mode 100644 board/compulab/common/splash.c (limited to 'board/compulab') diff --git a/board/compulab/cm_fx6/cm_fx6.c b/board/compulab/cm_fx6/cm_fx6.c index b5c3ea1..ae6945b 100644 --- a/board/compulab/cm_fx6/cm_fx6.c +++ b/board/compulab/cm_fx6/cm_fx6.c @@ -15,6 +15,7 @@ #include #include #include +#include #include #include #include @@ -42,8 +43,8 @@ static struct splash_location cm_fx6_splash_locations[] = { int splash_screen_prepare(void) { - return cl_splash_screen_prepare(cm_fx6_splash_locations, - ARRAY_SIZE(cm_fx6_splash_locations)); + return splash_source_load(cm_fx6_splash_locations, + ARRAY_SIZE(cm_fx6_splash_locations)); } #endif diff --git a/board/compulab/cm_t35/cm_t35.c b/board/compulab/cm_t35/cm_t35.c index 8143c05..c4ea8ea 100644 --- a/board/compulab/cm_t35/cm_t35.c +++ b/board/compulab/cm_t35/cm_t35.c @@ -19,6 +19,7 @@ #include #include #include +#include #include #include @@ -69,8 +70,8 @@ struct splash_location splash_locations[] = { int splash_screen_prepare(void) { - return cl_splash_screen_prepare(splash_locations, - ARRAY_SIZE(splash_locations)); + return splash_source_load(splash_locations, + ARRAY_SIZE(splash_locations)); } /* diff --git a/board/compulab/common/Makefile b/board/compulab/common/Makefile index dbf0009..286f327 100644 --- a/board/compulab/common/Makefile +++ b/board/compulab/common/Makefile @@ -9,5 +9,4 @@ obj-y += common.o obj-$(CONFIG_SYS_I2C) += eeprom.o obj-$(CONFIG_LCD) += omap3_display.o -obj-$(CONFIG_SPLASH_SCREEN) += splash.o obj-$(CONFIG_SMC911X) += omap3_smc911x.o diff --git a/board/compulab/common/common.h b/board/compulab/common/common.h index b992965..8f38b79 100644 --- a/board/compulab/common/common.h +++ b/board/compulab/common/common.h @@ -24,27 +24,6 @@ static inline int cl_usb_hub_init(int gpio, const char *label) static inline void cl_usb_hub_deinit(int gpio) {} #endif /* CONFIG_CMD_USB */ -enum splash_storage { - SPLASH_STORAGE_NAND, - SPLASH_STORAGE_SF, -}; - -struct splash_location { - char *name; - enum splash_storage storage; - u32 offset; /* offset from start of storage */ -}; - -#ifdef CONFIG_SPLASH_SCREEN -int cl_splash_screen_prepare(struct splash_location *locations, uint size); -#else /* !CONFIG_SPLASH_SCREEN */ -static inline int cl_splash_screen_prepare(struct splash_location *locations, - uint size) -{ - return -ENOSYS; -} -#endif /* CONFIG_SPLASH_SCREEN */ - #ifdef CONFIG_SMC911X int cl_omap3_smc911x_init(int id, int cs, u32 base_addr, int (*reset)(int), int rst_gpio); diff --git a/board/compulab/common/splash.c b/board/compulab/common/splash.c deleted file mode 100644 index 16c315c..0000000 --- a/board/compulab/common/splash.c +++ /dev/null @@ -1,165 +0,0 @@ -/* - * (C) Copyright 2014 CompuLab, Ltd. - * - * Authors: Igor Grinberg - * - * SPDX-License-Identifier: GPL-2.0+ - */ - -#include -#include -#include -#include -#include -#include -#include "common.h" - -DECLARE_GLOBAL_DATA_PTR; - -#ifdef CONFIG_SPI_FLASH -static struct spi_flash *sf; -static int splash_sf_read(u32 bmp_load_addr, int offset, size_t read_size) -{ - if (!sf) { - sf = spi_flash_probe(CONFIG_SF_DEFAULT_BUS, - CONFIG_SF_DEFAULT_CS, - CONFIG_SF_DEFAULT_SPEED, - CONFIG_SF_DEFAULT_MODE); - if (!sf) - return -ENODEV; - } - - return spi_flash_read(sf, offset, read_size, (void *)bmp_load_addr); -} -#else -static int splash_sf_read(u32 bmp_load_addr, int offset, size_t read_size) -{ - debug("%s: sf support not available\n", __func__); - return -ENOSYS; -} -#endif - -#ifdef CONFIG_CMD_NAND -static int splash_nand_read(u32 bmp_load_addr, int offset, size_t read_size) -{ - return nand_read_skip_bad(&nand_info[nand_curr_device], offset, - &read_size, NULL, - nand_info[nand_curr_device].size, - (u_char *)bmp_load_addr); -} -#else -static int splash_nand_read(u32 bmp_load_addr, int offset, size_t read_size) -{ - debug("%s: nand support not available\n", __func__); - return -ENOSYS; -} -#endif - -static int splash_storage_read(struct splash_location *location, - u32 bmp_load_addr, size_t read_size) -{ - u32 offset; - - if (!location) - return -EINVAL; - - offset = location->offset; - switch (location->storage) { - case SPLASH_STORAGE_NAND: - return splash_nand_read(bmp_load_addr, offset, read_size); - case SPLASH_STORAGE_SF: - return splash_sf_read(bmp_load_addr, offset, read_size); - default: - printf("Unknown splash location\n"); - } - - return -EINVAL; -} - -static int splash_load_raw(struct splash_location *location, u32 bmp_load_addr) -{ - struct bmp_header *bmp_hdr; - int res; - size_t bmp_size, bmp_header_size = sizeof(struct bmp_header); - - if (bmp_load_addr + bmp_header_size >= gd->start_addr_sp) - goto splash_address_too_high; - - res = splash_storage_read(location, bmp_load_addr, bmp_header_size); - if (res < 0) - return res; - - bmp_hdr = (struct bmp_header *)bmp_load_addr; - bmp_size = le32_to_cpu(bmp_hdr->file_size); - - if (bmp_load_addr + bmp_size >= gd->start_addr_sp) - goto splash_address_too_high; - - return splash_storage_read(location, bmp_load_addr, bmp_size); - -splash_address_too_high: - printf("Error: splashimage address too high. Data overwrites U-Boot " - "and/or placed beyond DRAM boundaries.\n"); - - return -EFAULT; -} - -/** - * select_splash_location - return the splash location based on board support - * and env variable "splashsource". - * - * @locations: An array of supported splash locations. - * @size: Size of splash_locations array. - * - * @return: If a null set of splash locations is given, or - * splashsource env variable is set to unsupported value - * return NULL. - * If splashsource env variable is not defined - * return the first entry in splash_locations as default. - * If splashsource env variable contains a supported value - * return the location selected by splashsource. - */ -static struct splash_location *select_splash_location( - struct splash_location *locations, uint size) -{ - int i; - char *env_splashsource; - - if (!locations || size == 0) - return NULL; - - env_splashsource = getenv("splashsource"); - if (env_splashsource == NULL) - return &locations[0]; - - for (i = 0; i < size; i++) { - if (!strcmp(locations[i].name, env_splashsource)) - return &locations[i]; - } - - printf("splashsource env variable set to unsupported value\n"); - return NULL; -} - -int cl_splash_screen_prepare(struct splash_location *locations, uint size) -{ - struct splash_location *splash_location; - char *env_splashimage_value; - u32 bmp_load_addr; - - env_splashimage_value = getenv("splashimage"); - if (env_splashimage_value == NULL) - return -ENOENT; - - bmp_load_addr = simple_strtoul(env_splashimage_value, 0, 16); - if (bmp_load_addr == 0) { - printf("Error: bad splashimage address specified\n"); - return -EFAULT; - } - - splash_location = select_splash_location(locations, size); - if (!splash_location) - return -EINVAL; - - return splash_load_raw(splash_location, bmp_load_addr); -} -- cgit v1.1