Merge tag 'clk-fixes-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git...
[linux.git] / drivers / gpu / drm / solomon / ssd130x-i2c.c
blob941a2eb44c57eba72040658f939aaed9a266fec9
1 // SPDX-License-Identifier: GPL-2.0-only
2 /*
3 * DRM driver for Solomon SSD13xx OLED displays (I2C bus)
5 * Copyright 2022 Red Hat Inc.
6 * Author: Javier Martinez Canillas <javierm@redhat.com>
8 * Based on drivers/video/fbdev/ssd1307fb.c
9 * Copyright 2012 Free Electrons
11 #include <linux/i2c.h>
12 #include <linux/module.h>
14 #include "ssd130x.h"
16 #define DRIVER_NAME "ssd130x-i2c"
17 #define DRIVER_DESC "DRM driver for Solomon SSD13xx OLED displays (I2C)"
19 static const struct regmap_config ssd130x_i2c_regmap_config = {
20 .reg_bits = 8,
21 .val_bits = 8,
24 static int ssd130x_i2c_probe(struct i2c_client *client)
26 struct ssd130x_device *ssd130x;
27 struct regmap *regmap;
29 regmap = devm_regmap_init_i2c(client, &ssd130x_i2c_regmap_config);
30 if (IS_ERR(regmap))
31 return PTR_ERR(regmap);
33 ssd130x = ssd130x_probe(&client->dev, regmap);
34 if (IS_ERR(ssd130x))
35 return PTR_ERR(ssd130x);
37 i2c_set_clientdata(client, ssd130x);
39 return 0;
42 static void ssd130x_i2c_remove(struct i2c_client *client)
44 struct ssd130x_device *ssd130x = i2c_get_clientdata(client);
46 ssd130x_remove(ssd130x);
49 static void ssd130x_i2c_shutdown(struct i2c_client *client)
51 struct ssd130x_device *ssd130x = i2c_get_clientdata(client);
53 ssd130x_shutdown(ssd130x);
56 static const struct of_device_id ssd130x_of_match[] = {
57 /* ssd130x family */
59 .compatible = "sinowealth,sh1106",
60 .data = &ssd130x_variants[SH1106_ID],
63 .compatible = "solomon,ssd1305",
64 .data = &ssd130x_variants[SSD1305_ID],
67 .compatible = "solomon,ssd1306",
68 .data = &ssd130x_variants[SSD1306_ID],
71 .compatible = "solomon,ssd1307",
72 .data = &ssd130x_variants[SSD1307_ID],
75 .compatible = "solomon,ssd1309",
76 .data = &ssd130x_variants[SSD1309_ID],
78 /* Deprecated but kept for backward compatibility */
80 .compatible = "solomon,ssd1305fb-i2c",
81 .data = &ssd130x_variants[SSD1305_ID],
84 .compatible = "solomon,ssd1306fb-i2c",
85 .data = &ssd130x_variants[SSD1306_ID],
88 .compatible = "solomon,ssd1307fb-i2c",
89 .data = &ssd130x_variants[SSD1307_ID],
92 .compatible = "solomon,ssd1309fb-i2c",
93 .data = &ssd130x_variants[SSD1309_ID],
95 /* ssd132x family */
97 .compatible = "solomon,ssd1322",
98 .data = &ssd130x_variants[SSD1322_ID],
101 .compatible = "solomon,ssd1325",
102 .data = &ssd130x_variants[SSD1325_ID],
105 .compatible = "solomon,ssd1327",
106 .data = &ssd130x_variants[SSD1327_ID],
108 { /* sentinel */ }
110 MODULE_DEVICE_TABLE(of, ssd130x_of_match);
112 static struct i2c_driver ssd130x_i2c_driver = {
113 .driver = {
114 .name = DRIVER_NAME,
115 .of_match_table = ssd130x_of_match,
117 .probe = ssd130x_i2c_probe,
118 .remove = ssd130x_i2c_remove,
119 .shutdown = ssd130x_i2c_shutdown,
121 module_i2c_driver(ssd130x_i2c_driver);
123 MODULE_DESCRIPTION(DRIVER_DESC);
124 MODULE_AUTHOR("Javier Martinez Canillas <javierm@redhat.com>");
125 MODULE_LICENSE("GPL v2");
126 MODULE_IMPORT_NS("DRM_SSD130X");