aboutsummaryrefslogtreecommitdiff
path: root/common
diff options
context:
space:
mode:
Diffstat (limited to 'common')
-rw-r--r--common/Makefile1
-rw-r--r--common/board_f.c31
-rw-r--r--common/board_r.c15
-rw-r--r--common/cmd_itest.c21
-rw-r--r--common/cmd_tpm.c13
-rw-r--r--common/cmd_ubi.c6
-rw-r--r--common/cmd_ubifs.c12
-rw-r--r--common/cmd_usb.c10
-rw-r--r--common/cmd_ximg.c3
-rw-r--r--common/image.c2
-rw-r--r--common/init/Makefile7
-rw-r--r--common/init/board_init.c60
-rw-r--r--common/miiphyutil.c19
-rw-r--r--common/usb_hub.c4
-rw-r--r--common/usb_storage.c2
15 files changed, 133 insertions, 73 deletions
diff --git a/common/Makefile b/common/Makefile
index 8c7775a783..d986cde7b9 100644
--- a/common/Makefile
+++ b/common/Makefile
@@ -7,6 +7,7 @@
# core
ifndef CONFIG_SPL_BUILD
+obj-y += init/
obj-y += main.o
obj-y += exports.o
obj-y += hash.o
diff --git a/common/board_f.c b/common/board_f.c
index 613332e1dc..486e828fe8 100644
--- a/common/board_f.c
+++ b/common/board_f.c
@@ -806,7 +806,7 @@ static init_fnc_t init_sequence_f[] = {
#if defined(CONFIG_BOARD_POSTCLK_INIT)
board_postclk_init,
#endif
-#ifdef CONFIG_FSL_ESDHC
+#ifdef CONFIG_FSL_CLK
get_clocks,
#endif
#ifdef CONFIG_M68K
@@ -1030,32 +1030,3 @@ void board_init_f_r(void)
hang();
}
#endif /* CONFIG_X86 */
-
-/* Unfortunately x86 can't compile this code as gd cannot be assigned */
-#ifndef CONFIG_X86
-__weak void arch_setup_gd(struct global_data *gd_ptr)
-{
- gd = gd_ptr;
-}
-#endif /* !CONFIG_X86 */
-
-ulong board_init_f_mem(ulong top)
-{
- struct global_data *gd_ptr;
-
- /* Leave space for the stack we are running with now */
- top -= 0x40;
-
- top -= sizeof(struct global_data);
- top = ALIGN(top, 16);
- gd_ptr = (struct global_data *)top;
- memset(gd_ptr, '\0', sizeof(*gd));
- arch_setup_gd(gd_ptr);
-
-#ifdef CONFIG_SYS_MALLOC_F_LEN
- top -= CONFIG_SYS_MALLOC_F_LEN;
- gd->malloc_base = top;
-#endif
-
- return top;
-}
diff --git a/common/board_r.c b/common/board_r.c
index f8c1baa949..c4fd3eaf8c 100644
--- a/common/board_r.c
+++ b/common/board_r.c
@@ -290,6 +290,9 @@ static int initr_dm(void)
/* Save the pre-reloc driver model and start a new one */
gd->dm_root_f = gd->dm_root;
gd->dm_root = NULL;
+#ifdef CONFIG_TIMER
+ gd->timer = NULL;
+#endif
return dm_init_and_scan(false);
}
#endif
@@ -446,6 +449,9 @@ static int initr_env(void)
env_relocate();
else
set_default_env(NULL);
+#ifdef CONFIG_OF_CONTROL
+ setenv_addr("fdtcontroladdr", gd->fdt_blob);
+#endif
/* Initialize from environment */
load_addr = getenv_ulong("loadaddr", 16, load_addr);
@@ -541,11 +547,14 @@ static int initr_kgdb(void)
}
#endif
-#if defined(CONFIG_STATUS_LED) && defined(STATUS_LED_BOOT)
+#if defined(CONFIG_STATUS_LED)
static int initr_status_led(void)
{
+#if defined(STATUS_LED_BOOT)
status_led_set(STATUS_LED_BOOT, STATUS_LED_BLINKING);
-
+#else
+ status_led_init();
+#endif
return 0;
}
#endif
@@ -832,7 +841,7 @@ init_fnc_t init_sequence_r[] = {
|| defined(CONFIG_M68K)
timer_init, /* initialize timer */
#endif
-#if defined(CONFIG_STATUS_LED) && defined(STATUS_LED_BOOT)
+#if defined(CONFIG_STATUS_LED)
initr_status_led,
#endif
/* PPC has a udelay(20) here dating from 2002. Why? */
diff --git a/common/cmd_itest.c b/common/cmd_itest.c
index 76af62b46e..596341c963 100644
--- a/common/cmd_itest.c
+++ b/common/cmd_itest.c
@@ -15,6 +15,9 @@
#include <common.h>
#include <config.h>
#include <command.h>
+#include <mapmem.h>
+
+#include <asm/io.h>
#define EQ 0
#define NE 1
@@ -49,16 +52,24 @@ static const op_tbl_t op_table [] = {
static long evalexp(char *s, int w)
{
long l = 0;
- long *p;
+ unsigned long addr;
+ void *buf;
/* if the parameter starts with a * then assume is a pointer to the value we want */
if (s[0] == '*') {
- p = (long *)simple_strtoul(&s[1], NULL, 16);
+ addr = simple_strtoul(&s[1], NULL, 16);
+ buf = map_physmem(addr, w, MAP_WRBACK);
+ if (!buf) {
+ puts("Failed to map physical memory\n");
+ return 0;
+ }
switch (w) {
- case 1: return((long)(*(unsigned char *)p));
- case 2: return((long)(*(unsigned short *)p));
- case 4: return(*p);
+ case 1: l = (long)(*(unsigned char *)buf);
+ case 2: l = (long)(*(unsigned short *)buf);
+ case 4: l = (long)(*(unsigned long *)buf);
}
+ unmap_physmem(buf, w);
+ return l;
} else {
l = simple_strtoul(s, NULL, 16);
}
diff --git a/common/cmd_tpm.c b/common/cmd_tpm.c
index 97501cc3d1..add6bfb416 100644
--- a/common/cmd_tpm.c
+++ b/common/cmd_tpm.c
@@ -443,7 +443,6 @@ TPM_COMMAND_NO_ARG(tpm_force_clear)
TPM_COMMAND_NO_ARG(tpm_physical_enable)
TPM_COMMAND_NO_ARG(tpm_physical_disable)
-#ifdef CONFIG_DM_TPM
static int get_tpm(struct udevice **devp)
{
int rc;
@@ -476,11 +475,11 @@ static int do_tpm_info(cmd_tbl_t *cmdtp, int flag, int argc,
return 0;
}
-#endif
static int do_tpm_raw_transfer(cmd_tbl_t *cmdtp, int flag,
int argc, char * const argv[])
{
+ struct udevice *dev;
void *command;
uint8_t response[1024];
size_t count, response_length = sizeof(response);
@@ -492,17 +491,11 @@ static int do_tpm_raw_transfer(cmd_tbl_t *cmdtp, int flag,
return CMD_RET_FAILURE;
}
-#ifdef CONFIG_DM_TPM
- struct udevice *dev;
-
rc = get_tpm(&dev);
if (rc)
return rc;
rc = tpm_xfer(dev, command, count, response, &response_length);
-#else
- rc = tis_sendrecv(command, count, response, &response_length);
-#endif
free(command);
if (!rc) {
puts("tpm response:\n");
@@ -657,9 +650,7 @@ TPM_COMMAND_NO_ARG(tpm_end_oiap)
U_BOOT_CMD_MKENT(cmd, 0, 1, do_tpm_ ## cmd, "", "")
static cmd_tbl_t tpm_commands[] = {
-#ifdef CONFIG_DM_TPM
U_BOOT_CMD_MKENT(info, 0, 1, do_tpm_info, "", ""),
-#endif
U_BOOT_CMD_MKENT(init, 0, 1,
do_tpm_init, "", ""),
U_BOOT_CMD_MKENT(startup, 0, 1,
@@ -730,9 +721,7 @@ U_BOOT_CMD(tpm, CONFIG_SYS_MAXARGS, 1, do_tpm,
"cmd args...\n"
" - Issue TPM command <cmd> with arguments <args...>.\n"
"Admin Startup and State Commands:\n"
-#ifdef CONFIG_DM_TPM
" info - Show information about the TPM\n"
-#endif
" init\n"
" - Put TPM into a state where it waits for 'startup' command.\n"
" startup mode\n"
diff --git a/common/cmd_ubi.c b/common/cmd_ubi.c
index 0460b4cc56..753a4dba3d 100644
--- a/common/cmd_ubi.c
+++ b/common/cmd_ubi.c
@@ -255,7 +255,7 @@ static int ubi_remove_vol(char *volume)
return 0;
out_err:
- ubi_err("cannot remove volume %s, error %d", volume, err);
+ ubi_err(ubi, "cannot remove volume %s, error %d", volume, err);
if (err < 0)
err = -err;
return err;
@@ -284,8 +284,8 @@ static int ubi_volume_continue_write(char *volume, void *buf, size_t size)
return -err;
if (err) {
- ubi_warn("volume %d on UBI device %d is corrupted",
- vol->vol_id, ubi->ubi_num);
+ ubi_warn(ubi, "volume %d on UBI device %d is corrupt",
+ vol->vol_id, ubi->ubi_num);
vol->corrupted = 1;
}
diff --git a/common/cmd_ubifs.c b/common/cmd_ubifs.c
index 8e9a4e5038..5e9d357cd7 100644
--- a/common/cmd_ubifs.c
+++ b/common/cmd_ubifs.c
@@ -15,8 +15,7 @@
#include <common.h>
#include <config.h>
#include <command.h>
-
-#include "../fs/ubifs/ubifs.h"
+#include <ubifs_uboot.h>
static int ubifs_initialized;
static int ubifs_mounted;
@@ -54,14 +53,7 @@ int ubifs_is_mounted(void)
void cmd_ubifs_umount(void)
{
-
- if (ubifs_sb) {
- printf("Unmounting UBIFS volume %s!\n",
- ((struct ubifs_info *)(ubifs_sb->s_fs_info))->vi.name);
- ubifs_umount(ubifs_sb->s_fs_info);
- }
-
- ubifs_sb = NULL;
+ uboot_ubifs_umount();
ubifs_mounted = 0;
ubifs_initialized = 0;
}
diff --git a/common/cmd_usb.c b/common/cmd_usb.c
index 6bdbbc5c05..1ef55dcd1c 100644
--- a/common/cmd_usb.c
+++ b/common/cmd_usb.c
@@ -281,7 +281,7 @@ static struct usb_device *usb_find_device(int devnum)
if (!device_active(hub))
continue;
- udev = dev_get_parentdata(hub);
+ udev = dev_get_parent_priv(hub);
if (udev->devnum == devnum)
return udev;
@@ -291,7 +291,7 @@ static struct usb_device *usb_find_device(int devnum)
if (!device_active(hub))
continue;
- udev = dev_get_parentdata(dev);
+ udev = dev_get_parent_priv(dev);
if (udev->devnum == devnum)
return udev;
}
@@ -407,7 +407,7 @@ static void usb_show_tree_graph(struct usb_device *dev, char *pre)
if (!device_active(child))
continue;
- udev = dev_get_parentdata(child);
+ udev = dev_get_parent_priv(child);
/* Ignore emulators, we only want real devices */
if (device_get_uclass_id(child) != UCLASS_USB_EMUL) {
@@ -553,7 +553,7 @@ static void show_info(struct udevice *dev)
struct udevice *child;
struct usb_device *udev;
- udev = dev_get_parentdata(dev);
+ udev = dev_get_parent_priv(dev);
usb_display_desc(udev);
usb_display_config(udev);
for (device_find_first_child(dev, &child);
@@ -641,7 +641,7 @@ static int do_usb(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
device_find_first_child(bus, &dev);
if (dev && device_active(dev)) {
- udev = dev_get_parentdata(dev);
+ udev = dev_get_parent_priv(dev);
usb_show_tree(udev);
}
}
diff --git a/common/cmd_ximg.c b/common/cmd_ximg.c
index 8b8645c9e1..d033c15b62 100644
--- a/common/cmd_ximg.c
+++ b/common/cmd_ximg.c
@@ -88,7 +88,8 @@ do_imgextract(cmd_tbl_t * cmdtp, int flag, int argc, char * const argv[])
image_print_contents(hdr);
#endif
- if (!image_check_type(hdr, IH_TYPE_MULTI)) {
+ if (!image_check_type(hdr, IH_TYPE_MULTI) &&
+ !image_check_type(hdr, IH_TYPE_SCRIPT)) {
printf("Wrong Image Type for %s command\n",
cmdtp->name);
return 1;
diff --git a/common/image.c b/common/image.c
index e6071099d6..85c4f39cdf 100644
--- a/common/image.c
+++ b/common/image.c
@@ -913,7 +913,7 @@ int boot_get_ramdisk(int argc, char * const argv[], bootm_headers_t *images,
* Look for an Android boot image.
*/
buf = map_sysmem(images->os.start, 0);
- if (genimg_get_format(buf) == IMAGE_FORMAT_ANDROID)
+ if (buf && genimg_get_format(buf) == IMAGE_FORMAT_ANDROID)
select = argv[0];
#endif
diff --git a/common/init/Makefile b/common/init/Makefile
new file mode 100644
index 0000000000..4902635f53
--- /dev/null
+++ b/common/init/Makefile
@@ -0,0 +1,7 @@
+#
+# Copyright (c) 2015 Google, Inc
+#
+# SPDX-License-Identifier: GPL-2.0+
+#
+
+obj-y += board_init.o
diff --git a/common/init/board_init.c b/common/init/board_init.c
new file mode 100644
index 0000000000..e74b63b8a8
--- /dev/null
+++ b/common/init/board_init.c
@@ -0,0 +1,60 @@
+/*
+ * Code shared between SPL and U-Boot proper
+ *
+ * Copyright (c) 2015 Google, Inc
+ * Written by Simon Glass <sjg@chromium.org>
+ *
+ * SPDX-License-Identifier: GPL-2.0+
+ */
+
+#include <common.h>
+
+DECLARE_GLOBAL_DATA_PTR;
+
+/*
+ * It isn't trivial to figure out whether memcpy() exists. The arch-specific
+ * memcpy() is not normally available in SPL due to code size.
+ */
+#if !defined(CONFIG_SPL_BUILD) || \
+ (defined(CONFIG_SPL_LIBGENERIC_SUPPORT) && \
+ !defined(CONFIG_USE_ARCH_MEMSET))
+#define _USE_MEMCPY
+#endif
+
+/* Unfortunately x86 can't compile this code as gd cannot be assigned */
+#ifndef CONFIG_X86
+__weak void arch_setup_gd(struct global_data *gd_ptr)
+{
+ gd = gd_ptr;
+}
+#endif /* !CONFIG_X86 */
+
+ulong board_init_f_mem(ulong top)
+{
+ struct global_data *gd_ptr;
+#ifndef _USE_MEMCPY
+ int *ptr;
+#endif
+
+ /* Leave space for the stack we are running with now */
+ top -= 0x40;
+
+ top -= sizeof(struct global_data);
+ top = ALIGN(top, 16);
+ gd_ptr = (struct global_data *)top;
+#ifdef _USE_MEMCPY
+ memset(gd_ptr, '\0', sizeof(*gd));
+#else
+ for (ptr = (int *)gd_ptr; ptr < (int *)(gd_ptr + 1); )
+ *ptr++ = 0;
+#endif
+ arch_setup_gd(gd_ptr);
+
+#if defined(CONFIG_SYS_MALLOC_F) && \
+ (!defined(CONFIG_SPL_BUILD) || !defined(CONFIG_SYS_SPL_MALLOC_START))
+ top -= CONFIG_SYS_MALLOC_F_LEN;
+ gd->malloc_base = top;
+#endif
+
+ return top;
+}
diff --git a/common/miiphyutil.c b/common/miiphyutil.c
index c88c28adbf..e499b58836 100644
--- a/common/miiphyutil.c
+++ b/common/miiphyutil.c
@@ -152,6 +152,11 @@ struct mii_dev *mdio_alloc(void)
return bus;
}
+void mdio_free(struct mii_dev *bus)
+{
+ free(bus);
+}
+
int mdio_register(struct mii_dev *bus)
{
if (!bus || !bus->name || !bus->read || !bus->write)
@@ -173,6 +178,20 @@ int mdio_register(struct mii_dev *bus)
return 0;
}
+int mdio_unregister(struct mii_dev *bus)
+{
+ if (!bus)
+ return 0;
+
+ /* delete it from the list */
+ list_del(&bus->link);
+
+ if (current_mii == bus)
+ current_mii = NULL;
+
+ return 0;
+}
+
void mdio_list_devices(void)
{
struct list_head *entry;
diff --git a/common/usb_hub.c b/common/usb_hub.c
index 415b45c1f1..a92c9fb73d 100644
--- a/common/usb_hub.c
+++ b/common/usb_hub.c
@@ -230,7 +230,7 @@ int legacy_hub_port_reset(struct usb_device *dev, int port,
#ifdef CONFIG_DM_USB
int hub_port_reset(struct udevice *dev, int port, unsigned short *portstat)
{
- struct usb_device *udev = dev_get_parentdata(dev);
+ struct usb_device *udev = dev_get_parent_priv(dev);
return legacy_hub_port_reset(udev, port, portstat);
}
@@ -610,7 +610,7 @@ int usb_hub_probe(struct usb_device *dev, int ifnum)
#ifdef CONFIG_DM_USB
int usb_hub_scan(struct udevice *hub)
{
- struct usb_device *udev = dev_get_parentdata(hub);
+ struct usb_device *udev = dev_get_parent_priv(hub);
return usb_hub_configure(udev);
}
diff --git a/common/usb_storage.c b/common/usb_storage.c
index b390310ee3..0ccaeb4a14 100644
--- a/common/usb_storage.c
+++ b/common/usb_storage.c
@@ -1408,7 +1408,7 @@ int usb_stor_get_info(struct usb_device *dev, struct us_data *ss,
static int usb_mass_storage_probe(struct udevice *dev)
{
- struct usb_device *udev = dev_get_parentdata(dev);
+ struct usb_device *udev = dev_get_parent_priv(dev);
int ret;
usb_disable_asynch(1); /* asynch transfer not allowed */