aboutsummaryrefslogtreecommitdiff
path: root/drivers
diff options
context:
space:
mode:
authorTom Rini2018-11-30 17:09:50 -0500
committerTom Rini2018-11-30 17:09:50 -0500
commit172e3c11901229f0fb88317ac73a47d944a74f46 (patch)
tree15b0252705fe2ee78d7501c79a2161a172e2c75b /drivers
parentdaec1fd482b5ea735d70676a1909aec4355bbf86 (diff)
parent1678754f5e2cbc14f9612e953b39cc08ada66866 (diff)
Merge tag 'pull-30nov18' of git://git.denx.de/u-boot-dm
Fix sound on sandbox Convert TPM fully to DM Tidy up sandbox I2C emulation Add a 'make qcheck' target for faster testing A few other misc things (dropped the final patch which breaks clang for some reason)
Diffstat (limited to 'drivers')
-rw-r--r--drivers/core/device.c34
-rw-r--r--drivers/core/ofnode.c17
-rw-r--r--drivers/core/uclass.c6
-rw-r--r--drivers/i2c/i2c-emul-uclass.c77
-rw-r--r--drivers/i2c/sandbox_i2c.c20
-rw-r--r--drivers/power/pmic/act8846.c2
-rw-r--r--drivers/power/pmic/as3722.c14
-rw-r--r--drivers/power/pmic/as3722_gpio.c11
-rw-r--r--drivers/power/pmic/i2c_pmic_emul.c2
-rw-r--r--drivers/power/pmic/lp873x.c6
-rw-r--r--drivers/power/pmic/lp87565.c6
-rw-r--r--drivers/power/pmic/max77686.c8
-rw-r--r--drivers/power/pmic/max8997.c4
-rw-r--r--drivers/power/pmic/max8998.c4
-rw-r--r--drivers/power/pmic/mc34708.c4
-rw-r--r--drivers/power/pmic/palmas.c8
-rw-r--r--drivers/power/pmic/pfuze100.c6
-rw-r--r--drivers/power/pmic/rk8xx.c6
-rw-r--r--drivers/power/pmic/rn5t567.c4
-rw-r--r--drivers/power/pmic/s2mps11.c8
-rw-r--r--drivers/power/pmic/s5m8767.c6
-rw-r--r--drivers/power/pmic/sandbox.c4
-rw-r--r--drivers/power/pmic/stpmu1.c2
-rw-r--r--drivers/power/pmic/tps65090.c8
-rw-r--r--drivers/rtc/rtc-uclass.c1
-rw-r--r--drivers/sound/sound-i2s.c3
-rw-r--r--drivers/sound/sound.c8
-rw-r--r--drivers/tpm/tpm_tis_lpc.c47
28 files changed, 214 insertions, 112 deletions
diff --git a/drivers/core/device.c b/drivers/core/device.c
index 47a697f3e5c..836bcadced5 100644
--- a/drivers/core/device.c
+++ b/drivers/core/device.c
@@ -699,6 +699,40 @@ int device_find_first_inactive_child(struct udevice *parent,
return -ENODEV;
}
+int device_find_first_child_by_uclass(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_get_uclass_id(dev) == uclass_id) {
+ *devp = dev;
+ return 0;
+ }
+ }
+
+ return -ENODEV;
+}
+
+int device_find_child_by_name(struct udevice *parent, const char *name,
+ struct udevice **devp)
+{
+ struct udevice *dev;
+
+ *devp = NULL;
+
+ list_for_each_entry(dev, &parent->child_head, sibling_node) {
+ if (!strcmp(dev->name, name)) {
+ *devp = dev;
+ return 0;
+ }
+ }
+
+ return -ENODEV;
+}
+
struct udevice *dev_get_parent(const struct udevice *child)
{
return child->parent;
diff --git a/drivers/core/ofnode.c b/drivers/core/ofnode.c
index d9b5280b2d4..0e584c12dc8 100644
--- a/drivers/core/ofnode.c
+++ b/drivers/core/ofnode.c
@@ -253,15 +253,15 @@ int ofnode_read_size(ofnode node, const char *propname)
fdt_addr_t ofnode_get_addr_index(ofnode node, int index)
{
+ int na, ns;
+ fdt_size_t size;
+
if (ofnode_is_np(node)) {
const __be32 *prop_val;
uint flags;
- u64 size;
- int na;
- int ns;
- prop_val = of_get_address(ofnode_to_np(node), index, &size,
- &flags);
+ prop_val = of_get_address(ofnode_to_np(node), index,
+ (u64 *)&size, &flags);
if (!prop_val)
return FDT_ADDR_T_NONE;
@@ -274,8 +274,11 @@ fdt_addr_t ofnode_get_addr_index(ofnode node, int index)
return of_read_number(prop_val, na);
}
} else {
- return fdt_get_base_address(gd->fdt_blob,
- ofnode_to_offset(node));
+ na = ofnode_read_simple_addr_cells(ofnode_get_parent(node));
+ ns = ofnode_read_simple_size_cells(ofnode_get_parent(node));
+ return fdtdec_get_addr_size_fixed(gd->fdt_blob,
+ ofnode_to_offset(node), "reg",
+ index, na, ns, &size, true);
}
return FDT_ADDR_T_NONE;
diff --git a/drivers/core/uclass.c b/drivers/core/uclass.c
index d9c5719a878..9766aeabd19 100644
--- a/drivers/core/uclass.c
+++ b/drivers/core/uclass.c
@@ -354,10 +354,8 @@ done:
}
#if CONFIG_IS_ENABLED(OF_CONTROL)
-static int uclass_find_device_by_phandle(enum uclass_id id,
- struct udevice *parent,
- const char *name,
- struct udevice **devp)
+int uclass_find_device_by_phandle(enum uclass_id id, struct udevice *parent,
+ const char *name, struct udevice **devp)
{
struct udevice *dev;
struct uclass *uc;
diff --git a/drivers/i2c/i2c-emul-uclass.c b/drivers/i2c/i2c-emul-uclass.c
index a2bdd5aa844..ae5aae03e72 100644
--- a/drivers/i2c/i2c-emul-uclass.c
+++ b/drivers/i2c/i2c-emul-uclass.c
@@ -6,8 +6,85 @@
#include <common.h>
#include <dm.h>
#include <i2c.h>
+#include <dm/device-internal.h>
+#include <dm/uclass-internal.h>
+
+/*
+ * i2c emulation works using an 'emul' node at the bus level. Each device in
+ * that node is in the UCLASS_I2C_EMUL uclass, and emulates one i2c device. A
+ * pointer to the device it emulates is in the 'dev' property of the emul device
+ * uclass platdata (struct i2c_emul_platdata), put there by i2c_emul_find().
+ * When sandbox wants an emulator for a device, it calls i2c_emul_find() which
+ * searches for the emulator with the correct address. To find the device for an
+ * emulator, call i2c_emul_get_device().
+ *
+ * The 'emul' node is in the UCLASS_I2C_EMUL_PARENT uclass. We use a separate
+ * uclass so avoid having strange devices on the I2C bus.
+ */
+
+/**
+ * struct i2c_emul_uc_platdata - information about the emulator for this device
+ *
+ * This is used by devices in UCLASS_I2C_EMUL to record information about the
+ * device being emulated. It is accessible with dev_get_uclass_platdata()
+ *
+ * @dev: Device being emulated
+ */
+struct i2c_emul_uc_platdata {
+ struct udevice *dev;
+};
+
+struct udevice *i2c_emul_get_device(struct udevice *emul)
+{
+ struct i2c_emul_uc_platdata *uc_plat = dev_get_uclass_platdata(emul);
+
+ return uc_plat->dev;
+}
+
+int i2c_emul_find(struct udevice *dev, struct udevice **emulp)
+{
+ struct i2c_emul_uc_platdata *uc_plat;
+ struct udevice *emul;
+ int ret;
+
+ ret = uclass_find_device_by_phandle(UCLASS_I2C_EMUL, dev,
+ "sandbox,emul", &emul);
+ if (ret) {
+ log_err("No emulators for device '%s'\n", dev->name);
+ return ret;
+ }
+ uc_plat = dev_get_uclass_platdata(emul);
+ uc_plat->dev = dev;
+ *emulp = emul;
+
+ return device_probe(emul);
+}
UCLASS_DRIVER(i2c_emul) = {
.id = UCLASS_I2C_EMUL,
.name = "i2c_emul",
+ .per_device_platdata_auto_alloc_size =
+ sizeof(struct i2c_emul_uc_platdata),
+};
+
+/*
+ * This uclass is a child of the i2c bus. Its platdata is not defined here so
+ * is defined by its parent, UCLASS_I2C, which uses struct dm_i2c_chip. See
+ * per_child_platdata_auto_alloc_size in UCLASS_DRIVER(i2c).
+ */
+UCLASS_DRIVER(i2c_emul_parent) = {
+ .id = UCLASS_I2C_EMUL_PARENT,
+ .name = "i2c_emul_parent",
+ .post_bind = dm_scan_fdt_dev,
+};
+
+static const struct udevice_id i2c_emul_parent_ids[] = {
+ { .compatible = "sandbox,i2c-emul-parent" },
+ { }
+};
+
+U_BOOT_DRIVER(i2c_emul_parent_drv) = {
+ .name = "i2c_emul_parent_drv",
+ .id = UCLASS_I2C_EMUL_PARENT,
+ .of_match = i2c_emul_parent_ids,
};
diff --git a/drivers/i2c/sandbox_i2c.c b/drivers/i2c/sandbox_i2c.c
index 66578510849..0dbbaa0c447 100644
--- a/drivers/i2c/sandbox_i2c.c
+++ b/drivers/i2c/sandbox_i2c.c
@@ -21,33 +21,15 @@ static int get_emul(struct udevice *dev, struct udevice **devp,
struct dm_i2c_ops **opsp)
{
struct dm_i2c_chip *plat;
- struct udevice *child;
int ret;
*devp = NULL;
*opsp = NULL;
plat = dev_get_parent_platdata(dev);
if (!plat->emul) {
- ret = dm_scan_fdt_dev(dev);
+ ret = i2c_emul_find(dev, &plat->emul);
if (ret)
return ret;
-
- for (device_find_first_child(dev, &child); child;
- device_find_next_child(&child)) {
- if (device_get_uclass_id(child) != UCLASS_I2C_EMUL)
- continue;
-
- ret = device_probe(child);
- if (ret)
- return ret;
-
- break;
- }
-
- if (child)
- plat->emul = child;
- else
- return -ENODEV;
}
*devp = plat->emul;
*opsp = i2c_get_ops(plat->emul);
diff --git a/drivers/power/pmic/act8846.c b/drivers/power/pmic/act8846.c
index b0c759c647c..186fa907e18 100644
--- a/drivers/power/pmic/act8846.c
+++ b/drivers/power/pmic/act8846.c
@@ -50,7 +50,7 @@ static int act8846_bind(struct udevice *dev)
regulators_node = dev_read_subnode(dev, "regulators");
if (!ofnode_valid(regulators_node)) {
- debug("%s: %s regulators subnode not found!", __func__,
+ debug("%s: %s regulators subnode not found!\n", __func__,
dev->name);
return -ENXIO;
}
diff --git a/drivers/power/pmic/as3722.c b/drivers/power/pmic/as3722.c
index 63df6133549..54adcbf50f5 100644
--- a/drivers/power/pmic/as3722.c
+++ b/drivers/power/pmic/as3722.c
@@ -45,14 +45,14 @@ static int as3722_read_id(struct udevice *dev, uint *idp, uint *revisionp)
ret = pmic_reg_read(dev, AS3722_ASIC_ID1);
if (ret < 0) {
- pr_err("failed to read ID1 register: %d", ret);
+ pr_err("failed to read ID1 register: %d\n", ret);
return ret;
}
*idp = ret;
ret = pmic_reg_read(dev, AS3722_ASIC_ID2);
if (ret < 0) {
- pr_err("failed to read ID2 register: %d", ret);
+ pr_err("failed to read ID2 register: %d\n", ret);
return ret;
}
*revisionp = ret;
@@ -70,7 +70,7 @@ int as3722_sd_set_voltage(struct udevice *dev, unsigned int sd, u8 value)
ret = pmic_reg_write(dev, AS3722_SD_VOLTAGE(sd), value);
if (ret < 0) {
- pr_err("failed to write SD%u voltage register: %d", sd, ret);
+ pr_err("failed to write SD%u voltage register: %d\n", sd, ret);
return ret;
}
@@ -86,8 +86,8 @@ int as3722_ldo_set_voltage(struct udevice *dev, unsigned int ldo, u8 value)
ret = pmic_reg_write(dev, AS3722_LDO_VOLTAGE(ldo), value);
if (ret < 0) {
- pr_err("failed to write LDO%u voltage register: %d", ldo,
- ret);
+ pr_err("failed to write LDO%u voltage register: %d\n", ldo,
+ ret);
return ret;
}
@@ -101,12 +101,12 @@ static int as3722_probe(struct udevice *dev)
ret = as3722_read_id(dev, &id, &revision);
if (ret < 0) {
- pr_err("failed to read ID: %d", ret);
+ pr_err("failed to read ID: %d\n", ret);
return ret;
}
if (id != AS3722_DEVICE_ID) {
- pr_err("unknown device");
+ pr_err("unknown device\n");
return -ENOENT;
}
diff --git a/drivers/power/pmic/as3722_gpio.c b/drivers/power/pmic/as3722_gpio.c
index 36f4fbfa470..96943bc1ad5 100644
--- a/drivers/power/pmic/as3722_gpio.c
+++ b/drivers/power/pmic/as3722_gpio.c
@@ -25,7 +25,7 @@ int as3722_gpio_configure(struct udevice *pmic, unsigned int gpio,
err = pmic_reg_write(pmic, AS3722_GPIO_CONTROL(gpio), value);
if (err) {
- pr_err("failed to configure GPIO#%u: %d", gpio, err);
+ pr_err("failed to configure GPIO#%u: %d\n", gpio, err);
return err;
}
@@ -45,7 +45,7 @@ static int as3722_gpio_set_value(struct udevice *dev, unsigned int gpio,
err = pmic_reg_read(pmic, AS3722_GPIO_SIGNAL_OUT);
if (err < 0) {
- pr_err("failed to read GPIO signal out register: %d", err);
+ pr_err("failed to read GPIO signal out register: %d\n", err);
return err;
}
value = err;
@@ -60,7 +60,7 @@ static int as3722_gpio_set_value(struct udevice *dev, unsigned int gpio,
err = pmic_reg_write(pmic, AS3722_GPIO_SIGNAL_OUT, value);
if (err) {
- pr_err("failed to set GPIO#%u %s: %d", gpio, l, err);
+ pr_err("failed to set GPIO#%u %s: %d\n", gpio, l, err);
return err;
}
@@ -83,13 +83,14 @@ int as3722_gpio_direction_output(struct udevice *dev, unsigned int gpio,
err = pmic_reg_write(pmic, AS3722_GPIO_CONTROL(gpio), value);
if (err) {
- pr_err("failed to configure GPIO#%u as output: %d", gpio, err);
+ pr_err("failed to configure GPIO#%u as output: %d\n", gpio,
+ err);
return err;
}
err = as3722_gpio_set_value(pmic, gpio, value);
if (err < 0) {
- pr_err("failed to set GPIO#%u high: %d", gpio, err);
+ pr_err("failed to set GPIO#%u high: %d\n", gpio, err);
return err;
}
diff --git a/drivers/power/pmic/i2c_pmic_emul.c b/drivers/power/pmic/i2c_pmic_emul.c
index 61fa76a5619..80efc0265d9 100644
--- a/drivers/power/pmic/i2c_pmic_emul.c
+++ b/drivers/power/pmic/i2c_pmic_emul.c
@@ -104,7 +104,7 @@ static int sandbox_i2c_pmic_xfer(struct udevice *emul, struct i2c_msg *msg,
static int sandbox_i2c_pmic_ofdata_to_platdata(struct udevice *emul)
{
struct sandbox_i2c_pmic_plat_data *plat = dev_get_platdata(emul);
- struct udevice *pmic_dev = dev_get_parent(emul);
+ struct udevice *pmic_dev = i2c_emul_get_device(emul);
struct uc_pmic_priv *priv = dev_get_uclass_priv(pmic_dev);
const u8 *reg_defaults;
diff --git a/drivers/power/pmic/lp873x.c b/drivers/power/pmic/lp873x.c
index 432ad4cecf6..4ae4043b943 100644
--- a/drivers/power/pmic/lp873x.c
+++ b/drivers/power/pmic/lp873x.c
@@ -24,7 +24,7 @@ static int lp873x_write(struct udevice *dev, uint reg, const uint8_t *buff,
int len)
{
if (dm_i2c_write(dev, reg, buff, len)) {
- pr_err("write error to device: %p register: %#x!", dev, reg);
+ pr_err("write error to device: %p register: %#x!\n", dev, reg);
return -EIO;
}
@@ -34,7 +34,7 @@ static int lp873x_write(struct udevice *dev, uint reg, const uint8_t *buff,
static int lp873x_read(struct udevice *dev, uint reg, uint8_t *buff, int len)
{
if (dm_i2c_read(dev, reg, buff, len)) {
- pr_err("read error from device: %p register: %#x!", dev, reg);
+ pr_err("read error from device: %p register: %#x!\n", dev, reg);
return -EIO;
}
@@ -48,7 +48,7 @@ static int lp873x_bind(struct udevice *dev)
regulators_node = dev_read_subnode(dev, "regulators");
if (!ofnode_valid(regulators_node)) {
- debug("%s: %s regulators subnode not found!", __func__,
+ debug("%s: %s regulators subnode not found!\n", __func__,
dev->name);
return -ENXIO;
}
diff --git a/drivers/power/pmic/lp87565.c b/drivers/power/pmic/lp87565.c
index 450dbb8a780..3e5fc608d28 100644
--- a/drivers/power/pmic/lp87565.c
+++ b/drivers/power/pmic/lp87565.c
@@ -26,7 +26,7 @@ static int lp87565_write(struct udevice *dev, uint reg, const uint8_t *buff,
ret = dm_i2c_write(dev, reg, buff, len);
if (ret)
- pr_err("write error to device: %p register: %#x!", dev, reg);
+ pr_err("write error to device: %p register: %#x!\n", dev, reg);
return ret;
}
@@ -37,7 +37,7 @@ static int lp87565_read(struct udevice *dev, uint reg, uint8_t *buff, int len)
ret = dm_i2c_read(dev, reg, buff, len);
if (ret)
- pr_err("read error from device: %p register: %#x!", dev, reg);
+ pr_err("read error from device: %p register: %#x!\n", dev, reg);
return ret;
}
@@ -49,7 +49,7 @@ static int lp87565_bind(struct udevice *dev)
regulators_node = dev_read_subnode(dev, "regulators");
if (!ofnode_valid(regulators_node)) {
- debug("%s: %s regulators subnode not found!", __func__,
+ debug("%s: %s regulators subnode not found!\n", __func__,
dev->name);
return -ENXIO;
}
diff --git a/drivers/power/pmic/max77686.c b/drivers/power/pmic/max77686.c
index 834713af286..8e3a8cf870b 100644
--- a/drivers/power/pmic/max77686.c
+++ b/drivers/power/pmic/max77686.c
@@ -28,7 +28,7 @@ static int max77686_write(struct udevice *dev, uint reg, const uint8_t *buff,
int len)
{
if (dm_i2c_write(dev, reg, buff, len)) {
- pr_err("write error to device: %p register: %#x!", dev, reg);
+ pr_err("write error to device: %p register: %#x!\n", dev, reg);
return -EIO;
}
@@ -38,7 +38,7 @@ static int max77686_write(struct udevice *dev, uint reg, const uint8_t *buff,
static int max77686_read(struct udevice *dev, uint reg, uint8_t *buff, int len)
{
if (dm_i2c_read(dev, reg, buff, len)) {
- pr_err("read error from device: %p register: %#x!", dev, reg);
+ pr_err("read error from device: %p register: %#x!\n", dev, reg);
return -EIO;
}
@@ -52,8 +52,8 @@ static int max77686_bind(struct udevice *dev)
regulators_node = dev_read_subnode(dev, "voltage-regulators");
if (!ofnode_valid(regulators_node)) {
- debug("%s: %s regulators subnode not found!", __func__,
- dev->name);
+ debug("%s: %s regulators subnode not found!\n", __func__,
+ dev->name);
return -ENXIO;
}
diff --git a/drivers/power/pmic/max8997.c b/drivers/power/pmic/max8997.c
index 0dcdbad5832..dbae155fb34 100644
--- a/drivers/power/pmic/max8997.c
+++ b/drivers/power/pmic/max8997.c
@@ -23,7 +23,7 @@ static int max8997_write(struct udevice *dev, uint reg, const uint8_t *buff,
ret = dm_i2c_write(dev, reg, buff, len);
if (ret)
- pr_err("write error to device: %p register: %#x!", dev, reg);
+ pr_err("write error to device: %p register: %#x!\n", dev, reg);
return ret;
}
@@ -34,7 +34,7 @@ static int max8997_read(struct udevice *dev, uint reg, uint8_t *buff, int len)
ret = dm_i2c_read(dev, reg, buff, len);
if (ret)
- pr_err("read error from device: %p register: %#x!", dev, reg);
+ pr_err("read error from device: %p register: %#x!\n", dev, reg);
return ret;
}
diff --git a/drivers/power/pmic/max8998.c b/drivers/power/pmic/max8998.c
index f571add6e6a..f58d9f2d74c 100644
--- a/drivers/power/pmic/max8998.c
+++ b/drivers/power/pmic/max8998.c
@@ -23,7 +23,7 @@ static int max8998_write(struct udevice *dev, uint reg, const uint8_t *buff,
ret = dm_i2c_write(dev, reg, buff, len);
if (ret)
- pr_err("write error to device: %p register: %#x!", dev, reg);
+ pr_err("write error to device: %p register: %#x!\n", dev, reg);
return ret;
}
@@ -34,7 +34,7 @@ static int max8998_read(struct udevice *dev, uint reg, uint8_t *buff, int len)
ret = dm_i2c_read(dev, reg, buff, len);
if (ret)
- pr_err("read error from device: %p register: %#x!", dev, reg);
+ pr_err("read error from device: %p register: %#x!\n", dev, reg);
return ret;
}
diff --git a/drivers/power/pmic/mc34708.c b/drivers/power/pmic/mc34708.c
index 2b2fc72a472..66253a4a43b 100644
--- a/drivers/power/pmic/mc34708.c
+++ b/drivers/power/pmic/mc34708.c
@@ -38,7 +38,7 @@ static int mc34708_write(struct udevice *dev, uint reg, const u8 *buff,
ret = dm_i2c_write(dev, reg, buf, len);
if (ret)
- printf("write error to device: %p register: %#x!", dev, reg);
+ printf("write error to device: %p register: %#x!\n", dev, reg);
return ret;
}
@@ -53,7 +53,7 @@ static int mc34708_read(struct udevice *dev, uint reg, u8 *buff, int len)
ret = dm_i2c_read(dev, reg, buf, len);
if (ret)
- printf("read error from device: %p register: %#x!", dev, reg);
+ printf("read error from device: %p register: %#x!\n", dev, reg);
buff[0] = buf[2];
buff[1] = buf[1];
diff --git a/drivers/power/pmic/palmas.c b/drivers/power/pmic/palmas.c
index 250a5d34bbf..36be119b6cf 100644
--- a/drivers/power/pmic/palmas.c
+++ b/drivers/power/pmic/palmas.c
@@ -24,7 +24,7 @@ static int palmas_write(struct udevice *dev, uint reg, const uint8_t *buff,
int len)
{
if (dm_i2c_write(dev, reg, buff, len)) {
- pr_err("write error to device: %p register: %#x!", dev, reg);
+ pr_err("write error to device: %p register: %#x!\n", dev, reg);
return -EIO;
}
@@ -34,7 +34,7 @@ static int palmas_write(struct udevice *dev, uint reg, const uint8_t *buff,
static int palmas_read(struct udevice *dev, uint reg, uint8_t *buff, int len)
{
if (dm_i2c_read(dev, reg, buff, len)) {
- pr_err("read error from device: %p register: %#x!", dev, reg);
+ pr_err("read error from device: %p register: %#x!\n", dev, reg);
return -EIO;
}
@@ -60,14 +60,14 @@ static int palmas_bind(struct udevice *dev)
}
if (!ofnode_valid(pmic_node)) {
- debug("%s: %s pmic subnode not found!", __func__, dev->name);
+ debug("%s: %s pmic subnode not found!\n", __func__, dev->name);
return -ENXIO;
}
regulators_node = ofnode_find_subnode(pmic_node, "regulators");
if (!ofnode_valid(regulators_node)) {
- debug("%s: %s reg subnode not found!", __func__, dev->name);
+ debug("%s: %s reg subnode not found!\n", __func__, dev->name);
return -ENXIO;
}
diff --git a/drivers/power/pmic/pfuze100.c b/drivers/power/pmic/pfuze100.c
index 8a5a8996b43..6cf5f35f0f2 100644
--- a/drivers/power/pmic/pfuze100.c
+++ b/drivers/power/pmic/pfuze100.c
@@ -31,7 +31,7 @@ static int pfuze100_write(struct udevice *dev, uint reg, const uint8_t *buff,
int len)
{
if (dm_i2c_write(dev, reg, buff, len)) {
- pr_err("write error to device: %p register: %#x!", dev, reg);
+ pr_err("write error to device: %p register: %#x!\n", dev, reg);
return -EIO;
}
@@ -41,7 +41,7 @@ static int pfuze100_write(struct udevice *dev, uint reg, const uint8_t *buff,
static int pfuze100_read(struct udevice *dev, uint reg, uint8_t *buff, int len)
{
if (dm_i2c_read(dev, reg, buff, len)) {
- pr_err("read error from device: %p register: %#x!", dev, reg);
+ pr_err("read error from device: %p register: %#x!\n", dev, reg);
return -EIO;
}
@@ -55,7 +55,7 @@ static int pfuze100_bind(struct udevice *dev)
regulators_node = dev_read_subnode(dev, "regulators");
if (!ofnode_valid(regulators_node)) {
- debug("%s: %s regulators subnode not found!", __func__,
+ debug("%s: %s regulators subnode not found!\n", __func__,
dev->name);
return -ENXIO;
}
diff --git a/drivers/power/pmic/rk8xx.c b/drivers/power/pmic/rk8xx.c
index c60dfff5bfd..25c339ab12c 100644
--- a/drivers/power/pmic/rk8xx.c
+++ b/drivers/power/pmic/rk8xx.c
@@ -29,7 +29,7 @@ static int rk8xx_write(struct udevice *dev, uint reg, const uint8_t *buff,
ret = dm_i2c_write(dev, reg, buff, len);
if (ret) {
- debug("write error to device: %p register: %#x!", dev, reg);
+ debug("write error to device: %p register: %#x!\n", dev, reg);
return ret;
}
@@ -42,7 +42,7 @@ static int rk8xx_read(struct udevice *dev, uint reg, uint8_t *buff, int len)
ret = dm_i2c_read(dev, reg, buff, len);
if (ret) {
- debug("read error from device: %p register: %#x!", dev, reg);
+ debug("read error from device: %p register: %#x!\n", dev, reg);
return ret;
}
@@ -57,7 +57,7 @@ static int rk8xx_bind(struct udevice *dev)
regulators_node = dev_read_subnode(dev, "regulators");
if (!ofnode_valid(regulators_node)) {
- debug("%s: %s regulators subnode not found!", __func__,
+ debug("%s: %s regulators subnode not found!\n", __func__,
dev->name);
return -ENXIO;
}
diff --git a/drivers/power/pmic/rn5t567.c b/drivers/power/pmic/rn5t567.c
index c3be3fed4a0..f238396d368 100644
--- a/drivers/power/pmic/rn5t567.c
+++ b/drivers/power/pmic/rn5t567.c
@@ -24,7 +24,7 @@ static int rn5t567_write(struct udevice *dev, uint reg, const uint8_t *buff,
ret = dm_i2c_write(dev, reg, buff, len);
if (ret) {
- debug("write error to device: %p register: %#x!", dev, reg);
+ debug("write error to device: %p register: %#x!\n", dev, reg);
return ret;
}
@@ -37,7 +37,7 @@ static int rn5t567_read(struct udevice *dev, uint reg, uint8_t *buff, int len)
ret = dm_i2c_read(dev, reg, buff, len);
if (ret) {
- debug("read error from device: %p register: %#x!", dev, reg);
+ debug("read error from device: %p register: %#x!\n", dev, reg);
return ret;
}
diff --git a/drivers/power/pmic/s2mps11.c b/drivers/power/pmic/s2mps11.c
index e45d4bc6e16..f2aab6c4570 100644
--- a/drivers/power/pmic/s2mps11.c
+++ b/drivers/power/pmic/s2mps11.c
@@ -30,7 +30,7 @@ static int s2mps11_write(struct udevice *dev, uint reg, const uint8_t *buff,
ret = dm_i2c_write(dev, reg, buff, len);
if (ret)
- pr_err("write error to device: %p register: %#x!", dev, reg);
+ pr_err("write error to device: %p register: %#x!\n", dev, reg);
return ret;
}
@@ -41,7 +41,7 @@ static int s2mps11_read(struct udevice *dev, uint reg, uint8_t *buff, int len)
ret = dm_i2c_read(dev, reg, buff, len);
if (ret)
- pr_err("read error from device: %p register: %#x!", dev, reg);
+ pr_err("read error from device: %p register: %#x!\n", dev, reg);
return ret;
}
@@ -53,8 +53,8 @@ static int s2mps11_probe(struct udevice *dev)
regulators_node = dev_read_subnode(dev, "voltage-regulators");
if (!ofnode_valid(regulators_node)) {
- debug("%s: %s regulators subnode not found!", __func__,
- dev->name);
+ debug("%s: %s regulators subnode not found!\n", __func__,
+ dev->name);
return -ENXIO;
}
diff --git a/drivers/power/pmic/s5m8767.c b/drivers/power/pmic/s5m8767.c
index 54e44ce8645..b5ddd4930e3 100644
--- a/drivers/power/pmic/s5m8767.c
+++ b/drivers/power/pmic/s5m8767.c
@@ -27,7 +27,7 @@ static int s5m8767_write(struct udevice *dev, uint reg, const uint8_t *buff,
int len)
{
if (dm_i2c_write(dev, reg, buff, len)) {
- pr_err("write error to device: %p register: %#x!", dev, reg);
+ pr_err("write error to device: %p register: %#x!\n", dev, reg);
return -EIO;
}
@@ -37,7 +37,7 @@ static int s5m8767_write(struct udevice *dev, uint reg, const uint8_t *buff,
static int s5m8767_read(struct udevice *dev, uint reg, uint8_t *buff, int len)
{
if (dm_i2c_read(dev, reg, buff, len)) {
- pr_err("read error from device: %p register: %#x!", dev, reg);
+ pr_err("read error from device: %p register: %#x!\n", dev, reg);
return -EIO;
}
@@ -56,7 +56,7 @@ static int s5m8767_bind(struct udevice *dev)
node = dev_read_subnode(dev, "regulators");
if (!ofnode_valid(node)) {
- debug("%s: %s regulators subnode not found!", __func__,
+ debug("%s: %s regulators subnode not found!\n", __func__,
dev->name);
return -ENXIO;
}
diff --git a/drivers/power/pmic/sandbox.c b/drivers/power/pmic/sandbox.c
index 64e2f276dab..d7870915de8 100644
--- a/drivers/power/pmic/sandbox.c
+++ b/drivers/power/pmic/sandbox.c
@@ -28,7 +28,7 @@ static int sandbox_pmic_write(struct udevice *dev, uint reg,
const uint8_t *buff, int len)
{
if (dm_i2c_write(dev, reg, buff, len)) {
- pr_err("write error to device: %p register: %#x!", dev, reg);
+ pr_err("write error to device: %p register: %#x!\n", dev, reg);
return -EIO;
}
@@ -39,7 +39,7 @@ static int sandbox_pmic_read(struct udevice *dev, uint reg,
uint8_t *buff, int len)
{
if (dm_i2c_read(dev, reg, buff, len)) {
- pr_err("read error from device: %p register: %#x!", dev, reg);
+ pr_err("read error from device: %p register: %#x!\n", dev, reg);
return -EIO;
}
diff --git a/drivers/power/pmic/stpmu1.c b/drivers/power/pmic/stpmu1.c
index 82351b66137..47af0123328 100644
--- a/drivers/power/pmic/stpmu1.c
+++ b/drivers/power/pmic/stpmu1.c
@@ -61,7 +61,7 @@ static int stpmu1_bind(struct udevice *dev)
regulators_node = dev_read_subnode(dev, "regulators");
if (!ofnode_valid(regulators_node)) {
- dev_dbg(dev, "regulators subnode not found!");
+ dev_dbg(dev, "regulators subnode not found!\n");
return -ENXIO;
}
dev_dbg(dev, "found regulators subnode\n");
diff --git a/drivers/power/pmic/tps65090.c b/drivers/power/pmic/tps65090.c
index 1d3bf00b568..5b1d19f3e0b 100644
--- a/drivers/power/pmic/tps65090.c
+++ b/drivers/power/pmic/tps65090.c
@@ -26,7 +26,7 @@ static int tps65090_write(struct udevice *dev, uint reg, const uint8_t *buff,
int len)
{
if (dm_i2c_write(dev, reg, buff, len)) {
- pr_err("write error to device: %p register: %#x!", dev, reg);
+ pr_err("write error to device: %p register: %#x!\n", dev, reg);
return -EIO;
}
@@ -39,8 +39,8 @@ static int tps65090_read(struct udevice *dev, uint reg, uint8_t *buff, int len)
ret = dm_i2c_read(dev, reg, buff, len);
if (ret) {
- pr_err("read error %d from device: %p register: %#x!", ret, dev,
- reg);
+ pr_err("read error %d from device: %p register: %#x!\n", ret,
+ dev, reg);
return -EIO;
}
@@ -54,7 +54,7 @@ static int tps65090_bind(struct udevice *dev)
regulators_node = dev_read_subnode(dev, "regulators");
if (!ofnode_valid(regulators_node)) {
- debug("%s: %s regulators subnode not found!", __func__,
+ debug("%s: %s regulators subnode not found!\n", __func__,
dev->name);
return -ENXIO;
}
diff --git a/drivers/rtc/rtc-uclass.c b/drivers/rtc/rtc-uclass.c
index c676f0ff359..a0a238aedda 100644
--- a/drivers/rtc/rtc-uclass.c
+++ b/drivers/rtc/rtc-uclass.c
@@ -122,4 +122,5 @@ int rtc_write32(struct udevice *dev, unsigned int reg, u32 value)
UCLASS_DRIVER(rtc) = {
.name = "rtc",
.id = UCLASS_RTC,
+ .post_bind = dm_scan_fdt_dev,
};
diff --git a/drivers/sound/sound-i2s.c b/drivers/sound/sound-i2s.c
index 9f09e3bf930..f0f0b79bc52 100644
--- a/drivers/sound/sound-i2s.c
+++ b/drivers/sound/sound-i2s.c
@@ -185,7 +185,8 @@ int sound_play(uint32_t msec, uint32_t frequency)
return -1;
}
- sound_create_square_wave((unsigned short *)data,
+ sound_create_square_wave(g_i2stx_pri.samplingrate,
+ (unsigned short *)data,
data_size / sizeof(unsigned short),
frequency);
diff --git a/drivers/sound/sound.c b/drivers/sound/sound.c
index 969408186fd..4f0ad0d8f0d 100644
--- a/drivers/sound/sound.c
+++ b/drivers/sound/sound.c
@@ -7,11 +7,11 @@
#include <common.h>
#include <sound.h>
-void sound_create_square_wave(unsigned short *data, int size, uint32_t freq)
+void sound_create_square_wave(uint sample_rate, unsigned short *data, int size,
+ uint freq)
{
- const int sample = 48000;
const unsigned short amplitude = 16000; /* between 1 and 32767 */
- const int period = freq ? sample / freq : 0;
+ const int period = freq ? sample_rate / freq : 0;
const int half = period / 2;
assert(freq);
@@ -25,12 +25,10 @@ void sound_create_square_wave(unsigned short *data, int size, uint32_t freq)
for (i = 0; size && i < half; i++) {
size -= 2;
*data++ = amplitude;
- *data++ = amplitude;
}
for (i = 0; size && i < period - half; i++) {
size -= 2;
*data++ = -amplitude;
- *data++ = -amplitude;
}
}
}
diff --git a/drivers/tpm/tpm_tis_lpc.c b/drivers/tpm/tpm_tis_lpc.c
index e993fd9f833..30194bce078 100644
--- a/drivers/tpm/tpm_tis_lpc.c
+++ b/drivers/tpm/tpm_tis_lpc.c
@@ -388,6 +388,27 @@ static int tis_readresponse(struct udevice *dev, u8 *buffer, size_t len)
return offset;
}
+static int tpm_tis_lpc_close(struct udevice *dev)
+{
+ struct tpm_tis_lpc_priv *priv = dev_get_priv(dev);
+ struct tpm_locality *regs = priv->regs;
+ u8 locality = 0;
+
+ if (tpm_read_word(priv, &regs[locality].access) &
+ TIS_ACCESS_ACTIVE_LOCALITY) {
+ tpm_write_word(priv, TIS_ACCESS_ACTIVE_LOCALITY,
+ &regs[locality].access);
+
+ if (tis_wait_reg(priv, &regs[locality].access,
+ TIS_ACCESS_ACTIVE_LOCALITY, 0) == -ETIMEDOUT) {
+ printf("%s:%d - failed to release locality %d\n",
+ __FILE__, __LINE__, locality);
+ return -ETIMEDOUT;
+ }
+ }
+ return 0;
+}
+
static int tpm_tis_lpc_open(struct udevice *dev)
{
struct tpm_tis_lpc_priv *priv = dev_get_priv(dev);
@@ -395,6 +416,12 @@ static int tpm_tis_lpc_open(struct udevice *dev)
u8 locality = 0; /* we use locality zero for everything. */
int ret;
+ ret = tpm_tis_lpc_close(dev);
+ if (ret) {
+ printf("%s: Failed to close TPM\n", __func__);
+ return ret;
+ }
+
/* now request access to locality. */
tpm_write_word(priv, TIS_ACCESS_REQUEST_USE, &regs[locality].access);
@@ -410,27 +437,7 @@ static int tpm_tis_lpc_open(struct udevice *dev)
tpm_write_word(priv, TIS_STS_COMMAND_READY,
&regs[locality].tpm_status);
- return 0;
-}
-
-static int tpm_tis_lpc_close(struct udevice *dev)
-{
- struct tpm_tis_lpc_priv *priv = dev_get_priv(dev);
- struct tpm_locality *regs = priv->regs;
- u8 locality = 0;
-
- if (tpm_read_word(priv, &regs[locality].access) &
- TIS_ACCESS_ACTIVE_LOCALITY) {
- tpm_write_word(priv, TIS_ACCESS_ACTIVE_LOCALITY,
- &regs[locality].access);
- if (tis_wait_reg(priv, &regs[locality].access,
- TIS_ACCESS_ACTIVE_LOCALITY, 0) == -ETIMEDOUT) {
- printf("%s:%d - failed to release locality %d\n",
- __FILE__, __LINE__, locality);
- return -ETIMEDOUT;
- }
- }
return 0;
}