From 6d0bdfdde58b4df825b67dc58b3a948deea268e0 Mon Sep 17 00:00:00 2001 From: Hans de Goede <hdegoede@redhat.com> Date: Sun, 13 Sep 2015 12:31:24 +0200 Subject: sunxi: Switch to using malloc_simple for the spl common/dlmalloc.c is quite big, both in .text and .data usage. E.g. for a Mele_M9 sun6i board build this reduces .text from 0x4214 to 0x3b94 bytes, and .data from 0x54c to 0x144 bytes. Signed-off-by: Hans de Goede <hdegoede@redhat.com> Acked-by: Ian Campbell <ijc@hellion.org.uk> Reviewed-by: Tom Rini <trini@konsulko.com> --- arch/arm/cpu/armv7/sunxi/board.c | 1 + 1 file changed, 1 insertion(+) (limited to 'arch/arm/cpu/armv7') diff --git a/arch/arm/cpu/armv7/sunxi/board.c b/arch/arm/cpu/armv7/sunxi/board.c index d11365b65b..1d79ba1126 100644 --- a/arch/arm/cpu/armv7/sunxi/board.c +++ b/arch/arm/cpu/armv7/sunxi/board.c @@ -192,6 +192,7 @@ u32 spl_boot_mode(void) void board_init_f(ulong dummy) { + spl_init(); preloader_console_init(); #ifdef CONFIG_SPL_I2C_SUPPORT -- cgit From 6944aff1ca91e8cf2c373193982cbb0417b4d4cc Mon Sep 17 00:00:00 2001 From: Hans de Goede <hdegoede@redhat.com> Date: Sat, 3 Oct 2015 15:18:33 +0200 Subject: sunxi: power: Unify axp pmic function names Stop prefixing the axp functions for setting voltages, etc. with the model number, there ever is only one pmic driver built into u-boot, this allows simplifying the callers. Signed-off-by: Hans de Goede <hdegoede@redhat.com> Acked-by: Ian Campbell <ijc@hellion.org.uk> --- arch/arm/cpu/armv7/sunxi/cpu_info.c | 4 ++-- arch/arm/cpu/armv7/sunxi/usb_phy.c | 9 --------- 2 files changed, 2 insertions(+), 11 deletions(-) (limited to 'arch/arm/cpu/armv7') diff --git a/arch/arm/cpu/armv7/sunxi/cpu_info.c b/arch/arm/cpu/armv7/sunxi/cpu_info.c index a276fad316..05fef3216d 100644 --- a/arch/arm/cpu/armv7/sunxi/cpu_info.c +++ b/arch/arm/cpu/armv7/sunxi/cpu_info.c @@ -10,7 +10,7 @@ #include <asm/io.h> #include <asm/arch/cpu.h> #include <asm/arch/clock.h> -#include <axp221.h> +#include <axp_pmic.h> #include <errno.h> #ifdef CONFIG_MACH_SUN6I @@ -82,7 +82,7 @@ int print_cpuinfo(void) int sunxi_get_sid(unsigned int *sid) { #ifdef CONFIG_AXP221_POWER - return axp221_get_sid(sid); + return axp_get_sid(sid); #elif defined SUNXI_SID_BASE int i; diff --git a/arch/arm/cpu/armv7/sunxi/usb_phy.c b/arch/arm/cpu/armv7/sunxi/usb_phy.c index b7ca5d423a..19bb5a1fe5 100644 --- a/arch/arm/cpu/armv7/sunxi/usb_phy.c +++ b/arch/arm/cpu/armv7/sunxi/usb_phy.c @@ -17,15 +17,6 @@ #include <asm/gpio.h> #include <asm/io.h> #include <errno.h> -#ifdef CONFIG_AXP152_POWER -#include <axp152.h> -#endif -#ifdef CONFIG_AXP209_POWER -#include <axp209.h> -#endif -#ifdef CONFIG_AXP221_POWER -#include <axp221.h> -#endif #define SUNXI_USB_PMU_IRQ_ENABLE 0x800 #ifdef CONFIG_MACH_SUN8I_A33 -- cgit From f7d6b3cc1686f2fc6ea4c28590710c89bedd3a55 Mon Sep 17 00:00:00 2001 From: Maxime Ripard <maxime.ripard@free-electrons.com> Date: Thu, 15 Oct 2015 22:04:06 +0200 Subject: sunxi: board: Only try to use the MMC related functions if enabled So far, even if CONFIG_MMC was not enabled the board code was trying to use the MMC-related functions, resulting in linker errors. Protect those calls by an ifdef. Signed-off-by: Maxime Ripard <maxime.ripard@free-electrons.com> Reviewed-by: Hans de Goede <hdegoede@redhat.com> Signed-off-by: Hans de Goede <hdegoede@redhat.com> --- arch/arm/cpu/armv7/sunxi/board.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'arch/arm/cpu/armv7') diff --git a/arch/arm/cpu/armv7/sunxi/board.c b/arch/arm/cpu/armv7/sunxi/board.c index 1d79ba1126..4785ac68a9 100644 --- a/arch/arm/cpu/armv7/sunxi/board.c +++ b/arch/arm/cpu/armv7/sunxi/board.c @@ -136,7 +136,7 @@ DECLARE_GLOBAL_DATA_PTR; */ u32 spl_boot_device(void) { - struct mmc *mmc0, *mmc1; + __maybe_unused struct mmc *mmc0, *mmc1; /* * When booting from the SD card or NAND memory, the "eGON.BT0" * signature is expected to be found in memory at the address 0x0004 @@ -157,15 +157,18 @@ u32 spl_boot_device(void) return BOOT_DEVICE_BOARD; /* The BROM will try to boot from mmc0 first, so try that first. */ +#ifdef CONFIG_MMC mmc_initialize(gd->bd); mmc0 = find_mmc_device(0); if (sunxi_mmc_has_egon_boot_signature(mmc0)) return BOOT_DEVICE_MMC1; +#endif /* Fallback to booting NAND if enabled. */ if (IS_ENABLED(CONFIG_SPL_NAND_SUPPORT)) return BOOT_DEVICE_NAND; +#ifdef CONFIG_MMC if (CONFIG_MMC_SUNXI_SLOT_EXTRA == 2) { mmc1 = find_mmc_device(1); if (sunxi_mmc_has_egon_boot_signature(mmc1)) { @@ -179,6 +182,7 @@ u32 spl_boot_device(void) return BOOT_DEVICE_MMC2; } } +#endif panic("Could not determine boot source\n"); return -1; /* Never reached */ -- cgit From 72931b15e7a49840a3c439096e4966400e60c65e Mon Sep 17 00:00:00 2001 From: Paul Kocialkowski <contact@paulk.fr> Date: Thu, 27 Aug 2015 19:37:08 +0200 Subject: omap-common: Common omap_die_id definition This introduces a common definition for omap_die_id, that aims at providing a common interface for accessing omap platform's die id bits. Signed-off-by: Paul Kocialkowski <contact@paulk.fr> Reviewed-by: Tom Rini <trini@konsulko.com> --- arch/arm/cpu/armv7/omap-common/utils.c | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'arch/arm/cpu/armv7') diff --git a/arch/arm/cpu/armv7/omap-common/utils.c b/arch/arm/cpu/armv7/omap-common/utils.c index df5f817baa..acff16bd3a 100644 --- a/arch/arm/cpu/armv7/omap-common/utils.c +++ b/arch/arm/cpu/armv7/omap-common/utils.c @@ -41,6 +41,11 @@ void cancel_out(u32 *num, u32 *den, u32 den_limit) } } +__weak void omap_die_id(unsigned int *die_id) +{ + die_id[0] = die_id[1] = die_id[2] = die_id[3] = 0; +} + void __weak usb_fake_mac_from_die_id(u32 *id) { uint8_t device_mac[6]; -- cgit From b50a7685283b66623a6acb60329c57caa78795f5 Mon Sep 17 00:00:00 2001 From: Paul Kocialkowski <contact@paulk.fr> Date: Thu, 27 Aug 2015 19:37:09 +0200 Subject: omap3: omap_die_id support This replaces the previous get_dieid definition with omap_die_id, that matches the common omap_die_id definition. Signed-off-by: Paul Kocialkowski <contact@paulk.fr> Reviewed-by: Tom Rini <trini@konsulko.com> --- arch/arm/cpu/armv7/omap3/sys_info.c | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) (limited to 'arch/arm/cpu/armv7') diff --git a/arch/arm/cpu/armv7/omap3/sys_info.c b/arch/arm/cpu/armv7/omap3/sys_info.c index ab60a03415..497dc1392a 100644 --- a/arch/arm/cpu/armv7/omap3/sys_info.c +++ b/arch/arm/cpu/armv7/omap3/sys_info.c @@ -42,17 +42,14 @@ static char *rev_s_37xx[CPU_37XX_MAX_REV] = { "1.2"}; #endif /* CONFIG_DISPLAY_CPUINFO */ -/***************************************************************** - * get_dieid(u32 *id) - read die ID - *****************************************************************/ -void get_dieid(u32 *id) +void omap_die_id(unsigned int *die_id) { struct ctrl_id *id_base = (struct ctrl_id *)OMAP34XX_ID_L4_IO_BASE; - id[3] = readl(&id_base->die_id_0); - id[2] = readl(&id_base->die_id_1); - id[1] = readl(&id_base->die_id_2); - id[0] = readl(&id_base->die_id_3); + die_id[0] = readl(&id_base->die_id_0); + die_id[1] = readl(&id_base->die_id_1); + die_id[2] = readl(&id_base->die_id_2); + die_id[3] = readl(&id_base->die_id_3); } /***************************************************************** @@ -68,7 +65,7 @@ void dieid_num_r(void) uid_s = getenv("dieid#"); if (uid_s == NULL) { - get_dieid(id); + omap_die_id(id); sprintf(die_id, "%08x%08x%08x%08x", id[0], id[1], id[2], id[3]); setenv("dieid#", die_id); uid_s = die_id; -- cgit From 987a40d52ea617ee609fafcee5463274983d2827 Mon Sep 17 00:00:00 2001 From: Paul Kocialkowski <contact@paulk.fr> Date: Thu, 27 Aug 2015 19:37:10 +0200 Subject: omap4: omap_die_id support This introduces omap4 support for omap_die_id, which matches the common omap_die_id definition. It replaces board-specific code to grab the die id bits. Signed-off-by: Paul Kocialkowski <contact@paulk.fr> Reviewed-by: Tom Rini <trini@konsulko.com> --- arch/arm/cpu/armv7/omap4/hwinit.c | 8 ++++++++ arch/arm/cpu/armv7/omap4/prcm-regs.c | 5 ++++- 2 files changed, 12 insertions(+), 1 deletion(-) (limited to 'arch/arm/cpu/armv7') diff --git a/arch/arm/cpu/armv7/omap4/hwinit.c b/arch/arm/cpu/armv7/omap4/hwinit.c index a68947faf1..7c6638ca80 100644 --- a/arch/arm/cpu/armv7/omap4/hwinit.c +++ b/arch/arm/cpu/armv7/omap4/hwinit.c @@ -156,6 +156,14 @@ void init_omap_revision(void) } } +void omap_die_id(unsigned int *die_id) +{ + die_id[0] = readl((*ctrl)->control_std_fuse_die_id_0); + die_id[1] = readl((*ctrl)->control_std_fuse_die_id_1); + die_id[2] = readl((*ctrl)->control_std_fuse_die_id_2); + die_id[3] = readl((*ctrl)->control_std_fuse_die_id_3); +} + #ifndef CONFIG_SYS_L2CACHE_OFF void v7_outer_cache_enable(void) { diff --git a/arch/arm/cpu/armv7/omap4/prcm-regs.c b/arch/arm/cpu/armv7/omap4/prcm-regs.c index 8698ec7a48..a09581e55b 100644 --- a/arch/arm/cpu/armv7/omap4/prcm-regs.c +++ b/arch/arm/cpu/armv7/omap4/prcm-regs.c @@ -280,7 +280,10 @@ struct prcm_regs const omap4_prcm = { struct omap_sys_ctrl_regs const omap4_ctrl = { .control_status = 0x4A0022C4, - .control_id_code = 0x4A002204, + .control_std_fuse_die_id_0 = 0x4A002200, + .control_std_fuse_die_id_1 = 0x4A002208, + .control_std_fuse_die_id_2 = 0x4A00220C, + .control_std_fuse_die_id_3 = 0x4A002210, .control_std_fuse_opp_bgap = 0x4a002260, .control_status = 0x4a0022c4, .control_ldosram_iva_voltage_ctrl = 0x4A002320, -- cgit From 9fd5401659c34b9b07f5d729ad35611b002830ff Mon Sep 17 00:00:00 2001 From: Paul Kocialkowski <contact@paulk.fr> Date: Thu, 27 Aug 2015 19:37:11 +0200 Subject: omap5: omap_die_id support This introduces omap5 support for omap_die_id, which matches the common omap_die_id definition. It replaces board-specific code to grab the die id bits. Signed-off-by: Paul Kocialkowski <contact@paulk.fr> Reviewed-by: Tom Rini <trini@konsulko.com> --- arch/arm/cpu/armv7/omap5/hwinit.c | 8 ++++++++ arch/arm/cpu/armv7/omap5/prcm-regs.c | 4 ++++ 2 files changed, 12 insertions(+) (limited to 'arch/arm/cpu/armv7') diff --git a/arch/arm/cpu/armv7/omap5/hwinit.c b/arch/arm/cpu/armv7/omap5/hwinit.c index 325a7e85c7..8f184df2ab 100644 --- a/arch/arm/cpu/armv7/omap5/hwinit.c +++ b/arch/arm/cpu/armv7/omap5/hwinit.c @@ -379,6 +379,14 @@ void init_omap_revision(void) init_cpu_configuration(); } +void omap_die_id(unsigned int *die_id) +{ + die_id[0] = readl((*ctrl)->control_std_fuse_die_id_0); + die_id[1] = readl((*ctrl)->control_std_fuse_die_id_1); + die_id[2] = readl((*ctrl)->control_std_fuse_die_id_2); + die_id[3] = readl((*ctrl)->control_std_fuse_die_id_3); +} + void reset_cpu(ulong ignored) { u32 omap_rev = omap_revision(); diff --git a/arch/arm/cpu/armv7/omap5/prcm-regs.c b/arch/arm/cpu/armv7/omap5/prcm-regs.c index ea659bdc71..cd289ddd2b 100644 --- a/arch/arm/cpu/armv7/omap5/prcm-regs.c +++ b/arch/arm/cpu/armv7/omap5/prcm-regs.c @@ -298,6 +298,10 @@ struct prcm_regs const omap5_es1_prcm = { struct omap_sys_ctrl_regs const omap5_ctrl = { .control_status = 0x4A002134, .control_std_fuse_opp_vdd_mpu_2 = 0x4A0021B4, + .control_std_fuse_die_id_0 = 0x4A002200, + .control_std_fuse_die_id_1 = 0x4A002208, + .control_std_fuse_die_id_2 = 0x4A00220C, + .control_std_fuse_die_id_3 = 0x4A002210, .control_phy_power_usb = 0x4A002370, .control_phy_power_sata = 0x4A002374, .control_padconf_core_base = 0x4A002800, -- cgit From 07815eb9f3f742237085e3eda947e095926212b0 Mon Sep 17 00:00:00 2001 From: Paul Kocialkowski <contact@paulk.fr> Date: Thu, 27 Aug 2015 19:37:12 +0200 Subject: omap-common: Common serial and usbethaddr functions based on die id Now that we have a common prototype to grab the omap die id, functions to figure out a serial number and usb ethernet address can use it directly. Those also get an omap_die_id prefix for better consistency. Signed-off-by: Paul Kocialkowski <contact@paulk.fr> Reviewed-by: Tom Rini <trini@konsulko.com> --- arch/arm/cpu/armv7/omap-common/utils.c | 49 +++++++++++++++++++--------------- 1 file changed, 27 insertions(+), 22 deletions(-) (limited to 'arch/arm/cpu/armv7') diff --git a/arch/arm/cpu/armv7/omap-common/utils.c b/arch/arm/cpu/armv7/omap-common/utils.c index acff16bd3a..28d0f86251 100644 --- a/arch/arm/cpu/armv7/omap-common/utils.c +++ b/arch/arm/cpu/armv7/omap-common/utils.c @@ -46,35 +46,40 @@ __weak void omap_die_id(unsigned int *die_id) die_id[0] = die_id[1] = die_id[2] = die_id[3] = 0; } -void __weak usb_fake_mac_from_die_id(u32 *id) +void omap_die_id_serial(void) { - uint8_t device_mac[6]; + unsigned int die_id[4] = { 0 }; + char serial_string[17] = { 0 }; - if (!getenv("usbethaddr")) { - /* - * create a fake MAC address from the processor ID code. - * first byte is 0x02 to signify locally administered. - */ - device_mac[0] = 0x02; - device_mac[1] = id[3] & 0xff; - device_mac[2] = id[2] & 0xff; - device_mac[3] = id[1] & 0xff; - device_mac[4] = id[0] & 0xff; - device_mac[5] = (id[0] >> 8) & 0xff; + omap_die_id((unsigned int *)&die_id); - eth_setenv_enetaddr("usbethaddr", device_mac); + if (!getenv("serial#")) { + snprintf(serial_string, sizeof(serial_string), + "%08x%08x", die_id[0], die_id[3]); + + setenv("serial#", serial_string); } } -void __weak usb_set_serial_num_from_die_id(u32 *id) +void omap_die_id_usbethaddr(void) { - char serialno[72]; - uint32_t serialno_lo, serialno_hi; + unsigned int die_id[4] = { 0 }; + unsigned char mac[6] = { 0 }; - if (!getenv("serial#")) { - serialno_hi = id[0]; - serialno_lo = id[1]; - sprintf(serialno, "%08x%08x", serialno_hi, serialno_lo); - setenv("serial#", serialno); + omap_die_id((unsigned int *)&die_id); + + if (!getenv("usbethaddr")) { + /* + * Create a fake MAC address from the processor ID code. + * First byte is 0x02 to signify locally administered. + */ + mac[0] = 0x02; + mac[1] = die_id[3] & 0xff; + mac[2] = die_id[2] & 0xff; + mac[3] = die_id[1] & 0xff; + mac[4] = die_id[0] & 0xff; + mac[5] = (die_id[0] >> 8) & 0xff; + + eth_setenv_enetaddr("usbethaddr", mac); } } -- cgit From 679f82c349473c894159795c14a7fc0a8db0cd43 Mon Sep 17 00:00:00 2001 From: Paul Kocialkowski <contact@paulk.fr> Date: Thu, 27 Aug 2015 19:37:13 +0200 Subject: omap-common: Common function to display die id, replacing omap3-specific version This introduces omap_die_id_display to display the full die id. There is no need to store it in an environment variable, that no boot script is using anyway. Signed-off-by: Paul Kocialkowski <contact@paulk.fr> Reviewed-by: Tom Rini <trini@konsulko.com> --- arch/arm/cpu/armv7/omap-common/utils.c | 10 ++++++++++ arch/arm/cpu/armv7/omap3/board.c | 2 +- arch/arm/cpu/armv7/omap3/sys_info.c | 22 ---------------------- 3 files changed, 11 insertions(+), 23 deletions(-) (limited to 'arch/arm/cpu/armv7') diff --git a/arch/arm/cpu/armv7/omap-common/utils.c b/arch/arm/cpu/armv7/omap-common/utils.c index 28d0f86251..dc5a169f9a 100644 --- a/arch/arm/cpu/armv7/omap-common/utils.c +++ b/arch/arm/cpu/armv7/omap-common/utils.c @@ -83,3 +83,13 @@ void omap_die_id_usbethaddr(void) eth_setenv_enetaddr("usbethaddr", mac); } } + +void omap_die_id_display(void) +{ + unsigned int die_id[4] = { 0 }; + + omap_die_id(die_id); + + printf("OMAP die ID: %08x%08x%08x%08x", die_id[0], die_id[1], die_id[2], + die_id[3]); +} diff --git a/arch/arm/cpu/armv7/omap3/board.c b/arch/arm/cpu/armv7/omap3/board.c index 8252b322f6..0c44ea53e1 100644 --- a/arch/arm/cpu/armv7/omap3/board.c +++ b/arch/arm/cpu/armv7/omap3/board.c @@ -214,7 +214,7 @@ void board_init_f(ulong dummy) */ int __weak misc_init_r(void) { - dieid_num_r(); + omap_die_id_display(); return 0; } diff --git a/arch/arm/cpu/armv7/omap3/sys_info.c b/arch/arm/cpu/armv7/omap3/sys_info.c index 497dc1392a..6818fab253 100644 --- a/arch/arm/cpu/armv7/omap3/sys_info.c +++ b/arch/arm/cpu/armv7/omap3/sys_info.c @@ -52,28 +52,6 @@ void omap_die_id(unsigned int *die_id) die_id[3] = readl(&id_base->die_id_3); } -/***************************************************************** - * dieid_num_r(void) - read and set die ID - *****************************************************************/ -void dieid_num_r(void) -{ - char *uid_s, die_id[34]; - u32 id[4]; - - memset(die_id, 0, sizeof(die_id)); - - uid_s = getenv("dieid#"); - - if (uid_s == NULL) { - omap_die_id(id); - sprintf(die_id, "%08x%08x%08x%08x", id[0], id[1], id[2], id[3]); - setenv("dieid#", die_id); - uid_s = die_id; - } - - printf("Die ID #%s\n", uid_s); -} - /****************************************** * get_cpu_type(void) - extract cpu info ******************************************/ -- cgit From 2da87ab3539264af595d8cb2d6dc7e087f1f1ca7 Mon Sep 17 00:00:00 2001 From: Paul Kocialkowski <contact@paulk.fr> Date: Thu, 27 Aug 2015 19:37:14 +0200 Subject: omap-common: Common get_board_serial function to pass serial through ATAG Since there is a common function to grab the serial number from the die id bits, it makes sense have one to parse that serial number and feed it to the serial ATAG. Signed-off-by: Paul Kocialkowski <contact@paulk.fr> Reviewed-by: Tom Rini <trini@konsulko.com> --- arch/arm/cpu/armv7/omap-common/utils.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'arch/arm/cpu/armv7') diff --git a/arch/arm/cpu/armv7/omap-common/utils.c b/arch/arm/cpu/armv7/omap-common/utils.c index dc5a169f9a..602d993e39 100644 --- a/arch/arm/cpu/armv7/omap-common/utils.c +++ b/arch/arm/cpu/armv7/omap-common/utils.c @@ -61,6 +61,24 @@ void omap_die_id_serial(void) } } +void omap_die_id_get_board_serial(struct tag_serialnr *serialnr) +{ + char *serial_string; + unsigned long long serial; + + serial_string = getenv("serial#"); + + if (serial_string) { + serial = simple_strtoull(serial_string, NULL, 16); + + serialnr->high = (unsigned int) (serial >> 32); + serialnr->low = (unsigned int) (serial & 0xffffffff); + } else { + serialnr->high = 0; + serialnr->low = 0; + } +} + void omap_die_id_usbethaddr(void) { unsigned int die_id[4] = { 0 }; -- cgit