summaryrefslogtreecommitdiff
path: root/common
diff options
context:
space:
mode:
Diffstat (limited to 'common')
-rw-r--r--common/Makefile1
-rw-r--r--common/board_f.c48
-rw-r--r--common/cros_ec.c44
-rw-r--r--common/lcd.c21
4 files changed, 83 insertions, 31 deletions
diff --git a/common/Makefile b/common/Makefile
index 04e9cdd..e2ff0cb 100644
--- a/common/Makefile
+++ b/common/Makefile
@@ -230,6 +230,7 @@ obj-$(SPD) += ddr_spd.o
obj-$(CONFIG_HWCONFIG) += hwconfig.o
obj-$(CONFIG_BOUNCE_BUFFER) += bouncebuf.o
obj-y += console.o
+obj-$(CONFIG_CROS_EC) += cros_ec.o
obj-y += dlmalloc.o
obj-y += image.o
obj-$(CONFIG_OF_LIBFDT) += image-fdt.o
diff --git a/common/board_f.c b/common/board_f.c
index 4856975..f285bad 100644
--- a/common/board_f.c
+++ b/common/board_f.c
@@ -282,45 +282,39 @@ __weak int arch_cpu_init(void)
#ifdef CONFIG_OF_HOSTFILE
-#define CHECK(x) err = (x); if (err) goto failed;
-
-/* Create an empty device tree blob */
-static int make_empty_fdt(void *fdt)
-{
- int err;
-
- CHECK(fdt_create(fdt, 256));
- CHECK(fdt_finish_reservemap(fdt));
- CHECK(fdt_begin_node(fdt, ""));
- CHECK(fdt_end_node(fdt));
- CHECK(fdt_finish(fdt));
-
- return 0;
-failed:
- printf("Unable to create empty FDT: %s\n", fdt_strerror(err));
- return -EACCES;
-}
-
static int read_fdt_from_file(void)
{
struct sandbox_state *state = state_get_current();
+ const char *fname = state->fdt_fname;
void *blob;
- int size;
+ ssize_t size;
int err;
+ int fd;
blob = map_sysmem(CONFIG_SYS_FDT_LOAD_ADDR, 0);
if (!state->fdt_fname) {
- err = make_empty_fdt(blob);
+ err = fdt_create_empty_tree(blob, 256);
if (!err)
goto done;
- return err;
+ printf("Unable to create empty FDT: %s\n", fdt_strerror(err));
+ return -EINVAL;
+ }
+
+ size = os_get_filesize(fname);
+ if (size < 0) {
+ printf("Failed to file FDT file '%s'\n", fname);
+ return -ENOENT;
+ }
+ fd = os_open(fname, OS_O_RDONLY);
+ if (fd < 0) {
+ printf("Failed to open FDT file '%s'\n", fname);
+ return -EACCES;
}
- err = fs_set_blk_dev("host", NULL, FS_TYPE_SANDBOX);
- if (err)
- return err;
- size = fs_read(state->fdt_fname, CONFIG_SYS_FDT_LOAD_ADDR, 0, 0);
- if (size < 0)
+ if (os_read(fd, blob, size) != size) {
+ os_close(fd);
return -EIO;
+ }
+ os_close(fd);
done:
gd->fdt_blob = blob;
diff --git a/common/cros_ec.c b/common/cros_ec.c
new file mode 100644
index 0000000..b8ce1b5
--- /dev/null
+++ b/common/cros_ec.c
@@ -0,0 +1,44 @@
+/*
+ * Copyright (c) 2012 The Chromium OS Authors. All rights reserved.
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ *
+ * Alternatively, this software may be distributed under the terms of the
+ * GNU General Public License ("GPL") version 2 as published by the Free
+ * Software Foundation.
+ */
+
+#include <common.h>
+#include <cros_ec.h>
+DECLARE_GLOBAL_DATA_PTR;
+
+struct local_info {
+ struct cros_ec_dev *cros_ec_dev; /* Pointer to cros_ec device */
+ int cros_ec_err; /* Error for cros_ec, 0 if ok */
+};
+
+static struct local_info local;
+
+struct cros_ec_dev *board_get_cros_ec_dev(void)
+{
+ return local.cros_ec_dev;
+}
+
+static int board_init_cros_ec_devices(const void *blob)
+{
+ local.cros_ec_err = cros_ec_init(blob, &local.cros_ec_dev);
+ if (local.cros_ec_err)
+ return -1; /* Will report in board_late_init() */
+
+ return 0;
+}
+
+int cros_ec_board_init(void)
+{
+ return board_init_cros_ec_devices(gd->fdt_blob);
+}
+
+int cros_ec_get_error(void)
+{
+ return local.cros_ec_err;
+}
diff --git a/common/lcd.c b/common/lcd.c
index aa81522..19b86b7 100644
--- a/common/lcd.c
+++ b/common/lcd.c
@@ -28,6 +28,8 @@
#include <watchdog.h>
#include <asm/unaligned.h>
#include <splash.h>
+#include <asm/io.h>
+#include <asm/unaligned.h>
#if defined(CONFIG_CPU_PXA25X) || defined(CONFIG_CPU_PXA27X) || \
defined(CONFIG_CPU_MONAHANS)
@@ -63,6 +65,10 @@
# endif
#endif
+#ifdef CONFIG_SANDBOX
+#include <asm/sdl.h>
+#endif
+
#ifndef CONFIG_LCD_ALIGNMENT
#define CONFIG_LCD_ALIGNMENT PAGE_SIZE
#endif
@@ -144,6 +150,13 @@ void lcd_sync(void)
if (lcd_flush_dcache)
flush_dcache_range((u32)lcd_base,
(u32)(lcd_base + lcd_get_size(&line_length)));
+#elif defined(CONFIG_SANDBOX) && defined(CONFIG_VIDEO_SANDBOX_SDL)
+ static ulong last_sync;
+
+ if (get_timer(last_sync) > 10) {
+ sandbox_sdl_sync(lcd_base);
+ last_sync = get_timer(0);
+ }
#endif
}
@@ -403,7 +416,7 @@ int drv_lcd_init(void)
struct stdio_dev lcddev;
int rc;
- lcd_base = (void *) gd->fb_base;
+ lcd_base = map_sysmem(gd->fb_base, 0);
lcd_init(lcd_base); /* LCD initialization */
@@ -494,8 +507,8 @@ static int lcd_init(void *lcdbase)
* by setting up gd->fb_base. Check for this condition and fixup
* 'lcd_base' address.
*/
- if ((unsigned long)lcdbase != gd->fb_base)
- lcd_base = (void *)gd->fb_base;
+ if (map_to_sysmem(lcdbase) != gd->fb_base)
+ lcd_base = map_sysmem(gd->fb_base, 0);
debug("[LCD] Using LCD frambuffer at %p\n", lcd_base);
@@ -886,7 +899,7 @@ int lcd_display_bitmap(ulong bmp_image, int x, int y)
ushort *cmap_base = NULL;
ushort i, j;
uchar *fb;
- bmp_image_t *bmp=(bmp_image_t *)bmp_image;
+ bmp_image_t *bmp = (bmp_image_t *)map_sysmem(bmp_image, 0);
uchar *bmap;
ushort padded_width;
unsigned long width, height, byte_width;