From 5f8e0493f2562462c9299ae6a63384672abdc3a4 Mon Sep 17 00:00:00 2001 From: Dave Stevenson Date: Mon, 29 Nov 2021 18:31:37 +0000 Subject: [PATCH 1/5] regulator/rpi-panel-attiny: Don't read the LCD power status The I2C to the Atmel is very fussy, and locks up easily on Pi0-3 particularly on reads. The LCD power status is controlled solely by this driver, so rather than reading it back from the Atmel, use the cached status last set. Signed-off-by: Dave Stevenson --- drivers/regulator/rpi-panel-attiny-regulator.c | 18 +----------------- 1 file changed, 1 insertion(+), 17 deletions(-) diff --git a/drivers/regulator/rpi-panel-attiny-regulator.c b/drivers/regulator/rpi-panel-attiny-regulator.c index 8090b9a485b5e5..8b80c0de102225 100644 --- a/drivers/regulator/rpi-panel-attiny-regulator.c +++ b/drivers/regulator/rpi-panel-attiny-regulator.c @@ -144,24 +144,8 @@ static int attiny_lcd_power_disable(struct regulator_dev *rdev) static int attiny_lcd_power_is_enabled(struct regulator_dev *rdev) { struct attiny_lcd *state = rdev_get_drvdata(rdev); - unsigned int data; - int ret, i; - - mutex_lock(&state->lock); - - for (i = 0; i < 10; i++) { - ret = regmap_read(rdev->regmap, REG_PORTC, &data); - if (!ret) - break; - usleep_range(10000, 12000); - } - - mutex_unlock(&state->lock); - - if (ret < 0) - return ret; - return data & PC_RST_BRIDGE_N; + return state->port_states[REG_PORTC - REG_PORTA] & PC_RST_BRIDGE_N; } static const struct regulator_init_data attiny_regulator_default = { From 96fc524048b499e001d241e8e105d7aae45e232d Mon Sep 17 00:00:00 2001 From: Dave Stevenson Date: Thu, 25 Nov 2021 14:50:10 +0000 Subject: [PATCH 2/5] regulator/rpi-panel-attiny: Use two transactions for I2C read The I2C to the Atmel is very fussy, and locks up easily on Pi0-3 particularly on reads. If running at 100kHz on Pi3, reading the ID register generally locks up the Atmel, but splitting the register select write and read into two transactions is reliable. Signed-off-by: Dave Stevenson --- .../regulator/rpi-panel-attiny-regulator.c | 35 ++++++++++++++++++- 1 file changed, 34 insertions(+), 1 deletion(-) diff --git a/drivers/regulator/rpi-panel-attiny-regulator.c b/drivers/regulator/rpi-panel-attiny-regulator.c index 8b80c0de102225..e3decc419814e1 100644 --- a/drivers/regulator/rpi-panel-attiny-regulator.c +++ b/drivers/regulator/rpi-panel-attiny-regulator.c @@ -234,6 +234,39 @@ static void attiny_gpio_set(struct gpio_chip *gc, unsigned int off, int val) mutex_unlock(&state->lock); } +static int attiny_i2c_read(struct i2c_client *client, u8 reg, unsigned int *buf) +{ + struct i2c_msg msgs[1]; + u8 addr_buf[1] = { reg }; + u8 data_buf[1] = { 0, }; + int ret; + + /* Write register address */ + msgs[0].addr = client->addr; + msgs[0].flags = 0; + msgs[0].len = ARRAY_SIZE(addr_buf); + msgs[0].buf = addr_buf; + + ret = i2c_transfer(client->adapter, msgs, ARRAY_SIZE(msgs)); + if (ret != ARRAY_SIZE(msgs)) + return -EIO; + + usleep_range(5000, 10000); + + /* Read data from register */ + msgs[0].addr = client->addr; + msgs[0].flags = I2C_M_RD; + msgs[0].len = 1; + msgs[0].buf = data_buf; + + ret = i2c_transfer(client->adapter, msgs, ARRAY_SIZE(msgs)); + if (ret != ARRAY_SIZE(msgs)) + return -EIO; + + *buf = data_buf[0]; + return 0; +} + /* * I2C driver interface functions */ @@ -264,7 +297,7 @@ static int attiny_i2c_probe(struct i2c_client *i2c, goto error; } - ret = regmap_read(regmap, REG_ID, &data); + ret = attiny_i2c_read(i2c, REG_ID, &data); if (ret < 0) { dev_err(&i2c->dev, "Failed to read REG_ID reg: %d\n", ret); goto error; From 59b9b2aa9b6048c9670c6cfe1154148395ca6e3b Mon Sep 17 00:00:00 2001 From: Dave Stevenson Date: Tue, 30 Nov 2021 17:39:17 +0000 Subject: [PATCH 3/5] Revert "dtoverlays: Drop i2c baudrate for Pi 7inch DSI screen to 50kHz" This reverts commit 0c41710df564f76275c2868beaa0c316553e8247. The regulator driver is now hopefully fixed, therefore revert the workaround that dropped the I2C frequency. Signed-off-by: Dave Stevenson --- arch/arm/boot/dts/overlays/vc4-kms-dsi-7inch-overlay.dts | 1 - 1 file changed, 1 deletion(-) diff --git a/arch/arm/boot/dts/overlays/vc4-kms-dsi-7inch-overlay.dts b/arch/arm/boot/dts/overlays/vc4-kms-dsi-7inch-overlay.dts index 5b6f82aaa6fbc2..5e1700d0367a03 100644 --- a/arch/arm/boot/dts/overlays/vc4-kms-dsi-7inch-overlay.dts +++ b/arch/arm/boot/dts/overlays/vc4-kms-dsi-7inch-overlay.dts @@ -95,7 +95,6 @@ target = <&i2c0if>; __overlay__ { status = "okay"; - clock-frequency = <50000>; }; }; From 60f4ce948235dd136c6dfae0983686cf226261bd Mon Sep 17 00:00:00 2001 From: Dave Stevenson Date: Tue, 30 Nov 2021 17:28:50 +0000 Subject: [PATCH 4/5] input: edt-ft5x06: Only look at the number of points reported Register 0x02 in the FT5x06 is TD_STATUS containing the number of valid touch points being reported. Iterate over that number of points rather than all that are supported on the device. Signed-off-by: Dave Stevenson --- drivers/input/touchscreen/edt-ft5x06.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/drivers/input/touchscreen/edt-ft5x06.c b/drivers/input/touchscreen/edt-ft5x06.c index e33b5f0775defd..9be7a6aba4097d 100644 --- a/drivers/input/touchscreen/edt-ft5x06.c +++ b/drivers/input/touchscreen/edt-ft5x06.c @@ -201,6 +201,7 @@ static irqreturn_t edt_ft5x06_ts_isr(int irq, void *dev_id) unsigned int active_ids = 0, known_ids = tsdata->known_ids; long released_ids; int b = 0; + unsigned int num_points; switch (tsdata->version) { case EDT_M06: @@ -248,9 +249,15 @@ static irqreturn_t edt_ft5x06_ts_isr(int irq, void *dev_id) if (!edt_ft5x06_ts_check_crc(tsdata, rdbuf, datalen)) goto out; + num_points = tsdata->max_support_points; + } else { + /* Register 2 is TD_STATUS, containing the number of touch + * points. + */ + num_points = min(rdbuf[2] & 0xf, tsdata->max_support_points); } - for (i = 0; i < tsdata->max_support_points; i++) { + for (i = 0; i < num_points; i++) { u8 *buf = &rdbuf[i * tplen + offset]; type = buf[0] >> 6; From 636f7dc5531759f3cba4cac4b26aedb87ff9f63e Mon Sep 17 00:00:00 2001 From: Dave Stevenson Date: Tue, 30 Nov 2021 17:35:06 +0000 Subject: [PATCH 5/5] drm/vc4: Correct logging string for dev_err_probe The commit that changed from dev_err to dev_err_probe left the %d in the format string, but removed the parameter, leading to a compile warning. Fixes: "6505412df625 drm/vc4: Use dev_err_probe when logging error registering HDMI audio" Signed-off-by: Dave Stevenson --- drivers/gpu/drm/vc4/vc4_hdmi.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/gpu/drm/vc4/vc4_hdmi.c b/drivers/gpu/drm/vc4/vc4_hdmi.c index f673c04dad1218..807cf15e213029 100644 --- a/drivers/gpu/drm/vc4/vc4_hdmi.c +++ b/drivers/gpu/drm/vc4/vc4_hdmi.c @@ -1848,7 +1848,7 @@ static int vc4_hdmi_audio_init(struct vc4_hdmi *vc4_hdmi) snd_soc_card_set_drvdata(card, vc4_hdmi); ret = devm_snd_soc_register_card(dev, card); if (ret) - dev_err_probe(dev, ret, "Could not register sound card: %d\n"); + dev_err_probe(dev, ret, "Could not register sound card.\n"); return ret;