mirror of
https://github.com/Fishwaldo/u-boot.git
synced 2025-03-21 06:31:31 +00:00
Test improvements to tidy up output and drop duplicate tests
Sandbox SPL/TPL support Various dm-related improvements -----BEGIN PGP SIGNATURE----- iQFFBAABCgAvFiEEslwAIq+Gp8wWVbYnfxc6PpAIreYFAlu9RL4RHHNqZ0BjaHJv bWl1bS5vcmcACgkQfxc6PpAIreYd8gf+NYAGhpiEZZ5vc3DB4Xdn2okgakbbg0QQ /b0Lr9xQsKgZthK0rvPlH2dXxf+ViAm1iHTy8KBCFi0SHNder48Zui9uTrX0NRq8 pLZGyJPXPYbiyc4pQTEJpTth4iShcphRVio0no4sLpNQqO4aQrialSLa9fnwd9Ra 1l9mF91aaYw6cG+/ejg3UR1LfsDdQ5bjubt0Fw0wGX9UvQOAz5gz5+a17wrz6+Gx L0gzvyfbuLUhbWB36DXikrL14DAFys2uV9aHJ5zEd53l+F7ZHWsupCO0OtN66cV7 KpPKoYG7vhLqBXKpyrW20T+BPeSyDKmDQE6wbpECmEDOvKzvW67O/w== =Bfjm -----END PGP SIGNATURE----- Merge tag 'dm-9oct18' of git://git.denx.de/u-boot-dm Test improvements to tidy up output and drop duplicate tests Sandbox SPL/TPL support Various dm-related improvements
This commit is contained in:
commit
3d5ced9e22
224 changed files with 5469 additions and 1333 deletions
|
@ -47,6 +47,7 @@ install:
|
|||
- virtualenv /tmp/venv
|
||||
- . /tmp/venv/bin/activate
|
||||
- pip install pytest
|
||||
- pip install python-subunit
|
||||
- grub-mkimage -o ~/grub_x86.efi -O i386-efi normal echo lsefimmap lsefi lsefisystab efinet tftp minicmd
|
||||
- mkdir ~/grub2-arm
|
||||
- ( cd ~/grub2-arm; wget -O - http://download.opensuse.org/ports/armv7hl/distribution/leap/42.2/repo/oss/suse/armv7hl/grub2-arm-efi-2.02~beta2-87.1.armv7hl.rpm | rpm2cpio | cpio -di )
|
||||
|
|
8
Makefile
8
Makefile
|
@ -1524,7 +1524,7 @@ $(defaultenv_h): $(CONFIG_DEFAULT_ENV_FILE:"%"=%) FORCE
|
|||
# ---------------------------------------------------------------------------
|
||||
quiet_cmd_cpp_lds = LDS $@
|
||||
cmd_cpp_lds = $(CPP) -Wp,-MD,$(depfile) $(cpp_flags) $(LDPPFLAGS) \
|
||||
-D__ASSEMBLY__ -x assembler-with-cpp -P -o $@ $<
|
||||
-D__ASSEMBLY__ -x assembler-with-cpp -std=c99 -P -o $@ $<
|
||||
|
||||
u-boot.lds: $(LDSCRIPT) prepare FORCE
|
||||
$(call if_changed_dep,cpp_lds)
|
||||
|
@ -1698,6 +1698,10 @@ help:
|
|||
@echo 'Configuration targets:'
|
||||
@$(MAKE) -f $(srctree)/scripts/kconfig/Makefile help
|
||||
@echo ''
|
||||
@echo 'Test targets:'
|
||||
@echo ''
|
||||
@echo ' check - Run all automated tests that use sandbox'
|
||||
@echo ''
|
||||
@echo 'Other generic targets:'
|
||||
@echo ' all - Build all necessary images depending on configuration'
|
||||
@echo ' tests - Build U-Boot for sandbox and run tests'
|
||||
|
@ -1736,7 +1740,7 @@ help:
|
|||
@echo 'Execute "make" or "make all" to build all targets marked with [*] '
|
||||
@echo 'For further info see the ./README file'
|
||||
|
||||
tests:
|
||||
tests check:
|
||||
$(srctree)/test/run
|
||||
|
||||
# Documentation targets
|
||||
|
|
|
@ -38,14 +38,6 @@ ssize_t os_read(int fd, void *buf, size_t count)
|
|||
return read(fd, buf, count);
|
||||
}
|
||||
|
||||
ssize_t os_read_no_block(int fd, void *buf, size_t count)
|
||||
{
|
||||
const int flags = fcntl(fd, F_GETFL, 0);
|
||||
|
||||
fcntl(fd, F_SETFL, flags | O_NONBLOCK);
|
||||
return os_read(fd, buf, count);
|
||||
}
|
||||
|
||||
ssize_t os_write(int fd, const void *buf, size_t count)
|
||||
{
|
||||
return write(fd, buf, count);
|
||||
|
@ -85,6 +77,8 @@ int os_open(const char *pathname, int os_flags)
|
|||
|
||||
if (os_flags & OS_O_CREAT)
|
||||
flags |= O_CREAT;
|
||||
if (os_flags & OS_O_TRUNC)
|
||||
flags |= O_TRUNC;
|
||||
|
||||
return open(pathname, flags, 0777);
|
||||
}
|
||||
|
@ -104,14 +98,41 @@ void os_exit(int exit_code)
|
|||
exit(exit_code);
|
||||
}
|
||||
|
||||
int os_write_file(const char *name, const void *buf, int size)
|
||||
{
|
||||
char fname[256];
|
||||
int fd;
|
||||
|
||||
fd = os_open(fname, OS_O_WRONLY | OS_O_CREAT | OS_O_TRUNC);
|
||||
if (fd < 0) {
|
||||
printf("Cannot open file '%s'\n", fname);
|
||||
return -EIO;
|
||||
}
|
||||
if (os_write(fd, buf, size) != size) {
|
||||
printf("Cannot write to file '%s'\n", fname);
|
||||
return -EIO;
|
||||
}
|
||||
os_close(fd);
|
||||
printf("Write '%s', size %#x (%d)\n", name, size, size);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Restore tty state when we exit */
|
||||
static struct termios orig_term;
|
||||
static bool term_setup;
|
||||
static bool term_nonblock;
|
||||
|
||||
void os_fd_restore(void)
|
||||
{
|
||||
if (term_setup) {
|
||||
int flags;
|
||||
|
||||
tcsetattr(0, TCSANOW, &orig_term);
|
||||
if (term_nonblock) {
|
||||
flags = fcntl(0, F_GETFL, 0);
|
||||
fcntl(0, F_SETFL, flags & ~O_NONBLOCK);
|
||||
}
|
||||
term_setup = false;
|
||||
}
|
||||
}
|
||||
|
@ -120,6 +141,7 @@ void os_fd_restore(void)
|
|||
void os_tty_raw(int fd, bool allow_sigs)
|
||||
{
|
||||
struct termios term;
|
||||
int flags;
|
||||
|
||||
if (term_setup)
|
||||
return;
|
||||
|
@ -136,6 +158,13 @@ void os_tty_raw(int fd, bool allow_sigs)
|
|||
if (tcsetattr(fd, TCSANOW, &term))
|
||||
return;
|
||||
|
||||
flags = fcntl(fd, F_GETFL, 0);
|
||||
if (!(flags & O_NONBLOCK)) {
|
||||
if (fcntl(fd, F_SETFL, flags | O_NONBLOCK))
|
||||
return;
|
||||
term_nonblock = true;
|
||||
}
|
||||
|
||||
term_setup = true;
|
||||
atexit(os_fd_restore);
|
||||
}
|
||||
|
@ -569,15 +598,40 @@ int os_find_u_boot(char *fname, int maxlen)
|
|||
struct sandbox_state *state = state_get_current();
|
||||
const char *progname = state->argv[0];
|
||||
int len = strlen(progname);
|
||||
const char *suffix;
|
||||
char *p;
|
||||
int fd;
|
||||
|
||||
if (len >= maxlen || len < 4)
|
||||
return -ENOSPC;
|
||||
|
||||
/* Look for 'u-boot' in the same directory as 'u-boot-spl' */
|
||||
strcpy(fname, progname);
|
||||
if (!strcmp(fname + len - 4, "-spl")) {
|
||||
suffix = fname + len - 4;
|
||||
|
||||
/* If we are TPL, boot to SPL */
|
||||
if (!strcmp(suffix, "-tpl")) {
|
||||
fname[len - 3] = 's';
|
||||
fd = os_open(fname, O_RDONLY);
|
||||
if (fd >= 0) {
|
||||
close(fd);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Look for 'u-boot-tpl' in the tpl/ directory */
|
||||
p = strstr(fname, "/tpl/");
|
||||
if (p) {
|
||||
p[1] = 's';
|
||||
fd = os_open(fname, O_RDONLY);
|
||||
if (fd >= 0) {
|
||||
close(fd);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
return -ENOENT;
|
||||
}
|
||||
|
||||
/* Look for 'u-boot' in the same directory as 'u-boot-spl' */
|
||||
if (!strcmp(suffix, "-spl")) {
|
||||
fname[len - 4] = '\0';
|
||||
fd = os_open(fname, O_RDONLY);
|
||||
if (fd >= 0) {
|
||||
|
@ -636,3 +690,14 @@ void os_abort(void)
|
|||
{
|
||||
abort();
|
||||
}
|
||||
|
||||
int os_mprotect_allow(void *start, size_t len)
|
||||
{
|
||||
int page_size = getpagesize();
|
||||
|
||||
/* Move start to the start of a page, len to the end */
|
||||
start = (void *)(((ulong)start) & ~(page_size - 1));
|
||||
len = (len + page_size * 2) & ~(page_size - 1);
|
||||
|
||||
return mprotect(start, len, PROT_READ | PROT_WRITE);
|
||||
}
|
||||
|
|
|
@ -177,7 +177,7 @@ static int sandbox_cmdline_cb_memory(struct sandbox_state *state,
|
|||
|
||||
err = os_read_ram_buf(arg);
|
||||
if (err) {
|
||||
printf("Failed to read RAM buffer\n");
|
||||
printf("Failed to read RAM buffer '%s': %d\n", arg, err);
|
||||
return err;
|
||||
}
|
||||
|
||||
|
@ -273,6 +273,16 @@ static int sandbox_cmdline_cb_verbose(struct sandbox_state *state,
|
|||
}
|
||||
SANDBOX_CMDLINE_OPT_SHORT(verbose, 'v', 0, "Show test output");
|
||||
|
||||
static int sandbox_cmdline_cb_log_level(struct sandbox_state *state,
|
||||
const char *arg)
|
||||
{
|
||||
state->default_log_level = simple_strtol(arg, NULL, 10);
|
||||
|
||||
return 0;
|
||||
}
|
||||
SANDBOX_CMDLINE_OPT_SHORT(log_level, 'L', 1,
|
||||
"Set log level (0=panic, 7=debug)");
|
||||
|
||||
int board_run_command(const char *cmdline)
|
||||
{
|
||||
printf("## Commands are disabled. Please enable CONFIG_CMDLINE.\n");
|
||||
|
@ -304,14 +314,13 @@ int main(int argc, char *argv[])
|
|||
if (ret)
|
||||
goto err;
|
||||
|
||||
/* Remove old memory file if required */
|
||||
if (state->ram_buf_rm && state->ram_buf_fname)
|
||||
os_unlink(state->ram_buf_fname);
|
||||
|
||||
memset(&data, '\0', sizeof(data));
|
||||
gd = &data;
|
||||
#if CONFIG_VAL(SYS_MALLOC_F_LEN)
|
||||
gd->malloc_base = CONFIG_MALLOC_F_ADDR;
|
||||
#endif
|
||||
#if CONFIG_IS_ENABLED(LOG)
|
||||
gd->default_log_level = state->default_log_level;
|
||||
#endif
|
||||
setup_ram_buf(state);
|
||||
|
||||
|
|
|
@ -393,7 +393,7 @@ int state_uninit(void)
|
|||
|
||||
state = &main_state;
|
||||
|
||||
if (state->write_ram_buf && !state->ram_buf_rm) {
|
||||
if (state->write_ram_buf) {
|
||||
err = os_write_ram_buf(state->ram_buf_fname);
|
||||
if (err) {
|
||||
printf("Failed to write RAM buffer\n");
|
||||
|
@ -408,6 +408,10 @@ int state_uninit(void)
|
|||
}
|
||||
}
|
||||
|
||||
/* Remove old memory file if required */
|
||||
if (state->ram_buf_rm && state->ram_buf_fname)
|
||||
os_unlink(state->ram_buf_fname);
|
||||
|
||||
/* Delete this at the last moment so as not to upset gdb too much */
|
||||
if (state->jumped_fname)
|
||||
os_unlink(state->jumped_fname);
|
||||
|
|
|
@ -18,7 +18,7 @@
|
|||
stdout-path = "/serial";
|
||||
};
|
||||
|
||||
cros_ec: cros-ec@0 {
|
||||
cros_ec: cros-ec {
|
||||
reg = <0 0>;
|
||||
compatible = "google,cros-ec-sandbox";
|
||||
|
||||
|
@ -26,23 +26,23 @@
|
|||
* This describes the flash memory within the EC. Note
|
||||
* that the STM32L flash erases to 0, not 0xff.
|
||||
*/
|
||||
#address-cells = <1>;
|
||||
#size-cells = <1>;
|
||||
flash@8000000 {
|
||||
reg = <0x08000000 0x20000>;
|
||||
flash {
|
||||
image-pos = <0x08000000>;
|
||||
size = <0x20000>;
|
||||
erase-value = <0>;
|
||||
#address-cells = <1>;
|
||||
#size-cells = <1>;
|
||||
|
||||
/* Information for sandbox */
|
||||
ro {
|
||||
reg = <0 0xf000>;
|
||||
image-pos = <0>;
|
||||
size = <0xf000>;
|
||||
};
|
||||
wp-ro {
|
||||
reg = <0xf000 0x1000>;
|
||||
image-pos = <0xf000>;
|
||||
size = <0x1000>;
|
||||
};
|
||||
rw {
|
||||
reg = <0x10000 0x10000>;
|
||||
image-pos = <0x10000>;
|
||||
size = <0x10000>;
|
||||
};
|
||||
};
|
||||
};
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
stdout-path = "/serial";
|
||||
};
|
||||
|
||||
cros_ec: cros-ec@0 {
|
||||
cros_ec: cros-ec {
|
||||
reg = <0 0 0 0>;
|
||||
compatible = "google,cros-ec-sandbox";
|
||||
|
||||
|
@ -25,23 +25,23 @@
|
|||
* This describes the flash memory within the EC. Note
|
||||
* that the STM32L flash erases to 0, not 0xff.
|
||||
*/
|
||||
#address-cells = <1>;
|
||||
#size-cells = <1>;
|
||||
flash@8000000 {
|
||||
reg = <0x08000000 0x20000>;
|
||||
flash {
|
||||
image-pos = <0x08000000>;
|
||||
size = <0x20000>;
|
||||
erase-value = <0>;
|
||||
#address-cells = <1>;
|
||||
#size-cells = <1>;
|
||||
|
||||
/* Information for sandbox */
|
||||
ro {
|
||||
reg = <0 0xf000>;
|
||||
image-pos = <0>;
|
||||
size = <0xf000>;
|
||||
};
|
||||
wp-ro {
|
||||
reg = <0xf000 0x1000>;
|
||||
image-pos = <0xf000>;
|
||||
size = <0x1000>;
|
||||
};
|
||||
rw {
|
||||
reg = <0x10000 0x10000>;
|
||||
image-pos = <0x10000>;
|
||||
size = <0x10000>;
|
||||
};
|
||||
};
|
||||
};
|
||||
|
|
|
@ -60,7 +60,7 @@
|
|||
regulator-max-microvolt = <3300000>;
|
||||
};
|
||||
|
||||
ldo1 {
|
||||
ldo_1: ldo1 {
|
||||
regulator-name = "VDD_EMMC_1.8V";
|
||||
regulator-min-microvolt = <1800000>;
|
||||
regulator-max-microvolt = <1800000>;
|
||||
|
|
|
@ -11,6 +11,8 @@
|
|||
eth0 = "/eth@10002000";
|
||||
eth3 = ð_3;
|
||||
eth5 = ð_5;
|
||||
gpio1 = &gpio_a;
|
||||
gpio2 = &gpio_b;
|
||||
i2c0 = "/i2c@0";
|
||||
mmc0 = "/mmc0";
|
||||
mmc1 = "/mmc1";
|
||||
|
@ -40,6 +42,35 @@
|
|||
osd0 = "/osd";
|
||||
};
|
||||
|
||||
cros_ec: cros-ec {
|
||||
reg = <0 0>;
|
||||
compatible = "google,cros-ec-sandbox";
|
||||
|
||||
/*
|
||||
* This describes the flash memory within the EC. Note
|
||||
* that the STM32L flash erases to 0, not 0xff.
|
||||
*/
|
||||
flash {
|
||||
image-pos = <0x08000000>;
|
||||
size = <0x20000>;
|
||||
erase-value = <0>;
|
||||
|
||||
/* Information for sandbox */
|
||||
ro {
|
||||
image-pos = <0>;
|
||||
size = <0xf000>;
|
||||
};
|
||||
wp-ro {
|
||||
image-pos = <0xf000>;
|
||||
size = <0x1000>;
|
||||
};
|
||||
rw {
|
||||
image-pos = <0x10000>;
|
||||
size = <0x10000>;
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
a-test {
|
||||
reg = <0 1>;
|
||||
compatible = "denx,u-boot-fdt-test";
|
||||
|
@ -62,6 +93,15 @@
|
|||
reg = <2 1>;
|
||||
};
|
||||
|
||||
backlight: backlight {
|
||||
compatible = "pwm-backlight";
|
||||
enable-gpios = <&gpio_a 1>;
|
||||
power-supply = <&ldo_1>;
|
||||
pwms = <&pwm 0 1000>;
|
||||
default-brightness-level = <5>;
|
||||
brightness-levels = <0 16 32 64 128 170 202 234 255>;
|
||||
};
|
||||
|
||||
bind-test {
|
||||
bind-test-child1 {
|
||||
compatible = "sandbox,phy";
|
||||
|
@ -412,12 +452,14 @@
|
|||
power-domains = <&pwrdom 2>;
|
||||
};
|
||||
|
||||
pwm {
|
||||
pwm: pwm {
|
||||
compatible = "sandbox,pwm";
|
||||
#pwm-cells = <2>;
|
||||
};
|
||||
|
||||
pwm2 {
|
||||
compatible = "sandbox,pwm";
|
||||
#pwm-cells = <2>;
|
||||
};
|
||||
|
||||
ram {
|
||||
|
@ -454,6 +496,11 @@
|
|||
remoteproc-name = "remoteproc-test-dev2";
|
||||
};
|
||||
|
||||
panel {
|
||||
compatible = "simple-panel";
|
||||
backlight = <&backlight 0 100>;
|
||||
};
|
||||
|
||||
smem@0 {
|
||||
compatible = "sandbox,smem";
|
||||
};
|
||||
|
|
|
@ -36,7 +36,6 @@ enum state_terminal_raw {
|
|||
};
|
||||
|
||||
struct sandbox_spi_info {
|
||||
const char *spec;
|
||||
struct udevice *emul;
|
||||
};
|
||||
|
||||
|
@ -89,6 +88,7 @@ struct sandbox_state {
|
|||
enum state_terminal_raw term_raw; /* Terminal raw/cooked */
|
||||
bool skip_delays; /* Ignore any time delays (for test) */
|
||||
bool show_test_output; /* Don't suppress stdout in tests */
|
||||
int default_log_level; /* Default log level for sandbox */
|
||||
|
||||
/* Pointer to information for each SPI bus/cs */
|
||||
struct sandbox_spi_info spi[CONFIG_SANDBOX_SPI_MAX_BUS]
|
||||
|
|
|
@ -98,4 +98,19 @@ int sandbox_usb_keyb_add_string(struct udevice *dev, const char *str);
|
|||
* @buflen: length of buffer in bytes
|
||||
*/
|
||||
int sandbox_osd_get_mem(struct udevice *dev, u8 *buf, size_t buflen);
|
||||
|
||||
/**
|
||||
* sandbox_pwm_get_config() - get the PWM config for a channel
|
||||
*
|
||||
* @dev: Device to check
|
||||
* @channel: Channel number to check
|
||||
* @period_ns: Period of the PWM in nanoseconds
|
||||
* @duty_ns: Current duty cycle of the PWM in nanoseconds
|
||||
* @enable: true if the PWM is enabled
|
||||
* @polarity: true if the PWM polarity is active high
|
||||
* @return 0 if OK, -ENOSPC if the PWM number is invalid
|
||||
*/
|
||||
int sandbox_pwm_get_config(struct udevice *dev, uint channel, uint *period_nsp,
|
||||
uint *duty_nsp, bool *enablep, bool *polarityp);
|
||||
|
||||
#endif
|
||||
|
|
|
@ -55,10 +55,10 @@ static void board_final_cleanup(void)
|
|||
if (top_type == MTRR_TYPE_WRPROT) {
|
||||
struct mtrr_state state;
|
||||
|
||||
mtrr_open(&state);
|
||||
mtrr_open(&state, true);
|
||||
wrmsrl(MTRR_PHYS_BASE_MSR(top_mtrr), 0);
|
||||
wrmsrl(MTRR_PHYS_MASK_MSR(top_mtrr), 0);
|
||||
mtrr_close(&state);
|
||||
mtrr_close(&state, true);
|
||||
}
|
||||
|
||||
if (!fdtdec_get_config_bool(gd->fdt_blob, "u-boot,no-apm-finalize")) {
|
||||
|
|
|
@ -11,6 +11,11 @@
|
|||
* System Programming
|
||||
*/
|
||||
|
||||
/*
|
||||
* Note that any console output (e.g. debug()) in this file will likely fail
|
||||
* since the MTRR registers are sometimes in flux.
|
||||
*/
|
||||
|
||||
#include <common.h>
|
||||
#include <asm/io.h>
|
||||
#include <asm/msr.h>
|
||||
|
@ -19,27 +24,29 @@
|
|||
DECLARE_GLOBAL_DATA_PTR;
|
||||
|
||||
/* Prepare to adjust MTRRs */
|
||||
void mtrr_open(struct mtrr_state *state)
|
||||
void mtrr_open(struct mtrr_state *state, bool do_caches)
|
||||
{
|
||||
if (!gd->arch.has_mtrr)
|
||||
return;
|
||||
|
||||
state->enable_cache = dcache_status();
|
||||
if (do_caches) {
|
||||
state->enable_cache = dcache_status();
|
||||
|
||||
if (state->enable_cache)
|
||||
disable_caches();
|
||||
if (state->enable_cache)
|
||||
disable_caches();
|
||||
}
|
||||
state->deftype = native_read_msr(MTRR_DEF_TYPE_MSR);
|
||||
wrmsrl(MTRR_DEF_TYPE_MSR, state->deftype & ~MTRR_DEF_TYPE_EN);
|
||||
}
|
||||
|
||||
/* Clean up after adjusting MTRRs, and enable them */
|
||||
void mtrr_close(struct mtrr_state *state)
|
||||
void mtrr_close(struct mtrr_state *state, bool do_caches)
|
||||
{
|
||||
if (!gd->arch.has_mtrr)
|
||||
return;
|
||||
|
||||
wrmsrl(MTRR_DEF_TYPE_MSR, state->deftype | MTRR_DEF_TYPE_EN);
|
||||
if (state->enable_cache)
|
||||
if (do_caches && state->enable_cache)
|
||||
enable_caches();
|
||||
}
|
||||
|
||||
|
@ -50,10 +57,14 @@ int mtrr_commit(bool do_caches)
|
|||
uint64_t mask;
|
||||
int i;
|
||||
|
||||
debug("%s: enabled=%d, count=%d\n", __func__, gd->arch.has_mtrr,
|
||||
gd->arch.mtrr_req_count);
|
||||
if (!gd->arch.has_mtrr)
|
||||
return -ENOSYS;
|
||||
|
||||
mtrr_open(&state);
|
||||
debug("open\n");
|
||||
mtrr_open(&state, do_caches);
|
||||
debug("open done\n");
|
||||
for (i = 0; i < gd->arch.mtrr_req_count; i++, req++) {
|
||||
mask = ~(req->size - 1);
|
||||
mask &= (1ULL << CONFIG_CPU_ADDR_BITS) - 1;
|
||||
|
@ -62,9 +73,12 @@ int mtrr_commit(bool do_caches)
|
|||
}
|
||||
|
||||
/* Clear the ones that are unused */
|
||||
debug("clear\n");
|
||||
for (; i < MTRR_COUNT; i++)
|
||||
wrmsrl(MTRR_PHYS_MASK_MSR(i), 0);
|
||||
mtrr_close(&state);
|
||||
debug("close\n");
|
||||
mtrr_close(&state, do_caches);
|
||||
debug("mtrr done\n");
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -74,6 +88,7 @@ int mtrr_add_request(int type, uint64_t start, uint64_t size)
|
|||
struct mtrr_request *req;
|
||||
uint64_t mask;
|
||||
|
||||
debug("%s: count=%d\n", __func__, gd->arch.mtrr_req_count);
|
||||
if (!gd->arch.has_mtrr)
|
||||
return -ENOSYS;
|
||||
|
||||
|
|
|
@ -77,8 +77,9 @@ struct mtrr_state {
|
|||
* possibly the cache.
|
||||
*
|
||||
* @state: Empty structure to pass in to hold settings
|
||||
* @do_caches: true to disable caches before opening
|
||||
*/
|
||||
void mtrr_open(struct mtrr_state *state);
|
||||
void mtrr_open(struct mtrr_state *state, bool do_caches);
|
||||
|
||||
/**
|
||||
* mtrr_open() - Clean up after adjusting MTRRs, and enable them
|
||||
|
@ -86,8 +87,9 @@ void mtrr_open(struct mtrr_state *state);
|
|||
* This uses the structure containing information returned from mtrr_open().
|
||||
*
|
||||
* @state: Structure from mtrr_open()
|
||||
* @state: true to restore cache state to that before mtrr_open()
|
||||
*/
|
||||
void mtrr_close(struct mtrr_state *state);
|
||||
void mtrr_close(struct mtrr_state *state, bool do_caches);
|
||||
|
||||
/**
|
||||
* mtrr_add_request() - Add a new MTRR request
|
||||
|
|
|
@ -18,6 +18,7 @@ DECLARE_GLOBAL_DATA_PTR;
|
|||
|
||||
int at91_video_show_board_info(void)
|
||||
{
|
||||
struct vidconsole_priv *priv;
|
||||
ulong dram_size, nand_size;
|
||||
int i;
|
||||
u32 len = 0;
|
||||
|
@ -63,7 +64,9 @@ int at91_video_show_board_info(void)
|
|||
if (ret)
|
||||
return ret;
|
||||
|
||||
vidconsole_position_cursor(con, 0, logo_info.logo_height);
|
||||
priv = dev_get_uclass_priv(con);
|
||||
vidconsole_position_cursor(con, 0, (logo_info.logo_height +
|
||||
priv->y_charsize - 1) / priv->y_charsize);
|
||||
for (s = buf, i = 0; i < len; s++, i++)
|
||||
vidconsole_put_char(con, *s);
|
||||
|
||||
|
|
|
@ -27,7 +27,7 @@ static int cros_ec_decode_region(int argc, char * const argv[])
|
|||
{
|
||||
if (argc > 0) {
|
||||
if (0 == strcmp(*argv, "rw"))
|
||||
return EC_FLASH_REGION_RW;
|
||||
return EC_FLASH_REGION_ACTIVE;
|
||||
else if (0 == strcmp(*argv, "ro"))
|
||||
return EC_FLASH_REGION_RO;
|
||||
|
||||
|
@ -49,7 +49,7 @@ static int cros_ec_decode_region(int argc, char * const argv[])
|
|||
* @return 0 for ok, 1 for a usage error or -ve for ec command error
|
||||
* (negative EC_RES_...)
|
||||
*/
|
||||
static int do_read_write(struct cros_ec_dev *dev, int is_write, int argc,
|
||||
static int do_read_write(struct udevice *dev, int is_write, int argc,
|
||||
char * const argv[])
|
||||
{
|
||||
uint32_t offset, size = -1U, region_size;
|
||||
|
@ -94,8 +94,7 @@ static int do_read_write(struct cros_ec_dev *dev, int is_write, int argc,
|
|||
|
||||
static int do_cros_ec(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
|
||||
{
|
||||
struct cros_ec_dev *dev;
|
||||
struct udevice *udev;
|
||||
struct udevice *dev;
|
||||
const char *cmd;
|
||||
int ret = 0;
|
||||
|
||||
|
@ -105,10 +104,10 @@ static int do_cros_ec(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
|
|||
cmd = argv[1];
|
||||
if (0 == strcmp("init", cmd)) {
|
||||
/* Remove any existing device */
|
||||
ret = uclass_find_device(UCLASS_CROS_EC, 0, &udev);
|
||||
ret = uclass_find_device(UCLASS_CROS_EC, 0, &dev);
|
||||
if (!ret)
|
||||
device_remove(udev, DM_REMOVE_NORMAL);
|
||||
ret = uclass_get_device(UCLASS_CROS_EC, 0, &udev);
|
||||
device_remove(dev, DM_REMOVE_NORMAL);
|
||||
ret = uclass_get_device(UCLASS_CROS_EC, 0, &dev);
|
||||
if (ret) {
|
||||
printf("Could not init cros_ec device (err %d)\n", ret);
|
||||
return 1;
|
||||
|
@ -116,12 +115,11 @@ static int do_cros_ec(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
|
|||
return 0;
|
||||
}
|
||||
|
||||
ret = uclass_get_device(UCLASS_CROS_EC, 0, &udev);
|
||||
ret = uclass_get_device(UCLASS_CROS_EC, 0, &dev);
|
||||
if (ret) {
|
||||
printf("Cannot get cros-ec device (err=%d)\n", ret);
|
||||
return 1;
|
||||
}
|
||||
dev = dev_get_uclass_priv(udev);
|
||||
if (0 == strcmp("id", cmd)) {
|
||||
char id[MSG_BYTES];
|
||||
|
||||
|
@ -139,7 +137,6 @@ static int do_cros_ec(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
|
|||
}
|
||||
printf("rows = %u\n", info.rows);
|
||||
printf("cols = %u\n", info.cols);
|
||||
printf("switches = %#x\n", info.switches);
|
||||
} else if (0 == strcmp("curimage", cmd)) {
|
||||
enum ec_current_image image;
|
||||
|
||||
|
@ -152,7 +149,7 @@ static int do_cros_ec(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
|
|||
struct ec_response_vboot_hash hash;
|
||||
int i;
|
||||
|
||||
if (cros_ec_read_hash(dev, &hash)) {
|
||||
if (cros_ec_read_hash(dev, EC_VBOOT_HASH_OFFSET_ACTIVE, &hash)) {
|
||||
debug("%s: Could not read KBC hash\n", __func__);
|
||||
return 1;
|
||||
}
|
||||
|
@ -179,7 +176,7 @@ static int do_cros_ec(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
|
|||
region = cros_ec_decode_region(argc - 2, argv + 2);
|
||||
if (region == EC_FLASH_REGION_RO)
|
||||
cmd = EC_REBOOT_JUMP_RO;
|
||||
else if (region == EC_FLASH_REGION_RW)
|
||||
else if (region == EC_FLASH_REGION_ACTIVE)
|
||||
cmd = EC_REBOOT_JUMP_RW;
|
||||
else
|
||||
return CMD_RET_USAGE;
|
||||
|
@ -262,7 +259,8 @@ static int do_cros_ec(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
|
|||
unsigned long result;
|
||||
|
||||
if (argc <= 2) {
|
||||
ret = cros_ec_read_vbnvcontext(dev, block);
|
||||
ret = cros_ec_read_nvdata(dev, block,
|
||||
EC_VBNV_BLOCK_SIZE);
|
||||
if (!ret) {
|
||||
printf("vbnv_block: ");
|
||||
for (i = 0; i < EC_VBNV_BLOCK_SIZE; i++)
|
||||
|
@ -288,7 +286,8 @@ static int do_cros_ec(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
|
|||
strict_strtoul(buf, 16, &result);
|
||||
block[i] = result;
|
||||
}
|
||||
ret = cros_ec_write_vbnvcontext(dev, block);
|
||||
ret = cros_ec_write_nvdata(dev, block,
|
||||
EC_VBNV_BLOCK_SIZE);
|
||||
}
|
||||
if (ret) {
|
||||
debug("%s: Could not %s VbNvContext\n", __func__,
|
||||
|
@ -336,9 +335,9 @@ static int do_cros_ec(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
|
|||
state = simple_strtoul(argv[3], &endp, 10);
|
||||
if (*argv[3] == 0 || *endp != 0)
|
||||
return CMD_RET_USAGE;
|
||||
ret = cros_ec_set_ldo(udev, index, state);
|
||||
ret = cros_ec_set_ldo(dev, index, state);
|
||||
} else {
|
||||
ret = cros_ec_get_ldo(udev, index, &state);
|
||||
ret = cros_ec_get_ldo(dev, index, &state);
|
||||
if (!ret) {
|
||||
printf("LDO%d: %s\n", index,
|
||||
state == EC_LDO_STATE_ON ?
|
||||
|
|
|
@ -62,14 +62,6 @@ static uint32_t tpm_get_flags(uint8_t *disable, uint8_t *deactivated,
|
|||
return 0;
|
||||
}
|
||||
|
||||
static uint32_t tpm_set_global_lock(void)
|
||||
{
|
||||
uint32_t x;
|
||||
|
||||
debug("TPM: Set global lock\n");
|
||||
return tpm_nv_write_value(INDEX0, (uint8_t *)&x, 0);
|
||||
}
|
||||
|
||||
static uint32_t tpm_nv_write_value_lock(uint32_t index)
|
||||
{
|
||||
debug("TPM: Write lock 0x%x\n", index);
|
||||
|
@ -77,13 +69,6 @@ static uint32_t tpm_nv_write_value_lock(uint32_t index)
|
|||
return tpm_nv_write_value(index, NULL, 0);
|
||||
}
|
||||
|
||||
static uint32_t tpm_nv_set_locked(void)
|
||||
{
|
||||
debug("TPM: Set NV locked\n");
|
||||
|
||||
return tpm_nv_define_space(TPM_NV_INDEX_LOCK, 0, 0);
|
||||
}
|
||||
|
||||
static int tpm_is_owned(void)
|
||||
{
|
||||
uint8_t response[TPM_PUBEK_SIZE];
|
||||
|
|
|
@ -73,10 +73,10 @@ static int do_mtrr_set(uint reg, int argc, char * const argv[])
|
|||
mask |= MTRR_PHYS_MASK_VALID;
|
||||
|
||||
printf("base=%llx, mask=%llx\n", base, mask);
|
||||
mtrr_open(&state);
|
||||
mtrr_open(&state, true);
|
||||
wrmsrl(MTRR_PHYS_BASE_MSR(reg), base);
|
||||
wrmsrl(MTRR_PHYS_MASK_MSR(reg), mask);
|
||||
mtrr_close(&state);
|
||||
mtrr_close(&state, true);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -86,14 +86,14 @@ static int mtrr_set_valid(int reg, bool valid)
|
|||
struct mtrr_state state;
|
||||
uint64_t mask;
|
||||
|
||||
mtrr_open(&state);
|
||||
mtrr_open(&state, true);
|
||||
mask = native_read_msr(MTRR_PHYS_MASK_MSR(reg));
|
||||
if (valid)
|
||||
mask |= MTRR_PHYS_MASK_VALID;
|
||||
else
|
||||
mask &= ~MTRR_PHYS_MASK_VALID;
|
||||
wrmsrl(MTRR_PHYS_MASK_MSR(reg), mask);
|
||||
mtrr_close(&state);
|
||||
mtrr_close(&state, true);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
#include <dm.h>
|
||||
#include <errno.h>
|
||||
|
||||
struct cros_ec_dev *board_get_cros_ec_dev(void)
|
||||
struct udevice *board_get_cros_ec_dev(void)
|
||||
{
|
||||
struct udevice *dev;
|
||||
int ret;
|
||||
|
@ -23,7 +23,7 @@ struct cros_ec_dev *board_get_cros_ec_dev(void)
|
|||
debug("%s: Error %d\n", __func__, ret);
|
||||
return NULL;
|
||||
}
|
||||
return dev_get_uclass_priv(dev);
|
||||
return dev;
|
||||
}
|
||||
|
||||
int cros_ec_get_error(void)
|
||||
|
|
|
@ -315,7 +315,8 @@ int log_init(void)
|
|||
drv++;
|
||||
}
|
||||
gd->flags |= GD_FLG_LOG_READY;
|
||||
gd->default_log_level = LOGL_INFO;
|
||||
if (!gd->default_log_level)
|
||||
gd->default_log_level = LOGL_INFO;
|
||||
gd->log_fmt = LOGF_DEFAULT;
|
||||
|
||||
return 0;
|
||||
|
|
|
@ -69,6 +69,7 @@ CONFIG_DM_I2C=y
|
|||
CONFIG_SYS_I2C_INTEL=y
|
||||
CONFIG_CROS_EC=y
|
||||
CONFIG_CROS_EC_LPC=y
|
||||
CONFIG_SPL_DM_RTC=y
|
||||
CONFIG_SYS_NS16550=y
|
||||
CONFIG_SPI=y
|
||||
CONFIG_SPL_TIMER=y
|
||||
|
|
|
@ -33,6 +33,7 @@ CONFIG_CPU=y
|
|||
CONFIG_DFU_MMC=y
|
||||
CONFIG_DFU_RAM=y
|
||||
CONFIG_DM_PCI_COMPAT=y
|
||||
CONFIG_RTC_MC146818=y
|
||||
CONFIG_USB_DWC3_GADGET=y
|
||||
CONFIG_USB_GADGET=y
|
||||
CONFIG_USB_GADGET_MANUFACTURER="Intel"
|
||||
|
|
|
@ -23,4 +23,5 @@ CONFIG_DEFAULT_DEVICE_TREE="mti,malta"
|
|||
CONFIG_ENV_IS_IN_FLASH=y
|
||||
CONFIG_MTD_NOR_FLASH=y
|
||||
CONFIG_PCI=y
|
||||
CONFIG_RTC_MC146818=y
|
||||
CONFIG_SYS_NS16550=y
|
||||
|
|
|
@ -24,4 +24,5 @@ CONFIG_DEFAULT_DEVICE_TREE="mti,malta"
|
|||
CONFIG_ENV_IS_IN_FLASH=y
|
||||
CONFIG_MTD_NOR_FLASH=y
|
||||
CONFIG_PCI=y
|
||||
CONFIG_RTC_MC146818=y
|
||||
CONFIG_SYS_NS16550=y
|
||||
|
|
|
@ -22,4 +22,5 @@ CONFIG_DEFAULT_DEVICE_TREE="mti,malta"
|
|||
CONFIG_ENV_IS_IN_FLASH=y
|
||||
CONFIG_MTD_NOR_FLASH=y
|
||||
CONFIG_PCI=y
|
||||
CONFIG_RTC_MC146818=y
|
||||
CONFIG_SYS_NS16550=y
|
||||
|
|
|
@ -23,4 +23,5 @@ CONFIG_DEFAULT_DEVICE_TREE="mti,malta"
|
|||
CONFIG_ENV_IS_IN_FLASH=y
|
||||
CONFIG_MTD_NOR_FLASH=y
|
||||
CONFIG_PCI=y
|
||||
CONFIG_RTC_MC146818=y
|
||||
CONFIG_SYS_NS16550=y
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
CONFIG_SYS_TEXT_BASE=0
|
||||
CONFIG_SYS_MALLOC_F_LEN=0x2000
|
||||
CONFIG_DEBUG_UART=y
|
||||
CONFIG_DISTRO_DEFAULTS=y
|
||||
CONFIG_NR_DRAM_BANKS=1
|
||||
CONFIG_ANDROID_BOOT_IMAGE=y
|
||||
|
@ -173,6 +174,7 @@ CONFIG_REMOTEPROC_SANDBOX=y
|
|||
CONFIG_DM_RESET=y
|
||||
CONFIG_SANDBOX_RESET=y
|
||||
CONFIG_DM_RTC=y
|
||||
CONFIG_DEBUG_UART_SANDBOX=y
|
||||
CONFIG_SANDBOX_SERIAL=y
|
||||
CONFIG_SMEM=y
|
||||
CONFIG_SANDBOX_SMEM=y
|
||||
|
|
|
@ -15,6 +15,7 @@ CONFIG_BOOTSTAGE_STASH_SIZE=0x4096
|
|||
CONFIG_CONSOLE_RECORD=y
|
||||
CONFIG_CONSOLE_RECORD_OUT_SIZE=0x1000
|
||||
CONFIG_SILENT_CONSOLE=y
|
||||
CONFIG_LOG_MAX_LEVEL=6
|
||||
CONFIG_DISPLAY_BOARDINFO_LATE=y
|
||||
CONFIG_CMD_CPU=y
|
||||
CONFIG_CMD_LICENSE=y
|
||||
|
|
|
@ -82,11 +82,11 @@ static int validate_gpt_header(gpt_header *gpt_h, lbaint_t lba,
|
|||
uint32_t calc_crc32;
|
||||
|
||||
/* Check the GPT header signature */
|
||||
if (le64_to_cpu(gpt_h->signature) != GPT_HEADER_SIGNATURE) {
|
||||
if (le64_to_cpu(gpt_h->signature) != GPT_HEADER_SIGNATURE_UBOOT) {
|
||||
printf("%s signature is wrong: 0x%llX != 0x%llX\n",
|
||||
"GUID Partition Table Header",
|
||||
le64_to_cpu(gpt_h->signature),
|
||||
GPT_HEADER_SIGNATURE);
|
||||
GPT_HEADER_SIGNATURE_UBOOT);
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
@ -603,7 +603,7 @@ static uint32_t partition_entries_offset(struct blk_desc *dev_desc)
|
|||
int gpt_fill_header(struct blk_desc *dev_desc, gpt_header *gpt_h,
|
||||
char *str_guid, int parts_count)
|
||||
{
|
||||
gpt_h->signature = cpu_to_le64(GPT_HEADER_SIGNATURE);
|
||||
gpt_h->signature = cpu_to_le64(GPT_HEADER_SIGNATURE_UBOOT);
|
||||
gpt_h->revision = cpu_to_le32(GPT_HEADER_REVISION_V1);
|
||||
gpt_h->header_size = cpu_to_le32(sizeof(gpt_header));
|
||||
gpt_h->my_lba = cpu_to_le64(1);
|
||||
|
|
|
@ -56,7 +56,11 @@ In case you are wondering, OF stands for Open Firmware.
|
|||
Tools
|
||||
-----
|
||||
|
||||
To use this feature you will need to get the device tree compiler here:
|
||||
To use this feature you will need to get the device tree compiler. This is
|
||||
provided by U-Boot automatically. If you have a system version of dtc
|
||||
(typically in the 'device-tree-compiler' package), it is currently not used.
|
||||
|
||||
If you want to build your own dtc, it is kept here:
|
||||
|
||||
git://git.kernel.org/pub/scm/utils/dtc/dtc.git
|
||||
|
||||
|
@ -170,6 +174,16 @@ After board configuration is done, fdt supported u-boot can be build in two ways
|
|||
$ make DEVICE_TREE=<dts-file-name>
|
||||
|
||||
|
||||
Relocation, SPL and TPL
|
||||
-----------------------
|
||||
|
||||
U-Boot can be divided into three phases: TPL, SPL and U-Boot proper.
|
||||
|
||||
The full device tree is available to U-Boot proper, but normally only a subset
|
||||
(or none at all) is available to TPL and SPL. See 'Pre-Relocation Support' and
|
||||
'SPL Support' in doc/driver-model/README.txt for more details.
|
||||
|
||||
|
||||
Limitations
|
||||
-----------
|
||||
|
||||
|
|
|
@ -832,11 +832,14 @@ Pre-Relocation Support
|
|||
For pre-relocation we simply call the driver model init function. Only
|
||||
drivers marked with DM_FLAG_PRE_RELOC or the device tree
|
||||
'u-boot,dm-pre-reloc' flag are initialised prior to relocation. This helps
|
||||
to reduce the driver model overhead.
|
||||
to reduce the driver model overhead. This flag applies to SPL and TPL as
|
||||
well, if device tree is enabled there.
|
||||
|
||||
It is possible to limit this to specific relocation steps, by using
|
||||
the more specialized 'u-boot,dm-spl' and 'u-boot,dm-tpl' flags
|
||||
in the devicetree.
|
||||
in the device tree node. For U-Boot proper you can use 'u-boot,dm-pre-proper'
|
||||
which means that it will be processed (and a driver bound) in U-Boot proper
|
||||
prior to relocation, but will not be available in SPL or TPL.
|
||||
|
||||
Then post relocation we throw that away and re-init driver model again.
|
||||
For drivers which require some sort of continuity between pre- and
|
||||
|
|
|
@ -27,6 +27,18 @@ config SPL_BLK
|
|||
be partitioned into several areas, called 'partitions' in U-Boot.
|
||||
A filesystem can be placed in each partition.
|
||||
|
||||
config TPL_BLK
|
||||
bool "Support block devices in TPL"
|
||||
depends on TPL_DM && BLK
|
||||
default y
|
||||
help
|
||||
Enable support for block devices, such as SCSI, MMC and USB
|
||||
flash sticks. These provide a block-level interface which permits
|
||||
reading, writing and (in some cases) erasing blocks. Block
|
||||
devices often have a partition table which allows the device to
|
||||
be partitioned into several areas, called 'partitions' in U-Boot.
|
||||
A filesystem can be placed in each partition.
|
||||
|
||||
config BLOCK_CACHE
|
||||
bool "Use block device cache"
|
||||
depends on BLK
|
||||
|
|
|
@ -11,4 +11,4 @@ endif
|
|||
|
||||
obj-$(CONFIG_IDE) += ide.o
|
||||
obj-$(CONFIG_SANDBOX) += sandbox.o
|
||||
obj-$(CONFIG_$(SPL_)BLOCK_CACHE) += blkcache.o
|
||||
obj-$(CONFIG_$(SPL_TPL_)BLOCK_CACHE) += blkcache.o
|
||||
|
|
|
@ -331,7 +331,8 @@ int device_probe(struct udevice *dev)
|
|||
/* Allocate private data if requested and not reentered */
|
||||
size = dev->uclass->uc_drv->per_device_auto_alloc_size;
|
||||
if (size && !dev->uclass_priv) {
|
||||
dev->uclass_priv = calloc(1, size);
|
||||
dev->uclass_priv = alloc_priv(size,
|
||||
dev->uclass->uc_drv->flags);
|
||||
if (!dev->uclass_priv) {
|
||||
ret = -ENOMEM;
|
||||
goto fail;
|
||||
|
@ -441,7 +442,7 @@ fail:
|
|||
return ret;
|
||||
}
|
||||
|
||||
void *dev_get_platdata(struct udevice *dev)
|
||||
void *dev_get_platdata(const struct udevice *dev)
|
||||
{
|
||||
if (!dev) {
|
||||
dm_warn("%s: null device\n", __func__);
|
||||
|
@ -451,7 +452,7 @@ void *dev_get_platdata(struct udevice *dev)
|
|||
return dev->platdata;
|
||||
}
|
||||
|
||||
void *dev_get_parent_platdata(struct udevice *dev)
|
||||
void *dev_get_parent_platdata(const struct udevice *dev)
|
||||
{
|
||||
if (!dev) {
|
||||
dm_warn("%s: null device\n", __func__);
|
||||
|
@ -461,7 +462,7 @@ void *dev_get_parent_platdata(struct udevice *dev)
|
|||
return dev->parent_platdata;
|
||||
}
|
||||
|
||||
void *dev_get_uclass_platdata(struct udevice *dev)
|
||||
void *dev_get_uclass_platdata(const struct udevice *dev)
|
||||
{
|
||||
if (!dev) {
|
||||
dm_warn("%s: null device\n", __func__);
|
||||
|
@ -471,7 +472,7 @@ void *dev_get_uclass_platdata(struct udevice *dev)
|
|||
return dev->uclass_platdata;
|
||||
}
|
||||
|
||||
void *dev_get_priv(struct udevice *dev)
|
||||
void *dev_get_priv(const struct udevice *dev)
|
||||
{
|
||||
if (!dev) {
|
||||
dm_warn("%s: null device\n", __func__);
|
||||
|
@ -481,7 +482,7 @@ void *dev_get_priv(struct udevice *dev)
|
|||
return dev->priv;
|
||||
}
|
||||
|
||||
void *dev_get_uclass_priv(struct udevice *dev)
|
||||
void *dev_get_uclass_priv(const struct udevice *dev)
|
||||
{
|
||||
if (!dev) {
|
||||
dm_warn("%s: null device\n", __func__);
|
||||
|
@ -491,7 +492,7 @@ void *dev_get_uclass_priv(struct udevice *dev)
|
|||
return dev->uclass_priv;
|
||||
}
|
||||
|
||||
void *dev_get_parent_priv(struct udevice *dev)
|
||||
void *dev_get_parent_priv(const struct udevice *dev)
|
||||
{
|
||||
if (!dev) {
|
||||
dm_warn("%s: null device\n", __func__);
|
||||
|
@ -680,17 +681,35 @@ int device_find_next_child(struct udevice **devp)
|
|||
return 0;
|
||||
}
|
||||
|
||||
struct udevice *dev_get_parent(struct udevice *child)
|
||||
int device_find_first_inactive_child(struct udevice *parent,
|
||||
enum uclass_id uclass_id,
|
||||
struct udevice **devp)
|
||||
{
|
||||
struct udevice *dev;
|
||||
|
||||
*devp = NULL;
|
||||
list_for_each_entry(dev, &parent->child_head, sibling_node) {
|
||||
if (!device_active(dev) &&
|
||||
device_get_uclass_id(dev) == uclass_id) {
|
||||
*devp = dev;
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
return -ENODEV;
|
||||
}
|
||||
|
||||
struct udevice *dev_get_parent(const struct udevice *child)
|
||||
{
|
||||
return child->parent;
|
||||
}
|
||||
|
||||
ulong dev_get_driver_data(struct udevice *dev)
|
||||
ulong dev_get_driver_data(const struct udevice *dev)
|
||||
{
|
||||
return dev->driver_data;
|
||||
}
|
||||
|
||||
const void *dev_get_driver_ops(struct udevice *dev)
|
||||
const void *dev_get_driver_ops(const struct udevice *dev)
|
||||
{
|
||||
if (!dev || !dev->driver->ops)
|
||||
return NULL;
|
||||
|
@ -698,12 +717,12 @@ const void *dev_get_driver_ops(struct udevice *dev)
|
|||
return dev->driver->ops;
|
||||
}
|
||||
|
||||
enum uclass_id device_get_uclass_id(struct udevice *dev)
|
||||
enum uclass_id device_get_uclass_id(const struct udevice *dev)
|
||||
{
|
||||
return dev->uclass->uc_drv->id;
|
||||
}
|
||||
|
||||
const char *dev_get_uclass_name(struct udevice *dev)
|
||||
const char *dev_get_uclass_name(const struct udevice *dev)
|
||||
{
|
||||
if (!dev)
|
||||
return NULL;
|
||||
|
@ -711,7 +730,7 @@ const char *dev_get_uclass_name(struct udevice *dev)
|
|||
return dev->uclass->uc_drv->name;
|
||||
}
|
||||
|
||||
bool device_has_children(struct udevice *dev)
|
||||
bool device_has_children(const struct udevice *dev)
|
||||
{
|
||||
return !list_empty(&dev->child_head);
|
||||
}
|
||||
|
|
|
@ -13,19 +13,30 @@
|
|||
int ofnode_read_fmap_entry(ofnode node, struct fmap_entry *entry)
|
||||
{
|
||||
const char *prop;
|
||||
u32 reg[2];
|
||||
|
||||
if (ofnode_read_u32_array(node, "reg", reg, 2)) {
|
||||
debug("Node '%s' has bad/missing 'reg' property\n",
|
||||
if (ofnode_read_u32(node, "image-pos", &entry->offset)) {
|
||||
debug("Node '%s' has bad/missing 'image-pos' property\n",
|
||||
ofnode_get_name(node));
|
||||
return -log_ret(ENOENT);
|
||||
return log_ret(-ENOENT);
|
||||
}
|
||||
if (ofnode_read_u32(node, "size", &entry->length)) {
|
||||
debug("Node '%s' has bad/missing 'size' property\n",
|
||||
ofnode_get_name(node));
|
||||
return log_ret(-ENOENT);
|
||||
}
|
||||
entry->offset = reg[0];
|
||||
entry->length = reg[1];
|
||||
entry->used = ofnode_read_s32_default(node, "used", entry->length);
|
||||
prop = ofnode_read_string(node, "compress");
|
||||
entry->compress_algo = prop && !strcmp(prop, "lzo") ?
|
||||
FMAP_COMPRESS_LZO : FMAP_COMPRESS_NONE;
|
||||
if (prop) {
|
||||
if (!strcmp(prop, "lz4"))
|
||||
entry->compress_algo = FMAP_COMPRESS_LZ4;
|
||||
else
|
||||
return log_msg_ret("Unknown compression algo",
|
||||
-EINVAL);
|
||||
} else {
|
||||
entry->compress_algo = FMAP_COMPRESS_NONE;
|
||||
}
|
||||
entry->unc_length = ofnode_read_s32_default(node, "uncomp-size",
|
||||
entry->length);
|
||||
prop = ofnode_read_string(node, "hash");
|
||||
if (prop)
|
||||
entry->hash_size = strlen(prop);
|
||||
|
|
|
@ -541,9 +541,13 @@ fdt_addr_t ofnode_get_addr_size(ofnode node, const char *property,
|
|||
if (!prop)
|
||||
return FDT_ADDR_T_NONE;
|
||||
na = of_n_addr_cells(np);
|
||||
ns = of_n_addr_cells(np);
|
||||
ns = of_n_size_cells(np);
|
||||
*sizep = of_read_number(prop + na, ns);
|
||||
return of_read_number(prop, na);
|
||||
|
||||
if (IS_ENABLED(CONFIG_OF_TRANSLATE) && ns > 0)
|
||||
return of_translate_address(np, prop);
|
||||
else
|
||||
return of_read_number(prop, na);
|
||||
} else {
|
||||
return fdtdec_get_addr_size(gd->fdt_blob,
|
||||
ofnode_to_offset(node), property,
|
||||
|
@ -695,6 +699,8 @@ bool ofnode_pre_reloc(ofnode node)
|
|||
{
|
||||
if (ofnode_read_bool(node, "u-boot,dm-pre-reloc"))
|
||||
return true;
|
||||
if (ofnode_read_bool(node, "u-boot,dm-pre-proper"))
|
||||
return true;
|
||||
|
||||
#ifdef CONFIG_TPL_BUILD
|
||||
if (ofnode_read_bool(node, "u-boot,dm-tpl"))
|
||||
|
|
|
@ -1,3 +1,16 @@
|
|||
config INPUT
|
||||
bool "Enable input subsystem"
|
||||
depends on DM
|
||||
default y
|
||||
|
||||
config SPL_INPUT
|
||||
bool "Enable input subsystem for SPL"
|
||||
depends on SPL_DM
|
||||
|
||||
config TPL_INPUT
|
||||
bool "Enable input subsystem for TPL"
|
||||
depends on TPL_DM
|
||||
|
||||
config DM_KEYBOARD
|
||||
bool "Enable driver model keyboard support"
|
||||
depends on DM
|
||||
|
@ -7,8 +20,43 @@ config DM_KEYBOARD
|
|||
includes methods to start/stop the device, check for available
|
||||
input and update LEDs if the keyboard has them.
|
||||
|
||||
config SPL_DM_KEYBOARD
|
||||
bool "Enable driver model keyboard support"
|
||||
depends on SPL_DM
|
||||
help
|
||||
This adds a uclass for keyboards and implements keyboard support
|
||||
using driver model. The API is implemented by keyboard.h and
|
||||
includes methods to start/stop the device, check for available
|
||||
input and update LEDs if the keyboard has them.
|
||||
|
||||
config TPL_DM_KEYBOARD
|
||||
bool "Enable driver model keyboard support"
|
||||
depends on TPL_DM
|
||||
help
|
||||
This adds a uclass for keyboards and implements keyboard support
|
||||
using driver model. The API is implemented by keyboard.h and
|
||||
includes methods to start/stop the device, check for available
|
||||
input and update LEDs if the keyboard has them.
|
||||
|
||||
config CROS_EC_KEYB
|
||||
bool "Enable Chrome OS EC keyboard support"
|
||||
depends on INPUT
|
||||
help
|
||||
Most ARM Chromebooks use an EC to provide access to the keyboard.
|
||||
Messages are used to request key scans from the EC and these are
|
||||
then decoded into keys by this driver.
|
||||
|
||||
config SPL_CROS_EC_KEYB
|
||||
bool "Enable Chrome OS EC keyboard support in SPL"
|
||||
depends on SPL_INPUT
|
||||
help
|
||||
Most ARM Chromebooks use an EC to provide access to the keyboard.
|
||||
Messages are used to request key scans from the EC and these are
|
||||
then decoded into keys by this driver.
|
||||
|
||||
config TPL_CROS_EC_KEYB
|
||||
bool "Enable Chrome OS EC keyboard support in TPL"
|
||||
depends on TPL_INPUT
|
||||
help
|
||||
Most ARM Chromebooks use an EC to provide access to the keyboard.
|
||||
Messages are used to request key scans from the EC and these are
|
||||
|
|
|
@ -3,12 +3,15 @@
|
|||
# (C) Copyright 2000-2007
|
||||
# Wolfgang Denk, DENX Software Engineering, wd@denx.de.
|
||||
|
||||
obj-$(CONFIG_DM_KEYBOARD) += keyboard-uclass.o
|
||||
obj-y += input.o
|
||||
obj-$(CONFIG_$(SPL_TPL_)CROS_EC_KEYB) += cros_ec_keyb.o
|
||||
obj-$(CONFIG_$(SPL_TPL_)OF_CONTROL) += key_matrix.o
|
||||
obj-$(CONFIG_$(SPL_TPL_)DM_KEYBOARD) += keyboard-uclass.o
|
||||
|
||||
ifndef CONFIG_SPL_BUILD
|
||||
|
||||
obj-$(CONFIG_I8042_KEYB) += i8042.o
|
||||
obj-$(CONFIG_TEGRA_KEYBOARD) += tegra-kbc.o
|
||||
obj-$(CONFIG_TWL4030_INPUT) += twl4030.o
|
||||
obj-$(CONFIG_TWL6030_INPUT) += twl6030.o
|
||||
obj-$(CONFIG_CROS_EC_KEYB) += cros_ec_keyb.o
|
||||
obj-y += input.o
|
||||
obj-$(CONFIG_$(SPL_)OF_CONTROL) += key_matrix.o
|
||||
endif
|
||||
|
|
|
@ -652,7 +652,7 @@ int input_stdio_register(struct stdio_dev *dev)
|
|||
int error;
|
||||
|
||||
error = stdio_register(dev);
|
||||
|
||||
#if !defined(CONFIG_SPL_BUILD) || CONFIG_IS_ENABLED(ENV_SUPPORT)
|
||||
/* check if this is the standard input device */
|
||||
if (!error && strcmp(env_get("stdin"), dev->name) == 0) {
|
||||
/* reassign the console */
|
||||
|
@ -660,6 +660,9 @@ int input_stdio_register(struct stdio_dev *dev)
|
|||
console_assign(stdin, dev->name))
|
||||
return -1;
|
||||
}
|
||||
#else
|
||||
error = error;
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -83,15 +83,15 @@ int cros_ec_calc_checksum(const uint8_t *data, int size)
|
|||
* @param dout_len Size of output data in bytes
|
||||
* @return packet size in bytes, or <0 if error.
|
||||
*/
|
||||
static int create_proto3_request(struct cros_ec_dev *dev,
|
||||
static int create_proto3_request(struct cros_ec_dev *cdev,
|
||||
int cmd, int cmd_version,
|
||||
const void *dout, int dout_len)
|
||||
{
|
||||
struct ec_host_request *rq = (struct ec_host_request *)dev->dout;
|
||||
struct ec_host_request *rq = (struct ec_host_request *)cdev->dout;
|
||||
int out_bytes = dout_len + sizeof(*rq);
|
||||
|
||||
/* Fail if output size is too big */
|
||||
if (out_bytes > (int)sizeof(dev->dout)) {
|
||||
if (out_bytes > (int)sizeof(cdev->dout)) {
|
||||
debug("%s: Cannot send %d bytes\n", __func__, dout_len);
|
||||
return -EC_RES_REQUEST_TRUNCATED;
|
||||
}
|
||||
|
@ -108,9 +108,9 @@ static int create_proto3_request(struct cros_ec_dev *dev,
|
|||
memcpy(rq + 1, dout, dout_len);
|
||||
|
||||
/* Write checksum field so the entire packet sums to 0 */
|
||||
rq->checksum = (uint8_t)(-cros_ec_calc_checksum(dev->dout, out_bytes));
|
||||
rq->checksum = (uint8_t)(-cros_ec_calc_checksum(cdev->dout, out_bytes));
|
||||
|
||||
cros_ec_dump_data("out", cmd, dev->dout, out_bytes);
|
||||
cros_ec_dump_data("out", cmd, cdev->dout, out_bytes);
|
||||
|
||||
/* Return size of request packet */
|
||||
return out_bytes;
|
||||
|
@ -123,12 +123,12 @@ static int create_proto3_request(struct cros_ec_dev *dev,
|
|||
* @param din_len Maximum size of response in bytes
|
||||
* @return maximum expected number of bytes in response, or <0 if error.
|
||||
*/
|
||||
static int prepare_proto3_response_buffer(struct cros_ec_dev *dev, int din_len)
|
||||
static int prepare_proto3_response_buffer(struct cros_ec_dev *cdev, int din_len)
|
||||
{
|
||||
int in_bytes = din_len + sizeof(struct ec_host_response);
|
||||
|
||||
/* Fail if input size is too big */
|
||||
if (in_bytes > (int)sizeof(dev->din)) {
|
||||
if (in_bytes > (int)sizeof(cdev->din)) {
|
||||
debug("%s: Cannot receive %d bytes\n", __func__, din_len);
|
||||
return -EC_RES_RESPONSE_TOO_BIG;
|
||||
}
|
||||
|
@ -197,7 +197,7 @@ static int handle_proto3_response(struct cros_ec_dev *dev,
|
|||
return rs->data_len;
|
||||
}
|
||||
|
||||
static int send_command_proto3(struct cros_ec_dev *dev,
|
||||
static int send_command_proto3(struct cros_ec_dev *cdev,
|
||||
int cmd, int cmd_version,
|
||||
const void *dout, int dout_len,
|
||||
uint8_t **dinp, int din_len)
|
||||
|
@ -207,23 +207,24 @@ static int send_command_proto3(struct cros_ec_dev *dev,
|
|||
int rv;
|
||||
|
||||
/* Create request packet */
|
||||
out_bytes = create_proto3_request(dev, cmd, cmd_version,
|
||||
out_bytes = create_proto3_request(cdev, cmd, cmd_version,
|
||||
dout, dout_len);
|
||||
if (out_bytes < 0)
|
||||
return out_bytes;
|
||||
|
||||
/* Prepare response buffer */
|
||||
in_bytes = prepare_proto3_response_buffer(dev, din_len);
|
||||
in_bytes = prepare_proto3_response_buffer(cdev, din_len);
|
||||
if (in_bytes < 0)
|
||||
return in_bytes;
|
||||
|
||||
ops = dm_cros_ec_get_ops(dev->dev);
|
||||
rv = ops->packet ? ops->packet(dev->dev, out_bytes, in_bytes) : -ENOSYS;
|
||||
ops = dm_cros_ec_get_ops(cdev->dev);
|
||||
rv = ops->packet ? ops->packet(cdev->dev, out_bytes, in_bytes) :
|
||||
-ENOSYS;
|
||||
if (rv < 0)
|
||||
return rv;
|
||||
|
||||
/* Process the response */
|
||||
return handle_proto3_response(dev, dinp, din_len);
|
||||
return handle_proto3_response(cdev, dinp, din_len);
|
||||
}
|
||||
|
||||
static int send_command(struct cros_ec_dev *dev, uint8_t cmd, int cmd_version,
|
||||
|
@ -262,15 +263,16 @@ static int send_command(struct cros_ec_dev *dev, uint8_t cmd, int cmd_version,
|
|||
* @param din_len Maximum size of response in bytes
|
||||
* @return number of bytes in response, or -ve on error
|
||||
*/
|
||||
static int ec_command_inptr(struct cros_ec_dev *dev, uint8_t cmd,
|
||||
int cmd_version, const void *dout, int dout_len, uint8_t **dinp,
|
||||
int din_len)
|
||||
static int ec_command_inptr(struct udevice *dev, uint8_t cmd,
|
||||
int cmd_version, const void *dout, int dout_len,
|
||||
uint8_t **dinp, int din_len)
|
||||
{
|
||||
struct cros_ec_dev *cdev = dev_get_uclass_priv(dev);
|
||||
uint8_t *din = NULL;
|
||||
int len;
|
||||
|
||||
len = send_command(dev, cmd, cmd_version, dout, dout_len,
|
||||
&din, din_len);
|
||||
len = send_command(cdev, cmd, cmd_version, dout, dout_len, &din,
|
||||
din_len);
|
||||
|
||||
/* If the command doesn't complete, wait a while */
|
||||
if (len == -EC_RES_IN_PROGRESS) {
|
||||
|
@ -283,9 +285,9 @@ static int ec_command_inptr(struct cros_ec_dev *dev, uint8_t cmd,
|
|||
int ret;
|
||||
|
||||
mdelay(50); /* Insert some reasonable delay */
|
||||
ret = send_command(dev, EC_CMD_GET_COMMS_STATUS, 0,
|
||||
NULL, 0,
|
||||
(uint8_t **)&resp, sizeof(*resp));
|
||||
ret = send_command(cdev, EC_CMD_GET_COMMS_STATUS, 0,
|
||||
NULL, 0,
|
||||
(uint8_t **)&resp, sizeof(*resp));
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
|
||||
|
@ -298,8 +300,8 @@ static int ec_command_inptr(struct cros_ec_dev *dev, uint8_t cmd,
|
|||
|
||||
/* OK it completed, so read the status response */
|
||||
/* not sure why it was 0 for the last argument */
|
||||
len = send_command(dev, EC_CMD_RESEND_RESPONSE, 0,
|
||||
NULL, 0, &din, din_len);
|
||||
len = send_command(cdev, EC_CMD_RESEND_RESPONSE, 0, NULL, 0,
|
||||
&din, din_len);
|
||||
}
|
||||
|
||||
debug("%s: len=%d, din=%p\n", __func__, len, din);
|
||||
|
@ -328,7 +330,7 @@ static int ec_command_inptr(struct cros_ec_dev *dev, uint8_t cmd,
|
|||
* @param din_len Maximum size of response in bytes
|
||||
* @return number of bytes in response, or -ve on error
|
||||
*/
|
||||
static int ec_command(struct cros_ec_dev *dev, uint8_t cmd, int cmd_version,
|
||||
static int ec_command(struct udevice *dev, uint8_t cmd, int cmd_version,
|
||||
const void *dout, int dout_len,
|
||||
void *din, int din_len)
|
||||
{
|
||||
|
@ -337,7 +339,7 @@ static int ec_command(struct cros_ec_dev *dev, uint8_t cmd, int cmd_version,
|
|||
|
||||
assert((din_len == 0) || din);
|
||||
len = ec_command_inptr(dev, cmd, cmd_version, dout, dout_len,
|
||||
&in_buffer, din_len);
|
||||
&in_buffer, din_len);
|
||||
if (len > 0) {
|
||||
/*
|
||||
* If we were asked to put it somewhere, do so, otherwise just
|
||||
|
@ -353,16 +355,14 @@ static int ec_command(struct cros_ec_dev *dev, uint8_t cmd, int cmd_version,
|
|||
|
||||
int cros_ec_scan_keyboard(struct udevice *dev, struct mbkp_keyscan *scan)
|
||||
{
|
||||
struct cros_ec_dev *cdev = dev_get_uclass_priv(dev);
|
||||
|
||||
if (ec_command(cdev, EC_CMD_MKBP_STATE, 0, NULL, 0, scan,
|
||||
if (ec_command(dev, EC_CMD_MKBP_STATE, 0, NULL, 0, scan,
|
||||
sizeof(scan->data)) != sizeof(scan->data))
|
||||
return -1;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int cros_ec_read_id(struct cros_ec_dev *dev, char *id, int maxlen)
|
||||
int cros_ec_read_id(struct udevice *dev, char *id, int maxlen)
|
||||
{
|
||||
struct ec_response_get_version *r;
|
||||
|
||||
|
@ -388,8 +388,8 @@ int cros_ec_read_id(struct cros_ec_dev *dev, char *id, int maxlen)
|
|||
return 0;
|
||||
}
|
||||
|
||||
int cros_ec_read_version(struct cros_ec_dev *dev,
|
||||
struct ec_response_get_version **versionp)
|
||||
int cros_ec_read_version(struct udevice *dev,
|
||||
struct ec_response_get_version **versionp)
|
||||
{
|
||||
if (ec_command_inptr(dev, EC_CMD_GET_VERSION, 0, NULL, 0,
|
||||
(uint8_t **)versionp, sizeof(**versionp))
|
||||
|
@ -399,7 +399,7 @@ int cros_ec_read_version(struct cros_ec_dev *dev,
|
|||
return 0;
|
||||
}
|
||||
|
||||
int cros_ec_read_build_info(struct cros_ec_dev *dev, char **strp)
|
||||
int cros_ec_read_build_info(struct udevice *dev, char **strp)
|
||||
{
|
||||
if (ec_command_inptr(dev, EC_CMD_GET_BUILD_INFO, 0, NULL, 0,
|
||||
(uint8_t **)strp, EC_PROTO2_MAX_PARAM_SIZE) < 0)
|
||||
|
@ -408,8 +408,8 @@ int cros_ec_read_build_info(struct cros_ec_dev *dev, char **strp)
|
|||
return 0;
|
||||
}
|
||||
|
||||
int cros_ec_read_current_image(struct cros_ec_dev *dev,
|
||||
enum ec_current_image *image)
|
||||
int cros_ec_read_current_image(struct udevice *dev,
|
||||
enum ec_current_image *image)
|
||||
{
|
||||
struct ec_response_get_version *r;
|
||||
|
||||
|
@ -421,8 +421,8 @@ int cros_ec_read_current_image(struct cros_ec_dev *dev,
|
|||
return 0;
|
||||
}
|
||||
|
||||
static int cros_ec_wait_on_hash_done(struct cros_ec_dev *dev,
|
||||
struct ec_response_vboot_hash *hash)
|
||||
static int cros_ec_wait_on_hash_done(struct udevice *dev,
|
||||
struct ec_response_vboot_hash *hash)
|
||||
{
|
||||
struct ec_params_vboot_hash p;
|
||||
ulong start;
|
||||
|
@ -444,14 +444,14 @@ static int cros_ec_wait_on_hash_done(struct cros_ec_dev *dev,
|
|||
return 0;
|
||||
}
|
||||
|
||||
|
||||
int cros_ec_read_hash(struct cros_ec_dev *dev,
|
||||
struct ec_response_vboot_hash *hash)
|
||||
int cros_ec_read_hash(struct udevice *dev, uint hash_offset,
|
||||
struct ec_response_vboot_hash *hash)
|
||||
{
|
||||
struct ec_params_vboot_hash p;
|
||||
int rv;
|
||||
|
||||
p.cmd = EC_VBOOT_HASH_GET;
|
||||
p.offset = hash_offset;
|
||||
if (ec_command(dev, EC_CMD_VBOOT_HASH, 0, &p, sizeof(p),
|
||||
hash, sizeof(*hash)) < 0)
|
||||
return -1;
|
||||
|
@ -474,7 +474,7 @@ int cros_ec_read_hash(struct cros_ec_dev *dev,
|
|||
p.cmd = EC_VBOOT_HASH_START;
|
||||
p.hash_type = EC_VBOOT_HASH_TYPE_SHA256;
|
||||
p.nonce_size = 0;
|
||||
p.offset = EC_VBOOT_HASH_OFFSET_RW;
|
||||
p.offset = hash_offset;
|
||||
|
||||
if (ec_command(dev, EC_CMD_VBOOT_HASH, 0, &p, sizeof(p),
|
||||
hash, sizeof(*hash)) < 0)
|
||||
|
@ -489,7 +489,7 @@ int cros_ec_read_hash(struct cros_ec_dev *dev,
|
|||
return 0;
|
||||
}
|
||||
|
||||
static int cros_ec_invalidate_hash(struct cros_ec_dev *dev)
|
||||
static int cros_ec_invalidate_hash(struct udevice *dev)
|
||||
{
|
||||
struct ec_params_vboot_hash p;
|
||||
struct ec_response_vboot_hash *hash;
|
||||
|
@ -514,8 +514,7 @@ static int cros_ec_invalidate_hash(struct cros_ec_dev *dev)
|
|||
return 0;
|
||||
}
|
||||
|
||||
int cros_ec_reboot(struct cros_ec_dev *dev, enum ec_reboot_cmd cmd,
|
||||
uint8_t flags)
|
||||
int cros_ec_reboot(struct udevice *dev, enum ec_reboot_cmd cmd, uint8_t flags)
|
||||
{
|
||||
struct ec_params_reboot_ec p;
|
||||
|
||||
|
@ -555,7 +554,7 @@ int cros_ec_interrupt_pending(struct udevice *dev)
|
|||
return dm_gpio_get_value(&cdev->ec_int);
|
||||
}
|
||||
|
||||
int cros_ec_info(struct cros_ec_dev *dev, struct ec_response_mkbp_info *info)
|
||||
int cros_ec_info(struct udevice *dev, struct ec_response_mkbp_info *info)
|
||||
{
|
||||
if (ec_command(dev, EC_CMD_MKBP_INFO, 0, NULL, 0, info,
|
||||
sizeof(*info)) != sizeof(*info))
|
||||
|
@ -564,7 +563,7 @@ int cros_ec_info(struct cros_ec_dev *dev, struct ec_response_mkbp_info *info)
|
|||
return 0;
|
||||
}
|
||||
|
||||
int cros_ec_get_host_events(struct cros_ec_dev *dev, uint32_t *events_ptr)
|
||||
int cros_ec_get_host_events(struct udevice *dev, uint32_t *events_ptr)
|
||||
{
|
||||
struct ec_response_host_event_mask *resp;
|
||||
|
||||
|
@ -583,7 +582,7 @@ int cros_ec_get_host_events(struct cros_ec_dev *dev, uint32_t *events_ptr)
|
|||
return 0;
|
||||
}
|
||||
|
||||
int cros_ec_clear_host_events(struct cros_ec_dev *dev, uint32_t events)
|
||||
int cros_ec_clear_host_events(struct udevice *dev, uint32_t events)
|
||||
{
|
||||
struct ec_params_host_event_mask params;
|
||||
|
||||
|
@ -600,9 +599,9 @@ int cros_ec_clear_host_events(struct cros_ec_dev *dev, uint32_t events)
|
|||
return 0;
|
||||
}
|
||||
|
||||
int cros_ec_flash_protect(struct cros_ec_dev *dev,
|
||||
uint32_t set_mask, uint32_t set_flags,
|
||||
struct ec_response_flash_protect *resp)
|
||||
int cros_ec_flash_protect(struct udevice *dev, uint32_t set_mask,
|
||||
uint32_t set_flags,
|
||||
struct ec_response_flash_protect *resp)
|
||||
{
|
||||
struct ec_params_flash_protect params;
|
||||
|
||||
|
@ -617,17 +616,18 @@ int cros_ec_flash_protect(struct cros_ec_dev *dev,
|
|||
return 0;
|
||||
}
|
||||
|
||||
static int cros_ec_check_version(struct cros_ec_dev *dev)
|
||||
static int cros_ec_check_version(struct udevice *dev)
|
||||
{
|
||||
struct cros_ec_dev *cdev = dev_get_uclass_priv(dev);
|
||||
struct ec_params_hello req;
|
||||
struct ec_response_hello *resp;
|
||||
|
||||
struct dm_cros_ec_ops *ops;
|
||||
int ret;
|
||||
|
||||
ops = dm_cros_ec_get_ops(dev->dev);
|
||||
ops = dm_cros_ec_get_ops(dev);
|
||||
if (ops->check_version) {
|
||||
ret = ops->check_version(dev->dev);
|
||||
ret = ops->check_version(dev);
|
||||
if (ret)
|
||||
return ret;
|
||||
}
|
||||
|
@ -647,7 +647,7 @@ static int cros_ec_check_version(struct cros_ec_dev *dev)
|
|||
*/
|
||||
|
||||
/* Try sending a version 3 packet */
|
||||
dev->protocol_version = 3;
|
||||
cdev->protocol_version = 3;
|
||||
req.in_data = 0;
|
||||
if (ec_command_inptr(dev, EC_CMD_HELLO, 0, &req, sizeof(req),
|
||||
(uint8_t **)&resp, sizeof(*resp)) > 0) {
|
||||
|
@ -655,9 +655,9 @@ static int cros_ec_check_version(struct cros_ec_dev *dev)
|
|||
}
|
||||
|
||||
/* Try sending a version 2 packet */
|
||||
dev->protocol_version = 2;
|
||||
cdev->protocol_version = 2;
|
||||
if (ec_command_inptr(dev, EC_CMD_HELLO, 0, &req, sizeof(req),
|
||||
(uint8_t **)&resp, sizeof(*resp)) > 0) {
|
||||
(uint8_t **)&resp, sizeof(*resp)) > 0) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -667,12 +667,12 @@ static int cros_ec_check_version(struct cros_ec_dev *dev)
|
|||
* version is no longer supported, and we don't know about any new
|
||||
* protocol versions.
|
||||
*/
|
||||
dev->protocol_version = 0;
|
||||
cdev->protocol_version = 0;
|
||||
printf("%s: ERROR: old EC interface not supported\n", __func__);
|
||||
return -1;
|
||||
}
|
||||
|
||||
int cros_ec_test(struct cros_ec_dev *dev)
|
||||
int cros_ec_test(struct udevice *dev)
|
||||
{
|
||||
struct ec_params_hello req;
|
||||
struct ec_response_hello *resp;
|
||||
|
@ -691,7 +691,7 @@ int cros_ec_test(struct cros_ec_dev *dev)
|
|||
return 0;
|
||||
}
|
||||
|
||||
int cros_ec_flash_offset(struct cros_ec_dev *dev, enum ec_flash_region region,
|
||||
int cros_ec_flash_offset(struct udevice *dev, enum ec_flash_region region,
|
||||
uint32_t *offset, uint32_t *size)
|
||||
{
|
||||
struct ec_params_flash_region_info p;
|
||||
|
@ -713,7 +713,7 @@ int cros_ec_flash_offset(struct cros_ec_dev *dev, enum ec_flash_region region,
|
|||
return 0;
|
||||
}
|
||||
|
||||
int cros_ec_flash_erase(struct cros_ec_dev *dev, uint32_t offset, uint32_t size)
|
||||
int cros_ec_flash_erase(struct udevice *dev, uint32_t offset, uint32_t size)
|
||||
{
|
||||
struct ec_params_flash_erase p;
|
||||
|
||||
|
@ -741,8 +741,8 @@ int cros_ec_flash_erase(struct cros_ec_dev *dev, uint32_t offset, uint32_t size)
|
|||
* @param size Number of bytes to write
|
||||
* @return 0 if ok, -1 on error
|
||||
*/
|
||||
static int cros_ec_flash_write_block(struct cros_ec_dev *dev,
|
||||
const uint8_t *data, uint32_t offset, uint32_t size)
|
||||
static int cros_ec_flash_write_block(struct udevice *dev, const uint8_t *data,
|
||||
uint32_t offset, uint32_t size)
|
||||
{
|
||||
struct ec_params_flash_write *p;
|
||||
int ret;
|
||||
|
@ -767,7 +767,7 @@ static int cros_ec_flash_write_block(struct cros_ec_dev *dev,
|
|||
/**
|
||||
* Return optimal flash write burst size
|
||||
*/
|
||||
static int cros_ec_flash_write_burst_size(struct cros_ec_dev *dev)
|
||||
static int cros_ec_flash_write_burst_size(struct udevice *dev)
|
||||
{
|
||||
return EC_FLASH_WRITE_VER0_SIZE;
|
||||
}
|
||||
|
@ -801,8 +801,8 @@ static int cros_ec_data_is_erased(const uint32_t *data, int size)
|
|||
* @param dev Pointer to device
|
||||
* @param info Pointer to output flash info struct
|
||||
*/
|
||||
int cros_ec_read_flashinfo(struct cros_ec_dev *dev,
|
||||
struct ec_response_flash_info *info)
|
||||
int cros_ec_read_flashinfo(struct udevice *dev,
|
||||
struct ec_response_flash_info *info)
|
||||
{
|
||||
int ret;
|
||||
|
||||
|
@ -814,9 +814,10 @@ int cros_ec_read_flashinfo(struct cros_ec_dev *dev,
|
|||
return ret < sizeof(*info) ? -1 : 0;
|
||||
}
|
||||
|
||||
int cros_ec_flash_write(struct cros_ec_dev *dev, const uint8_t *data,
|
||||
uint32_t offset, uint32_t size)
|
||||
int cros_ec_flash_write(struct udevice *dev, const uint8_t *data,
|
||||
uint32_t offset, uint32_t size)
|
||||
{
|
||||
struct cros_ec_dev *cdev = dev_get_uclass_priv(dev);
|
||||
uint32_t burst = cros_ec_flash_write_burst_size(dev);
|
||||
uint32_t end, off;
|
||||
int ret;
|
||||
|
@ -831,8 +832,8 @@ int cros_ec_flash_write(struct cros_ec_dev *dev, const uint8_t *data,
|
|||
|
||||
/* If the data is empty, there is no point in programming it */
|
||||
todo = min(end - off, burst);
|
||||
if (dev->optimise_flash_write &&
|
||||
cros_ec_data_is_erased((uint32_t *)data, todo))
|
||||
if (cdev->optimise_flash_write &&
|
||||
cros_ec_data_is_erased((uint32_t *)data, todo))
|
||||
continue;
|
||||
|
||||
ret = cros_ec_flash_write_block(dev, data, off, todo);
|
||||
|
@ -858,8 +859,8 @@ int cros_ec_flash_write(struct cros_ec_dev *dev, const uint8_t *data,
|
|||
* @param size Number of bytes to read
|
||||
* @return 0 if ok, -1 on error
|
||||
*/
|
||||
static int cros_ec_flash_read_block(struct cros_ec_dev *dev, uint8_t *data,
|
||||
uint32_t offset, uint32_t size)
|
||||
static int cros_ec_flash_read_block(struct udevice *dev, uint8_t *data,
|
||||
uint32_t offset, uint32_t size)
|
||||
{
|
||||
struct ec_params_flash_read p;
|
||||
|
||||
|
@ -870,8 +871,8 @@ static int cros_ec_flash_read_block(struct cros_ec_dev *dev, uint8_t *data,
|
|||
&p, sizeof(p), data, size) >= 0 ? 0 : -1;
|
||||
}
|
||||
|
||||
int cros_ec_flash_read(struct cros_ec_dev *dev, uint8_t *data, uint32_t offset,
|
||||
uint32_t size)
|
||||
int cros_ec_flash_read(struct udevice *dev, uint8_t *data, uint32_t offset,
|
||||
uint32_t size)
|
||||
{
|
||||
uint32_t burst = cros_ec_flash_write_burst_size(dev);
|
||||
uint32_t end, off;
|
||||
|
@ -888,13 +889,14 @@ int cros_ec_flash_read(struct cros_ec_dev *dev, uint8_t *data, uint32_t offset,
|
|||
return 0;
|
||||
}
|
||||
|
||||
int cros_ec_flash_update_rw(struct cros_ec_dev *dev,
|
||||
const uint8_t *image, int image_size)
|
||||
int cros_ec_flash_update_rw(struct udevice *dev, const uint8_t *image,
|
||||
int image_size)
|
||||
{
|
||||
uint32_t rw_offset, rw_size;
|
||||
int ret;
|
||||
|
||||
if (cros_ec_flash_offset(dev, EC_FLASH_REGION_RW, &rw_offset, &rw_size))
|
||||
if (cros_ec_flash_offset(dev, EC_FLASH_REGION_ACTIVE, &rw_offset,
|
||||
&rw_size))
|
||||
return -1;
|
||||
if (image_size > (int)rw_size)
|
||||
return -1;
|
||||
|
@ -927,26 +929,31 @@ int cros_ec_flash_update_rw(struct cros_ec_dev *dev,
|
|||
return 0;
|
||||
}
|
||||
|
||||
int cros_ec_read_vbnvcontext(struct cros_ec_dev *dev, uint8_t *block)
|
||||
int cros_ec_read_nvdata(struct udevice *dev, uint8_t *block, int size)
|
||||
{
|
||||
struct ec_params_vbnvcontext p;
|
||||
int len;
|
||||
|
||||
if (size != EC_VBNV_BLOCK_SIZE)
|
||||
return -EINVAL;
|
||||
|
||||
p.op = EC_VBNV_CONTEXT_OP_READ;
|
||||
|
||||
len = ec_command(dev, EC_CMD_VBNV_CONTEXT, EC_VER_VBNV_CONTEXT,
|
||||
&p, sizeof(p), block, EC_VBNV_BLOCK_SIZE);
|
||||
if (len < EC_VBNV_BLOCK_SIZE)
|
||||
return -1;
|
||||
return -EIO;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int cros_ec_write_vbnvcontext(struct cros_ec_dev *dev, const uint8_t *block)
|
||||
int cros_ec_write_nvdata(struct udevice *dev, const uint8_t *block, int size)
|
||||
{
|
||||
struct ec_params_vbnvcontext p;
|
||||
int len;
|
||||
|
||||
if (size != EC_VBNV_BLOCK_SIZE)
|
||||
return -EINVAL;
|
||||
p.op = EC_VBNV_CONTEXT_OP_WRITE;
|
||||
memcpy(p.block, block, sizeof(p.block));
|
||||
|
||||
|
@ -960,13 +967,12 @@ int cros_ec_write_vbnvcontext(struct cros_ec_dev *dev, const uint8_t *block)
|
|||
|
||||
int cros_ec_set_ldo(struct udevice *dev, uint8_t index, uint8_t state)
|
||||
{
|
||||
struct cros_ec_dev *cdev = dev_get_uclass_priv(dev);
|
||||
struct ec_params_ldo_set params;
|
||||
|
||||
params.index = index;
|
||||
params.state = state;
|
||||
|
||||
if (ec_command_inptr(cdev, EC_CMD_LDO_SET, 0, ¶ms, sizeof(params),
|
||||
if (ec_command_inptr(dev, EC_CMD_LDO_SET, 0, ¶ms, sizeof(params),
|
||||
NULL, 0))
|
||||
return -1;
|
||||
|
||||
|
@ -975,13 +981,12 @@ int cros_ec_set_ldo(struct udevice *dev, uint8_t index, uint8_t state)
|
|||
|
||||
int cros_ec_get_ldo(struct udevice *dev, uint8_t index, uint8_t *state)
|
||||
{
|
||||
struct cros_ec_dev *cdev = dev_get_uclass_priv(dev);
|
||||
struct ec_params_ldo_get params;
|
||||
struct ec_response_ldo_get *resp;
|
||||
|
||||
params.index = index;
|
||||
|
||||
if (ec_command_inptr(cdev, EC_CMD_LDO_GET, 0, ¶ms, sizeof(params),
|
||||
if (ec_command_inptr(dev, EC_CMD_LDO_GET, 0, ¶ms, sizeof(params),
|
||||
(uint8_t **)&resp, sizeof(*resp)) !=
|
||||
sizeof(*resp))
|
||||
return -1;
|
||||
|
@ -1001,12 +1006,12 @@ int cros_ec_register(struct udevice *dev)
|
|||
GPIOD_IS_IN);
|
||||
cdev->optimise_flash_write = dev_read_bool(dev, "optimise-flash-write");
|
||||
|
||||
if (cros_ec_check_version(cdev)) {
|
||||
if (cros_ec_check_version(dev)) {
|
||||
debug("%s: Could not detect CROS-EC version\n", __func__);
|
||||
return -CROS_EC_ERR_CHECK_VERSION;
|
||||
}
|
||||
|
||||
if (cros_ec_read_id(cdev, id, sizeof(id))) {
|
||||
if (cros_ec_read_id(dev, id, sizeof(id))) {
|
||||
debug("%s: Could not read KBC ID\n", __func__);
|
||||
return -CROS_EC_ERR_READ_ID;
|
||||
}
|
||||
|
@ -1042,7 +1047,7 @@ int cros_ec_decode_ec_flash(struct udevice *dev, struct fdt_cros_ec *config)
|
|||
if (0 == strcmp(name, "ro")) {
|
||||
region = EC_FLASH_REGION_RO;
|
||||
} else if (0 == strcmp(name, "rw")) {
|
||||
region = EC_FLASH_REGION_RW;
|
||||
region = EC_FLASH_REGION_ACTIVE;
|
||||
} else if (0 == strcmp(name, "wp-ro")) {
|
||||
region = EC_FLASH_REGION_WP_RO;
|
||||
} else {
|
||||
|
@ -1062,7 +1067,6 @@ int cros_ec_decode_ec_flash(struct udevice *dev, struct fdt_cros_ec *config)
|
|||
int cros_ec_i2c_tunnel(struct udevice *dev, int port, struct i2c_msg *in,
|
||||
int nmsgs)
|
||||
{
|
||||
struct cros_ec_dev *cdev = dev_get_uclass_priv(dev);
|
||||
union {
|
||||
struct ec_params_i2c_passthru p;
|
||||
uint8_t outbuf[EC_PROTO2_MAX_PARAM_SIZE];
|
||||
|
@ -1112,7 +1116,7 @@ int cros_ec_i2c_tunnel(struct udevice *dev, int port, struct i2c_msg *in,
|
|||
}
|
||||
}
|
||||
|
||||
rv = ec_command(cdev, EC_CMD_I2C_PASSTHRU, 0, p, pdata - (uint8_t *)p,
|
||||
rv = ec_command(dev, EC_CMD_I2C_PASSTHRU, 0, p, pdata - (uint8_t *)p,
|
||||
r, sizeof(*r) + read_len);
|
||||
if (rv < 0)
|
||||
return rv;
|
||||
|
|
|
@ -40,6 +40,38 @@ static int wait_for_sync(struct cros_ec_dev *dev)
|
|||
return 0;
|
||||
}
|
||||
|
||||
int cros_ec_lpc_packet(struct udevice *udev, int out_bytes, int in_bytes)
|
||||
{
|
||||
struct cros_ec_dev *dev = dev_get_uclass_priv(udev);
|
||||
uint8_t *d;
|
||||
int i;
|
||||
|
||||
if (out_bytes > EC_LPC_HOST_PACKET_SIZE)
|
||||
return log_msg_ret("Cannot send that many bytes\n", -E2BIG);
|
||||
|
||||
if (in_bytes > EC_LPC_HOST_PACKET_SIZE)
|
||||
return log_msg_ret("Cannot receive that many bytes\n", -E2BIG);
|
||||
|
||||
if (wait_for_sync(dev))
|
||||
return log_msg_ret("Timeout waiting ready\n", -ETIMEDOUT);
|
||||
|
||||
/* Write data */
|
||||
for (i = 0, d = (uint8_t *)dev->dout; i < out_bytes; i++, d++)
|
||||
outb(*d, EC_LPC_ADDR_HOST_PACKET + i);
|
||||
|
||||
/* Start the command */
|
||||
outb(EC_COMMAND_PROTOCOL_3, EC_LPC_ADDR_HOST_CMD);
|
||||
|
||||
if (wait_for_sync(dev))
|
||||
return log_msg_ret("Timeout waiting ready\n", -ETIMEDOUT);
|
||||
|
||||
/* Read back args */
|
||||
for (i = 0, d = dev->din; i < in_bytes; i++, d++)
|
||||
*d = inb(EC_LPC_ADDR_HOST_PACKET + i);
|
||||
|
||||
return in_bytes;
|
||||
}
|
||||
|
||||
int cros_ec_lpc_command(struct udevice *udev, uint8_t cmd, int cmd_version,
|
||||
const uint8_t *dout, int dout_len,
|
||||
uint8_t **dinp, int din_len)
|
||||
|
@ -200,6 +232,7 @@ static int cros_ec_probe(struct udevice *dev)
|
|||
}
|
||||
|
||||
static struct dm_cros_ec_ops cros_ec_ops = {
|
||||
.packet = cros_ec_lpc_packet,
|
||||
.command = cros_ec_lpc_command,
|
||||
.check_version = cros_ec_lpc_check_version,
|
||||
};
|
||||
|
|
|
@ -365,7 +365,7 @@ static int process_cmd(struct ec_state *ec,
|
|||
struct fmap_entry *entry;
|
||||
int ret, size;
|
||||
|
||||
entry = &ec->ec_config.region[EC_FLASH_REGION_RW];
|
||||
entry = &ec->ec_config.region[EC_FLASH_REGION_ACTIVE];
|
||||
|
||||
switch (req->cmd) {
|
||||
case EC_VBOOT_HASH_RECALC:
|
||||
|
@ -420,7 +420,7 @@ static int process_cmd(struct ec_state *ec,
|
|||
|
||||
switch (req->region) {
|
||||
case EC_FLASH_REGION_RO:
|
||||
case EC_FLASH_REGION_RW:
|
||||
case EC_FLASH_REGION_ACTIVE:
|
||||
case EC_FLASH_REGION_WP_RO:
|
||||
entry = &ec->ec_config.region[req->region];
|
||||
resp->offset = entry->offset;
|
||||
|
@ -491,9 +491,9 @@ int cros_ec_sandbox_packet(struct udevice *udev, int out_bytes, int in_bytes)
|
|||
return in_bytes;
|
||||
}
|
||||
|
||||
void cros_ec_check_keyboard(struct cros_ec_dev *dev)
|
||||
void cros_ec_check_keyboard(struct udevice *dev)
|
||||
{
|
||||
struct ec_state *ec = dev_get_priv(dev->dev);
|
||||
struct ec_state *ec = dev_get_priv(dev);
|
||||
ulong start;
|
||||
|
||||
printf("Press keys for EC to detect on reset (ESC=recovery)...");
|
||||
|
|
|
@ -8,6 +8,8 @@
|
|||
* Licensed under the GPL-2 or later.
|
||||
*/
|
||||
|
||||
#define LOG_CATEGORY UCLASS_SPI_FLASH
|
||||
|
||||
#include <common.h>
|
||||
#include <dm.h>
|
||||
#include <malloc.h>
|
||||
|
@ -41,6 +43,7 @@ enum sandbox_sf_state {
|
|||
SF_WRITE_STATUS, /* write the flash's status register */
|
||||
};
|
||||
|
||||
#if CONFIG_IS_ENABLED(LOG)
|
||||
static const char *sandbox_sf_state_name(enum sandbox_sf_state state)
|
||||
{
|
||||
static const char * const states[] = {
|
||||
|
@ -49,6 +52,7 @@ static const char *sandbox_sf_state_name(enum sandbox_sf_state state)
|
|||
};
|
||||
return states[state];
|
||||
}
|
||||
#endif /* LOG */
|
||||
|
||||
/* Bits for the status register */
|
||||
#define STAT_WIP (1 << 0)
|
||||
|
@ -101,69 +105,44 @@ struct sandbox_spi_flash_plat_data {
|
|||
/**
|
||||
* This is a very strange probe function. If it has platform data (which may
|
||||
* have come from the device tree) then this function gets the filename and
|
||||
* device type from there. Failing that it looks at the command line
|
||||
* parameter.
|
||||
* device type from there.
|
||||
*/
|
||||
static int sandbox_sf_probe(struct udevice *dev)
|
||||
{
|
||||
/* spec = idcode:file */
|
||||
struct sandbox_spi_flash *sbsf = dev_get_priv(dev);
|
||||
const char *file;
|
||||
size_t len, idname_len;
|
||||
const struct spi_flash_info *data;
|
||||
struct sandbox_spi_flash_plat_data *pdata = dev_get_platdata(dev);
|
||||
struct sandbox_state *state = state_get_current();
|
||||
struct dm_spi_slave_platdata *slave_plat;
|
||||
struct udevice *bus = dev->parent;
|
||||
const char *spec = NULL;
|
||||
struct udevice *emul;
|
||||
int ret = 0;
|
||||
int cs = -1;
|
||||
int i;
|
||||
|
||||
debug("%s: bus %d, looking for emul=%p: ", __func__, bus->seq, dev);
|
||||
if (bus->seq >= 0 && bus->seq < CONFIG_SANDBOX_SPI_MAX_BUS) {
|
||||
for (i = 0; i < CONFIG_SANDBOX_SPI_MAX_CS; i++) {
|
||||
if (state->spi[bus->seq][i].emul == dev)
|
||||
cs = i;
|
||||
}
|
||||
}
|
||||
if (cs == -1) {
|
||||
ret = sandbox_spi_get_emul(state, bus, dev, &emul);
|
||||
if (ret) {
|
||||
printf("Error: Unknown chip select for device '%s'\n",
|
||||
dev->name);
|
||||
return -EINVAL;
|
||||
dev->name);
|
||||
return ret;
|
||||
}
|
||||
slave_plat = dev_get_parent_platdata(dev);
|
||||
cs = slave_plat->cs;
|
||||
debug("found at cs %d\n", cs);
|
||||
|
||||
if (!pdata->filename) {
|
||||
struct sandbox_state *state = state_get_current();
|
||||
|
||||
assert(bus->seq != -1);
|
||||
if (bus->seq < CONFIG_SANDBOX_SPI_MAX_BUS)
|
||||
spec = state->spi[bus->seq][cs].spec;
|
||||
if (!spec) {
|
||||
debug("%s: No spec found for bus %d, cs %d\n",
|
||||
__func__, bus->seq, cs);
|
||||
ret = -ENOENT;
|
||||
goto error;
|
||||
}
|
||||
|
||||
file = strchr(spec, ':');
|
||||
if (!file) {
|
||||
printf("%s: unable to parse file\n", __func__);
|
||||
ret = -EINVAL;
|
||||
goto error;
|
||||
}
|
||||
idname_len = file - spec;
|
||||
pdata->filename = file + 1;
|
||||
pdata->device_name = spec;
|
||||
++file;
|
||||
} else {
|
||||
spec = strchr(pdata->device_name, ',');
|
||||
if (spec)
|
||||
spec++;
|
||||
else
|
||||
spec = pdata->device_name;
|
||||
idname_len = strlen(spec);
|
||||
printf("Error: No filename available\n");
|
||||
return -EINVAL;
|
||||
}
|
||||
spec = strchr(pdata->device_name, ',');
|
||||
if (spec)
|
||||
spec++;
|
||||
else
|
||||
spec = pdata->device_name;
|
||||
idname_len = strlen(spec);
|
||||
debug("%s: device='%s'\n", __func__, spec);
|
||||
|
||||
for (data = spi_flash_ids; data->name; data++) {
|
||||
|
@ -214,7 +193,7 @@ static void sandbox_sf_cs_activate(struct udevice *dev)
|
|||
{
|
||||
struct sandbox_spi_flash *sbsf = dev_get_priv(dev);
|
||||
|
||||
debug("sandbox_sf: CS activated; state is fresh!\n");
|
||||
log_content("sandbox_sf: CS activated; state is fresh!\n");
|
||||
|
||||
/* CS is asserted, so reset state */
|
||||
sbsf->off = 0;
|
||||
|
@ -226,7 +205,7 @@ static void sandbox_sf_cs_activate(struct udevice *dev)
|
|||
|
||||
static void sandbox_sf_cs_deactivate(struct udevice *dev)
|
||||
{
|
||||
debug("sandbox_sf: CS deactivated; cmd done processing!\n");
|
||||
log_content("sandbox_sf: CS deactivated; cmd done processing!\n");
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -302,8 +281,8 @@ static int sandbox_sf_process_cmd(struct sandbox_spi_flash *sbsf, const u8 *rx,
|
|||
}
|
||||
|
||||
if (oldstate != sbsf->state)
|
||||
debug(" cmd: transition to %s state\n",
|
||||
sandbox_sf_state_name(sbsf->state));
|
||||
log_content(" cmd: transition to %s state\n",
|
||||
sandbox_sf_state_name(sbsf->state));
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -334,8 +313,8 @@ static int sandbox_sf_xfer(struct udevice *dev, unsigned int bitlen,
|
|||
int bytes = bitlen / 8;
|
||||
int ret;
|
||||
|
||||
debug("sandbox_sf: state:%x(%s) bytes:%u\n", sbsf->state,
|
||||
sandbox_sf_state_name(sbsf->state), bytes);
|
||||
log_content("sandbox_sf: state:%x(%s) bytes:%u\n", sbsf->state,
|
||||
sandbox_sf_state_name(sbsf->state), bytes);
|
||||
|
||||
if ((flags & SPI_XFER_BEGIN))
|
||||
sandbox_sf_cs_activate(dev);
|
||||
|
@ -354,7 +333,7 @@ static int sandbox_sf_xfer(struct udevice *dev, unsigned int bitlen,
|
|||
case SF_ID: {
|
||||
u8 id;
|
||||
|
||||
debug(" id: off:%u tx:", sbsf->off);
|
||||
log_content(" id: off:%u tx:", sbsf->off);
|
||||
if (sbsf->off < IDCODE_LEN) {
|
||||
/* Extract correct byte from ID 0x00aabbcc */
|
||||
id = ((JEDEC_MFR(sbsf->data) << 16) |
|
||||
|
@ -363,18 +342,18 @@ static int sandbox_sf_xfer(struct udevice *dev, unsigned int bitlen,
|
|||
} else {
|
||||
id = 0;
|
||||
}
|
||||
debug("%d %02x\n", sbsf->off, id);
|
||||
log_content("%d %02x\n", sbsf->off, id);
|
||||
tx[pos++] = id;
|
||||
++sbsf->off;
|
||||
break;
|
||||
}
|
||||
case SF_ADDR:
|
||||
debug(" addr: bytes:%u rx:%02x ", sbsf->addr_bytes,
|
||||
rx[pos]);
|
||||
log_content(" addr: bytes:%u rx:%02x ",
|
||||
sbsf->addr_bytes, rx[pos]);
|
||||
|
||||
if (sbsf->addr_bytes++ < SF_ADDR_LEN)
|
||||
sbsf->off = (sbsf->off << 8) | rx[pos];
|
||||
debug("addr:%06x\n", sbsf->off);
|
||||
log_content("addr:%06x\n", sbsf->off);
|
||||
|
||||
if (tx)
|
||||
sandbox_spi_tristate(&tx[pos], 1);
|
||||
|
@ -403,8 +382,8 @@ static int sandbox_sf_xfer(struct udevice *dev, unsigned int bitlen,
|
|||
sbsf->state = SF_ERASE;
|
||||
goto case_sf_erase;
|
||||
}
|
||||
debug(" cmd: transition to %s state\n",
|
||||
sandbox_sf_state_name(sbsf->state));
|
||||
log_content(" cmd: transition to %s state\n",
|
||||
sandbox_sf_state_name(sbsf->state));
|
||||
break;
|
||||
case SF_READ:
|
||||
/*
|
||||
|
@ -413,7 +392,7 @@ static int sandbox_sf_xfer(struct udevice *dev, unsigned int bitlen,
|
|||
*/
|
||||
|
||||
cnt = bytes - pos;
|
||||
debug(" tx: read(%u)\n", cnt);
|
||||
log_content(" tx: read(%u)\n", cnt);
|
||||
assert(tx);
|
||||
ret = os_read(sbsf->fd, tx + pos, cnt);
|
||||
if (ret < 0) {
|
||||
|
@ -423,19 +402,19 @@ static int sandbox_sf_xfer(struct udevice *dev, unsigned int bitlen,
|
|||
pos += ret;
|
||||
break;
|
||||
case SF_READ_STATUS:
|
||||
debug(" read status: %#x\n", sbsf->status);
|
||||
log_content(" read status: %#x\n", sbsf->status);
|
||||
cnt = bytes - pos;
|
||||
memset(tx + pos, sbsf->status, cnt);
|
||||
pos += cnt;
|
||||
break;
|
||||
case SF_READ_STATUS1:
|
||||
debug(" read status: %#x\n", sbsf->status);
|
||||
log_content(" read status: %#x\n", sbsf->status);
|
||||
cnt = bytes - pos;
|
||||
memset(tx + pos, sbsf->status >> 8, cnt);
|
||||
pos += cnt;
|
||||
break;
|
||||
case SF_WRITE_STATUS:
|
||||
debug(" write status: %#x (ignored)\n", rx[pos]);
|
||||
log_content(" write status: %#x (ignored)\n", rx[pos]);
|
||||
pos = bytes;
|
||||
break;
|
||||
case SF_WRITE:
|
||||
|
@ -451,7 +430,7 @@ static int sandbox_sf_xfer(struct udevice *dev, unsigned int bitlen,
|
|||
}
|
||||
|
||||
cnt = bytes - pos;
|
||||
debug(" rx: write(%u)\n", cnt);
|
||||
log_content(" rx: write(%u)\n", cnt);
|
||||
if (tx)
|
||||
sandbox_spi_tristate(&tx[pos], cnt);
|
||||
ret = os_write(sbsf->fd, rx + pos, cnt);
|
||||
|
@ -471,15 +450,15 @@ static int sandbox_sf_xfer(struct udevice *dev, unsigned int bitlen,
|
|||
|
||||
/* verify address is aligned */
|
||||
if (sbsf->off & (sbsf->erase_size - 1)) {
|
||||
debug(" sector erase: cmd:%#x needs align:%#x, but we got %#x\n",
|
||||
sbsf->cmd, sbsf->erase_size,
|
||||
sbsf->off);
|
||||
log_content(" sector erase: cmd:%#x needs align:%#x, but we got %#x\n",
|
||||
sbsf->cmd, sbsf->erase_size,
|
||||
sbsf->off);
|
||||
sbsf->status &= ~STAT_WEL;
|
||||
goto done;
|
||||
}
|
||||
|
||||
debug(" sector erase addr: %u, size: %u\n", sbsf->off,
|
||||
sbsf->erase_size);
|
||||
log_content(" sector erase addr: %u, size: %u\n",
|
||||
sbsf->off, sbsf->erase_size);
|
||||
|
||||
cnt = bytes - pos;
|
||||
if (tx)
|
||||
|
@ -493,13 +472,13 @@ static int sandbox_sf_xfer(struct udevice *dev, unsigned int bitlen,
|
|||
ret = sandbox_erase_part(sbsf, sbsf->erase_size);
|
||||
sbsf->status &= ~STAT_WEL;
|
||||
if (ret) {
|
||||
debug("sandbox_sf: Erase failed\n");
|
||||
log_content("sandbox_sf: Erase failed\n");
|
||||
goto done;
|
||||
}
|
||||
goto done;
|
||||
}
|
||||
default:
|
||||
debug(" ??? no idea what to do ???\n");
|
||||
log_content(" ??? no idea what to do ???\n");
|
||||
goto done;
|
||||
}
|
||||
}
|
||||
|
@ -530,31 +509,6 @@ static const struct dm_spi_emul_ops sandbox_sf_emul_ops = {
|
|||
};
|
||||
|
||||
#ifdef CONFIG_SPI_FLASH
|
||||
static int sandbox_cmdline_cb_spi_sf(struct sandbox_state *state,
|
||||
const char *arg)
|
||||
{
|
||||
unsigned long bus, cs;
|
||||
const char *spec = sandbox_spi_parse_spec(arg, &bus, &cs);
|
||||
|
||||
if (!spec)
|
||||
return 1;
|
||||
|
||||
/*
|
||||
* It is safe to not make a copy of 'spec' because it comes from the
|
||||
* command line.
|
||||
*
|
||||
* TODO(sjg@chromium.org): It would be nice if we could parse the
|
||||
* spec here, but the problem is that no U-Boot init has been done
|
||||
* yet. Perhaps we can figure something out.
|
||||
*/
|
||||
state->spi[bus][cs].spec = spec;
|
||||
debug("%s: Setting up spec '%s' for bus %ld, cs %ld\n", __func__,
|
||||
spec, bus, cs);
|
||||
|
||||
return 0;
|
||||
}
|
||||
SANDBOX_CMDLINE_OPT(spi_sf, 1, "connect a SPI flash: <bus>:<cs>:<id>:<file>");
|
||||
|
||||
int sandbox_sf_bind_emul(struct sandbox_state *state, int busnum, int cs,
|
||||
struct udevice *bus, ofnode node, const char *spec)
|
||||
{
|
||||
|
@ -597,33 +551,6 @@ void sandbox_sf_unbind_emul(struct sandbox_state *state, int busnum, int cs)
|
|||
state->spi[busnum][cs].emul = NULL;
|
||||
}
|
||||
|
||||
static int sandbox_sf_bind_bus_cs(struct sandbox_state *state, int busnum,
|
||||
int cs, const char *spec)
|
||||
{
|
||||
struct udevice *bus, *slave;
|
||||
int ret;
|
||||
|
||||
ret = uclass_find_device_by_seq(UCLASS_SPI, busnum, true, &bus);
|
||||
if (ret) {
|
||||
printf("Invalid bus %d for spec '%s' (err=%d)\n", busnum,
|
||||
spec, ret);
|
||||
return ret;
|
||||
}
|
||||
ret = spi_find_chip_select(bus, cs, &slave);
|
||||
if (!ret) {
|
||||
printf("Chip select %d already exists for spec '%s'\n", cs,
|
||||
spec);
|
||||
return -EEXIST;
|
||||
}
|
||||
|
||||
ret = device_bind_driver(bus, "spi_flash_std", spec, &slave);
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
return sandbox_sf_bind_emul(state, busnum, cs, bus, ofnode_null(),
|
||||
spec);
|
||||
}
|
||||
|
||||
int sandbox_spi_get_emul(struct sandbox_state *state,
|
||||
struct udevice *bus, struct udevice *slave,
|
||||
struct udevice **emulp)
|
||||
|
@ -650,35 +577,6 @@ int sandbox_spi_get_emul(struct sandbox_state *state,
|
|||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int dm_scan_other(bool pre_reloc_only)
|
||||
{
|
||||
struct sandbox_state *state = state_get_current();
|
||||
int busnum, cs;
|
||||
|
||||
if (pre_reloc_only)
|
||||
return 0;
|
||||
for (busnum = 0; busnum < CONFIG_SANDBOX_SPI_MAX_BUS; busnum++) {
|
||||
for (cs = 0; cs < CONFIG_SANDBOX_SPI_MAX_CS; cs++) {
|
||||
const char *spec = state->spi[busnum][cs].spec;
|
||||
int ret;
|
||||
|
||||
if (spec) {
|
||||
ret = sandbox_sf_bind_bus_cs(state, busnum,
|
||||
cs, spec);
|
||||
if (ret) {
|
||||
debug("%s: Bind failed for bus %d, cs %d\n",
|
||||
__func__, busnum, cs);
|
||||
return ret;
|
||||
}
|
||||
debug("%s: Setting up spec '%s' for bus %d, cs %d\n",
|
||||
__func__, spec, busnum, cs);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
static const struct udevice_id sandbox_sf_ids[] = {
|
||||
|
|
|
@ -14,18 +14,18 @@ DECLARE_GLOBAL_DATA_PTR;
|
|||
|
||||
int spi_flash_read_dm(struct udevice *dev, u32 offset, size_t len, void *buf)
|
||||
{
|
||||
return sf_get_ops(dev)->read(dev, offset, len, buf);
|
||||
return log_ret(sf_get_ops(dev)->read(dev, offset, len, buf));
|
||||
}
|
||||
|
||||
int spi_flash_write_dm(struct udevice *dev, u32 offset, size_t len,
|
||||
const void *buf)
|
||||
{
|
||||
return sf_get_ops(dev)->write(dev, offset, len, buf);
|
||||
return log_ret(sf_get_ops(dev)->write(dev, offset, len, buf));
|
||||
}
|
||||
|
||||
int spi_flash_erase_dm(struct udevice *dev, u32 offset, size_t len)
|
||||
{
|
||||
return sf_get_ops(dev)->erase(dev, offset, len);
|
||||
return log_ret(sf_get_ops(dev)->erase(dev, offset, len));
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
|
@ -97,7 +97,7 @@ static int spi_flash_std_read(struct udevice *dev, u32 offset, size_t len,
|
|||
{
|
||||
struct spi_flash *flash = dev_get_uclass_priv(dev);
|
||||
|
||||
return spi_flash_cmd_read_ops(flash, offset, len, buf);
|
||||
return log_ret(spi_flash_cmd_read_ops(flash, offset, len, buf));
|
||||
}
|
||||
|
||||
static int spi_flash_std_write(struct udevice *dev, u32 offset, size_t len,
|
||||
|
|
|
@ -468,17 +468,17 @@ int spi_flash_cmd_read_ops(struct spi_flash *flash, u32 offset,
|
|||
size_t len, void *data)
|
||||
{
|
||||
struct spi_slave *spi = flash->spi;
|
||||
u8 *cmd, cmdsz;
|
||||
u8 cmdsz;
|
||||
u32 remain_len, read_len, read_addr;
|
||||
int bank_sel = 0;
|
||||
int ret = -1;
|
||||
int ret = 0;
|
||||
|
||||
/* Handle memory-mapped SPI */
|
||||
if (flash->memory_map) {
|
||||
ret = spi_claim_bus(spi);
|
||||
if (ret) {
|
||||
debug("SF: unable to claim SPI bus\n");
|
||||
return ret;
|
||||
return log_ret(ret);
|
||||
}
|
||||
spi_xfer(spi, 0, NULL, NULL, SPI_XFER_MMAP);
|
||||
spi_flash_copy_mmap(data, flash->memory_map + offset, len);
|
||||
|
@ -488,11 +488,7 @@ int spi_flash_cmd_read_ops(struct spi_flash *flash, u32 offset,
|
|||
}
|
||||
|
||||
cmdsz = SPI_FLASH_CMD_LEN + flash->dummy_byte;
|
||||
cmd = calloc(1, cmdsz);
|
||||
if (!cmd) {
|
||||
debug("SF: Failed to allocate cmd\n");
|
||||
return -ENOMEM;
|
||||
}
|
||||
u8 cmd[cmdsz];
|
||||
|
||||
cmd[0] = flash->read_cmd;
|
||||
while (len) {
|
||||
|
@ -505,7 +501,7 @@ int spi_flash_cmd_read_ops(struct spi_flash *flash, u32 offset,
|
|||
#ifdef CONFIG_SPI_FLASH_BAR
|
||||
ret = write_bar(flash, read_addr);
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
return log_ret(ret);
|
||||
bank_sel = flash->bank_curr;
|
||||
#endif
|
||||
remain_len = ((SPI_FLASH_16MB_BOUN << flash->shift) *
|
||||
|
@ -535,8 +531,7 @@ int spi_flash_cmd_read_ops(struct spi_flash *flash, u32 offset,
|
|||
ret = clean_bar(flash);
|
||||
#endif
|
||||
|
||||
free(cmd);
|
||||
return ret;
|
||||
return log_ret(ret);
|
||||
}
|
||||
|
||||
#ifdef CONFIG_SPI_FLASH_SST
|
||||
|
|
|
@ -247,7 +247,7 @@ int dm_pci_run_vga_bios(struct udevice *dev, int (*int15_handler)(void),
|
|||
}
|
||||
|
||||
if (!board_should_load_oprom(dev))
|
||||
return -ENXIO;
|
||||
return log_msg_ret("Should not load OPROM", -ENXIO);
|
||||
|
||||
ret = pci_rom_probe(dev, &rom);
|
||||
if (ret)
|
||||
|
@ -328,7 +328,7 @@ int vbe_setup_video_priv(struct vesa_mode_info *vesa,
|
|||
struct video_uc_platdata *plat)
|
||||
{
|
||||
if (!vesa->x_resolution)
|
||||
return -ENXIO;
|
||||
return log_msg_ret("No x resolution", -ENXIO);
|
||||
uc_priv->xsize = vesa->x_resolution;
|
||||
uc_priv->ysize = vesa->y_resolution;
|
||||
switch (vesa->bits_per_pixel) {
|
||||
|
|
|
@ -14,6 +14,14 @@ enum {
|
|||
NUM_CHANNELS = 3,
|
||||
};
|
||||
|
||||
/**
|
||||
* struct sandbox_pwm_chan - a sandbox PWM channel
|
||||
*
|
||||
* @period_ns: Period of the PWM in nanoseconds
|
||||
* @duty_ns: Current duty cycle of the PWM in nanoseconds
|
||||
* @enable: true if the PWM is enabled
|
||||
* @polarity: true if the PWM polarity is active high
|
||||
*/
|
||||
struct sandbox_pwm_chan {
|
||||
uint period_ns;
|
||||
uint duty_ns;
|
||||
|
@ -25,6 +33,23 @@ struct sandbox_pwm_priv {
|
|||
struct sandbox_pwm_chan chan[NUM_CHANNELS];
|
||||
};
|
||||
|
||||
int sandbox_pwm_get_config(struct udevice *dev, uint channel, uint *period_nsp,
|
||||
uint *duty_nsp, bool *enablep, bool *polarityp)
|
||||
{
|
||||
struct sandbox_pwm_priv *priv = dev_get_priv(dev);
|
||||
struct sandbox_pwm_chan *chan;
|
||||
|
||||
if (channel >= NUM_CHANNELS)
|
||||
return -ENOSPC;
|
||||
chan = &priv->chan[channel];
|
||||
*period_nsp = chan->period_ns;
|
||||
*duty_nsp = chan->duty_ns;
|
||||
*enablep = chan->enable;
|
||||
*polarityp = chan->polarity;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int sandbox_pwm_set_config(struct udevice *dev, uint channel,
|
||||
uint period_ns, uint duty_ns)
|
||||
{
|
||||
|
|
|
@ -13,6 +13,24 @@ config DM_RTC
|
|||
drivers to perform the actual functions. See rtc.h for a
|
||||
description of the API.
|
||||
|
||||
config SPL_DM_RTC
|
||||
bool "Enable Driver Model for RTC drivers in SPL"
|
||||
depends on SPL_DM
|
||||
help
|
||||
Enable drver model for real-time-clock drivers. The RTC uclass
|
||||
then provides the rtc_get()/rtc_set() interface, delegating to
|
||||
drivers to perform the actual functions. See rtc.h for a
|
||||
description of the API.
|
||||
|
||||
config TPL_DM_RTC
|
||||
bool "Enable Driver Model for RTC drivers in TPL"
|
||||
depends on TPL_DM
|
||||
help
|
||||
Enable drver model for real-time-clock drivers. The RTC uclass
|
||||
then provides the rtc_get()/rtc_set() interface, delegating to
|
||||
drivers to perform the actual functions. See rtc.h for a
|
||||
description of the API.
|
||||
|
||||
config RTC_PCF2127
|
||||
bool "Enable PCF2127 driver"
|
||||
depends on DM_RTC
|
||||
|
@ -68,4 +86,12 @@ config RTC_S35392A
|
|||
help
|
||||
Enable s35392a driver which provides rtc get and set function.
|
||||
|
||||
config RTC_MC146818
|
||||
bool "Enable MC146818 driver"
|
||||
help
|
||||
This is a widely used real-time clock chip originally by Motorola
|
||||
and now available from NXP. It includes a battery-backed real-time
|
||||
clock with a wide array of features and 50 bytes of general-purpose,
|
||||
battery-backed RAM. The driver supports access to the clock and RAM.
|
||||
|
||||
endmenu
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
# Wolfgang Denk, DENX Software Engineering, wd@denx.de.
|
||||
#ccflags-y += -DDEBUG
|
||||
|
||||
obj-$(CONFIG_DM_RTC) += rtc-uclass.o
|
||||
obj-$(CONFIG_$(SPL_TPL_)DM_RTC) += rtc-uclass.o
|
||||
|
||||
obj-$(CONFIG_RTC_AT91SAM9_RTT) += at91sam9_rtt.o
|
||||
obj-y += date.o
|
||||
|
|
|
@ -53,6 +53,16 @@ config SPL_SERIAL_PRESENT
|
|||
This option enables the full UART in SPL, so if is it disabled,
|
||||
the full UART driver will be omitted, thus saving space.
|
||||
|
||||
config TPL_SERIAL_PRESENT
|
||||
bool "Provide a serial driver in TPL"
|
||||
depends on DM_SERIAL
|
||||
default y
|
||||
help
|
||||
In very space-constrained devices even the full UART driver is too
|
||||
large. In this case the debug UART can still be used in some cases.
|
||||
This option enables the full UART in TPL, so if is it disabled,
|
||||
the full UART driver will be omitted, thus saving space.
|
||||
|
||||
# Logic to allow us to use the imply keyword to set what the default port
|
||||
# should be. The default is otherwise 1.
|
||||
config CONS_INDEX_0
|
||||
|
@ -324,6 +334,15 @@ config DEBUG_UART_MXC
|
|||
will need to provide parameters to make this work. The driver will
|
||||
be available until the real driver model serial is running.
|
||||
|
||||
config DEBUG_UART_SANDBOX
|
||||
bool "sandbox"
|
||||
depends on SANDBOX_SERIAL
|
||||
help
|
||||
Select this to enable the debug UART using the sandbox driver. This
|
||||
provides basic serial output from the console without needing to
|
||||
start up driver model. The driver will be available until the real
|
||||
driver model serial is running.
|
||||
|
||||
config DEBUG_UART_STM32
|
||||
bool "STMicroelectronics STM32"
|
||||
depends on STM32_SERIAL
|
||||
|
@ -354,6 +373,7 @@ endchoice
|
|||
config DEBUG_UART_BASE
|
||||
hex "Base address of UART"
|
||||
depends on DEBUG_UART
|
||||
default 0 if DEBUG_UART_SANDBOX
|
||||
help
|
||||
This is the base address of your UART for memory-mapped UARTs.
|
||||
|
||||
|
@ -363,6 +383,7 @@ config DEBUG_UART_BASE
|
|||
config DEBUG_UART_CLOCK
|
||||
int "UART input clock"
|
||||
depends on DEBUG_UART
|
||||
default 0 if DEBUG_UART_SANDBOX
|
||||
help
|
||||
The UART input clock determines the speed of the internal UART
|
||||
circuitry. The baud rate is derived from this by dividing the input
|
||||
|
|
|
@ -22,6 +22,8 @@
|
|||
|
||||
DECLARE_GLOBAL_DATA_PTR;
|
||||
|
||||
#if CONFIG_IS_ENABLED(OF_CONTROL)
|
||||
|
||||
/*
|
||||
*
|
||||
* serial_buf: A buffer that holds keyboard characters for the
|
||||
|
@ -124,7 +126,7 @@ static int sandbox_serial_pending(struct udevice *dev, bool input)
|
|||
if (next_index == serial_buf_read)
|
||||
return 1; /* buffer full */
|
||||
|
||||
count = os_read_no_block(0, &serial_buf[serial_buf_write], 1);
|
||||
count = os_read(0, &serial_buf[serial_buf_write], 1);
|
||||
if (count == 1)
|
||||
serial_buf_write = next_index;
|
||||
|
||||
|
@ -142,6 +144,24 @@ static int sandbox_serial_getc(struct udevice *dev)
|
|||
serial_buf_read = increment_buffer_index(serial_buf_read);
|
||||
return result;
|
||||
}
|
||||
#endif /* CONFIG_IS_ENABLED(OF_CONTROL) */
|
||||
|
||||
#ifdef CONFIG_DEBUG_UART_SANDBOX
|
||||
|
||||
#include <debug_uart.h>
|
||||
|
||||
static inline void _debug_uart_init(void)
|
||||
{
|
||||
}
|
||||
|
||||
static inline void _debug_uart_putc(int ch)
|
||||
{
|
||||
os_putc(ch);
|
||||
}
|
||||
|
||||
DEBUG_UART_FUNCS
|
||||
|
||||
#endif /* CONFIG_DEBUG_UART_SANDBOX */
|
||||
|
||||
static int sandbox_serial_setconfig(struct udevice *dev, uint serial_config)
|
||||
{
|
||||
|
@ -156,6 +176,7 @@ static int sandbox_serial_setconfig(struct udevice *dev, uint serial_config)
|
|||
return 0;
|
||||
}
|
||||
|
||||
#if CONFIG_IS_ENABLED(OF_CONTROL)
|
||||
static const char * const ansi_colour[] = {
|
||||
"black", "red", "green", "yellow", "blue", "megenta", "cyan",
|
||||
"white",
|
||||
|
@ -215,3 +236,4 @@ U_BOOT_DEVICE(serial_sandbox_non_fdt) = {
|
|||
.name = "serial_sandbox",
|
||||
.platdata = &platdata_non_fdt,
|
||||
};
|
||||
#endif /* CONFIG_IS_ENABLED(OF_CONTROL) */
|
||||
|
|
|
@ -26,6 +26,7 @@ static const unsigned long baudrate_table[] = CONFIG_SYS_BAUDRATE_TABLE;
|
|||
#error "Serial is required before relocation - define CONFIG_$(SPL_)SYS_MALLOC_F_LEN to make this work"
|
||||
#endif
|
||||
|
||||
#if CONFIG_IS_ENABLED(SERIAL_PRESENT)
|
||||
static int serial_check_stdout(const void *blob, struct udevice **devp)
|
||||
{
|
||||
int node;
|
||||
|
@ -150,12 +151,15 @@ static void serial_find_console_or_panic(void)
|
|||
panic_str("No serial driver found");
|
||||
#endif
|
||||
}
|
||||
#endif /* CONFIG_SERIAL_PRESENT */
|
||||
|
||||
/* Called prior to relocation */
|
||||
int serial_init(void)
|
||||
{
|
||||
#if CONFIG_IS_ENABLED(SERIAL_PRESENT)
|
||||
serial_find_console_or_panic();
|
||||
gd->flags |= GD_FLG_SERIAL_READY;
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -8,6 +8,8 @@
|
|||
* Licensed under the GPL-2 or later.
|
||||
*/
|
||||
|
||||
#define LOG_CATEGORY UCLASS_SPI
|
||||
|
||||
#include <common.h>
|
||||
#include <dm.h>
|
||||
#include <malloc.h>
|
||||
|
@ -56,7 +58,6 @@ static int sandbox_spi_xfer(struct udevice *slave, unsigned int bitlen,
|
|||
struct udevice *emul;
|
||||
uint bytes = bitlen / 8, i;
|
||||
int ret;
|
||||
u8 *tx = (void *)dout, *rx = din;
|
||||
uint busnum, cs;
|
||||
|
||||
if (bitlen == 0)
|
||||
|
@ -87,37 +88,16 @@ static int sandbox_spi_xfer(struct udevice *slave, unsigned int bitlen,
|
|||
if (ret)
|
||||
return ret;
|
||||
|
||||
/* make sure rx/tx buffers are full so clients can assume */
|
||||
if (!tx) {
|
||||
debug("sandbox_spi: xfer: auto-allocating tx scratch buffer\n");
|
||||
tx = malloc(bytes);
|
||||
if (!tx) {
|
||||
debug("sandbox_spi: Out of memory\n");
|
||||
return -ENOMEM;
|
||||
}
|
||||
}
|
||||
if (!rx) {
|
||||
debug("sandbox_spi: xfer: auto-allocating rx scratch buffer\n");
|
||||
rx = malloc(bytes);
|
||||
if (!rx) {
|
||||
debug("sandbox_spi: Out of memory\n");
|
||||
return -ENOMEM;
|
||||
}
|
||||
}
|
||||
|
||||
ops = spi_emul_get_ops(emul);
|
||||
ret = ops->xfer(emul, bitlen, dout, din, flags);
|
||||
|
||||
debug("sandbox_spi: xfer: got back %i (that's %s)\n rx:",
|
||||
ret, ret ? "bad" : "good");
|
||||
for (i = 0; i < bytes; ++i)
|
||||
debug(" %u:%02x", i, rx[i]);
|
||||
debug("\n");
|
||||
|
||||
if (tx != dout)
|
||||
free(tx);
|
||||
if (rx != din)
|
||||
free(rx);
|
||||
log_content("sandbox_spi: xfer: got back %i (that's %s)\n rx:",
|
||||
ret, ret ? "bad" : "good");
|
||||
if (din) {
|
||||
for (i = 0; i < bytes; ++i)
|
||||
log_content(" %u:%02x", i, ((u8 *)din)[i]);
|
||||
}
|
||||
log_content("\n");
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
|
|
@ -63,11 +63,11 @@ int dm_spi_claim_bus(struct udevice *dev)
|
|||
int ret = spi_set_speed_mode(bus, speed, slave->mode);
|
||||
|
||||
if (ret)
|
||||
return ret;
|
||||
return log_ret(ret);
|
||||
slave->speed = speed;
|
||||
}
|
||||
|
||||
return ops->claim_bus ? ops->claim_bus(dev) : 0;
|
||||
return log_ret(ops->claim_bus ? ops->claim_bus(dev) : 0);
|
||||
}
|
||||
|
||||
void dm_spi_release_bus(struct udevice *dev)
|
||||
|
@ -92,7 +92,7 @@ int dm_spi_xfer(struct udevice *dev, unsigned int bitlen,
|
|||
|
||||
int spi_claim_bus(struct spi_slave *slave)
|
||||
{
|
||||
return dm_spi_claim_bus(slave->dev);
|
||||
return log_ret(dm_spi_claim_bus(slave->dev));
|
||||
}
|
||||
|
||||
void spi_release_bus(struct spi_slave *slave)
|
||||
|
|
|
@ -4,6 +4,8 @@
|
|||
* Written by Simon Glass <sjg@chromium.org>
|
||||
*/
|
||||
|
||||
#define LOG_CATEGORY UCLASS_SYSRESET
|
||||
|
||||
#include <common.h>
|
||||
#include <sysreset.h>
|
||||
#include <dm.h>
|
||||
|
@ -34,6 +36,16 @@ int sysreset_get_status(struct udevice *dev, char *buf, int size)
|
|||
return ops->get_status(dev, buf, size);
|
||||
}
|
||||
|
||||
int sysreset_get_last(struct udevice *dev)
|
||||
{
|
||||
struct sysreset_ops *ops = sysreset_get_ops(dev);
|
||||
|
||||
if (!ops->get_last)
|
||||
return -ENOSYS;
|
||||
|
||||
return ops->get_last(dev);
|
||||
}
|
||||
|
||||
int sysreset_walk(enum sysreset_t type)
|
||||
{
|
||||
struct udevice *dev;
|
||||
|
@ -53,6 +65,26 @@ int sysreset_walk(enum sysreset_t type)
|
|||
return ret;
|
||||
}
|
||||
|
||||
int sysreset_get_last_walk(void)
|
||||
{
|
||||
struct udevice *dev;
|
||||
int value = -ENOENT;
|
||||
|
||||
for (uclass_first_device(UCLASS_SYSRESET, &dev);
|
||||
dev;
|
||||
uclass_next_device(&dev)) {
|
||||
int ret;
|
||||
|
||||
ret = sysreset_get_last(dev);
|
||||
if (ret >= 0) {
|
||||
value = ret;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return value;
|
||||
}
|
||||
|
||||
void sysreset_walk_halt(enum sysreset_t type)
|
||||
{
|
||||
int ret;
|
||||
|
@ -64,7 +96,7 @@ void sysreset_walk_halt(enum sysreset_t type)
|
|||
mdelay(100);
|
||||
|
||||
/* Still no reset? Give up */
|
||||
debug("System reset not supported on this platform\n");
|
||||
log_err("System reset not supported on this platform\n");
|
||||
hang();
|
||||
}
|
||||
|
||||
|
|
|
@ -36,6 +36,11 @@ int sandbox_warm_sysreset_get_status(struct udevice *dev, char *buf, int size)
|
|||
return 0;
|
||||
}
|
||||
|
||||
int sandbox_warm_sysreset_get_last(struct udevice *dev)
|
||||
{
|
||||
return SYSRESET_WARM;
|
||||
}
|
||||
|
||||
static int sandbox_sysreset_request(struct udevice *dev, enum sysreset_t type)
|
||||
{
|
||||
struct sandbox_state *state = state_get_current();
|
||||
|
@ -58,6 +63,9 @@ static int sandbox_sysreset_request(struct udevice *dev, enum sysreset_t type)
|
|||
return -EACCES;
|
||||
sandbox_exit();
|
||||
break;
|
||||
case SYSRESET_POWER_OFF:
|
||||
if (!state->sysreset_allowed[type])
|
||||
return -EACCES;
|
||||
default:
|
||||
return -ENOSYS;
|
||||
}
|
||||
|
@ -74,9 +82,15 @@ int sandbox_sysreset_get_status(struct udevice *dev, char *buf, int size)
|
|||
return 0;
|
||||
}
|
||||
|
||||
int sandbox_sysreset_get_last(struct udevice *dev)
|
||||
{
|
||||
return SYSRESET_COLD;
|
||||
}
|
||||
|
||||
static struct sysreset_ops sandbox_sysreset_ops = {
|
||||
.request = sandbox_sysreset_request,
|
||||
.get_status = sandbox_sysreset_get_status,
|
||||
.get_last = sandbox_sysreset_get_last,
|
||||
};
|
||||
|
||||
static const struct udevice_id sandbox_sysreset_ids[] = {
|
||||
|
@ -94,6 +108,7 @@ U_BOOT_DRIVER(sysreset_sandbox) = {
|
|||
static struct sysreset_ops sandbox_warm_sysreset_ops = {
|
||||
.request = sandbox_warm_sysreset_request,
|
||||
.get_status = sandbox_warm_sysreset_get_status,
|
||||
.get_last = sandbox_warm_sysreset_get_last,
|
||||
};
|
||||
|
||||
static const struct udevice_id sandbox_warm_sysreset_ids[] = {
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
# SPDX-License-Identifier: GPL-2.0+
|
||||
# Copyright (c) 2011 The Chromium OS Authors. All rights reserved.
|
||||
|
||||
obj-$(CONFIG_TPM) += tpm-uclass.o
|
||||
obj-$(CONFIG_$(SPL_TPL_)TPM) += tpm-uclass.o
|
||||
|
||||
obj-$(CONFIG_TPM_ATMEL_TWI) += tpm_atmel_twi.o
|
||||
obj-$(CONFIG_TPM_TIS_INFINEON) += tpm_tis_infineon.o
|
||||
|
|
|
@ -126,8 +126,11 @@ int tpm_xfer(struct udevice *dev, const uint8_t *sendbuf, size_t send_size,
|
|||
}
|
||||
|
||||
UCLASS_DRIVER(tpm) = {
|
||||
.id = UCLASS_TPM,
|
||||
.name = "tpm",
|
||||
.flags = DM_UC_FLAG_SEQ_ALIAS,
|
||||
.id = UCLASS_TPM,
|
||||
.name = "tpm",
|
||||
.flags = DM_UC_FLAG_SEQ_ALIAS,
|
||||
#if CONFIG_IS_ENABLED(OF_CONTROL) && !CONFIG_IS_ENABLED(OF_PLATDATA)
|
||||
.post_bind = dm_scan_fdt_dev,
|
||||
#endif
|
||||
.per_device_auto_alloc_size = sizeof(struct tpm_chip_priv),
|
||||
};
|
||||
|
|
|
@ -164,7 +164,7 @@ static int tpm_tis_lpc_probe(struct udevice *dev)
|
|||
u32 didvid;
|
||||
ulong chip_type = dev_get_driver_data(dev);
|
||||
|
||||
addr = devfdt_get_addr(dev);
|
||||
addr = dev_read_addr(dev);
|
||||
if (addr == FDT_ADDR_T_NONE)
|
||||
return -EINVAL;
|
||||
priv->regs = map_sysmem(addr, 0);
|
||||
|
|
|
@ -13,6 +13,10 @@
|
|||
/* TPM NVRAM location indices. */
|
||||
#define FIRMWARE_NV_INDEX 0x1007
|
||||
#define KERNEL_NV_INDEX 0x1008
|
||||
#define BACKUP_NV_INDEX 0x1009
|
||||
#define FWMP_NV_INDEX 0x100a
|
||||
#define REC_HASH_NV_INDEX 0x100b
|
||||
#define REC_HASH_NV_SIZE VB2_SHA256_DIGEST_SIZE
|
||||
|
||||
#define NV_DATA_PUBLIC_PERMISSIONS_OFFSET 60
|
||||
|
||||
|
@ -45,18 +49,28 @@ enum {
|
|||
NV_GLOBAL_LOCK,
|
||||
NV_SEQ_FIRMWARE,
|
||||
NV_SEQ_KERNEL,
|
||||
NV_SEQ_BACKUP,
|
||||
NV_SEQ_FWMP,
|
||||
NV_SEQ_REC_HASH,
|
||||
|
||||
NV_SEQ_COUNT,
|
||||
};
|
||||
|
||||
/* Size of each non-volatile space */
|
||||
#define NV_DATA_SIZE 0x20
|
||||
|
||||
struct nvdata_state {
|
||||
bool present;
|
||||
u8 data[NV_DATA_SIZE];
|
||||
};
|
||||
|
||||
/*
|
||||
* Information about our TPM emulation. This is preserved in the sandbox
|
||||
* state file if enabled.
|
||||
*/
|
||||
static struct tpm_state {
|
||||
uint8_t nvdata[NV_SEQ_COUNT][NV_DATA_SIZE];
|
||||
bool valid;
|
||||
struct nvdata_state nvdata[NV_SEQ_COUNT];
|
||||
} g_state;
|
||||
|
||||
/**
|
||||
|
@ -82,9 +96,12 @@ static int sandbox_tpm_read_state(const void *blob, int node)
|
|||
|
||||
sprintf(prop_name, "nvdata%d", i);
|
||||
prop = fdt_getprop(blob, node, prop_name, &len);
|
||||
if (prop && len == NV_DATA_SIZE)
|
||||
memcpy(g_state.nvdata[i], prop, NV_DATA_SIZE);
|
||||
if (prop && len == NV_DATA_SIZE) {
|
||||
memcpy(g_state.nvdata[i].data, prop, NV_DATA_SIZE);
|
||||
g_state.nvdata[i].present = true;
|
||||
}
|
||||
}
|
||||
g_state.valid = true;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -110,9 +127,11 @@ static int sandbox_tpm_write_state(void *blob, int node)
|
|||
for (i = 0; i < NV_SEQ_COUNT; i++) {
|
||||
char prop_name[20];
|
||||
|
||||
sprintf(prop_name, "nvdata%d", i);
|
||||
fdt_setprop(blob, node, prop_name, g_state.nvdata[i],
|
||||
NV_DATA_SIZE);
|
||||
if (g_state.nvdata[i].present) {
|
||||
sprintf(prop_name, "nvdata%d", i);
|
||||
fdt_setprop(blob, node, prop_name,
|
||||
g_state.nvdata[i].data, NV_DATA_SIZE);
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
@ -128,6 +147,12 @@ static int index_to_seq(uint32_t index)
|
|||
return NV_SEQ_FIRMWARE;
|
||||
case KERNEL_NV_INDEX:
|
||||
return NV_SEQ_KERNEL;
|
||||
case BACKUP_NV_INDEX:
|
||||
return NV_SEQ_BACKUP;
|
||||
case FWMP_NV_INDEX:
|
||||
return NV_SEQ_FWMP;
|
||||
case REC_HASH_NV_INDEX:
|
||||
return NV_SEQ_REC_HASH;
|
||||
case 0:
|
||||
return NV_GLOBAL_LOCK;
|
||||
}
|
||||
|
@ -136,6 +161,21 @@ static int index_to_seq(uint32_t index)
|
|||
return -1;
|
||||
}
|
||||
|
||||
static void handle_cap_flag_space(u8 **datap, uint index)
|
||||
{
|
||||
struct tpm_nv_data_public pub;
|
||||
|
||||
/* TPM_NV_PER_PPWRITE */
|
||||
memset(&pub, '\0', sizeof(pub));
|
||||
pub.nv_index = __cpu_to_be32(index);
|
||||
pub.pcr_info_read.pcr_selection.size_of_select = __cpu_to_be16(
|
||||
sizeof(pub.pcr_info_read.pcr_selection.pcr_select));
|
||||
pub.permission.attributes = __cpu_to_be32(1);
|
||||
pub.pcr_info_write = pub.pcr_info_read;
|
||||
memcpy(*datap, &pub, sizeof(pub));
|
||||
*datap += sizeof(pub);
|
||||
}
|
||||
|
||||
static int sandbox_tpm_xfer(struct udevice *dev, const uint8_t *sendbuf,
|
||||
size_t send_size, uint8_t *recvbuf,
|
||||
size_t *recv_len)
|
||||
|
@ -151,29 +191,45 @@ static int sandbox_tpm_xfer(struct udevice *dev, const uint8_t *sendbuf,
|
|||
*recv_len, code);
|
||||
print_buffer(0, sendbuf, 1, send_size, 0);
|
||||
switch (code) {
|
||||
case 0x65: /* get flags */
|
||||
case TPM_CMD_GET_CAPABILITY:
|
||||
type = get_unaligned_be32(sendbuf + 14);
|
||||
switch (type) {
|
||||
case 4:
|
||||
case TPM_CAP_FLAG:
|
||||
index = get_unaligned_be32(sendbuf + 18);
|
||||
printf("Get flags index %#02x\n", index);
|
||||
*recv_len = 22;
|
||||
memset(recvbuf, '\0', *recv_len);
|
||||
put_unaligned_be32(22, recvbuf +
|
||||
TPM_RESPONSE_HEADER_LENGTH);
|
||||
data = recvbuf + TPM_RESPONSE_HEADER_LENGTH +
|
||||
sizeof(uint32_t);
|
||||
switch (index) {
|
||||
case FIRMWARE_NV_INDEX:
|
||||
break;
|
||||
case KERNEL_NV_INDEX:
|
||||
/* TPM_NV_PER_PPWRITE */
|
||||
put_unaligned_be32(1, data +
|
||||
NV_DATA_PUBLIC_PERMISSIONS_OFFSET);
|
||||
handle_cap_flag_space(&data, index);
|
||||
*recv_len = data - recvbuf -
|
||||
TPM_RESPONSE_HEADER_LENGTH -
|
||||
sizeof(uint32_t);
|
||||
break;
|
||||
case TPM_CAP_FLAG_PERMANENT: {
|
||||
struct tpm_permanent_flags *pflags;
|
||||
|
||||
pflags = (struct tpm_permanent_flags *)data;
|
||||
memset(pflags, '\0', sizeof(*pflags));
|
||||
put_unaligned_be32(TPM_TAG_PERMANENT_FLAGS,
|
||||
&pflags->tag);
|
||||
*recv_len = TPM_HEADER_SIZE + 4 +
|
||||
sizeof(*pflags);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
printf(" ** Unknown flags index %x\n", index);
|
||||
return -ENOSYS;
|
||||
}
|
||||
put_unaligned_be32(*recv_len,
|
||||
recvbuf +
|
||||
TPM_RESPONSE_HEADER_LENGTH);
|
||||
break;
|
||||
case 0x11: /* TPM_CAP_NV_INDEX */
|
||||
case TPM_CAP_NV_INDEX:
|
||||
index = get_unaligned_be32(sendbuf + 18);
|
||||
printf("Get cap nv index %#02x\n", index);
|
||||
put_unaligned_be32(22, recvbuf +
|
||||
|
@ -182,27 +238,29 @@ static int sandbox_tpm_xfer(struct udevice *dev, const uint8_t *sendbuf,
|
|||
default:
|
||||
printf(" ** Unknown 0x65 command type %#02x\n",
|
||||
type);
|
||||
return -1;
|
||||
return -ENOSYS;
|
||||
}
|
||||
break;
|
||||
case 0xcd: /* nvwrite */
|
||||
case TPM_CMD_NV_WRITE_VALUE:
|
||||
index = get_unaligned_be32(sendbuf + 10);
|
||||
length = get_unaligned_be32(sendbuf + 18);
|
||||
seq = index_to_seq(index);
|
||||
if (seq < 0)
|
||||
return -1;
|
||||
return -EINVAL;
|
||||
printf("tpm: nvwrite index=%#02x, len=%#02x\n", index, length);
|
||||
memcpy(&tpm->nvdata[seq], sendbuf + 22, length);
|
||||
memcpy(&tpm->nvdata[seq].data, sendbuf + 22, length);
|
||||
tpm->nvdata[seq].present = true;
|
||||
*recv_len = 12;
|
||||
memset(recvbuf, '\0', *recv_len);
|
||||
break;
|
||||
case 0xcf: /* nvread */
|
||||
case TPM_CMD_NV_READ_VALUE: /* nvread */
|
||||
index = get_unaligned_be32(sendbuf + 10);
|
||||
length = get_unaligned_be32(sendbuf + 18);
|
||||
seq = index_to_seq(index);
|
||||
if (seq < 0)
|
||||
return -1;
|
||||
printf("tpm: nvread index=%#02x, len=%#02x\n", index, length);
|
||||
return -EINVAL;
|
||||
printf("tpm: nvread index=%#02x, len=%#02x, seq=%#02x\n", index,
|
||||
length, seq);
|
||||
*recv_len = TPM_RESPONSE_HEADER_LENGTH + sizeof(uint32_t) +
|
||||
length;
|
||||
memset(recvbuf, '\0', *recv_len);
|
||||
|
@ -220,24 +278,33 @@ static int sandbox_tpm_xfer(struct udevice *dev, const uint8_t *sendbuf,
|
|||
offsetof(struct rollback_space_kernel,
|
||||
crc8));
|
||||
memcpy(data, &rsk, sizeof(rsk));
|
||||
} else if (!tpm->nvdata[seq].present) {
|
||||
put_unaligned_be32(TPM_BADINDEX, recvbuf +
|
||||
sizeof(uint16_t) + sizeof(uint32_t));
|
||||
} else {
|
||||
memcpy(recvbuf + TPM_RESPONSE_HEADER_LENGTH +
|
||||
sizeof(uint32_t), &tpm->nvdata[seq], length);
|
||||
sizeof(uint32_t), &tpm->nvdata[seq].data,
|
||||
length);
|
||||
}
|
||||
break;
|
||||
case 0x14: /* tpm extend */
|
||||
case TPM_CMD_EXTEND:
|
||||
*recv_len = 30;
|
||||
memset(recvbuf, '\0', *recv_len);
|
||||
break;
|
||||
case TPM_CMD_NV_DEFINE_SPACE:
|
||||
case 0x15: /* pcr read */
|
||||
case 0x5d: /* force clear */
|
||||
case 0x6f: /* physical enable */
|
||||
case 0x72: /* physical set deactivated */
|
||||
case 0x99: /* startup */
|
||||
case 0x50: /* self test full */
|
||||
case 0x4000000a: /* assert physical presence */
|
||||
*recv_len = 12;
|
||||
memset(recvbuf, '\0', *recv_len);
|
||||
break;
|
||||
default:
|
||||
printf("Unknown tpm command %02x\n", code);
|
||||
return -1;
|
||||
return -ENOSYS;
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
|
|
@ -18,6 +18,16 @@ int backlight_enable(struct udevice *dev)
|
|||
return ops->enable(dev);
|
||||
}
|
||||
|
||||
int backlight_set_brightness(struct udevice *dev, int percent)
|
||||
{
|
||||
const struct backlight_ops *ops = backlight_get_ops(dev);
|
||||
|
||||
if (!ops->set_brightness)
|
||||
return -ENOSYS;
|
||||
|
||||
return ops->set_brightness(dev, percent);
|
||||
}
|
||||
|
||||
UCLASS_DRIVER(backlight) = {
|
||||
.id = UCLASS_PANEL_BACKLIGHT,
|
||||
.name = "backlight",
|
||||
|
|
|
@ -18,6 +18,24 @@ int panel_enable_backlight(struct udevice *dev)
|
|||
return ops->enable_backlight(dev);
|
||||
}
|
||||
|
||||
/**
|
||||
* panel_set_backlight - Set brightness for the panel backlight
|
||||
*
|
||||
* @dev: Panel device containing the backlight to update
|
||||
* @percent: Brightness value (0=off, 1=min brightness,
|
||||
* 100=full brightness)
|
||||
* @return 0 if OK, -ve on error
|
||||
*/
|
||||
int panel_set_backlight(struct udevice *dev, int percent)
|
||||
{
|
||||
struct panel_ops *ops = panel_get_ops(dev);
|
||||
|
||||
if (!ops->set_backlight)
|
||||
return -ENOSYS;
|
||||
|
||||
return ops->set_backlight(dev, percent);
|
||||
}
|
||||
|
||||
int panel_get_display_timing(struct udevice *dev,
|
||||
struct display_timing *timings)
|
||||
{
|
||||
|
|
|
@ -4,6 +4,8 @@
|
|||
* Written by Simon Glass <sjg@chromium.org>
|
||||
*/
|
||||
|
||||
#define LOG_CATEGORY UCLASS_PANEL_BACKLIGHT
|
||||
|
||||
#include <common.h>
|
||||
#include <dm.h>
|
||||
#include <backlight.h>
|
||||
|
@ -11,48 +13,156 @@
|
|||
#include <asm/gpio.h>
|
||||
#include <power/regulator.h>
|
||||
|
||||
/**
|
||||
* Private information for the PWM backlight
|
||||
*
|
||||
* If @num_levels is 0 then the levels are simple values with the backlight
|
||||
* value going between the minimum (default 0) and the maximum (default 255).
|
||||
* Otherwise the levels are an index into @levels (0..n-1).
|
||||
*
|
||||
* @reg: Regulator to enable to turn the backlight on (NULL if none)
|
||||
* @enable, GPIO to set to enable the backlight (can be missing)
|
||||
* @pwm: PWM to use to change the backlight brightness
|
||||
* @channel: PWM channel to use
|
||||
* @period_ns: Period of the backlight in nanoseconds
|
||||
* @levels: Levels for the backlight, or NULL if not using indexed levels
|
||||
* @num_levels: Number of levels
|
||||
* @cur_level: Current level for the backlight (index or value)
|
||||
* @default_level: Default level for the backlight (index or value)
|
||||
* @min_level: Minimum level of the backlight (full off)
|
||||
* @min_level: Maximum level of the backlight (full on)
|
||||
* @enabled: true if backlight is enabled
|
||||
*/
|
||||
struct pwm_backlight_priv {
|
||||
struct udevice *reg;
|
||||
struct gpio_desc enable;
|
||||
struct udevice *pwm;
|
||||
uint channel;
|
||||
uint period_ns;
|
||||
u32 *levels;
|
||||
int num_levels;
|
||||
uint default_level;
|
||||
int cur_level;
|
||||
uint min_level;
|
||||
uint max_level;
|
||||
bool enabled;
|
||||
};
|
||||
|
||||
static int set_pwm(struct pwm_backlight_priv *priv)
|
||||
{
|
||||
uint duty_cycle;
|
||||
int ret;
|
||||
|
||||
duty_cycle = priv->period_ns * (priv->cur_level - priv->min_level) /
|
||||
(priv->max_level - priv->min_level + 1);
|
||||
ret = pwm_set_config(priv->pwm, priv->channel, priv->period_ns,
|
||||
duty_cycle);
|
||||
|
||||
return log_ret(ret);
|
||||
}
|
||||
|
||||
static int enable_sequence(struct udevice *dev, int seq)
|
||||
{
|
||||
struct pwm_backlight_priv *priv = dev_get_priv(dev);
|
||||
int ret;
|
||||
|
||||
switch (seq) {
|
||||
case 0:
|
||||
if (priv->reg) {
|
||||
__maybe_unused struct dm_regulator_uclass_platdata
|
||||
*plat;
|
||||
|
||||
plat = dev_get_uclass_platdata(priv->reg);
|
||||
log_debug("Enable '%s', regulator '%s'/'%s'\n",
|
||||
dev->name, priv->reg->name, plat->name);
|
||||
ret = regulator_set_enable(priv->reg, true);
|
||||
if (ret) {
|
||||
log_debug("Cannot enable regulator for PWM '%s'\n",
|
||||
__func__, dev->name);
|
||||
return log_ret(ret);
|
||||
}
|
||||
mdelay(120);
|
||||
}
|
||||
break;
|
||||
case 1:
|
||||
mdelay(10);
|
||||
dm_gpio_set_value(&priv->enable, 1);
|
||||
break;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int pwm_backlight_enable(struct udevice *dev)
|
||||
{
|
||||
struct pwm_backlight_priv *priv = dev_get_priv(dev);
|
||||
struct dm_regulator_uclass_platdata *plat;
|
||||
uint duty_cycle;
|
||||
int ret;
|
||||
|
||||
if (priv->reg) {
|
||||
plat = dev_get_uclass_platdata(priv->reg);
|
||||
debug("%s: Enable '%s', regulator '%s'/'%s'\n", __func__,
|
||||
dev->name, priv->reg->name, plat->name);
|
||||
ret = regulator_set_enable(priv->reg, true);
|
||||
if (ret) {
|
||||
debug("%s: Cannot enable regulator for PWM '%s'\n",
|
||||
__func__, dev->name);
|
||||
return ret;
|
||||
}
|
||||
mdelay(120);
|
||||
}
|
||||
|
||||
duty_cycle = priv->period_ns * (priv->default_level - priv->min_level) /
|
||||
(priv->max_level - priv->min_level + 1);
|
||||
ret = pwm_set_config(priv->pwm, priv->channel, priv->period_ns,
|
||||
duty_cycle);
|
||||
ret = enable_sequence(dev, 0);
|
||||
if (ret)
|
||||
return ret;
|
||||
return log_ret(ret);
|
||||
ret = set_pwm(priv);
|
||||
if (ret)
|
||||
return log_ret(ret);
|
||||
ret = pwm_set_enable(priv->pwm, priv->channel, true);
|
||||
if (ret)
|
||||
return ret;
|
||||
mdelay(10);
|
||||
dm_gpio_set_value(&priv->enable, 1);
|
||||
return log_ret(ret);
|
||||
ret = enable_sequence(dev, 1);
|
||||
if (ret)
|
||||
return log_ret(ret);
|
||||
priv->enabled = true;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int pwm_backlight_set_brightness(struct udevice *dev, int percent)
|
||||
{
|
||||
struct pwm_backlight_priv *priv = dev_get_priv(dev);
|
||||
bool disable = false;
|
||||
int level;
|
||||
int ret;
|
||||
|
||||
if (!priv->enabled) {
|
||||
ret = enable_sequence(dev, 0);
|
||||
if (ret)
|
||||
return log_ret(ret);
|
||||
}
|
||||
if (percent == BACKLIGHT_OFF) {
|
||||
disable = true;
|
||||
percent = 0;
|
||||
}
|
||||
if (percent == BACKLIGHT_DEFAULT) {
|
||||
level = priv->default_level;
|
||||
} else {
|
||||
if (priv->levels) {
|
||||
level = priv->levels[percent * (priv->num_levels - 1)
|
||||
/ 100];
|
||||
} else {
|
||||
level = priv->min_level +
|
||||
(priv->max_level - priv->min_level) *
|
||||
percent / 100;
|
||||
}
|
||||
}
|
||||
priv->cur_level = level;
|
||||
|
||||
ret = set_pwm(priv);
|
||||
if (ret)
|
||||
return log_ret(ret);
|
||||
if (!priv->enabled) {
|
||||
ret = enable_sequence(dev, 1);
|
||||
if (ret)
|
||||
return log_ret(ret);
|
||||
priv->enabled = true;
|
||||
}
|
||||
if (disable) {
|
||||
dm_gpio_set_value(&priv->enable, 0);
|
||||
if (priv->reg) {
|
||||
ret = regulator_set_enable(priv->reg, false);
|
||||
if (ret)
|
||||
return log_ret(ret);
|
||||
}
|
||||
priv->enabled = false;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -64,31 +174,32 @@ static int pwm_backlight_ofdata_to_platdata(struct udevice *dev)
|
|||
int index, ret, count, len;
|
||||
const u32 *cell;
|
||||
|
||||
debug("%s: start\n", __func__);
|
||||
log_debug("start\n");
|
||||
ret = uclass_get_device_by_phandle(UCLASS_REGULATOR, dev,
|
||||
"power-supply", &priv->reg);
|
||||
if (ret)
|
||||
debug("%s: Cannot get power supply: ret=%d\n", __func__, ret);
|
||||
log_debug("Cannot get power supply: ret=%d\n", ret);
|
||||
ret = gpio_request_by_name(dev, "enable-gpios", 0, &priv->enable,
|
||||
GPIOD_IS_OUT);
|
||||
if (ret) {
|
||||
debug("%s: Warning: cannot get enable GPIO: ret=%d\n",
|
||||
__func__, ret);
|
||||
log_debug("Warning: cannot get enable GPIO: ret=%d\n", ret);
|
||||
if (ret != -ENOENT)
|
||||
return ret;
|
||||
return log_ret(ret);
|
||||
}
|
||||
ret = dev_read_phandle_with_args(dev, "pwms", "#pwm-cells", 0, 0,
|
||||
&args);
|
||||
if (ret) {
|
||||
debug("%s: Cannot get PWM phandle: ret=%d\n", __func__, ret);
|
||||
return ret;
|
||||
log_debug("Cannot get PWM phandle: ret=%d\n", ret);
|
||||
return log_ret(ret);
|
||||
}
|
||||
|
||||
ret = uclass_get_device_by_ofnode(UCLASS_PWM, args.node, &priv->pwm);
|
||||
if (ret) {
|
||||
debug("%s: Cannot get PWM: ret=%d\n", __func__, ret);
|
||||
return ret;
|
||||
log_debug("Cannot get PWM: ret=%d\n", ret);
|
||||
return log_ret(ret);
|
||||
}
|
||||
if (args.args_count < 2)
|
||||
return log_msg_ret("Not enough arguments to pwm\n", -EINVAL);
|
||||
priv->channel = args.args[0];
|
||||
priv->period_ns = args.args[1];
|
||||
|
||||
|
@ -96,13 +207,20 @@ static int pwm_backlight_ofdata_to_platdata(struct udevice *dev)
|
|||
cell = dev_read_prop(dev, "brightness-levels", &len);
|
||||
count = len / sizeof(u32);
|
||||
if (cell && count > index) {
|
||||
priv->default_level = fdt32_to_cpu(cell[index]);
|
||||
priv->max_level = fdt32_to_cpu(cell[count - 1]);
|
||||
priv->levels = malloc(len);
|
||||
if (!priv->levels)
|
||||
return log_ret(-ENOMEM);
|
||||
dev_read_u32_array(dev, "brightness-levels", priv->levels,
|
||||
count);
|
||||
priv->num_levels = count;
|
||||
priv->default_level = priv->levels[index];
|
||||
priv->max_level = priv->levels[count - 1];
|
||||
} else {
|
||||
priv->default_level = index;
|
||||
priv->max_level = 255;
|
||||
}
|
||||
debug("%s: done\n", __func__);
|
||||
priv->cur_level = priv->default_level;
|
||||
log_debug("done\n");
|
||||
|
||||
|
||||
return 0;
|
||||
|
@ -114,7 +232,8 @@ static int pwm_backlight_probe(struct udevice *dev)
|
|||
}
|
||||
|
||||
static const struct backlight_ops pwm_backlight_ops = {
|
||||
.enable = pwm_backlight_enable,
|
||||
.enable = pwm_backlight_enable,
|
||||
.set_brightness = pwm_backlight_set_brightness,
|
||||
};
|
||||
|
||||
static const struct udevice_id pwm_backlight_ids[] = {
|
||||
|
|
|
@ -32,6 +32,21 @@ static int simple_panel_enable_backlight(struct udevice *dev)
|
|||
return 0;
|
||||
}
|
||||
|
||||
static int simple_panel_set_backlight(struct udevice *dev, int percent)
|
||||
{
|
||||
struct simple_panel_priv *priv = dev_get_priv(dev);
|
||||
int ret;
|
||||
|
||||
debug("%s: start, backlight = '%s'\n", __func__, priv->backlight->name);
|
||||
dm_gpio_set_value(&priv->enable, 1);
|
||||
ret = backlight_set_brightness(priv->backlight, percent);
|
||||
debug("%s: done, ret = %d\n", __func__, ret);
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int simple_panel_ofdata_to_platdata(struct udevice *dev)
|
||||
{
|
||||
struct simple_panel_priv *priv = dev_get_priv(dev);
|
||||
|
@ -51,7 +66,7 @@ static int simple_panel_ofdata_to_platdata(struct udevice *dev)
|
|||
"backlight", &priv->backlight);
|
||||
if (ret) {
|
||||
debug("%s: Cannot get backlight: ret=%d\n", __func__, ret);
|
||||
return ret;
|
||||
return log_ret(ret);
|
||||
}
|
||||
ret = gpio_request_by_name(dev, "enable-gpios", 0, &priv->enable,
|
||||
GPIOD_IS_OUT);
|
||||
|
@ -59,7 +74,7 @@ static int simple_panel_ofdata_to_platdata(struct udevice *dev)
|
|||
debug("%s: Warning: cannot get enable GPIO: ret=%d\n",
|
||||
__func__, ret);
|
||||
if (ret != -ENOENT)
|
||||
return ret;
|
||||
return log_ret(ret);
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
@ -82,6 +97,7 @@ static int simple_panel_probe(struct udevice *dev)
|
|||
|
||||
static const struct panel_ops simple_panel_ops = {
|
||||
.enable_backlight = simple_panel_enable_backlight,
|
||||
.set_backlight = simple_panel_set_backlight,
|
||||
};
|
||||
|
||||
static const struct udevice_id simple_panel_ids[] = {
|
||||
|
|
|
@ -533,7 +533,8 @@ static int tegra_dc_sor_power_up(struct udevice *dev, int is_lvds)
|
|||
#if DEBUG_SOR
|
||||
static void dump_sor_reg(struct tegra_dc_sor_data *sor)
|
||||
{
|
||||
#define DUMP_REG(a) printk(BIOS_INFO, "%-32s %03x %08x\n", \
|
||||
#define DUMP_REG(a) printk(BIOS_INFO, \
|
||||
"%-32s %03x %08x\n", \
|
||||
#a, a, tegra_sor_readl(sor, a));
|
||||
|
||||
DUMP_REG(SUPER_STATE0);
|
||||
|
|
|
@ -86,7 +86,7 @@ static int vidconsole_back(struct udevice *dev)
|
|||
if (priv->ycur < 0)
|
||||
priv->ycur = 0;
|
||||
}
|
||||
video_sync(dev->parent);
|
||||
video_sync(dev->parent, false);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -113,7 +113,7 @@ static void vidconsole_newline(struct udevice *dev)
|
|||
}
|
||||
priv->last_ch = 0;
|
||||
|
||||
video_sync(dev->parent);
|
||||
video_sync(dev->parent, false);
|
||||
}
|
||||
|
||||
static const struct vid_rgb colors[VID_COLOR_COUNT] = {
|
||||
|
@ -293,7 +293,7 @@ static void vidconsole_escape_char(struct udevice *dev, char ch)
|
|||
|
||||
if (mode == 2) {
|
||||
video_clear(dev->parent);
|
||||
video_sync(dev->parent);
|
||||
video_sync(dev->parent, false);
|
||||
priv->ycur = 0;
|
||||
priv->xcur_frac = priv->xstart_frac;
|
||||
} else {
|
||||
|
@ -449,7 +449,7 @@ static void vidconsole_putc(struct stdio_dev *sdev, const char ch)
|
|||
struct udevice *dev = sdev->priv;
|
||||
|
||||
vidconsole_put_char(dev, ch);
|
||||
video_sync(dev->parent);
|
||||
video_sync(dev->parent, false);
|
||||
}
|
||||
|
||||
static void vidconsole_puts(struct stdio_dev *sdev, const char *s)
|
||||
|
@ -458,7 +458,7 @@ static void vidconsole_puts(struct stdio_dev *sdev, const char *s)
|
|||
|
||||
while (*s)
|
||||
vidconsole_put_char(dev, *s++);
|
||||
video_sync(dev->parent);
|
||||
video_sync(dev->parent, false);
|
||||
}
|
||||
|
||||
/* Set up the number of rows and colours (rotated drivers override this) */
|
||||
|
@ -511,6 +511,8 @@ void vidconsole_position_cursor(struct udevice *dev, unsigned col, unsigned row)
|
|||
struct udevice *vid_dev = dev->parent;
|
||||
struct video_priv *vid_priv = dev_get_uclass_priv(vid_dev);
|
||||
|
||||
col *= priv->x_charsize;
|
||||
row *= priv->y_charsize;
|
||||
priv->xcur_frac = VID_TO_POS(min_t(short, col, vid_priv->xsize - 1));
|
||||
priv->ycur = min_t(short, row, vid_priv->ysize - 1);
|
||||
}
|
||||
|
@ -547,7 +549,7 @@ static int do_video_puts(cmd_tbl_t *cmdtp, int flag, int argc,
|
|||
for (s = argv[1]; *s; s++)
|
||||
vidconsole_put_char(dev, *s);
|
||||
|
||||
video_sync(dev->parent);
|
||||
video_sync(dev->parent, false);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -86,7 +86,7 @@ int video_reserve(ulong *addrp)
|
|||
return 0;
|
||||
}
|
||||
|
||||
void video_clear(struct udevice *dev)
|
||||
int video_clear(struct udevice *dev)
|
||||
{
|
||||
struct video_priv *priv = dev_get_uclass_priv(dev);
|
||||
|
||||
|
@ -111,6 +111,8 @@ void video_clear(struct udevice *dev)
|
|||
memset(priv->fb, priv->colour_bg, priv->fb_size);
|
||||
break;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void video_set_default_colors(struct video_priv *priv)
|
||||
|
@ -128,7 +130,7 @@ void video_set_default_colors(struct video_priv *priv)
|
|||
}
|
||||
|
||||
/* Flush video activity to the caches */
|
||||
void video_sync(struct udevice *vid)
|
||||
void video_sync(struct udevice *vid, bool force)
|
||||
{
|
||||
/*
|
||||
* flush_dcache_range() is declared in common.h but it seems that some
|
||||
|
@ -147,7 +149,7 @@ void video_sync(struct udevice *vid)
|
|||
struct video_priv *priv = dev_get_uclass_priv(vid);
|
||||
static ulong last_sync;
|
||||
|
||||
if (get_timer(last_sync) > 10) {
|
||||
if (force || get_timer(last_sync) > 10) {
|
||||
sandbox_sdl_sync(priv->fb);
|
||||
last_sync = get_timer(0);
|
||||
}
|
||||
|
@ -162,7 +164,7 @@ void video_sync_all(void)
|
|||
dev;
|
||||
uclass_find_next_device(&dev)) {
|
||||
if (device_active(dev))
|
||||
video_sync(dev);
|
||||
video_sync(dev, true);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -345,7 +345,7 @@ int video_bmp_display(struct udevice *dev, ulong bmp_image, int x, int y,
|
|||
break;
|
||||
};
|
||||
|
||||
video_sync(dev);
|
||||
video_sync(dev, false);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -7,6 +7,13 @@
|
|||
#ifndef _BACKLIGHT_H
|
||||
#define _BACKLIGHT_H
|
||||
|
||||
enum {
|
||||
BACKLIGHT_MAX = 100,
|
||||
BACKLIGHT_MIN = 0,
|
||||
BACKLIGHT_OFF = -1,
|
||||
BACKLIGHT_DEFAULT = -2,
|
||||
};
|
||||
|
||||
struct backlight_ops {
|
||||
/**
|
||||
* enable() - Enable a backlight
|
||||
|
@ -15,6 +22,15 @@ struct backlight_ops {
|
|||
* @return 0 if OK, -ve on error
|
||||
*/
|
||||
int (*enable)(struct udevice *dev);
|
||||
|
||||
/**
|
||||
* set_brightness - Set brightness
|
||||
*
|
||||
* @dev: Backlight device to update
|
||||
* @percent: Brightness value (0 to 100, or BACKLIGHT_... value)
|
||||
* @return 0 if OK, -ve on error
|
||||
*/
|
||||
int (*set_brightness)(struct udevice *dev, int percent);
|
||||
};
|
||||
|
||||
#define backlight_get_ops(dev) ((struct backlight_ops *)(dev)->driver->ops)
|
||||
|
@ -27,4 +43,13 @@ struct backlight_ops {
|
|||
*/
|
||||
int backlight_enable(struct udevice *dev);
|
||||
|
||||
/**
|
||||
* backlight_set_brightness - Set brightness
|
||||
*
|
||||
* @dev: Backlight device to update
|
||||
* @percent: Brightness value (0 to 100, or BACKLIGHT_... value)
|
||||
* @return 0 if OK, -ve on error
|
||||
*/
|
||||
int backlight_set_brightness(struct udevice *dev, int percent);
|
||||
|
||||
#endif
|
||||
|
|
|
@ -48,6 +48,5 @@
|
|||
|
||||
/* RTC */
|
||||
#define CONFIG_SYS_ISA_IO_BASE_ADDRESS 0
|
||||
#define CONFIG_RTC_MC146818
|
||||
|
||||
#endif
|
||||
|
|
|
@ -19,7 +19,6 @@
|
|||
#define CONFIG_PCNET_79C973
|
||||
#define PCNET_HAS_PROM
|
||||
|
||||
#define CONFIG_RTC_MC146818
|
||||
#define CONFIG_SYS_ISA_IO_BASE_ADDRESS 0
|
||||
|
||||
/*
|
||||
|
|
|
@ -69,7 +69,7 @@ struct fdt_cros_ec {
|
|||
* @param maxlen Maximum length of the ID field
|
||||
* @return 0 if ok, -1 on error
|
||||
*/
|
||||
int cros_ec_read_id(struct cros_ec_dev *dev, char *id, int maxlen);
|
||||
int cros_ec_read_id(struct udevice *dev, char *id, int maxlen);
|
||||
|
||||
/**
|
||||
* Read a keyboard scan from the CROS-EC device
|
||||
|
@ -89,18 +89,19 @@ int cros_ec_scan_keyboard(struct udevice *dev, struct mbkp_keyscan *scan);
|
|||
* @param image Destination for image identifier
|
||||
* @return 0 if ok, <0 on error
|
||||
*/
|
||||
int cros_ec_read_current_image(struct cros_ec_dev *dev,
|
||||
enum ec_current_image *image);
|
||||
int cros_ec_read_current_image(struct udevice *dev,
|
||||
enum ec_current_image *image);
|
||||
|
||||
/**
|
||||
* Read the hash of the CROS-EC device firmware.
|
||||
*
|
||||
* @param dev CROS-EC device
|
||||
* @param hash_offset Offset in flash to read from
|
||||
* @param hash Destination for hash information
|
||||
* @return 0 if ok, <0 on error
|
||||
*/
|
||||
int cros_ec_read_hash(struct cros_ec_dev *dev,
|
||||
struct ec_response_vboot_hash *hash);
|
||||
int cros_ec_read_hash(struct udevice *dev, uint hash_offset,
|
||||
struct ec_response_vboot_hash *hash);
|
||||
|
||||
/**
|
||||
* Send a reboot command to the CROS-EC device.
|
||||
|
@ -112,8 +113,7 @@ int cros_ec_read_hash(struct cros_ec_dev *dev,
|
|||
* @param flags Flags for reboot command (EC_REBOOT_FLAG_*)
|
||||
* @return 0 if ok, <0 on error
|
||||
*/
|
||||
int cros_ec_reboot(struct cros_ec_dev *dev, enum ec_reboot_cmd cmd,
|
||||
uint8_t flags);
|
||||
int cros_ec_reboot(struct udevice *dev, enum ec_reboot_cmd cmd, uint8_t flags);
|
||||
|
||||
/**
|
||||
* Check if the CROS-EC device has an interrupt pending.
|
||||
|
@ -144,7 +144,7 @@ enum {
|
|||
* expected), -ve if we should have an cros_ec device but failed to find
|
||||
* one, or init failed (-CROS_EC_ERR_...).
|
||||
*/
|
||||
int cros_ec_init(const void *blob, struct cros_ec_dev **cros_ecp);
|
||||
int cros_ec_init(const void *blob, struct udevice**cros_ecp);
|
||||
|
||||
/**
|
||||
* Read information about the keyboard matrix
|
||||
|
@ -152,8 +152,7 @@ int cros_ec_init(const void *blob, struct cros_ec_dev **cros_ecp);
|
|||
* @param dev CROS-EC device
|
||||
* @param info Place to put the info structure
|
||||
*/
|
||||
int cros_ec_info(struct cros_ec_dev *dev,
|
||||
struct ec_response_mkbp_info *info);
|
||||
int cros_ec_info(struct udevice *dev, struct ec_response_mkbp_info *info);
|
||||
|
||||
/**
|
||||
* Read the host event flags
|
||||
|
@ -162,7 +161,7 @@ int cros_ec_info(struct cros_ec_dev *dev,
|
|||
* @param events_ptr Destination for event flags. Not changed on error.
|
||||
* @return 0 if ok, <0 on error
|
||||
*/
|
||||
int cros_ec_get_host_events(struct cros_ec_dev *dev, uint32_t *events_ptr);
|
||||
int cros_ec_get_host_events(struct udevice *dev, uint32_t *events_ptr);
|
||||
|
||||
/**
|
||||
* Clear the specified host event flags
|
||||
|
@ -171,7 +170,7 @@ int cros_ec_get_host_events(struct cros_ec_dev *dev, uint32_t *events_ptr);
|
|||
* @param events Event flags to clear
|
||||
* @return 0 if ok, <0 on error
|
||||
*/
|
||||
int cros_ec_clear_host_events(struct cros_ec_dev *dev, uint32_t events);
|
||||
int cros_ec_clear_host_events(struct udevice *dev, uint32_t events);
|
||||
|
||||
/**
|
||||
* Get/set flash protection
|
||||
|
@ -184,9 +183,9 @@ int cros_ec_clear_host_events(struct cros_ec_dev *dev, uint32_t events);
|
|||
* @param prot Destination for updated protection state from EC.
|
||||
* @return 0 if ok, <0 on error
|
||||
*/
|
||||
int cros_ec_flash_protect(struct cros_ec_dev *dev,
|
||||
uint32_t set_mask, uint32_t set_flags,
|
||||
struct ec_response_flash_protect *resp);
|
||||
int cros_ec_flash_protect(struct udevice *dev, uint32_t set_mask,
|
||||
uint32_t set_flags,
|
||||
struct ec_response_flash_protect *resp);
|
||||
|
||||
|
||||
/**
|
||||
|
@ -195,7 +194,7 @@ int cros_ec_flash_protect(struct cros_ec_dev *dev,
|
|||
* @param dev CROS-EC device
|
||||
* @return 0 if ok, <0 if the test failed
|
||||
*/
|
||||
int cros_ec_test(struct cros_ec_dev *dev);
|
||||
int cros_ec_test(struct udevice *dev);
|
||||
|
||||
/**
|
||||
* Update the EC RW copy.
|
||||
|
@ -205,17 +204,15 @@ int cros_ec_test(struct cros_ec_dev *dev);
|
|||
* @param imafge_size content length
|
||||
* @return 0 if ok, <0 if the test failed
|
||||
*/
|
||||
int cros_ec_flash_update_rw(struct cros_ec_dev *dev,
|
||||
const uint8_t *image, int image_size);
|
||||
int cros_ec_flash_update_rw(struct udevice *dev, const uint8_t *image,
|
||||
int image_size);
|
||||
|
||||
/**
|
||||
* Return a pointer to the board's CROS-EC device
|
||||
*
|
||||
* This should be implemented by board files.
|
||||
*
|
||||
* @return pointer to CROS-EC device, or NULL if none is available
|
||||
*/
|
||||
struct cros_ec_dev *board_get_cros_ec_dev(void);
|
||||
struct udevice *board_get_cros_ec_dev(void);
|
||||
|
||||
struct dm_cros_ec_ops {
|
||||
int (*check_version)(struct udevice *dev);
|
||||
|
@ -249,8 +246,7 @@ void cros_ec_dump_data(const char *name, int cmd, const uint8_t *data, int len);
|
|||
*/
|
||||
int cros_ec_calc_checksum(const uint8_t *data, int size);
|
||||
|
||||
int cros_ec_flash_erase(struct cros_ec_dev *dev, uint32_t offset,
|
||||
uint32_t size);
|
||||
int cros_ec_flash_erase(struct udevice *dev, uint32_t offset, uint32_t size);
|
||||
|
||||
/**
|
||||
* Read data from the flash
|
||||
|
@ -267,8 +263,8 @@ int cros_ec_flash_erase(struct cros_ec_dev *dev, uint32_t offset,
|
|||
* @param size Number of bytes to read
|
||||
* @return 0 if ok, -1 on error
|
||||
*/
|
||||
int cros_ec_flash_read(struct cros_ec_dev *dev, uint8_t *data, uint32_t offset,
|
||||
uint32_t size);
|
||||
int cros_ec_flash_read(struct udevice *dev, uint8_t *data, uint32_t offset,
|
||||
uint32_t size);
|
||||
|
||||
/**
|
||||
* Read back flash parameters
|
||||
|
@ -278,8 +274,8 @@ int cros_ec_flash_read(struct cros_ec_dev *dev, uint8_t *data, uint32_t offset,
|
|||
* @param dev Pointer to device
|
||||
* @param info Pointer to output flash info struct
|
||||
*/
|
||||
int cros_ec_read_flashinfo(struct cros_ec_dev *dev,
|
||||
struct ec_response_flash_info *info);
|
||||
int cros_ec_read_flashinfo(struct udevice *dev,
|
||||
struct ec_response_flash_info *info);
|
||||
|
||||
/**
|
||||
* Write data to the flash
|
||||
|
@ -299,8 +295,8 @@ int cros_ec_read_flashinfo(struct cros_ec_dev *dev,
|
|||
* @param size Number of bytes to write
|
||||
* @return 0 if ok, -1 on error
|
||||
*/
|
||||
int cros_ec_flash_write(struct cros_ec_dev *dev, const uint8_t *data,
|
||||
uint32_t offset, uint32_t size);
|
||||
int cros_ec_flash_write(struct udevice *dev, const uint8_t *data,
|
||||
uint32_t offset, uint32_t size);
|
||||
|
||||
/**
|
||||
* Obtain position and size of a flash region
|
||||
|
@ -311,18 +307,18 @@ int cros_ec_flash_write(struct cros_ec_dev *dev, const uint8_t *data,
|
|||
* @param size Returns size of flash region
|
||||
* @return 0 if ok, -1 on error
|
||||
*/
|
||||
int cros_ec_flash_offset(struct cros_ec_dev *dev, enum ec_flash_region region,
|
||||
uint32_t *offset, uint32_t *size);
|
||||
int cros_ec_flash_offset(struct udevice *dev, enum ec_flash_region region,
|
||||
uint32_t *offset, uint32_t *size);
|
||||
|
||||
/**
|
||||
* Read/write VbNvContext from/to a CROS-EC device.
|
||||
* Read/write non-volatile data from/to a CROS-EC device.
|
||||
*
|
||||
* @param dev CROS-EC device
|
||||
* @param block Buffer of VbNvContext to be read/write
|
||||
* @return 0 if ok, -1 on error
|
||||
*/
|
||||
int cros_ec_read_vbnvcontext(struct cros_ec_dev *dev, uint8_t *block);
|
||||
int cros_ec_write_vbnvcontext(struct cros_ec_dev *dev, const uint8_t *block);
|
||||
int cros_ec_read_nvdata(struct udevice *dev, uint8_t *block, int size);
|
||||
int cros_ec_write_nvdata(struct udevice *dev, const uint8_t *block, int size);
|
||||
|
||||
/**
|
||||
* Read the version information for the EC images
|
||||
|
@ -331,8 +327,8 @@ int cros_ec_write_vbnvcontext(struct cros_ec_dev *dev, const uint8_t *block);
|
|||
* @param versionp This is set to point to the version information
|
||||
* @return 0 if ok, -1 on error
|
||||
*/
|
||||
int cros_ec_read_version(struct cros_ec_dev *dev,
|
||||
struct ec_response_get_version **versionp);
|
||||
int cros_ec_read_version(struct udevice *dev,
|
||||
struct ec_response_get_version **versionp);
|
||||
|
||||
/**
|
||||
* Read the build information for the EC
|
||||
|
@ -341,7 +337,7 @@ int cros_ec_read_version(struct cros_ec_dev *dev,
|
|||
* @param versionp This is set to point to the build string
|
||||
* @return 0 if ok, -1 on error
|
||||
*/
|
||||
int cros_ec_read_build_info(struct cros_ec_dev *dev, char **strp);
|
||||
int cros_ec_read_build_info(struct udevice *dev, char **strp);
|
||||
|
||||
/**
|
||||
* Switch on/off a LDO / FET.
|
||||
|
@ -387,7 +383,7 @@ int cros_ec_decode_ec_flash(struct udevice *dev, struct fdt_cros_ec *config);
|
|||
*
|
||||
* @param ec CROS-EC device
|
||||
*/
|
||||
void cros_ec_check_keyboard(struct cros_ec_dev *dev);
|
||||
void cros_ec_check_keyboard(struct udevice *dev);
|
||||
|
||||
struct i2c_msg;
|
||||
/*
|
||||
|
|
|
@ -270,7 +270,7 @@ struct driver {
|
|||
* @dev Device to check
|
||||
* @return platform data, or NULL if none
|
||||
*/
|
||||
void *dev_get_platdata(struct udevice *dev);
|
||||
void *dev_get_platdata(const struct udevice *dev);
|
||||
|
||||
/**
|
||||
* dev_get_parent_platdata() - Get the parent platform data for a device
|
||||
|
@ -280,7 +280,7 @@ void *dev_get_platdata(struct udevice *dev);
|
|||
* @dev Device to check
|
||||
* @return parent's platform data, or NULL if none
|
||||
*/
|
||||
void *dev_get_parent_platdata(struct udevice *dev);
|
||||
void *dev_get_parent_platdata(const struct udevice *dev);
|
||||
|
||||
/**
|
||||
* dev_get_uclass_platdata() - Get the uclass platform data for a device
|
||||
|
@ -290,7 +290,7 @@ void *dev_get_parent_platdata(struct udevice *dev);
|
|||
* @dev Device to check
|
||||
* @return uclass's platform data, or NULL if none
|
||||
*/
|
||||
void *dev_get_uclass_platdata(struct udevice *dev);
|
||||
void *dev_get_uclass_platdata(const struct udevice *dev);
|
||||
|
||||
/**
|
||||
* dev_get_priv() - Get the private data for a device
|
||||
|
@ -300,7 +300,7 @@ void *dev_get_uclass_platdata(struct udevice *dev);
|
|||
* @dev Device to check
|
||||
* @return private data, or NULL if none
|
||||
*/
|
||||
void *dev_get_priv(struct udevice *dev);
|
||||
void *dev_get_priv(const struct udevice *dev);
|
||||
|
||||
/**
|
||||
* dev_get_parent_priv() - Get the parent private data for a device
|
||||
|
@ -314,7 +314,7 @@ void *dev_get_priv(struct udevice *dev);
|
|||
* @dev Device to check
|
||||
* @return parent data, or NULL if none
|
||||
*/
|
||||
void *dev_get_parent_priv(struct udevice *dev);
|
||||
void *dev_get_parent_priv(const struct udevice *dev);
|
||||
|
||||
/**
|
||||
* dev_get_uclass_priv() - Get the private uclass data for a device
|
||||
|
@ -324,7 +324,7 @@ void *dev_get_parent_priv(struct udevice *dev);
|
|||
* @dev Device to check
|
||||
* @return private uclass data for this device, or NULL if none
|
||||
*/
|
||||
void *dev_get_uclass_priv(struct udevice *dev);
|
||||
void *dev_get_uclass_priv(const struct udevice *dev);
|
||||
|
||||
/**
|
||||
* struct dev_get_parent() - Get the parent of a device
|
||||
|
@ -332,7 +332,7 @@ void *dev_get_uclass_priv(struct udevice *dev);
|
|||
* @child: Child to check
|
||||
* @return parent of child, or NULL if this is the root device
|
||||
*/
|
||||
struct udevice *dev_get_parent(struct udevice *child);
|
||||
struct udevice *dev_get_parent(const struct udevice *child);
|
||||
|
||||
/**
|
||||
* dev_get_driver_data() - get the driver data used to bind a device
|
||||
|
@ -359,7 +359,7 @@ struct udevice *dev_get_parent(struct udevice *child);
|
|||
* @dev: Device to check
|
||||
* @return driver data (0 if none is provided)
|
||||
*/
|
||||
ulong dev_get_driver_data(struct udevice *dev);
|
||||
ulong dev_get_driver_data(const struct udevice *dev);
|
||||
|
||||
/**
|
||||
* dev_get_driver_ops() - get the device's driver's operations
|
||||
|
@ -370,7 +370,7 @@ ulong dev_get_driver_data(struct udevice *dev);
|
|||
* @dev: Device to check
|
||||
* @return void pointer to driver's operations or NULL for NULL-dev or NULL-ops
|
||||
*/
|
||||
const void *dev_get_driver_ops(struct udevice *dev);
|
||||
const void *dev_get_driver_ops(const struct udevice *dev);
|
||||
|
||||
/**
|
||||
* device_get_uclass_id() - return the uclass ID of a device
|
||||
|
@ -378,7 +378,7 @@ const void *dev_get_driver_ops(struct udevice *dev);
|
|||
* @dev: Device to check
|
||||
* @return uclass ID for the device
|
||||
*/
|
||||
enum uclass_id device_get_uclass_id(struct udevice *dev);
|
||||
enum uclass_id device_get_uclass_id(const struct udevice *dev);
|
||||
|
||||
/**
|
||||
* dev_get_uclass_name() - return the uclass name of a device
|
||||
|
@ -388,7 +388,7 @@ enum uclass_id device_get_uclass_id(struct udevice *dev);
|
|||
* @dev: Device to check
|
||||
* @return pointer to the uclass name for the device
|
||||
*/
|
||||
const char *dev_get_uclass_name(struct udevice *dev);
|
||||
const char *dev_get_uclass_name(const struct udevice *dev);
|
||||
|
||||
/**
|
||||
* device_get_child() - Get the child of a device by index
|
||||
|
@ -519,13 +519,28 @@ int device_find_first_child(struct udevice *parent, struct udevice **devp);
|
|||
*/
|
||||
int device_find_next_child(struct udevice **devp);
|
||||
|
||||
/**
|
||||
* device_find_first_inactive_child() - Find the first inactive child
|
||||
*
|
||||
* This is used to locate an existing child of a device which is of a given
|
||||
* uclass.
|
||||
*
|
||||
* @parent: Parent device to search
|
||||
* @uclass_id: Uclass to look for
|
||||
* @devp: Returns device found, if any
|
||||
* @return 0 if found, else -ENODEV
|
||||
*/
|
||||
int device_find_first_inactive_child(struct udevice *parent,
|
||||
enum uclass_id uclass_id,
|
||||
struct udevice **devp);
|
||||
|
||||
/**
|
||||
* device_has_children() - check if a device has any children
|
||||
*
|
||||
* @dev: Device to check
|
||||
* @return true if the device has one or more children
|
||||
*/
|
||||
bool device_has_children(struct udevice *dev);
|
||||
bool device_has_children(const struct udevice *dev);
|
||||
|
||||
/**
|
||||
* device_has_active_children() - check if a device has any active children
|
||||
|
|
|
@ -11,7 +11,7 @@
|
|||
|
||||
enum fmap_compress_t {
|
||||
FMAP_COMPRESS_NONE,
|
||||
FMAP_COMPRESS_LZO,
|
||||
FMAP_COMPRESS_LZ4,
|
||||
};
|
||||
|
||||
enum fmap_hash_t {
|
||||
|
@ -26,6 +26,7 @@ struct fmap_entry {
|
|||
uint32_t length;
|
||||
uint32_t used; /* Number of bytes used in region */
|
||||
enum fmap_compress_t compress_algo; /* Compression type */
|
||||
uint32_t unc_length; /* Uncompressed length */
|
||||
enum fmap_hash_t hash_algo; /* Hash algorithm */
|
||||
const uint8_t *hash; /* Hash value */
|
||||
int hash_size; /* Hash size */
|
||||
|
|
|
@ -44,6 +44,9 @@ struct udevice;
|
|||
/* Members of this uclass sequence themselves with aliases */
|
||||
#define DM_UC_FLAG_SEQ_ALIAS (1 << 0)
|
||||
|
||||
/* Same as DM_FLAG_ALLOC_PRIV_DMA */
|
||||
#define DM_UC_FLAG_ALLOC_PRIV_DMA (1 << 5)
|
||||
|
||||
/**
|
||||
* struct uclass_driver - Driver for the uclass
|
||||
*
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -802,23 +802,6 @@ int fdtdec_get_byte_array(const void *blob, int node, const char *prop_name,
|
|||
const u8 *fdtdec_locate_byte_array(const void *blob, int node,
|
||||
const char *prop_name, int count);
|
||||
|
||||
/**
|
||||
* Look up a property in a node which contains a memory region address and
|
||||
* size. Then return a pointer to this address.
|
||||
*
|
||||
* The property must hold one address with a length. This is only tested on
|
||||
* 32-bit machines.
|
||||
*
|
||||
* @param blob FDT blob
|
||||
* @param node node to examine
|
||||
* @param prop_name name of property to find
|
||||
* @param basep Returns base address of region
|
||||
* @param size Returns size of region
|
||||
* @return 0 if ok, -1 on error (property not found)
|
||||
*/
|
||||
int fdtdec_decode_region(const void *blob, int node, const char *prop_name,
|
||||
fdt_addr_t *basep, fdt_size_t *sizep);
|
||||
|
||||
/**
|
||||
* Obtain an indexed resource from a device property.
|
||||
*
|
||||
|
@ -849,34 +832,6 @@ int fdt_get_named_resource(const void *fdt, int node, const char *property,
|
|||
const char *prop_names, const char *name,
|
||||
struct fdt_resource *res);
|
||||
|
||||
/**
|
||||
* Decode a named region within a memory bank of a given type.
|
||||
*
|
||||
* This function handles selection of a memory region. The region is
|
||||
* specified as an offset/size within a particular type of memory.
|
||||
*
|
||||
* The properties used are:
|
||||
*
|
||||
* <mem_type>-memory<suffix> for the name of the memory bank
|
||||
* <mem_type>-offset<suffix> for the offset in that bank
|
||||
*
|
||||
* The property value must have an offset and a size. The function checks
|
||||
* that the region is entirely within the memory bank.5
|
||||
*
|
||||
* @param blob FDT blob
|
||||
* @param node Node containing the properties (-1 for /config)
|
||||
* @param mem_type Type of memory to use, which is a name, such as
|
||||
* "u-boot" or "kernel".
|
||||
* @param suffix String to append to the memory/offset
|
||||
* property names
|
||||
* @param basep Returns base of region
|
||||
* @param sizep Returns size of region
|
||||
* @return 0 if OK, -ive on error
|
||||
*/
|
||||
int fdtdec_decode_memory_region(const void *blob, int node,
|
||||
const char *mem_type, const char *suffix,
|
||||
fdt_addr_t *basep, fdt_size_t *sizep);
|
||||
|
||||
/* Display timings from linux include/video/display_timing.h */
|
||||
enum display_flags {
|
||||
DISPLAY_FLAGS_HSYNC_LOW = 1 << 0,
|
||||
|
|
|
@ -12,7 +12,8 @@
|
|||
/* Optimization barrier */
|
||||
|
||||
/* The "volatile" is due to gcc bugs */
|
||||
#define barrier() __asm__ __volatile__("": : :"memory")
|
||||
#define barrier() \
|
||||
__asm__ __volatile__("": : :"memory")
|
||||
/*
|
||||
* This version is i.e. to prevent dead stores elimination on @ptr
|
||||
* where gcc and llvm may behave differently when otherwise using
|
||||
|
@ -26,7 +27,8 @@
|
|||
* the compiler that the inline asm absolutely may see the contents
|
||||
* of @ptr. See also: https://llvm.org/bugs/show_bug.cgi?id=15495
|
||||
*/
|
||||
#define barrier_data(ptr) __asm__ __volatile__("": :"r"(ptr) :"memory")
|
||||
#define barrier_data(ptr) \
|
||||
__asm__ __volatile__("": :"r"(ptr) :"memory")
|
||||
|
||||
/*
|
||||
* This macro obfuscates arithmetic on a variable address so that gcc
|
||||
|
|
|
@ -39,16 +39,17 @@ enum log_level_t {
|
|||
enum log_category_t {
|
||||
LOGC_FIRST = 0, /* First part mirrors UCLASS_... */
|
||||
|
||||
LOGC_NONE = UCLASS_COUNT,
|
||||
LOGC_ARCH,
|
||||
LOGC_BOARD,
|
||||
LOGC_CORE,
|
||||
LOGC_NONE = UCLASS_COUNT, /* First number is after all uclasses */
|
||||
LOGC_ARCH, /* Related to arch-specific code */
|
||||
LOGC_BOARD, /* Related to board-specific code */
|
||||
LOGC_CORE, /* Related to core features (non-driver-model) */
|
||||
LOGC_DM, /* Core driver-model */
|
||||
LOGC_DT, /* Device-tree */
|
||||
LOGC_EFI, /* EFI implementation */
|
||||
LOGC_ALLOC, /* Memory allocation */
|
||||
|
||||
LOGC_COUNT,
|
||||
LOGC_END,
|
||||
LOGC_COUNT, /* Number of log categories */
|
||||
LOGC_END, /* Sentinel value for a list of log categories */
|
||||
};
|
||||
|
||||
/* Helper to cast a uclass ID to a log category */
|
||||
|
@ -88,8 +89,22 @@ int _log(enum log_category_t cat, enum log_level_t level, const char *file,
|
|||
*/
|
||||
#if CONFIG_IS_ENABLED(LOG)
|
||||
#define _LOG_MAX_LEVEL CONFIG_VAL(LOG_MAX_LEVEL)
|
||||
#define log_err(_fmt...) log(LOG_CATEGORY, LOGL_ERR, ##_fmt)
|
||||
#define log_warning(_fmt...) log(LOG_CATEGORY, LOGL_WARNING, ##_fmt)
|
||||
#define log_notice(_fmt...) log(LOG_CATEGORY, LOGL_NOTICE, ##_fmt)
|
||||
#define log_info(_fmt...) log(LOG_CATEGORY, LOGL_INFO, ##_fmt)
|
||||
#define log_debug(_fmt...) log(LOG_CATEGORY, LOGL_DEBUG, ##_fmt)
|
||||
#define log_content(_fmt...) log(LOG_CATEGORY, LOGL_DEBUG_CONTENT, ##_fmt)
|
||||
#define log_io(_fmt...) log(LOG_CATEGORY, LOGL_DEBUG_IO, ##_fmt)
|
||||
#else
|
||||
#define _LOG_MAX_LEVEL LOGL_INFO
|
||||
#define log_err(_fmt...)
|
||||
#define log_warning(_fmt...)
|
||||
#define log_notice(_fmt...)
|
||||
#define log_info(_fmt...)
|
||||
#define log_debug(_fmt...)
|
||||
#define log_content(_fmt...)
|
||||
#define log_io(_fmt...)
|
||||
#endif
|
||||
|
||||
/* Emit a log record if the level is less that the maximum */
|
||||
|
@ -175,7 +190,7 @@ void __assert_fail(const char *assertion, const char *file, unsigned int line,
|
|||
})
|
||||
#else
|
||||
#define log_ret(_ret) (_ret)
|
||||
#define log_msg_ret(_ret) (_ret)
|
||||
#define log_msg_ret(_msg, _ret) (_ret)
|
||||
#endif
|
||||
|
||||
/**
|
||||
|
|
36
include/os.h
36
include/os.h
|
@ -26,16 +26,6 @@ struct sandbox_state;
|
|||
*/
|
||||
ssize_t os_read(int fd, void *buf, size_t count);
|
||||
|
||||
/**
|
||||
* Access to the OS read() system call with non-blocking access
|
||||
*
|
||||
* \param fd File descriptor as returned by os_open()
|
||||
* \param buf Buffer to place data
|
||||
* \param count Number of bytes to read
|
||||
* \return number of bytes read, or -1 on error
|
||||
*/
|
||||
ssize_t os_read_no_block(int fd, void *buf, size_t count);
|
||||
|
||||
/**
|
||||
* Access to the OS write() system call
|
||||
*
|
||||
|
@ -75,6 +65,7 @@ int os_open(const char *pathname, int flags);
|
|||
#define OS_O_RDWR 2
|
||||
#define OS_O_MASK 3 /* Mask for read/write flags */
|
||||
#define OS_O_CREAT 0100
|
||||
#define OS_O_TRUNC 01000
|
||||
|
||||
/**
|
||||
* Access to the OS close() system call
|
||||
|
@ -334,4 +325,29 @@ void os_localtime(struct rtc_time *rt);
|
|||
* os_abort() - Raise SIGABRT to exit sandbox (e.g. to debugger)
|
||||
*/
|
||||
void os_abort(void);
|
||||
|
||||
/**
|
||||
* os_mprotect_allow() - Remove write-protection on a region of memory
|
||||
*
|
||||
* The start and length will be page-aligned before use.
|
||||
*
|
||||
* @start: Region start
|
||||
* @len: Region length in bytes
|
||||
* @return 0 if OK, -1 on error from mprotect()
|
||||
*/
|
||||
int os_mprotect_allow(void *start, size_t len);
|
||||
|
||||
/**
|
||||
* os_write_file() - Write a file to the host filesystem
|
||||
*
|
||||
* This can be useful when debugging for writing data out of sandbox for
|
||||
* inspection by external tools.
|
||||
*
|
||||
* @name: File path to write to
|
||||
* @buf: Data to write
|
||||
* @size: Size of data to write
|
||||
* @return 0 if OK, -ve on error
|
||||
*/
|
||||
int os_write_file(const char *name, const void *buf, int size);
|
||||
|
||||
#endif
|
||||
|
|
|
@ -15,6 +15,16 @@ struct panel_ops {
|
|||
* @return 0 if OK, -ve on error
|
||||
*/
|
||||
int (*enable_backlight)(struct udevice *dev);
|
||||
|
||||
/**
|
||||
* set_backlight - Set panel backlight brightness
|
||||
*
|
||||
* @dev: Panel device containing the backlight to update
|
||||
* @percent: Brightness value (0 to 100, or BACKLIGHT_... value)
|
||||
* @return 0 if OK, -ve on error
|
||||
*/
|
||||
int (*set_backlight)(struct udevice *dev, int percent);
|
||||
|
||||
/**
|
||||
* get_timings() - Get display timings from panel.
|
||||
*
|
||||
|
@ -29,13 +39,23 @@ struct panel_ops {
|
|||
#define panel_get_ops(dev) ((struct panel_ops *)(dev)->driver->ops)
|
||||
|
||||
/**
|
||||
* panel_enable_backlight() - Enable the panel backlight
|
||||
* panel_enable_backlight() - Enable/disable the panel backlight
|
||||
*
|
||||
* @dev: Panel device containing the backlight to enable
|
||||
* @enable: true to enable the backlight, false to dis
|
||||
* @return 0 if OK, -ve on error
|
||||
*/
|
||||
int panel_enable_backlight(struct udevice *dev);
|
||||
|
||||
/**
|
||||
* panel_set_backlight - Set brightness for the panel backlight
|
||||
*
|
||||
* @dev: Panel device containing the backlight to update
|
||||
* @percent: Brightness value (0 to 100, or BACKLIGHT_... value)
|
||||
* @return 0 if OK, -ve on error
|
||||
*/
|
||||
int panel_set_backlight(struct udevice *dev, int percent);
|
||||
|
||||
/**
|
||||
* panel_get_display_timing() - Get display timings from panel.
|
||||
*
|
||||
|
|
|
@ -24,7 +24,7 @@
|
|||
#define EFI_PMBR_OSTYPE_EFI 0xEF
|
||||
#define EFI_PMBR_OSTYPE_EFI_GPT 0xEE
|
||||
|
||||
#define GPT_HEADER_SIGNATURE 0x5452415020494645ULL
|
||||
#define GPT_HEADER_SIGNATURE_UBOOT 0x5452415020494645ULL
|
||||
#define GPT_HEADER_REVISION_V1 0x00010000
|
||||
#define GPT_PRIMARY_PARTITION_TABLE_LBA 1ULL
|
||||
#define GPT_ENTRY_NUMBERS CONFIG_EFI_PARTITION_ENTRIES_NUMBERS
|
||||
|
|
1
include/string.h
Normal file
1
include/string.h
Normal file
|
@ -0,0 +1 @@
|
|||
#include <linux/string.h>
|
|
@ -11,6 +11,7 @@ enum sysreset_t {
|
|||
SYSRESET_WARM, /* Reset CPU, keep GPIOs active */
|
||||
SYSRESET_COLD, /* Reset CPU and GPIOs */
|
||||
SYSRESET_POWER, /* Reset PMIC (remove and restore power) */
|
||||
SYSRESET_POWER_OFF, /* Turn off power */
|
||||
|
||||
SYSRESET_COUNT,
|
||||
};
|
||||
|
@ -31,11 +32,20 @@ struct sysreset_ops {
|
|||
/**
|
||||
* get_status() - get printable reset status information
|
||||
*
|
||||
* @dev: Device to check
|
||||
* @buf: Buffer to receive the textual reset information
|
||||
* @size: Size of the passed buffer
|
||||
* @return 0 if OK, -ve on error
|
||||
*/
|
||||
int (*get_status)(struct udevice *dev, char *buf, int size);
|
||||
|
||||
/**
|
||||
* get_last() - get information on the last reset
|
||||
*
|
||||
* @dev: Device to check
|
||||
* @return last reset state (enum sysreset_t) or -ve error
|
||||
*/
|
||||
int (*get_last)(struct udevice *dev);
|
||||
};
|
||||
|
||||
#define sysreset_get_ops(dev) ((struct sysreset_ops *)(dev)->driver->ops)
|
||||
|
@ -49,14 +59,23 @@ struct sysreset_ops {
|
|||
int sysreset_request(struct udevice *dev, enum sysreset_t type);
|
||||
|
||||
/**
|
||||
* get_status() - get printable reset status information
|
||||
* sysreset_get_status() - get printable reset status information
|
||||
*
|
||||
* @dev: Device to check
|
||||
* @buf: Buffer to receive the textual reset information
|
||||
* @size: Size of the passed buffer
|
||||
* @return 0 if OK, -ve on error
|
||||
*/
|
||||
int sysreset_get_status(struct udevice *dev, char *buf, int size);
|
||||
|
||||
/**
|
||||
* sysreset_get_last() - get information on the last reset
|
||||
*
|
||||
* @dev: Device to check
|
||||
* @return last reset state (enum sysreset_t) or -ve error
|
||||
*/
|
||||
int sysreset_get_last(struct udevice *dev);
|
||||
|
||||
/**
|
||||
* sysreset_walk() - cause a system reset
|
||||
*
|
||||
|
@ -71,6 +90,19 @@ int sysreset_get_status(struct udevice *dev, char *buf, int size);
|
|||
*/
|
||||
int sysreset_walk(enum sysreset_t type);
|
||||
|
||||
/**
|
||||
* sysreset_get_last_walk() - get information on the last reset
|
||||
*
|
||||
* This works through the available sysreset devices until it finds one that can
|
||||
* perform a reset. If the provided sysreset type is not available, the next one
|
||||
* will be tried.
|
||||
*
|
||||
* If no device prives the information, this function returns -ENOENT
|
||||
*
|
||||
* @return last reset state (enum sysreset_t) or -ve error
|
||||
*/
|
||||
int sysreset_get_last_walk(void);
|
||||
|
||||
/**
|
||||
* sysreset_walk_halt() - try to reset, otherwise halt
|
||||
*
|
||||
|
|
|
@ -81,6 +81,12 @@ enum tpm_capability_areas {
|
|||
TPM_CAP_VERSION_VAL = 0x0000001A,
|
||||
};
|
||||
|
||||
enum tmp_cap_flag {
|
||||
TPM_CAP_FLAG_PERMANENT = 0x108,
|
||||
};
|
||||
|
||||
#define TPM_TAG_PERMANENT_FLAGS 0x001f
|
||||
|
||||
#define TPM_NV_PER_GLOBALLOCK BIT(15)
|
||||
#define TPM_NV_PER_PPREAD BIT(16)
|
||||
#define TPM_NV_PER_PPWRITE BIT(0)
|
||||
|
@ -93,6 +99,14 @@ enum {
|
|||
TPM_PUBEK_SIZE = 256,
|
||||
};
|
||||
|
||||
enum {
|
||||
TPM_CMD_EXTEND = 0x14,
|
||||
TPM_CMD_GET_CAPABILITY = 0x65,
|
||||
TPM_CMD_NV_DEFINE_SPACE = 0xcc,
|
||||
TPM_CMD_NV_WRITE_VALUE = 0xcd,
|
||||
TPM_CMD_NV_READ_VALUE = 0xcf,
|
||||
};
|
||||
|
||||
/**
|
||||
* TPM return codes as defined in the TCG Main specification
|
||||
* (TPM Main Part 2 Structures; Specification version 1.2)
|
||||
|
@ -231,6 +245,40 @@ struct tpm_permanent_flags {
|
|||
u8 disable_full_da_logic_info;
|
||||
} __packed;
|
||||
|
||||
#define TPM_SHA1_160_HASH_LEN 0x14
|
||||
|
||||
struct __packed tpm_composite_hash {
|
||||
u8 digest[TPM_SHA1_160_HASH_LEN];
|
||||
};
|
||||
|
||||
struct __packed tpm_pcr_selection {
|
||||
__be16 size_of_select;
|
||||
u8 pcr_select[3]; /* matches vboot's struct */
|
||||
};
|
||||
|
||||
struct __packed tpm_pcr_info_short {
|
||||
struct tpm_pcr_selection pcr_selection;
|
||||
u8 locality_at_release;
|
||||
struct tpm_composite_hash digest_at_release;
|
||||
};
|
||||
|
||||
struct __packed tpm_nv_attributes {
|
||||
__be16 tag;
|
||||
__be32 attributes;
|
||||
};
|
||||
|
||||
struct __packed tpm_nv_data_public {
|
||||
__be16 tag;
|
||||
__be32 nv_index;
|
||||
struct tpm_pcr_info_short pcr_info_read;
|
||||
struct tpm_pcr_info_short pcr_info_write;
|
||||
struct tpm_nv_attributes permission;
|
||||
u8 read_st_clear;
|
||||
u8 write_st_clear;
|
||||
u8 write_define;
|
||||
__be32 data_size;
|
||||
};
|
||||
|
||||
/**
|
||||
* Issue a TPM_Startup command.
|
||||
*
|
||||
|
@ -477,4 +525,32 @@ u32 tpm_find_key_sha1(const u8 auth[20], const u8 pubkey_digest[20],
|
|||
*/
|
||||
u32 tpm_get_random(void *data, u32 count);
|
||||
|
||||
/**
|
||||
* tpm_finalise_physical_presence() - Finalise physical presence
|
||||
*
|
||||
* @return return code of the operation (0 = success)
|
||||
*/
|
||||
u32 tpm_finalise_physical_presence(void);
|
||||
|
||||
/**
|
||||
* tpm_nv_set_locked() - lock the non-volatile space
|
||||
*
|
||||
* @return return code of the operation (0 = success)
|
||||
*/
|
||||
u32 tpm_nv_set_locked(void);
|
||||
|
||||
/**
|
||||
* tpm_set_global_lock() - set the global lock
|
||||
*
|
||||
* @return return code of the operation (0 = success)
|
||||
*/
|
||||
u32 tpm_set_global_lock(void);
|
||||
|
||||
/**
|
||||
* tpm_resume() - start up the TPM from resume (after suspend)
|
||||
*
|
||||
* @return return code of the operation (0 = success)
|
||||
*/
|
||||
u32 tpm_resume(void);
|
||||
|
||||
#endif /* __TPM_V1_H */
|
||||
|
|
|
@ -83,6 +83,7 @@ enum tpm2_command_codes {
|
|||
TPM2_CC_PCR_SETAUTHPOL = 0x012C,
|
||||
TPM2_CC_DAM_RESET = 0x0139,
|
||||
TPM2_CC_DAM_PARAMETERS = 0x013A,
|
||||
TPM2_CC_NV_READ = 0x014E,
|
||||
TPM2_CC_GET_CAPABILITY = 0x017A,
|
||||
TPM2_CC_PCR_READ = 0x017E,
|
||||
TPM2_CC_PCR_EXTEND = 0x0182,
|
||||
|
|
|
@ -55,7 +55,7 @@ enum video_log2_bpp {
|
|||
* @xsize: Number of pixel columns (e.g. 1366)
|
||||
* @ysize: Number of pixels rows (e.g.. 768)
|
||||
* @rot: Display rotation (0=none, 1=90 degrees clockwise, etc.)
|
||||
* @bpix: Encoded bits per pixel
|
||||
* @bpix: Encoded bits per pixel (enum video_log2_bpp)
|
||||
* @vidconsole_drv_name: Driver to use for the text console, NULL to
|
||||
* select automatically
|
||||
* @font_size: Font size in pixels (0 to use a default value)
|
||||
|
@ -120,8 +120,9 @@ int video_reserve(ulong *addrp);
|
|||
* video_clear() - Clear a device's frame buffer to background color.
|
||||
*
|
||||
* @dev: Device to clear
|
||||
* @return 0
|
||||
*/
|
||||
void video_clear(struct udevice *dev);
|
||||
int video_clear(struct udevice *dev);
|
||||
|
||||
/**
|
||||
* video_sync() - Sync a device's frame buffer with its hardware
|
||||
|
@ -131,8 +132,10 @@ void video_clear(struct udevice *dev);
|
|||
* buffer are displayed to the user.
|
||||
*
|
||||
* @dev: Device to sync
|
||||
* @force: True to force a sync even if there was one recently (this is
|
||||
* very expensive on sandbox)
|
||||
*/
|
||||
void video_sync(struct udevice *vid);
|
||||
void video_sync(struct udevice *vid, bool force);
|
||||
|
||||
/**
|
||||
* video_sync_all() - Sync all devices' frame buffers with there hardware
|
||||
|
@ -266,6 +269,6 @@ int lg4573_spi_startup(unsigned int bus, unsigned int cs,
|
|||
*/
|
||||
void video_get_info_str(int line_number, char *info);
|
||||
|
||||
#endif /* CONFIG_DM_VIDEO */
|
||||
#endif /* !CONFIG_DM_VIDEO */
|
||||
|
||||
#endif
|
||||
|
|
32
lib/Kconfig
32
lib/Kconfig
|
@ -185,6 +185,28 @@ config TPM
|
|||
for the low-level TPM interface, but only one TPM is supported at
|
||||
a time by the TPM library.
|
||||
|
||||
config SPL_TPM
|
||||
bool "Trusted Platform Module (TPM) Support in SPL"
|
||||
depends on SPL_DM
|
||||
help
|
||||
This enables support for TPMs which can be used to provide security
|
||||
features for your board. The TPM can be connected via LPC or I2C
|
||||
and a sandbox TPM is provided for testing purposes. Use the 'tpm'
|
||||
command to interactive the TPM. Driver model support is provided
|
||||
for the low-level TPM interface, but only one TPM is supported at
|
||||
a time by the TPM library.
|
||||
|
||||
config TPL_TPM
|
||||
bool "Trusted Platform Module (TPM) Support in TPL"
|
||||
depends on TPL_DM
|
||||
help
|
||||
This enables support for TPMs which can be used to provide security
|
||||
features for your board. The TPM can be connected via LPC or I2C
|
||||
and a sandbox TPM is provided for testing purposes. Use the 'tpm'
|
||||
command to interactive the TPM. Driver model support is provided
|
||||
for the low-level TPM interface, but only one TPM is supported at
|
||||
a time by the TPM library.
|
||||
|
||||
endmenu
|
||||
|
||||
menu "Android Verified Boot"
|
||||
|
@ -331,6 +353,16 @@ config SPL_OF_LIBFDT
|
|||
particular compatible nodes. The library operates on a flattened
|
||||
version of the device tree.
|
||||
|
||||
config TPL_OF_LIBFDT
|
||||
bool "Enable the FDT library for TPL"
|
||||
default y if TPL_OF_CONTROL
|
||||
help
|
||||
This enables the FDT library (libfdt). It provides functions for
|
||||
accessing binary device tree images in memory, such as adding and
|
||||
removing nodes and properties, scanning through the tree and finding
|
||||
particular compatible nodes. The library operates on a flattened
|
||||
version of the device tree.
|
||||
|
||||
config FDT_FIXUP_PARTITIONS
|
||||
bool "overwrite MTD partitions in DTS through defined in 'mtdparts'"
|
||||
depends on OF_LIBFDT
|
||||
|
|
10
lib/Makefile
10
lib/Makefile
|
@ -45,14 +45,18 @@ obj-$(CONFIG_PHYSMEM) += physmem.o
|
|||
obj-y += qsort.o
|
||||
obj-y += rc4.o
|
||||
obj-$(CONFIG_SUPPORT_EMMC_RPMB) += sha256.o
|
||||
obj-$(CONFIG_TPM) += tpm-common.o
|
||||
obj-$(CONFIG_TPM_V1) += tpm-v1.o
|
||||
obj-$(CONFIG_TPM_V2) += tpm-v2.o
|
||||
obj-$(CONFIG_RBTREE) += rbtree.o
|
||||
obj-$(CONFIG_BITREVERSE) += bitrev.o
|
||||
obj-y += list_sort.o
|
||||
endif
|
||||
|
||||
obj-$(CONFIG_$(SPL_TPL_)TPM) += tpm-common.o
|
||||
ifeq ($(CONFIG_$(SPL_TPL_)TPM),y)
|
||||
obj-y += crc8.o
|
||||
obj-$(CONFIG_TPM_V1) += tpm-v1.o
|
||||
obj-$(CONFIG_TPM_V2) += tpm-v2.o
|
||||
endif
|
||||
|
||||
obj-$(CONFIG_RSA) += rsa/
|
||||
obj-$(CONFIG_SHA1) += sha1.o
|
||||
obj-$(CONFIG_SHA256) += sha256.o
|
||||
|
|
83
lib/fdtdec.c
83
lib/fdtdec.c
|
@ -922,28 +922,6 @@ char *fdtdec_get_config_string(const void *blob, const char *prop_name)
|
|||
return (char *)nodep;
|
||||
}
|
||||
|
||||
int fdtdec_decode_region(const void *blob, int node, const char *prop_name,
|
||||
fdt_addr_t *basep, fdt_size_t *sizep)
|
||||
{
|
||||
const fdt_addr_t *cell;
|
||||
int len;
|
||||
|
||||
debug("%s: %s: %s\n", __func__, fdt_get_name(blob, node, NULL),
|
||||
prop_name);
|
||||
cell = fdt_getprop(blob, node, prop_name, &len);
|
||||
if (!cell || (len < sizeof(fdt_addr_t) * 2)) {
|
||||
debug("cell=%p, len=%d\n", cell, len);
|
||||
return -1;
|
||||
}
|
||||
|
||||
*basep = fdt_addr_to_cpu(*cell);
|
||||
*sizep = fdt_size_to_cpu(cell[1]);
|
||||
debug("%s: base=%08lx, size=%lx\n", __func__, (ulong)*basep,
|
||||
(ulong)*sizep);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
u64 fdtdec_get_number(const fdt32_t *ptr, unsigned int cells)
|
||||
{
|
||||
u64 number = 0;
|
||||
|
@ -1002,67 +980,6 @@ int fdt_get_named_resource(const void *fdt, int node, const char *property,
|
|||
return fdt_get_resource(fdt, node, property, index, res);
|
||||
}
|
||||
|
||||
int fdtdec_decode_memory_region(const void *blob, int config_node,
|
||||
const char *mem_type, const char *suffix,
|
||||
fdt_addr_t *basep, fdt_size_t *sizep)
|
||||
{
|
||||
char prop_name[50];
|
||||
const char *mem;
|
||||
fdt_size_t size, offset_size;
|
||||
fdt_addr_t base, offset;
|
||||
int node;
|
||||
|
||||
if (config_node == -1) {
|
||||
config_node = fdt_path_offset(blob, "/config");
|
||||
if (config_node < 0) {
|
||||
debug("%s: Cannot find /config node\n", __func__);
|
||||
return -ENOENT;
|
||||
}
|
||||
}
|
||||
if (!suffix)
|
||||
suffix = "";
|
||||
|
||||
snprintf(prop_name, sizeof(prop_name), "%s-memory%s", mem_type,
|
||||
suffix);
|
||||
mem = fdt_getprop(blob, config_node, prop_name, NULL);
|
||||
if (!mem) {
|
||||
debug("%s: No memory type for '%s', using /memory\n", __func__,
|
||||
prop_name);
|
||||
mem = "/memory";
|
||||
}
|
||||
|
||||
node = fdt_path_offset(blob, mem);
|
||||
if (node < 0) {
|
||||
debug("%s: Failed to find node '%s': %s\n", __func__, mem,
|
||||
fdt_strerror(node));
|
||||
return -ENOENT;
|
||||
}
|
||||
|
||||
/*
|
||||
* Not strictly correct - the memory may have multiple banks. We just
|
||||
* use the first
|
||||
*/
|
||||
if (fdtdec_decode_region(blob, node, "reg", &base, &size)) {
|
||||
debug("%s: Failed to decode memory region %s\n", __func__,
|
||||
mem);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
snprintf(prop_name, sizeof(prop_name), "%s-offset%s", mem_type,
|
||||
suffix);
|
||||
if (fdtdec_decode_region(blob, config_node, prop_name, &offset,
|
||||
&offset_size)) {
|
||||
debug("%s: Failed to decode memory region '%s'\n", __func__,
|
||||
prop_name);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
*basep = base + offset;
|
||||
*sizep = offset_size;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int decode_timing_property(const void *blob, int node, const char *name,
|
||||
struct timing_entry *result)
|
||||
{
|
||||
|
|
|
@ -20,8 +20,9 @@
|
|||
*/
|
||||
void hang(void)
|
||||
{
|
||||
#if !defined(CONFIG_SPL_BUILD) || (defined(CONFIG_SPL_LIBCOMMON_SUPPORT) && \
|
||||
defined(CONFIG_SPL_SERIAL_SUPPORT))
|
||||
#if !defined(CONFIG_SPL_BUILD) || \
|
||||
(CONFIG_IS_ENABLED(LIBCOMMON_SUPPORT) && \
|
||||
CONFIG_IS_ENABLED(SERIAL_SUPPORT))
|
||||
puts("### ERROR ### Please RESET the board ###\n");
|
||||
#endif
|
||||
bootstage_error(BOOTSTAGE_ID_NEED_RESET);
|
||||
|
|
|
@ -4,6 +4,8 @@
|
|||
* Coypright (c) 2013 Guntermann & Drunck GmbH
|
||||
*/
|
||||
|
||||
#define LOG_CATEGORY UCLASS_TPM
|
||||
|
||||
#include <common.h>
|
||||
#include <dm.h>
|
||||
#include <asm/unaligned.h>
|
||||
|
@ -110,6 +112,8 @@ int unpack_byte_string(const u8 *str, size_t size, const char *format, ...)
|
|||
|
||||
if (offset + length > size) {
|
||||
va_end(args);
|
||||
log_err("Failed to read: size=%d, offset=%x, len=%x\n",
|
||||
size, offset, length);
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
@ -176,10 +180,10 @@ u32 tpm_sendrecv_command(const void *command, void *response, size_t *size_ptr)
|
|||
|
||||
ret = tpm_return_code(response);
|
||||
|
||||
log(LOGC_NONE, LOGL_DEBUG, "TPM response [ret:%d]: ", ret);
|
||||
log_debug("TPM response [ret:%d]: ", ret);
|
||||
for (i = 0; i < response_length; i++)
|
||||
log(LOGC_NONE, LOGL_DEBUG, "%02x ", ((u8 *)response)[i]);
|
||||
log(LOGC_NONE, LOGL_DEBUG, "\n");
|
||||
log_debug("%02x ", ((u8 *)response)[i]);
|
||||
log_debug("\n");
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
|
68
lib/tpm-v1.c
68
lib/tpm-v1.c
|
@ -4,6 +4,8 @@
|
|||
* Coypright (c) 2013 Guntermann & Drunck GmbH
|
||||
*/
|
||||
|
||||
#define LOG_CATEGORY UCLASS_TPM
|
||||
|
||||
#include <common.h>
|
||||
#include <dm.h>
|
||||
#include <asm/unaligned.h>
|
||||
|
@ -45,6 +47,11 @@ u32 tpm_startup(enum tpm_startup_type mode)
|
|||
return tpm_sendrecv_command(buf, NULL, NULL);
|
||||
}
|
||||
|
||||
u32 tpm_resume(void)
|
||||
{
|
||||
return tpm_startup(TPM_ST_STATE);
|
||||
}
|
||||
|
||||
u32 tpm_self_test_full(void)
|
||||
{
|
||||
const u8 command[10] = {
|
||||
|
@ -61,6 +68,34 @@ u32 tpm_continue_self_test(void)
|
|||
return tpm_sendrecv_command(command, NULL, NULL);
|
||||
}
|
||||
|
||||
u32 tpm_clear_and_reenable(void)
|
||||
{
|
||||
u32 ret;
|
||||
|
||||
log_info("TPM: Clear and re-enable\n");
|
||||
ret = tpm_force_clear();
|
||||
if (ret != TPM_SUCCESS) {
|
||||
log_err("Can't initiate a force clear\n");
|
||||
return ret;
|
||||
}
|
||||
|
||||
#if IS_ENABLED(CONFIG_TPM_V1)
|
||||
ret = tpm_physical_enable();
|
||||
if (ret != TPM_SUCCESS) {
|
||||
log_err("TPM: Can't set enabled state\n");
|
||||
return ret;
|
||||
}
|
||||
|
||||
ret = tpm_physical_set_deactivated(0);
|
||||
if (ret != TPM_SUCCESS) {
|
||||
log_err("TPM: Can't set deactivated state\n");
|
||||
return ret;
|
||||
}
|
||||
#endif
|
||||
|
||||
return TPM_SUCCESS;
|
||||
}
|
||||
|
||||
u32 tpm_nv_define_space(u32 index, u32 perm, u32 size)
|
||||
{
|
||||
const u8 command[101] = {
|
||||
|
@ -104,6 +139,11 @@ u32 tpm_nv_define_space(u32 index, u32 perm, u32 size)
|
|||
return tpm_sendrecv_command(buf, NULL, NULL);
|
||||
}
|
||||
|
||||
u32 tpm_nv_set_locked(void)
|
||||
{
|
||||
return tpm_nv_define_space(TPM_NV_INDEX_LOCK, 0, 0);
|
||||
}
|
||||
|
||||
u32 tpm_nv_read_value(u32 index, void *data, u32 count)
|
||||
{
|
||||
const u8 command[22] = {
|
||||
|
@ -168,6 +208,13 @@ u32 tpm_nv_write_value(u32 index, const void *data, u32 length)
|
|||
return 0;
|
||||
}
|
||||
|
||||
uint32_t tpm_set_global_lock(void)
|
||||
{
|
||||
u32 x;
|
||||
|
||||
return tpm_nv_write_value(TPM_NV_INDEX_0, (uint8_t *)&x, 0);
|
||||
}
|
||||
|
||||
u32 tpm_extend(u32 index, const void *in_digest, void *out_digest)
|
||||
{
|
||||
const u8 command[34] = {
|
||||
|
@ -243,6 +290,15 @@ u32 tpm_tsc_physical_presence(u16 presence)
|
|||
return tpm_sendrecv_command(buf, NULL, NULL);
|
||||
}
|
||||
|
||||
u32 tpm_finalise_physical_presence(void)
|
||||
{
|
||||
const u8 command[12] = {
|
||||
0x0, 0xc1, 0x0, 0x0, 0x0, 0xc, 0x40, 0x0, 0x0, 0xa, 0x2, 0xa0,
|
||||
};
|
||||
|
||||
return tpm_sendrecv_command(command, NULL, NULL);
|
||||
}
|
||||
|
||||
u32 tpm_read_pubek(void *data, size_t count)
|
||||
{
|
||||
const u8 command[30] = {
|
||||
|
@ -377,13 +433,19 @@ u32 tpm_get_permanent_flags(struct tpm_permanent_flags *pflags)
|
|||
if (err)
|
||||
return err;
|
||||
if (unpack_byte_string(response, response_length, "d",
|
||||
data_size_offset, &data_size))
|
||||
data_size_offset, &data_size)) {
|
||||
log_err("Cannot unpack data size\n");
|
||||
return TPM_LIB_ERROR;
|
||||
if (data_size < sizeof(*pflags))
|
||||
}
|
||||
if (data_size < sizeof(*pflags)) {
|
||||
log_err("Data size too small\n");
|
||||
return TPM_LIB_ERROR;
|
||||
}
|
||||
if (unpack_byte_string(response, response_length, "s",
|
||||
data_offset, pflags, sizeof(*pflags)))
|
||||
data_offset, pflags, sizeof(*pflags))) {
|
||||
log_err("Cannot unpack pflags\n");
|
||||
return TPM_LIB_ERROR;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -45,6 +45,13 @@ SPL_ :=
|
|||
SPL_TPL_ :=
|
||||
endif
|
||||
|
||||
ifeq ($(obj)$(CONFIG_SUPPORT_SPL),spl)
|
||||
$(error You cannot build SPL without enabling CONFIG_SUPPORT_SPL)
|
||||
endif
|
||||
ifeq ($(obj)$(CONFIG_SUPPORT_TPL),tpl)
|
||||
$(error You cannot build TPL without enabling CONFIG_SUPPORT_TPL)
|
||||
endif
|
||||
|
||||
include $(srctree)/config.mk
|
||||
include $(srctree)/arch/$(ARCH)/Makefile
|
||||
|
||||
|
@ -364,7 +371,7 @@ $(u-boot-spl-dirs): $(u-boot-spl-platdata)
|
|||
|
||||
quiet_cmd_cpp_lds = LDS $@
|
||||
cmd_cpp_lds = $(CPP) -Wp,-MD,$(depfile) $(cpp_flags) $(LDPPFLAGS) -ansi \
|
||||
-D__ASSEMBLY__ -x assembler-with-cpp -P -o $@ $<
|
||||
-D__ASSEMBLY__ -x assembler-with-cpp -std=c99 -P -o $@ $<
|
||||
|
||||
$(obj)/u-boot-spl.lds: $(LDSCRIPT) FORCE
|
||||
$(call if_changed_dep,cpp_lds)
|
||||
|
|
|
@ -1673,7 +1673,6 @@ CONFIG_RTC_IMXDI
|
|||
CONFIG_RTC_M41T11
|
||||
CONFIG_RTC_M41T62
|
||||
CONFIG_RTC_MC13XXX
|
||||
CONFIG_RTC_MC146818
|
||||
CONFIG_RTC_MCFRRTC
|
||||
CONFIG_RTC_MCP79411
|
||||
CONFIG_RTC_MXS
|
||||
|
|
|
@ -25,6 +25,7 @@ obj-$(CONFIG_DM_MAILBOX) += mailbox.o
|
|||
obj-$(CONFIG_DM_MMC) += mmc.o
|
||||
obj-y += ofnode.o
|
||||
obj-$(CONFIG_OSD) += osd.o
|
||||
obj-$(CONFIG_DM_VIDEO) += panel.o
|
||||
obj-$(CONFIG_DM_PCI) += pci.o
|
||||
obj-$(CONFIG_PHY) += phy.o
|
||||
obj-$(CONFIG_POWER_DOMAIN) += power-domain.o
|
||||
|
|
|
@ -4,6 +4,9 @@
|
|||
*/
|
||||
|
||||
#include <common.h>
|
||||
#ifdef CONFIG_SANDBOX
|
||||
#include <os.h>
|
||||
#endif
|
||||
#include <dm.h>
|
||||
#include <dm/device-internal.h>
|
||||
#include <dm/test.h>
|
||||
|
@ -297,6 +300,11 @@ static int dm_test_bus_parent_data_uclass(struct unit_test_state *uts)
|
|||
ut_assertok(uclass_find_device(UCLASS_TEST_BUS, 0, &bus));
|
||||
drv = (struct driver *)bus->driver;
|
||||
size = drv->per_child_auto_alloc_size;
|
||||
|
||||
#ifdef CONFIG_SANDBOX
|
||||
os_mprotect_allow(bus->uclass->uc_drv, sizeof(*bus->uclass->uc_drv));
|
||||
os_mprotect_allow(drv, sizeof(*drv));
|
||||
#endif
|
||||
bus->uclass->uc_drv->per_child_auto_alloc_size = size;
|
||||
drv->per_child_auto_alloc_size = 0;
|
||||
ret = test_bus_parent_data(uts);
|
||||
|
@ -440,6 +448,10 @@ static int dm_test_bus_parent_platdata_uclass(struct unit_test_state *uts)
|
|||
ut_assertok(uclass_find_device(UCLASS_TEST_BUS, 0, &bus));
|
||||
drv = (struct driver *)bus->driver;
|
||||
size = drv->per_child_platdata_auto_alloc_size;
|
||||
#ifdef CONFIG_SANDBOX
|
||||
os_mprotect_allow(bus->uclass->uc_drv, sizeof(*bus->uclass->uc_drv));
|
||||
os_mprotect_allow(drv, sizeof(*drv));
|
||||
#endif
|
||||
bus->uclass->uc_drv->per_child_platdata_auto_alloc_size = size;
|
||||
drv->per_child_platdata_auto_alloc_size = 0;
|
||||
ret = test_bus_parent_platdata(uts);
|
||||
|
|
|
@ -870,3 +870,34 @@ static int dm_test_uclass_names(struct unit_test_state *uts)
|
|||
return 0;
|
||||
}
|
||||
DM_TEST(dm_test_uclass_names, DM_TESTF_SCAN_PDATA);
|
||||
|
||||
static int dm_test_inactive_child(struct unit_test_state *uts)
|
||||
{
|
||||
struct dm_test_state *dms = uts->priv;
|
||||
struct udevice *parent, *dev1, *dev2;
|
||||
|
||||
/* Skip the behaviour in test_post_probe() */
|
||||
dms->skip_post_probe = 1;
|
||||
|
||||
ut_assertok(uclass_first_device_err(UCLASS_TEST, &parent));
|
||||
|
||||
/*
|
||||
* Create a child but do not activate it. Calling the function again
|
||||
* should return the same child.
|
||||
*/
|
||||
ut_asserteq(-ENODEV, device_find_first_inactive_child(parent,
|
||||
UCLASS_TEST, &dev1));
|
||||
ut_assertok(device_bind_ofnode(parent, DM_GET_DRIVER(test_drv),
|
||||
"test_child", 0, ofnode_null(), &dev1));
|
||||
|
||||
ut_assertok(device_find_first_inactive_child(parent, UCLASS_TEST,
|
||||
&dev2));
|
||||
ut_asserteq_ptr(dev1, dev2);
|
||||
|
||||
ut_assertok(device_probe(dev1));
|
||||
ut_asserteq(-ENODEV, device_find_first_inactive_child(parent,
|
||||
UCLASS_TEST, &dev2));
|
||||
|
||||
return 0;
|
||||
}
|
||||
DM_TEST(dm_test_inactive_child, DM_TESTF_SCAN_PDATA);
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
|
||||
#include <common.h>
|
||||
#include <dm.h>
|
||||
#include <dm/of_extra.h>
|
||||
#include <dm/test.h>
|
||||
#include <test/ut.h>
|
||||
|
||||
|
@ -42,3 +43,18 @@ static int dm_test_ofnode_by_prop_value(struct unit_test_state *uts)
|
|||
return 0;
|
||||
}
|
||||
DM_TEST(dm_test_ofnode_by_prop_value, DM_TESTF_SCAN_FDT);
|
||||
|
||||
static int dm_test_ofnode_fmap(struct unit_test_state *uts)
|
||||
{
|
||||
struct fmap_entry entry;
|
||||
ofnode node;
|
||||
|
||||
node = ofnode_path("/cros-ec/flash");
|
||||
ut_assert(ofnode_valid(node));
|
||||
ut_assertok(ofnode_read_fmap_entry(node, &entry));
|
||||
ut_asserteq(0x08000000, entry.offset);
|
||||
ut_asserteq(0x20000, entry.length);
|
||||
|
||||
return 0;
|
||||
}
|
||||
DM_TEST(dm_test_ofnode_fmap, DM_TESTF_SCAN_PDATA | DM_TESTF_SCAN_FDT);
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Reference in a new issue