drm/sitronix/st7571: split up driver to support both I2C and SPI
Subsystems (3)
Marcus Folkesson
maintainerv2 cover drm/sitronix/st7571: split up driver to support both I2C and SPI
This series splits up the driver and finally implements support for ST7571/ST7561 connected to a SPI bus.
I've not tested the SPI interface myself as I lack HW, but the implementation should be okay from what I've read in the datasheet.
---
Changes in v2:
- Add MODULE_IMPORT_NS to st7571-i2c.c st7571-spi.c (Kernel test robot)
- Link to v1: https://lore.kernel.org/r/[email protected]
---
Marcus Folkesson (6):
drm/sitronix/st7571-i2c: rename 'struct drm_device' in st7571_device drm/sitronix/st7571-i2c: add 'struct device' to st7571_device drm/sitronix/st7571-i2c: move common structures to st7571.h drm/sitronix/st7571-i2c: make probe independent of hw interface drm/sitronix/st7571: split up the driver into a common and an i2c part drm/sitronix/st7571-spi: add support for SPI interface
MAINTAINERS | 3 + drivers/gpu/drm/sitronix/Kconfig | 38 +- drivers/gpu/drm/sitronix/Makefile | 2 + drivers/gpu/drm/sitronix/st7571-i2c.c | 1003 ++------------------------------- drivers/gpu/drm/sitronix/st7571-spi.c | 76 +++ drivers/gpu/drm/sitronix/st7571.c | 918 ++++++++++++++++++++++++++++++ drivers/gpu/drm/sitronix/st7571.h | 91 +++ 7 files changed, 1162 insertions(+), 969 deletions(-)
---
base-commit: 07a4844f2ef49f352ef46d0a4774ad63576a6694
change-id: 20251024-st7571-split-c734b06106a4
Best regards,
Signature · 1 line
Marcus Folkesson <[email protected]>
Marcus Folkesson
maintainerPATCH RESEND v2 1/6 drm/sitronix/st7571-i2c: rename 'struct drm_device' in st7571_device
Rename st7571_device.dev to st7571_device.drm in preparation to introduce a 'struct device' member to this structure.
--- drivers/gpu/drm/sitronix/st7571-i2c.c | 60 +++++++++++++++++------------------ 1 file changed, 30 insertions(+), 30 deletions(-)
drivers/gpu/drm/sitronix/st7571-i2c.c +30 -30
@@ -112,7 +112,7 @@ struct st7571_panel_format { };struct st7571_device { -struct drm_device dev; +struct drm_device drm;struct drm_plane primary_plane;struct drm_crtc crtc;
@@ -166,9 +166,9 @@ struct st7571_device {u8 *row; }; -static inline struct st7571_device *drm_to_st7571 (struct drm_device *dev) +static inline struct st7571_device *drm_to_st7571 (struct drm_device *drm) { - return container_of(dev, struct st7571_device, dev); + return container_of(drm, struct st7571_device, drm); }static int st7571_regmap_write (void *context,const void *data,size_t count)
@@ -467,7 +467,7 @@ static void st7571_primary_plane_helper_atomic_update(struct drm_plane *plane,struct drm_shadow_plane_state *shadow_plane_state =to_drm_shadow_plane_state (plane_state);struct drm_framebuffer *fb = plane_state->fb;struct drm_atomic_helper_damage_iter iter; -struct drm_device *dev = plane->dev; +struct drm_device *drm = plane->dev;struct drm_rect damage;struct st7571_device *st7571 =drm_to_st7571 (plane->dev);int ret, idx;
@@ -479,7 +479,7 @@ static void st7571_primary_plane_helper_atomic_update(struct drm_plane *plane,if (ret)return ; -if (!drm_dev_enter (dev, &idx)) +if (!drm_dev_enter (drm, &idx)) goto out_drm_gem_fb_end_cpu_access;drm_atomic_helper_damage_iter_init (&iter, old_plane_state, plane_state);
@@ -501,11 +501,11 @@ static void st7571_primary_plane_helper_atomic_update(struct drm_plane *plane,static void st7571_primary_plane_helper_atomic_disable (struct drm_plane *plane,struct drm_atomic_state *state) { -struct drm_device *dev = plane->dev; +struct drm_device *drm = plane->dev;struct st7571_device *st7571 =drm_to_st7571 (plane->dev);int idx; -if (!drm_dev_enter (dev, &idx)) +if (!drm_dev_enter (drm, &idx))return ;st7571_fb_clear_screen (st7571);
@@ -621,20 +621,20 @@ static struct drm_display_mode st7571_mode(struct st7571_device *st7571)static int st7571_mode_config_init (struct st7571_device *st7571) { -struct drm_device *dev = &st7571->dev; +struct drm_device *drm = &st7571->drm;const struct st7571_panel_constraints *constraints = &st7571->pdata->constraints;int ret; - ret =drmm_mode_config_init (dev); + ret =drmm_mode_config_init (drm);if (ret)return ret; - dev->mode_config.min_width = constraints->min_ncols; - dev->mode_config.min_height = constraints->min_nlines; - dev->mode_config.max_width = constraints->max_ncols; - dev->mode_config.max_height = constraints->max_nlines; - dev->mode_config.preferred_depth =24 ; - dev->mode_config.funcs = &st7571_mode_config_funcs; + drm->mode_config.min_width = constraints->min_ncols; + drm->mode_config.min_height = constraints->min_nlines; + drm->mode_config.max_width = constraints->max_ncols; + drm->mode_config.max_height = constraints->max_nlines; + drm->mode_config.preferred_depth =24 ; + drm->mode_config.funcs = &st7571_mode_config_funcs;return 0 ; }
@@ -643,10 +643,10 @@ static int st7571_plane_init(struct st7571_device *st7571, const struct st7571_panel_format *pformat) {struct drm_plane *primary_plane = &st7571->primary_plane; -struct drm_device *dev = &st7571->dev; +struct drm_device *drm = &st7571->drm;int ret; - ret = drm_universal_plane_init(dev, primary_plane, 0, + ret = drm_universal_plane_init(drm, primary_plane, 0, &st7571_primary_plane_funcs, pformat->formats, pformat->nformats,
@@ -665,10 +665,10 @@ static int st7571_crtc_init(struct st7571_device *st7571) {struct drm_plane *primary_plane = &st7571->primary_plane;struct drm_crtc *crtc = &st7571->crtc; -struct drm_device *dev = &st7571->dev; +struct drm_device *drm = &st7571->drm;int ret; - ret =drm_crtc_init_with_planes (dev, crtc, primary_plane,NULL , + ret =drm_crtc_init_with_planes (drm, crtc, primary_plane,NULL , &st7571_crtc_funcs,NULL );if (ret)return ret;
@@ -682,10 +682,10 @@ static int st7571_encoder_init(struct st7571_device *st7571) {struct drm_encoder *encoder = &st7571->encoder;struct drm_crtc *crtc = &st7571->crtc; -struct drm_device *dev = &st7571->dev; +struct drm_device *drm = &st7571->drm;int ret; - ret =drm_encoder_init (dev, encoder, &st7571_encoder_funcs,DRM_MODE_ENCODER_NONE ,NULL ); + ret =drm_encoder_init (drm, encoder, &st7571_encoder_funcs,DRM_MODE_ENCODER_NONE ,NULL );if (ret)return ret;
@@ -700,10 +700,10 @@ static int st7571_connector_init(struct st7571_device *st7571) {struct drm_connector *connector = &st7571->connector;struct drm_encoder *encoder = &st7571->encoder; -struct drm_device *dev = &st7571->dev; +struct drm_device *drm = &st7571->drm;int ret; - ret =drm_connector_init (dev, connector, &st7571_connector_funcs, + ret =drm_connector_init (drm, connector, &st7571_connector_funcs, DRM_MODE_CONNECTOR_Unknown);if (ret)return ret;
@@ -934,15 +934,15 @@ static int st7571_lcd_init(struct st7571_device *st7571)static int st7571_probe (struct i2c_client *client) {struct st7571_device *st7571; -struct drm_device *dev; +struct drm_device *drm;int ret; st7571 =devm_drm_dev_alloc (&client->dev, &st7571_driver, - struct st7571_device, dev); + struct st7571_device, drm);if (IS_ERR (st7571))return PTR_ERR (st7571); - dev = &st7571->dev; + drm = &st7571->drm; st7571->client = client;i2c_set_clientdata (client, st7571); st7571->pdata =device_get_match_data (&client->dev);
@@ -1010,14 +1010,14 @@ static int st7571_probe(struct i2c_client *client)return dev_err_probe (&client->dev, ret,"Failed to initialize connector\n" ); -drm_mode_config_reset (dev); +drm_mode_config_reset (drm); - ret =drm_dev_register (dev,0 ); + ret =drm_dev_register (drm,0 );if (ret)return dev_err_probe (&client->dev, ret,"Failed to register DRM device\n" ); -drm_client_setup (dev,NULL ); +drm_client_setup (drm,NULL );return 0 ; }
@@ -1025,7 +1025,7 @@ static void st7571_remove(struct i2c_client *client) {struct st7571_device *st7571 =i2c_get_clientdata (client); -drm_dev_unplug (&st7571->dev); +drm_dev_unplug (&st7571->drm); }static const struct st7571_panel_data st7567_config = {
Signature · 1 line
2.51.2
Re: [PATCH RESEND v2 1/6] drm/sitronix/st7571-i2c: rename 'struct drm_device' in st7571_device
Marcus Folkesson <[email protected]> writes:
Hello Marcus,
Quoted 5 lines
Rename st7571_device.dev to st7571_device.drm in preparation to introduce a 'struct device' member to this structure.
Signed-off-by Marcus Folkesson <[email protected]>---
Signature · 5 lines
Best regards, Javier Martinez Canillas Core Platforms Red Hat
Marcus Folkesson
maintainerPATCH RESEND v2 2/6 drm/sitronix/st7571-i2c: add 'struct device' to st7571_device
In reply to Marcus FolkessonKeep a copy of the device structure instead of referring to i2c_client. This is a preparation step to separate the generic part from all i2c stuff.
--- drivers/gpu/drm/sitronix/st7571-i2c.c | 30 ++++++++++++++++-------------- 1 file changed, 16 insertions(+), 14 deletions(-)
drivers/gpu/drm/sitronix/st7571-i2c.c +16 -14
@@ -113,6 +113,7 @@ struct st7571_panel_format {struct st7571_device {struct drm_device drm; +struct device *dev;struct drm_plane primary_plane;struct drm_crtc crtc;
@@ -741,7 +742,7 @@ static const struct regmap_config st7571_regmap_config = {static int st7571_validate_parameters (struct st7571_device *st7571) { -struct device *dev = st7571->dev.dev; +struct device *dev = st7571->dev;const struct st7571_panel_constraints *constraints = &st7571->pdata->constraints;if (st7571->width_mm ==0 ) {
@@ -781,7 +782,7 @@ static int st7571_validate_parameters(struct st7571_device *st7571)static int st7567_parse_dt (struct st7571_device *st7567) { -struct device *dev = &st7567->client->dev; +struct device *dev = st7567->dev;struct device_node *np = dev->of_node;struct display_timing dt;int ret;
@@ -808,7 +809,7 @@ static int st7567_parse_dt(struct st7571_device *st7567)static int st7571_parse_dt (struct st7571_device *st7571) { -struct device *dev = &st7571->client->dev; +struct device *dev = st7571->dev;struct device_node *np = dev->of_node;struct display_timing dt;int ret;
@@ -943,9 +944,10 @@ static int st7571_probe(struct i2c_client *client)return PTR_ERR (st7571); drm = &st7571->drm; + st7571->dev = &client->dev; st7571->client = client;i2c_set_clientdata (client, st7571); - st7571->pdata =device_get_match_data (&client->dev); + st7571->pdata =device_get_match_data (st7571->dev); ret = st7571->pdata->parse_dt (st7571);if (ret)
@@ -966,20 +968,20 @@ static int st7571_probe(struct i2c_client *client)if (i2c_check_functionality (client->adapter,I2C_FUNC_PROTOCOL_MANGLING )) st7571->ignore_nak = true; - st7571->regmap =devm_regmap_init (&client->dev, &st7571_regmap_bus, + st7571->regmap =devm_regmap_init (st7571->dev, &st7571_regmap_bus, client, &st7571_regmap_config);if (IS_ERR (st7571->regmap)) { -return dev_err_probe (&client->dev,PTR_ERR (st7571->regmap), +return dev_err_probe (st7571->dev,PTR_ERR (st7571->regmap),"Failed to initialize regmap\n" ); } - st7571->hwbuf =devm_kzalloc (&client->dev, + st7571->hwbuf =devm_kzalloc (st7571->dev, (st7571->nlines * st7571->ncols * st7571->bpp) /8 ,GFP_KERNEL );if (!st7571->hwbuf)return -ENOMEM ; - st7571->row =devm_kzalloc (&client->dev, + st7571->row =devm_kzalloc (st7571->dev, (st7571->ncols * st7571->bpp),GFP_KERNEL );if (!st7571->row)
@@ -987,34 +989,34 @@ static int st7571_probe(struct i2c_client *client) ret =st7571_mode_config_init (st7571);if (ret) -return dev_err_probe (&client->dev, ret, +return dev_err_probe (st7571->dev, ret,"Failed to initialize mode config\n" ); ret =st7571_plane_init (st7571, st7571->pformat);if (ret) -return dev_err_probe (&client->dev, ret, +return dev_err_probe (st7571->dev, ret,"Failed to initialize primary plane\n" ); ret =st7571_crtc_init (st7571);if (ret <0 ) -return dev_err_probe (&client->dev, ret, +return dev_err_probe (st7571->dev, ret,"Failed to initialize CRTC\n" ); ret =st7571_encoder_init (st7571);if (ret <0 ) -return dev_err_probe (&client->dev, ret, +return dev_err_probe (st7571->dev, ret,"Failed to initialize encoder\n" ); ret =st7571_connector_init (st7571);if (ret <0 ) -return dev_err_probe (&client->dev, ret, +return dev_err_probe (st7571->dev, ret,"Failed to initialize connector\n" );drm_mode_config_reset (drm); ret =drm_dev_register (drm,0 );if (ret) -return dev_err_probe (&client->dev, ret, +return dev_err_probe (st7571->dev, ret,"Failed to register DRM device\n" );drm_client_setup (drm,NULL );
Signature · 1 line
2.51.2
Re: [PATCH RESEND v2 2/6] drm/sitronix/st7571-i2c: add 'struct device' to st7571_device
Quoted 6 lines · Marcus Folkesson
Keep a copy of the device structure instead of referring to
i2c_client. This is a preparation step to separate the generic part from all i2c stuff.Signed-off-by Marcus Folkesson <[email protected]>---
Signature · 5 lines
Best regards, Javier Martinez Canillas Core Platforms Red Hat
Marcus Folkesson
maintainerPATCH RESEND v2 3/6 drm/sitronix/st7571-i2c: move common structures to st7571.h
In reply to Marcus FolkessonMove all structures that will be common for all interfaces (SPI/I2C) to a separate header file.
--- MAINTAINERS | 1 + drivers/gpu/drm/sitronix/st7571-i2c.c | 91 +--------------------------- drivers/gpu/drm/sitronix/st7571.h | 108 ++++++++++++++++++++++++++++++++++ 3 files changed, 111 insertions(+), 89 deletions(-)
MAINTAINERS +1 -0
@@ -8083,6 +8083,7 @@ S: Maintained F: Documentation/devicetree/bindings/display/sitronix,st7567.yaml F: Documentation/devicetree/bindings/display/sitronix,st7571.yaml F: drivers/gpu/drm/sitronix/st7571-i2c.c +F: drivers/gpu/drm/sitronix/st7571.h DRM DRIVER FOR SITRONIX ST7701 PANELS M: Jagan Teki <[email protected]>
drivers/gpu/drm/sitronix/st7571-i2c.c +2 -89
103 lines not on this page · raw message
drivers/gpu/drm/sitronix/st7571.h new file +108 -0
108 lines not on this page · raw message
Signature · 1 line
2.51.2
Re: [PATCH RESEND v2 3/6] drm/sitronix/st7571-i2c: move common structures to st7571.h
Quoted 5 lines · Marcus Folkesson
Move all structures that will be common for all interfaces (SPI/I2C) to a separate header file.
Signed-off-by Marcus Folkesson <[email protected]>---
Signature · 5 lines
Best regards, Javier Martinez Canillas Core Platforms Red Hat
Marcus Folkesson
maintainerPATCH RESEND v2 4/6 drm/sitronix/st7571-i2c: make probe independent of hw interface
In reply to Marcus FolkessonCreate a interface independent layer for the probe function. This to make it possible to add support for other interfaces.
--- drivers/gpu/drm/sitronix/st7571-i2c.c | 165 +++++++++++++++++++++++----------- drivers/gpu/drm/sitronix/st7571.h | 25 +----- 2 files changed, 113 insertions(+), 77 deletions(-)
drivers/gpu/drm/sitronix/st7571-i2c.c +112 -53
@@ -80,6 +80,33 @@#define DRIVER_MAJOR 1#define DRIVER_MINOR 0 +struct st7571_i2c_transport { +struct i2c_client *client; + +/* +* Depending on the hardware design, the acknowledge signal may be hard to +* recognize as a valid logic "0" level. +* Therefor, ignore NAK if possible to stay compatible with most hardware designs +* and off-the-shelf panels out there. +* +* From section 6.4 MICROPOCESSOR INTERFACE section in the datasheet: +* +* "By connecting SDA_OUT to SDA_IN externally, the SDA line becomes fully +* I2C interface compatible. +* Separating acknowledge-output from serial data +* input is advantageous for chip-on-glass (COG) applications. In COG +* applications, the ITO resistance and the pull-up resistor will form a +* voltage divider, which affects acknowledge-signal level. Larger ITO +* resistance will raise the acknowledged-signal level and system cannot +* recognize this level as a valid logic “0” level. By separating SDA_IN from +* SDA_OUT, the IC can be used in a mode that ignores the acknowledge-bit. +* For applications which check acknowledge-bit, it is necessary to minimize +* the ITO resistance of the SDA_OUT trace to guarantee a valid low level." +* +*/ +bool ignore_nak; +}; +static inline struct st7571_device *drm_to_st7571 (struct drm_device *drm) { return container_of(drm, struct st7571_device, drm);
@@ -87,18 +114,17 @@ static inline struct st7571_device *drm_to_st7571(struct drm_device *drm)static int st7571_regmap_write (void *context,const void *data,size_t count) { -struct i2c_client *client = context; -struct st7571_device *st7571 =i2c_get_clientdata (client); +struct st7571_i2c_transport *t = context;int ret;struct i2c_msg msg = { - .addr = st7571->client->addr, - .flags = st7571->ignore_nak ?I2C_M_IGNORE_NAK :0 , + .addr = t->client->addr, + .flags = t->ignore_nak ?I2C_M_IGNORE_NAK :0 , .len = count, .buf = (u8 *)data }; - ret =i2c_transfer (st7571->client->adapter, &msg,1 ); + ret =i2c_transfer (t->client->adapter, &msg,1 );/* * Unfortunately, there is no way to check if the transfer failed because of
@@ -106,7 +132,7 @@ static int st7571_regmap_write(void *context, const void *data, size_t count)* * However, if the transfer fails and ignore_nak is set, we know it is an error. */ -if (ret <0 && st7571->ignore_nak) +if (ret <0 && t->ignore_nak)return ret;return 0 ;
@@ -845,102 +871,135 @@ static int st7571_lcd_init(struct st7571_device *st7571)return st7571_send_command_list (st7571, commands,ARRAY_SIZE (commands)); } -static int st7571_probe (struct i2c_client *client) +static struct st7571_device *st7571_probe (struct device *dev, +struct regmap *regmap) {struct st7571_device *st7571;struct drm_device *drm;int ret; - st7571 =devm_drm_dev_alloc (&client->dev, &st7571_driver, + st7571 =devm_drm_dev_alloc (dev, &st7571_driver, struct st7571_device, drm);if (IS_ERR (st7571)) -return PTR_ERR (st7571); +return st7571; drm = &st7571->drm; - st7571->dev = &client->dev; - st7571->client = client; -i2c_set_clientdata (client, st7571); + st7571->dev = dev; st7571->pdata =device_get_match_data (st7571->dev); ret = st7571->pdata->parse_dt (st7571);if (ret) -return ret; +return ERR_PTR (ret); ret =st7571_validate_parameters (st7571);if (ret) -return ret; +return ERR_PTR (ret); st7571->mode =st7571_mode (st7571); + st7571->regmap = regmap; -/* -* The hardware design could make it hard to detect a NAK on the I2C bus. -* If the adapter does not support protocol mangling do -* not set the I2C_M_IGNORE_NAK flag at the expense * of possible -* cruft in the logs. -*/ -if (i2c_check_functionality (client->adapter,I2C_FUNC_PROTOCOL_MANGLING )) - st7571->ignore_nak = true; - - st7571->regmap =devm_regmap_init (st7571->dev, &st7571_regmap_bus, - client, &st7571_regmap_config); -if (IS_ERR (st7571->regmap)) { -return dev_err_probe (st7571->dev,PTR_ERR (st7571->regmap), -"Failed to initialize regmap\n" ); - } st7571->hwbuf =devm_kzalloc (st7571->dev, (st7571->nlines * st7571->ncols * st7571->bpp) /8 ,GFP_KERNEL );if (!st7571->hwbuf) -return -ENOMEM ; +return ERR_PTR (-ENOMEM ); st7571->row =devm_kzalloc (st7571->dev, (st7571->ncols * st7571->bpp),GFP_KERNEL );if (!st7571->row) -return -ENOMEM ; +return ERR_PTR (-ENOMEM ); ret =st7571_mode_config_init (st7571); -if (ret) -return dev_err_probe (st7571->dev, ret, -"Failed to initialize mode config\n" ); +if (ret) { +dev_err (st7571->dev,"Failed to initialize mode config\n" ); +return ERR_PTR (ret); + } ret =st7571_plane_init (st7571, st7571->pformat); -if (ret) -return dev_err_probe (st7571->dev, ret, -"Failed to initialize primary plane\n" ); +if (ret) { +dev_err (st7571->dev,"Failed to initialize primary plane\n" ); +return ERR_PTR (ret); + } ret =st7571_crtc_init (st7571); -if (ret <0 ) -return dev_err_probe (st7571->dev, ret, -"Failed to initialize CRTC\n" ); +if (ret <0 ) { +dev_err (st7571->dev,"Failed to initialize CRTC\n" ); +return ERR_PTR (ret); + } ret =st7571_encoder_init (st7571); -if (ret <0 ) -return dev_err_probe (st7571->dev, ret, -"Failed to initialize encoder\n" ); +if (ret <0 ) { +dev_err (st7571->dev,"Failed to initialize encoder\n" ); +return ERR_PTR (ret); + } ret =st7571_connector_init (st7571); -if (ret <0 ) -return dev_err_probe (st7571->dev, ret, -"Failed to initialize connector\n" ); +if (ret <0 ) { +dev_err (st7571->dev,"Failed to initialize connector\n" ); +return ERR_PTR (ret); + }drm_mode_config_reset (drm); ret =drm_dev_register (drm,0 ); -if (ret) -return dev_err_probe (st7571->dev, ret, -"Failed to register DRM device\n" ); +if (ret) { +dev_err (st7571->dev,"Failed to register DRM device\n" ); +return ERR_PTR (ret); + }drm_client_setup (drm,NULL ); +return st7571; +} + +static void st7571_remove (struct st7571_device *st7571) +{ +drm_dev_unplug (&st7571->drm); +} + +static int st7571_i2c_probe (struct i2c_client *client) +{ +struct st7571_device *st7571; +struct st7571_i2c_transport *t; +struct regmap *regmap; + + t =devm_kzalloc (&client->dev,sizeof (*t),GFP_KERNEL ); +if (!t) +return -ENOMEM ; + + t->client = client; + +/* +* The hardware design could make it hard to detect a NAK on the I2C bus. +* If the adapter does not support protocol mangling do +* not set the I2C_M_IGNORE_NAK flag at the expense * of possible +* cruft in the logs. +*/ +if (i2c_check_functionality (client->adapter,I2C_FUNC_PROTOCOL_MANGLING )) + t->ignore_nak = true; + + regmap =devm_regmap_init (&client->dev, &st7571_regmap_bus, + t, &st7571_regmap_config); +if (IS_ERR (regmap)) { +return dev_err_probe (&client->dev,PTR_ERR (regmap), +"Failed to initialize regmap\n" ); + } + + st7571 =st7571_probe (&client->dev, regmap); +if (IS_ERR (st7571)) +return dev_err_probe (&client->dev,PTR_ERR (st7571), +"Failed to initialize regmap\n" ); + +i2c_set_clientdata (client, st7571);return 0 ; } -static void st7571_remove (struct i2c_client *client) +static void st7571_i2c_remove (struct i2c_client *client) {struct st7571_device *st7571 =i2c_get_clientdata (client); -drm_dev_unplug (&st7571->drm); +st7571_remove (st7571); }static const struct st7571_panel_data st7567_config = {
@@ -986,8 +1045,8 @@ static struct i2c_driver st7571_i2c_driver = { .name = "st7571", .of_match_table = st7571_of_match, }, - .probe = st7571_probe, - .remove = st7571_remove, + .probe = st7571_i2c_probe, + .remove = st7571_i2c_remove, .id_table = st7571_id, };
drivers/gpu/drm/sitronix/st7571.h +1 -24
@@ -13,6 +13,7 @@#include <drm/drm_crtc.h> #include <drm/drm_drv.h> #include <drm/drm_encoder.h> +#include <drm/drm_format_helper.h> #include <linux/regmap.h>
@@ -62,33 +63,9 @@ struct st7571_device {const struct st7571_panel_format *pformat;const struct st7571_panel_data *pdata; -struct i2c_client *client;struct gpio_desc *reset;struct regmap *regmap; -/* -* Depending on the hardware design, the acknowledge signal may be hard to -* recognize as a valid logic "0" level. -* Therefor, ignore NAK if possible to stay compatible with most hardware designs -* and off-the-shelf panels out there. -* -* From section 6.4 MICROPOCESSOR INTERFACE section in the datasheet: -* -* "By connecting SDA_OUT to SDA_IN externally, the SDA line becomes fully -* I2C interface compatible. -* Separating acknowledge-output from serial data -* input is advantageous for chip-on-glass (COG) applications. In COG -* applications, the ITO resistance and the pull-up resistor will form a -* voltage divider, which affects acknowledge-signal level. Larger ITO -* resistance will raise the acknowledged-signal level and system cannot -* recognize this level as a valid logic “0” level. By separating SDA_IN from -* SDA_OUT, the IC can be used in a mode that ignores the acknowledge-bit. -* For applications which check acknowledge-bit, it is necessary to minimize -* the ITO resistance of the SDA_OUT trace to guarantee a valid low level." -* -*/ -bool ignore_nak; -bool grayscale;bool inverted;u32 height_mm;
Signature · 1 line
2.51.2
Re: [PATCH RESEND v2 4/6] drm/sitronix/st7571-i2c: make probe independent of hw interface
Quoted 1 line · Marcus Folkesson
Create a interface independent layer for the probe function. This to
"an interface" and "This is to"
Quoted 4 lines
make it possible to add support for other interfaces.
Signed-off-by Marcus Folkesson <[email protected]>---
Signature · 5 lines
Best regards, Javier Martinez Canillas Core Platforms Red Hat
Marcus Folkesson
maintainerPATCH RESEND v2 5/6 drm/sitronix/st7571: split up the driver into a common and an i2c part
In reply to Marcus FolkessonSplit up the driver to make it possible to add support for hw interfaces other than I2C.
--- MAINTAINERS | 1 + drivers/gpu/drm/sitronix/Kconfig | 26 +- drivers/gpu/drm/sitronix/Makefile | 1 + drivers/gpu/drm/sitronix/st7571-i2c.c | 925 +--------------------------------- drivers/gpu/drm/sitronix/st7571.c | 918 +++++++++++++++++++++++++++++++++ drivers/gpu/drm/sitronix/st7571.h | 6 + 6 files changed, 960 insertions(+), 917 deletions(-)
MAINTAINERS +1 -0
@@ -8083,6 +8083,7 @@ S: Maintained F: Documentation/devicetree/bindings/display/sitronix,st7567.yaml F: Documentation/devicetree/bindings/display/sitronix,st7571.yaml F: drivers/gpu/drm/sitronix/st7571-i2c.c +F: drivers/gpu/drm/sitronix/st7571.c F: drivers/gpu/drm/sitronix/st7571.h DRM DRIVER FOR SITRONIX ST7701 PANELS
drivers/gpu/drm/sitronix/Kconfig +21 -5
@@ -1,13 +1,29 @@ -config DRM_ST7571_I2C - tristate "DRM support for Sitronix ST7571 display panels (I2C)" - depends on DRM && I2C && MMU +config DRM_ST7571 + tristate "DRM support for Sitronix ST7567/ST7571 display panels" + depends on DRM && MMU select DRM_CLIENT_SELECTION select DRM_GEM_SHMEM_HELPER select DRM_KMS_HELPER - select REGMAP_I2C select VIDEOMODE_HELPERS help - DRM driver for Sitronix ST7571 panels controlled over I2C. + Sitronix ST7571 is a driver and controller for 4-level gray + scale and monochrome dot matrix LCD panels. + + DRM driver for Sitronix ST7567/ST7571 panels. + This is only the core driver, a driver for the appropriate bus + transport in your chip also must be selected. + + if M is selected the module will be called st7571. + +config DRM_ST7571_I2C + tristate "DRM support for Sitronix ST7567/ST7571 display panels (I2C)" + depends on DRM_ST7571 && I2C + select REGMAP_I2C + help + Sitronix ST7571 is a driver and controller for 4-level gray + scale and monochrome dot matrix LCD panels. + + DRM driver for Sitronix ST7565/ST7571 panels connected via I2C bus. if M is selected the module will be called st7571-i2c.
drivers/gpu/drm/sitronix/Makefile +1 -0
@@ -1,3 +1,4 @@ +obj-$(CONFIG_DRM_ST7571) += st7571.o obj-$(CONFIG_DRM_ST7571_I2C) += st7571-i2c.o obj-$(CONFIG_DRM_ST7586) += st7586.o obj-$(CONFIG_DRM_ST7735R) += st7735r.o
drivers/gpu/drm/sitronix/st7571-i2c.c +13 -912
985 lines not on this page · raw message
drivers/gpu/drm/sitronix/st7571.c new file +918 -0
918 lines not on this page · raw message
drivers/gpu/drm/sitronix/st7571.h +6 -0
@@ -82,4 +82,10 @@ struct st7571_device { u8 *row; }; +extern const struct st7571_panel_data st7567_config; +extern const struct st7571_panel_data st7571_config; + +struct st7571_device *st7571_probe (struct device *dev,struct regmap *regmap); +void st7571_remove (struct st7571_device *st7571); +#endif /* __ST7571_H__ */
Signature · 1 line
2.51.2
Re: [PATCH RESEND v2 5/6] drm/sitronix/st7571: split up the driver into a common and an i2c part
Quoted 5 lines · Marcus Folkesson
Split up the driver to make it possible to add support for hw interfaces other than I2C.
Signed-off-by Marcus Folkesson <[email protected]>---
[...]
drivers/gpu/drm/sitronix/Kconfig line 21
Quoted 4 lines
drivers/gpu/drm/sitronix/Kconfig +4
-0+config DRM_ST7571_I2C + tristate "DRM support for Sitronix ST7567/ST7571 display panels (I2C)" + depends on DRM_ST7571 && I2C + select REGMAP_I2C
I think this should only be "select REGMAP", since you are not using the REGMAP I2C support but instead have your own regmap write callback (due the need to I2C_M_IGNORE_NAK).
Signature · 5 lines
Best regards, Javier Martinez Canillas Core Platforms Red Hat
Marcus Folkesson
maintainerPATCH RESEND v2 6/6 drm/sitronix/st7571-spi: add support for SPI interface
In reply to Marcus FolkessonAdd support for ST7561/ST7571 connected to SPI bus.
--- MAINTAINERS | 1 + drivers/gpu/drm/sitronix/Kconfig | 12 ++++++ drivers/gpu/drm/sitronix/Makefile | 1 + drivers/gpu/drm/sitronix/st7571-spi.c | 76 +++++++++++++++++++++++++++++++++++ 4 files changed, 90 insertions(+)
MAINTAINERS +1 -0
@@ -8083,6 +8083,7 @@ S: Maintained F: Documentation/devicetree/bindings/display/sitronix,st7567.yaml F: Documentation/devicetree/bindings/display/sitronix,st7571.yaml F: drivers/gpu/drm/sitronix/st7571-i2c.c +F: drivers/gpu/drm/sitronix/st7571-spi.c F: drivers/gpu/drm/sitronix/st7571.c F: drivers/gpu/drm/sitronix/st7571.h
drivers/gpu/drm/sitronix/Kconfig +12 -0
@@ -27,6 +27,18 @@ config DRM_ST7571_I2C if M is selected the module will be called st7571-i2c. +config DRM_ST7571_SPI + tristate "DRM support for Sitronix ST7567/ST7571 display panels (SPI)" + depends on DRM_ST7571 && SPI + select REGMAP_SPI + help + Sitronix ST7571 is a driver and controller for 4-level gray + scale and monochrome dot matrix LCD panels. + + DRM driver for Sitronix ST7565/ST7571 panels connected via SPI bus. + + if M is selected the module will be called st7571-spi. + config DRM_ST7586 tristate "DRM support for Sitronix ST7586 display panels" depends on DRM && SPI
drivers/gpu/drm/sitronix/Makefile +1 -0
@@ -1,4 +1,5 @@ obj-$(CONFIG_DRM_ST7571) += st7571.o obj-$(CONFIG_DRM_ST7571_I2C) += st7571-i2c.o +obj-$(CONFIG_DRM_ST7571_SPI) += st7571-spi.o obj-$(CONFIG_DRM_ST7586) += st7586.o obj-$(CONFIG_DRM_ST7735R) += st7735r.o
drivers/gpu/drm/sitronix/st7571-spi.c new file +76 -0
76 lines not on this page · raw message
Signature · 1 line
2.51.2
Re: [PATCH RESEND v2 6/6] drm/sitronix/st7571-spi: add support for SPI interface
Quoted 15 lines · Marcus Folkesson
Add support for ST7561/ST7571 connected to SPI bus.
Signed-off-by Marcus Folkesson <[email protected]>--- MAINTAINERS | 1 + drivers/gpu/drm/sitronix/Kconfig | 12 ++++++ drivers/gpu/drm/sitronix/Makefile | 1 + drivers/gpu/drm/sitronix/st7571-spi.c | 76 +++++++++++++++++++++++++++++++++++ 4 files changed, 90 insertions(+)MAINTAINERS +0
-0
MAINTAINERS S: Maintained · line 8084
Quoted 2 lines
MAINTAINERS +0
-0@@ -8083,6 +8083,7 @@ S: Maintained F: Documentation/devicetree/bindings/display/sitronix,st7567.yaml F: Documentation/devicetree/bindings/display/sitronix,st7571.yaml
I would add SPI examples to the DT binding docs.
Signature · 5 lines
Best regards, Javier Martinez Canillas Core Platforms Red Hat