Skip to content

Commit

Permalink
Merge tag 'dm-pull-15jan19' of git://git.denx.de/u-boot-dm
Browse files Browse the repository at this point in the history
Fix recent changes to serial API for driver model
Buildman clang support and a few fixes
Small fixes to 'dm tree' and regmap test
Improve sandbox build compatibility
A few other minor fixes
  • Loading branch information
trini committed Jan 16, 2019
2 parents f4cfd73 + f51f671 commit aac0c29
Show file tree
Hide file tree
Showing 25 changed files with 174 additions and 96 deletions.
13 changes: 3 additions & 10 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -109,16 +109,9 @@ script:
#
# From buildman, exit code 129 means warnings only. If we've been asked to
# use clang only do one configuration.
- if [[ "${TOOLCHAIN}" == "clang" ]]; then
- if [[ "${BUILDMAN}" != "" ]]; then
ret=0;
make O=../.bm-work/${TEST_PY_BD} HOSTCC=clang-7 CC=clang-7 -j$(nproc)
KCFLAGS=-Werror sandbox_config all || ret=$?;
if [[ $ret -ne 0 ]]; then
exit $ret;
fi;
elif [[ "${BUILDMAN}" != "" ]]; then
ret=0;
tools/buildman/buildman -P -E ${BUILDMAN} || ret=$?;
tools/buildman/buildman -P -E ${BUILDMAN} ${OVERRIDE}|| ret=$?;
if [[ $ret -ne 0 && $ret -ne 129 ]]; then
tools/buildman/buildman -sdeP ${BUILDMAN};
exit $ret;
Expand Down Expand Up @@ -351,7 +344,7 @@ matrix:
env:
- TEST_PY_BD="sandbox"
BUILDMAN="^sandbox$"
TOOLCHAIN="clang"
OVERRIDE="clang-7"
- name: "test/py sandbox_spl"
env:
- TEST_PY_BD="sandbox_spl"
Expand Down
2 changes: 0 additions & 2 deletions arch/sandbox/config.mk
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,9 @@ PLATFORM_LIBS += -lrt
ifneq ($(NO_SDL),)
PLATFORM_CPPFLAGS += -DSANDBOX_NO_SDL
else
ifdef CONFIG_SANDBOX_SDL
PLATFORM_LIBS += $(shell sdl-config --libs)
PLATFORM_CPPFLAGS += $(shell sdl-config --cflags)
endif
endif

cmd_u-boot__ = $(CC) -o $@ -Wl,-T u-boot.lds $(u-boot-init) \
-Wl,--start-group $(u-boot-main) -Wl,--end-group \
Expand Down
2 changes: 1 addition & 1 deletion arch/sandbox/cpu/sdl.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
#include <errno.h>
#include <unistd.h>
#include <linux/input.h>
#include <SDL/SDL.h>
#include <SDL.h>
#include <asm/state.h>

/**
Expand Down
10 changes: 4 additions & 6 deletions arch/sandbox/dts/sandbox.dts
Original file line number Diff line number Diff line change
Expand Up @@ -100,11 +100,13 @@
eeprom@2c {
reg = <0x2c>;
compatible = "i2c-eeprom";
sandbox,emul = <&emul_eeprom>;
};

rtc_0: rtc@43 {
reg = <0x43>;
compatible = "sandbox-rtc";
sandbox,emul = <&emul0>;
};
sandbox_pmic: sandbox_pmic {
reg = <0x40>;
Expand All @@ -115,18 +117,14 @@
};

i2c_emul: emul {
#address-cells = <1>;
#size-cells = <0>;
reg = <0xff>;
compatible = "sandbox,i2c-emul-parent";
emul-eeprom {
reg = <0x2c>;
emul_eeprom: emul-eeprom {
compatible = "sandbox,i2c-eeprom";
sandbox,filename = "i2c.bin";
sandbox,size = <256>;
};
emul0 {
reg = <0x43>;
emul0: emul0 {
compatible = "sandbox,i2c-rtc";
};
};
Expand Down
6 changes: 4 additions & 2 deletions arch/sandbox/dts/sandbox64.dts
Original file line number Diff line number Diff line change
Expand Up @@ -90,11 +90,13 @@
eeprom@2c {
reg = <0x2c>;
compatible = "i2c-eeprom";
sandbox,emul = <&emul_eeprom>;
};

rtc_0: rtc@43 {
reg = <0x43>;
compatible = "sandbox-rtc";
sandbox,emul = <&emul0>;
};
sandbox_pmic: sandbox_pmic {
reg = <0x40>;
Expand All @@ -107,12 +109,12 @@
i2c_emul: emul {
reg = <0xff>;
compatible = "sandbox,i2c-emul-parent";
emul-eeprom {
emul_eeprom: emul-eeprom {
compatible = "sandbox,i2c-eeprom";
sandbox,filename = "i2c.bin";
sandbox,size = <256>;
};
emul0 {
emul0: emul0 {
compatible = "sandbox,i2c-rtc";
};
};
Expand Down
12 changes: 12 additions & 0 deletions arch/sandbox/include/asm/io.h
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,18 @@ static inline void _outsw(volatile u16 *port, const void *buf, int ns)
{
}

static inline void memset_io(volatile void *addr, unsigned char val, int count)
{
}

static inline void memcpy_fromio(void *dst, const volatile void *src, int count)
{
}

static inline void memcpy_toio(volatile void *dst, const void *src, int count)
{
}

#define insw(port, buf, ns) _insw((u16 *)port, buf, ns)
#define outsw(port, buf, ns) _outsw((u16 *)port, buf, ns)

Expand Down
12 changes: 8 additions & 4 deletions arch/x86/lib/acpi_table.c
Original file line number Diff line number Diff line change
Expand Up @@ -342,6 +342,7 @@ static void acpi_create_spcr(struct acpi_spcr *spcr)
struct acpi_table_header *header = &(spcr->header);
struct serial_device_info serial_info = {0};
ulong serial_address, serial_offset;
struct udevice *dev;
uint serial_config;
uint serial_width;
int access_size;
Expand All @@ -353,7 +354,10 @@ static void acpi_create_spcr(struct acpi_spcr *spcr)
header->length = sizeof(struct acpi_spcr);
header->revision = 2;

ret = serial_getinfo(&serial_info);
/* Read the device once, here. It is reused below */
ret = uclass_first_device_err(UCLASS_SERIAL, &dev);
if (!ret)
ret = serial_getinfo(dev, &serial_info);
if (ret)
serial_info.type = SERIAL_CHIP_UNKNOWN;

Expand Down Expand Up @@ -431,9 +435,9 @@ static void acpi_create_spcr(struct acpi_spcr *spcr)
break;
}

ret = serial_getconfig(&serial_config);
if (ret)
serial_config = SERIAL_DEFAULT_CONFIG;
serial_config = SERIAL_DEFAULT_CONFIG;
if (dev)
ret = serial_getconfig(dev, &serial_config);

spcr->parity = SERIAL_GET_PARITY(serial_config);
spcr->stop_bits = SERIAL_GET_STOP(serial_config);
Expand Down
4 changes: 2 additions & 2 deletions common/fdt_support.c
Original file line number Diff line number Diff line change
Expand Up @@ -1025,7 +1025,7 @@ static u64 of_bus_default_map(fdt32_t *addr, const fdt32_t *range,
s = fdt_read_number(range + na + pna, ns);
da = fdt_read_number(addr, na);

debug("OF: default map, cp=%llu, s=%llu, da=%llu\n", cp, s, da);
debug("OF: default map, cp=%llx, s=%llx, da=%llx\n", cp, s, da);

if (da < cp || da >= (cp + s))
return OF_BAD_ADDR;
Expand Down Expand Up @@ -1080,7 +1080,7 @@ static u64 of_bus_isa_map(fdt32_t *addr, const fdt32_t *range,
s = fdt_read_number(range + na + pna, ns);
da = fdt_read_number(addr + 1, na - 1);

debug("OF: ISA map, cp=%llu, s=%llu, da=%llu\n", cp, s, da);
debug("OF: ISA map, cp=%llx, s=%llx, da=%llx\n", cp, s, da);

if (da < cp || da >= (cp + s))
return OF_BAD_ADDR;
Expand Down
4 changes: 2 additions & 2 deletions drivers/core/dump.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ static void show_devices(struct udevice *dev, int depth, int last_flag)
struct udevice *child;

/* print the first 20 characters to not break the tree-format. */
printf(" %-10.10s %d [ %c ] %-20.20s ", dev->uclass->uc_drv->name,
printf(" %-10.10s %2d [ %c ] %-20.20s ", dev->uclass->uc_drv->name,
dev_get_uclass_index(dev, NULL),
dev->flags & DM_FLAG_ACTIVATED ? '+' : ' ', dev->driver->name);

Expand Down Expand Up @@ -49,7 +49,7 @@ void dm_dump_all(void)

root = dm_root();
if (root) {
printf(" Class index Probed Driver Name\n");
printf(" Class Index Probed Driver Name\n");
printf("-----------------------------------------------------------\n");
show_devices(root, -1, 0);
}
Expand Down
9 changes: 4 additions & 5 deletions drivers/net/sandbox-raw.c
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,6 @@ static int sb_eth_raw_ofdata_to_platdata(struct udevice *dev)
struct eth_pdata *pdata = dev_get_platdata(dev);
struct eth_sandbox_raw_priv *priv = dev_get_priv(dev);
const char *ifname;
u32 local;
int ret;

pdata->iobase = dev_read_addr(dev);
Expand All @@ -173,10 +172,10 @@ static int sb_eth_raw_ofdata_to_platdata(struct udevice *dev)
priv->host_ifindex, priv->host_ifname);
}

local = sandbox_eth_raw_os_is_local(priv->host_ifname);
if (local < 0)
return local;
priv->local = local;
ret = sandbox_eth_raw_os_is_local(priv->host_ifname);
if (ret < 0)
return ret;
priv->local = ret;

return 0;
}
Expand Down
27 changes: 9 additions & 18 deletions drivers/serial/serial-uclass.c
Original file line number Diff line number Diff line change
Expand Up @@ -294,49 +294,40 @@ void serial_setbrg(void)
ops->setbrg(gd->cur_serial_dev, gd->baudrate);
}

int serial_getconfig(uint *config)
int serial_getconfig(struct udevice *dev, uint *config)
{
struct dm_serial_ops *ops;

if (!gd->cur_serial_dev)
return 0;

ops = serial_get_ops(gd->cur_serial_dev);
ops = serial_get_ops(dev);
if (ops->getconfig)
return ops->getconfig(gd->cur_serial_dev, config);
return ops->getconfig(dev, config);

return 0;
}

int serial_setconfig(uint config)
int serial_setconfig(struct udevice *dev, uint config)
{
struct dm_serial_ops *ops;

if (!gd->cur_serial_dev)
return 0;

ops = serial_get_ops(gd->cur_serial_dev);
ops = serial_get_ops(dev);
if (ops->setconfig)
return ops->setconfig(gd->cur_serial_dev, config);
return ops->setconfig(dev, config);

return 0;
}

int serial_getinfo(struct serial_device_info *info)
int serial_getinfo(struct udevice *dev, struct serial_device_info *info)
{
struct dm_serial_ops *ops;

if (!gd->cur_serial_dev)
return -ENODEV;

if (!info)
return -EINVAL;

info->baudrate = gd->baudrate;

ops = serial_get_ops(gd->cur_serial_dev);
ops = serial_get_ops(dev);
if (ops->getinfo)
return ops->getinfo(gd->cur_serial_dev, info);
return ops->getinfo(dev, info);

return -EINVAL;
}
Expand Down
5 changes: 0 additions & 5 deletions include/common.h
Original file line number Diff line number Diff line change
Expand Up @@ -351,18 +351,13 @@ void smp_set_core_boot_addr(unsigned long addr, int corenr);
void smp_kick_all_cpus(void);

/* $(CPU)/serial.c */
struct serial_device_info;

int serial_init (void);
void serial_setbrg (void);
void serial_putc (const char);
void serial_putc_raw(const char);
void serial_puts (const char *);
int serial_getc (void);
int serial_tstc (void);
int serial_getconfig(uint *config);
int serial_setconfig(uint config);
int serial_getinfo(struct serial_device_info *info);

/* $(CPU)/speed.c */
int get_clocks (void);
Expand Down
3 changes: 2 additions & 1 deletion include/log.h
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,8 @@ static inline int log_uc_cat(enum uclass_id id)
* @return 0 if log record was emitted, -ve on error
*/
int _log(enum log_category_t cat, enum log_level_t level, const char *file,
int line, const char *func, const char *fmt, ...);
int line, const char *func, const char *fmt, ...)
__attribute__ ((format (__printf__, 6, 7)));

/* Define this at the top of a file to add a prefix to debug messages */
#ifndef pr_fmt
Expand Down
14 changes: 13 additions & 1 deletion include/regmap.h
Original file line number Diff line number Diff line change
Expand Up @@ -248,6 +248,8 @@ int regmap_raw_read_range(struct regmap *map, uint range_num, uint offset,
* @cond: Break condition (usually involving @val)
* @sleep_us: Maximum time to sleep between reads in us (0 tight-loops).
* @timeout_ms: Timeout in ms, 0 means never timeout
* @test_add_time: Used for sandbox testing - amount of time to add after
* starting the loop (0 if not testing)
*
* Returns 0 on success and -ETIMEDOUT upon a timeout or the regmap_read
* error return value in case of a error read. In the two former cases,
Expand All @@ -256,8 +258,12 @@ int regmap_raw_read_range(struct regmap *map, uint range_num, uint offset,
*
* This is modelled after the regmap_read_poll_timeout macros in linux but
* with millisecond timeout.
*
* The _test version is for sandbox testing only. Do not use this in normal
* code as it advances the timer.
*/
#define regmap_read_poll_timeout(map, addr, val, cond, sleep_us, timeout_ms) \
#define regmap_read_poll_timeout_test(map, addr, val, cond, sleep_us, \
timeout_ms, test_add_time) \
({ \
unsigned long __start = get_timer(0); \
int __ret; \
Expand All @@ -267,6 +273,8 @@ int regmap_raw_read_range(struct regmap *map, uint range_num, uint offset,
break; \
if (cond) \
break; \
if (IS_ENABLED(CONFIG_SANDBOX) && test_add_time) \
sandbox_timer_add_offset(test_add_time); \
if ((timeout_ms) && get_timer(__start) > (timeout_ms)) { \
__ret = regmap_read((map), (addr), &(val)); \
break; \
Expand All @@ -277,6 +285,10 @@ int regmap_raw_read_range(struct regmap *map, uint range_num, uint offset,
__ret ?: ((cond) ? 0 : -ETIMEDOUT); \
})

#define regmap_read_poll_timeout(map, addr, val, cond, sleep_us, timeout_ms) \
regmap_read_poll_timeout_test(map, addr, val, cond, sleep_us, \
timeout_ms, 0) \

/**
* regmap_update_bits() - Perform a read/modify/write using a mask
*
Expand Down
Loading

0 comments on commit aac0c29

Please sign in to comment.