ASoC: wm_adsp: Limit I2C transfer buffer size

I2C driver on Qcom platform only allows 15 256b TX/RX buffers
per transmission. Limit max transfer size to 15*256 = 3840b.

Change-Id: I74fc25f845597a1677134b66a36dce8e73d7ac18
Signed-off-by: Vlad Karpovich <Vlad.Karpovich@cirrus.com>
Signed-off-by: Ravi Vembu <raviv@motorola.com>
Mot-CRs-Fixed: (CR)
Reviewed-on: https://gerrit.mot.com/1215137
SLTApproved: Slta Waiver
SME-Granted: SME Approvals Granted
Tested-by: Jira Key
Submit-Approved: Jira Key
This commit is contained in:
Vlad Karpovich 2018-07-23 17:15:18 -05:00 • committed by Ravikumar Vembu
commit 775bdbb8ed

View file

@ -45,6 +45,12 @@
#define adsp_dbg(_dsp, fmt, ...) \
dev_dbg(_dsp->dev, "DSP%d: " fmt, _dsp->num, ##__VA_ARGS__)
/*
* Max I2C transfer size on Qcom platform, 3840 bytes (15 buffers * 256b)
*/
#define MAX_I2C_TX_SIZE 0xf00
#define ADSP1_CONTROL_1 0x00
#define ADSP1_CONTROL_2 0x02
#define ADSP1_CONTROL_3 0x03
@ -1329,8 +1335,8 @@ static int wm_coeff_read_control(struct wm_coeff_ctl *ctl,
return ret;
while ((len - read_len) > 0) {
toread_len = (len - read_len) > PAGE_SIZE ?
PAGE_SIZE : (len - read_len);
toread_len = (len - read_len) > MAX_I2C_TX_SIZE ?
MAX_I2C_TX_SIZE : (len - read_len);
scratch = wm_adsp_buf_alloc(NULL, toread_len, &buf_list);
if (!scratch) {
@ -1959,7 +1965,7 @@ static int wm_adsp_write_blocks(struct wm_adsp *dsp, const u8 *data, size_t len,
size_t burst_multiple)
{
size_t to_write = PAGE_SIZE - (PAGE_SIZE % burst_multiple);
size_t to_write = MAX_I2C_TX_SIZE - (MAX_I2C_TX_SIZE % burst_multiple);
size_t remain = len;
struct wm_adsp_buf *buf;
unsigned int addr_div;