From 5046f8b005a59cdf7adfaa5d059cef003e4bd9e2 Mon Sep 17 00:00:00 2001 From: Dmitry Rakhchev Date: Wed, 25 Mar 2026 19:42:16 +0300 Subject: [PATCH 1/5] regulator/rpi-panel-attiny: update from official RPi kernel branch rpi-6.12.y, 848280fcccd1a60eef407e2fcce6ace851b23d82 --- .../regulator/rpi-panel-attiny-regulator.c | 77 +++---------------- 1 file changed, 10 insertions(+), 67 deletions(-) diff --git a/drivers/regulator/rpi-panel-attiny-regulator.c b/drivers/regulator/rpi-panel-attiny-regulator.c index 6c3b6bfac961d..a1ac963dfe5d0 100644 --- a/drivers/regulator/rpi-panel-attiny-regulator.c +++ b/drivers/regulator/rpi-panel-attiny-regulator.c @@ -143,24 +143,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 = { @@ -245,39 +229,6 @@ 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 */ @@ -289,7 +240,6 @@ static int attiny_i2c_probe(struct i2c_client *i2c) struct regulator_dev *rdev; struct attiny_lcd *state; struct regmap *regmap; - unsigned int data; int ret; state = devm_kzalloc(&i2c->dev, sizeof(*state), GFP_KERNEL); @@ -307,22 +257,6 @@ static int attiny_i2c_probe(struct i2c_client *i2c) goto error; } - 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; - } - - switch (data) { - case 0xde: /* ver 1 */ - case 0xc3: /* ver 2 */ - break; - default: - dev_err(&i2c->dev, "Unknown Atmel firmware revision: 0x%02x\n", data); - ret = -ENODEV; - goto error; - } - regmap_write(regmap, REG_POWERON, 0); msleep(30); regmap_write(regmap, REG_PWM, 0); @@ -386,6 +320,14 @@ static void attiny_i2c_remove(struct i2c_client *client) mutex_destroy(&state->lock); } +static void attiny_i2c_shutdown(struct i2c_client *client) +{ + struct attiny_lcd *state = i2c_get_clientdata(client); + + regmap_write(state->regmap, REG_PWM, 0); + regmap_write(state->regmap, REG_POWERON, 0); +} + static const struct of_device_id attiny_dt_ids[] = { { .compatible = "raspberrypi,7inch-touchscreen-panel-regulator" }, {}, @@ -400,6 +342,7 @@ static struct i2c_driver attiny_regulator_driver = { }, .probe = attiny_i2c_probe, .remove = attiny_i2c_remove, + .shutdown = attiny_i2c_shutdown, }; module_i2c_driver(attiny_regulator_driver); From c21cd479a3211ff06c805f71dc87b84883eaf887 Mon Sep 17 00:00:00 2001 From: Dmitry Rakhchev Date: Wed, 25 Mar 2026 19:45:55 +0300 Subject: [PATCH 2/5] fbdev/mxc/mxcfb_rpi_7inch: add RPi 7inch panel --- drivers/video/fbdev/mxc/Kconfig | 4 + drivers/video/fbdev/mxc/Makefile | 1 + drivers/video/fbdev/mxc/mipi_dsi.h | 5 + drivers/video/fbdev/mxc/mipi_dsi_northwest.c | 6 + drivers/video/fbdev/mxc/mxcfb_rpi_7inch.c | 256 +++++++++++++++++++ 5 files changed, 272 insertions(+) create mode 100644 drivers/video/fbdev/mxc/mxcfb_rpi_7inch.c diff --git a/drivers/video/fbdev/mxc/Kconfig b/drivers/video/fbdev/mxc/Kconfig index d8896a0513d84..329d222494f4d 100644 --- a/drivers/video/fbdev/mxc/Kconfig +++ b/drivers/video/fbdev/mxc/Kconfig @@ -130,3 +130,7 @@ config FB_MXC_DCIC depends on FB_MXC_SYNC_PANEL depends on MXC_IPU_V3 || FB_MXS select VIDEOMODE_HELPERS + +config FB_MXC_RPI_7INCH_LCD + depends on I2C + tristate "Raspberry Pi 7 inch LCD" diff --git a/drivers/video/fbdev/mxc/Makefile b/drivers/video/fbdev/mxc/Makefile index 0cb0925a5282a..6ad13155fa0d0 100644 --- a/drivers/video/fbdev/mxc/Makefile +++ b/drivers/video/fbdev/mxc/Makefile @@ -1,3 +1,4 @@ +obj-$(CONFIG_FB_MXC_RPI_7INCH_LCD) += mxcfb_rpi_7inch.o obj-$(CONFIG_FB_MXC_DISP_FRAMEWORK) += mxc_dispdrv.o obj-$(CONFIG_FB_MXC_MIPI_DSI_NORTHWEST) += mipi_dsi_northwest.o obj-$(CONFIG_FB_MXC_EDID) += mxc_edid.o diff --git a/drivers/video/fbdev/mxc/mipi_dsi.h b/drivers/video/fbdev/mxc/mipi_dsi.h index b8fc12cd60054..d19edd85a57a4 100644 --- a/drivers/video/fbdev/mxc/mipi_dsi.h +++ b/drivers/video/fbdev/mxc/mipi_dsi.h @@ -187,5 +187,10 @@ void mipid_hx8394_get_lcd_videomode(struct fb_videomode **mode, int *size, struct mipi_lcd_config **data); int mipid_hx8394_lcd_setup(struct mipi_dsi_info *mipi_dsi); #endif +#ifdef CONFIG_FB_MXC_RPI_7INCH_LCD +void mipid_rpi_get_lcd_videomode(struct fb_videomode **mode, int *size, + struct mipi_lcd_config **data); +int mipid_rpi_lcd_setup(struct mipi_dsi_info *mipi_dsi); +#endif #endif diff --git a/drivers/video/fbdev/mxc/mipi_dsi_northwest.c b/drivers/video/fbdev/mxc/mipi_dsi_northwest.c index c33157a860779..066b8ad39b1fe 100644 --- a/drivers/video/fbdev/mxc/mipi_dsi_northwest.c +++ b/drivers/video/fbdev/mxc/mipi_dsi_northwest.c @@ -94,6 +94,12 @@ static struct mipi_dsi_match_lcd mipi_dsi_lcd_db[] = { "ROCKTECH-RK055AHD091", {mipid_hx8394_get_lcd_videomode, mipid_hx8394_lcd_setup} }, +#endif +#ifdef CONFIG_FB_MXC_RPI_7INCH_LCD + { + "RPI-7INCH-LCD", + {mipid_rpi_get_lcd_videomode, mipid_rpi_lcd_setup} + }, #endif { "", {NULL, NULL} diff --git a/drivers/video/fbdev/mxc/mxcfb_rpi_7inch.c b/drivers/video/fbdev/mxc/mxcfb_rpi_7inch.c new file mode 100644 index 0000000000000..fdcbf376c5618 --- /dev/null +++ b/drivers/video/fbdev/mxc/mxcfb_rpi_7inch.c @@ -0,0 +1,256 @@ +/* SPDX-License-Identifier: GPL-2.0+ */ +/* + * Copyright(C) 2024-2026 Emcraft Systems + * Author(s): Vladimir Skvortsov + */ +#include +#include +#include +#include +#include +#include +#include +#include