Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 60e10194 authored by Yamit Mehta's avatar Yamit Mehta
Browse files

mfd: wcd9xxx-core: write same register with multiple values



Write same register with multiple values. All these values
are sent to slave in single i2c message execution.

CRs-Fixed: 1064526
Change-Id: I1e16668f5b0cb20af6baf0afdca3f5e8fb1e3f76
Signed-off-by: default avatarYamit Mehta <ymehta@codeaurora.org>
parent 10b36128
Loading
Loading
Loading
Loading
+21 −9
Original line number Original line Diff line number Diff line
@@ -805,7 +805,7 @@ static int __wcd9xxx_slim_write_repeat(struct wcd9xxx *wcd9xxx,
}
}


/*
/*
 * wcd9xxx_slim_write_repeat: Write the same register with multiple values
 * wcd9xxx_bus_write_repeat: Write the same register with multiple values
 * @wcd9xxx: handle to wcd core
 * @wcd9xxx: handle to wcd core
 * @reg: register to be written
 * @reg: register to be written
 * @bytes: number of bytes to be written to reg
 * @bytes: number of bytes to be written to reg
@@ -813,7 +813,7 @@ static int __wcd9xxx_slim_write_repeat(struct wcd9xxx *wcd9xxx,
 * This API will write reg with bytes from src in a single slimbus
 * This API will write reg with bytes from src in a single slimbus
 * transaction. All values from 1 to 16 are supported by this API.
 * transaction. All values from 1 to 16 are supported by this API.
 */
 */
int wcd9xxx_slim_write_repeat(struct wcd9xxx *wcd9xxx, unsigned short reg,
int wcd9xxx_bus_write_repeat(struct wcd9xxx *wcd9xxx, unsigned short reg,
			      int bytes, void *src)
			      int bytes, void *src)
{
{
	int ret = 0;
	int ret = 0;
@@ -824,11 +824,21 @@ int wcd9xxx_slim_write_repeat(struct wcd9xxx *wcd9xxx, unsigned short reg,
		if (ret)
		if (ret)
			goto err;
			goto err;


		ret = __wcd9xxx_slim_write_repeat(wcd9xxx, reg, bytes, src);
		if (wcd9xxx_get_intf_type() == WCD9XXX_INTERFACE_TYPE_I2C) {
			ret = wcd9xxx->write_dev(wcd9xxx, reg, bytes, src,
						false);
			if (ret < 0)
				dev_err(wcd9xxx->dev,
					"%s: Codec repeat write failed (%d)\n",
					__func__, ret);
		} else {
			ret = __wcd9xxx_slim_write_repeat(wcd9xxx, reg, bytes,
							src);
			if (ret < 0)
			if (ret < 0)
				dev_err(wcd9xxx->dev,
				dev_err(wcd9xxx->dev,
					"%s: Codec repeat write failed (%d)\n",
					"%s: Codec repeat write failed (%d)\n",
					__func__, ret);
					__func__, ret);
		}
	} else {
	} else {
		ret = __wcd9xxx_slim_write_repeat(wcd9xxx, reg, bytes, src);
		ret = __wcd9xxx_slim_write_repeat(wcd9xxx, reg, bytes, src);
	}
	}
@@ -836,7 +846,7 @@ err:
	mutex_unlock(&wcd9xxx->io_lock);
	mutex_unlock(&wcd9xxx->io_lock);
	return ret;
	return ret;
}
}
EXPORT_SYMBOL(wcd9xxx_slim_write_repeat);
EXPORT_SYMBOL(wcd9xxx_bus_write_repeat);


/*
/*
 * wcd9xxx_slim_reserve_bw: API to reserve the slimbus bandwidth
 * wcd9xxx_slim_reserve_bw: API to reserve the slimbus bandwidth
@@ -2088,6 +2098,7 @@ static int wcd9xxx_i2c_write_device(struct wcd9xxx *wcd9xxx, u16 reg, u8 *value,
	u8 reg_addr = 0;
	u8 reg_addr = 0;
	u8 data[bytes + 1];
	u8 data[bytes + 1];
	struct wcd9xxx_i2c *wcd9xxx_i2c;
	struct wcd9xxx_i2c *wcd9xxx_i2c;
	int i;


	wcd9xxx_i2c = wcd9xxx_i2c_get_device_info(wcd9xxx, reg);
	wcd9xxx_i2c = wcd9xxx_i2c_get_device_info(wcd9xxx, reg);
	if (wcd9xxx_i2c == NULL || wcd9xxx_i2c->client == NULL) {
	if (wcd9xxx_i2c == NULL || wcd9xxx_i2c->client == NULL) {
@@ -2100,7 +2111,8 @@ static int wcd9xxx_i2c_write_device(struct wcd9xxx *wcd9xxx, u16 reg, u8 *value,
	msg->len = bytes + 1;
	msg->len = bytes + 1;
	msg->flags = 0;
	msg->flags = 0;
	data[0] = reg;
	data[0] = reg;
	data[1] = *value;
	for (i = 0; i < bytes; i++)
		data[i + 1] = value[i];
	msg->buf = data;
	msg->buf = data;
	ret = i2c_transfer(wcd9xxx_i2c->client->adapter,
	ret = i2c_transfer(wcd9xxx_i2c->client->adapter,
			   wcd9xxx_i2c->xfer_msg, 1);
			   wcd9xxx_i2c->xfer_msg, 1);
+1 −1
Original line number Original line Diff line number Diff line
@@ -308,7 +308,7 @@ int wcd9xxx_interface_reg_read(struct wcd9xxx *wcd9xxx, unsigned short reg);
int wcd9xxx_interface_reg_write(struct wcd9xxx *wcd9xxx, unsigned short reg,
int wcd9xxx_interface_reg_write(struct wcd9xxx *wcd9xxx, unsigned short reg,
		u8 val);
		u8 val);
int wcd9xxx_get_logical_addresses(u8 *pgd_la, u8 *inf_la);
int wcd9xxx_get_logical_addresses(u8 *pgd_la, u8 *inf_la);
int wcd9xxx_slim_write_repeat(struct wcd9xxx *wcd9xxx, unsigned short reg,
int wcd9xxx_bus_write_repeat(struct wcd9xxx *wcd9xxx, unsigned short reg,
			     int bytes, void *src);
			     int bytes, void *src);
int wcd9xxx_slim_reserve_bw(struct wcd9xxx *wcd9xxx,
int wcd9xxx_slim_reserve_bw(struct wcd9xxx *wcd9xxx,
			    u32 bw_ops, bool commit);
			    u32 bw_ops, bool commit);
+1 −1
Original line number Original line Diff line number Diff line
@@ -333,7 +333,7 @@ static int cpe_register_write_repeat(u32 reg, u8 *ptr, u32 to_write)
	struct wcd9xxx *wcd9xxx = dev_get_drvdata(codec->dev->parent);
	struct wcd9xxx *wcd9xxx = dev_get_drvdata(codec->dev->parent);
	int ret = 0;
	int ret = 0;


	ret = wcd9xxx_slim_write_repeat(wcd9xxx, reg, to_write, ptr);
	ret = wcd9xxx_bus_write_repeat(wcd9xxx, reg, to_write, ptr);
	if (ret != 0)
	if (ret != 0)
		pr_err("%s: slim_write_repeat failed\n", __func__);
		pr_err("%s: slim_write_repeat failed\n", __func__);