cachepc-linux

Fork of AMDESE/linux with modifications for CachePC side-channel attack
git clone https://git.sinitax.com/sinitax/cachepc-linux
Log | Files | Refs | README | LICENSE | sfeed.txt

ssd130x-i2c.c (2630B)


      1// SPDX-License-Identifier: GPL-2.0-only
      2/*
      3 * DRM driver for Solomon SSD130x OLED displays (I2C bus)
      4 *
      5 * Copyright 2022 Red Hat Inc.
      6 * Author: Javier Martinez Canillas <javierm@redhat.com>
      7 *
      8 * Based on drivers/video/fbdev/ssd1307fb.c
      9 * Copyright 2012 Free Electrons
     10 */
     11#include <linux/i2c.h>
     12#include <linux/module.h>
     13
     14#include "ssd130x.h"
     15
     16#define DRIVER_NAME	"ssd130x-i2c"
     17#define DRIVER_DESC	"DRM driver for Solomon SSD130x OLED displays (I2C)"
     18
     19static const struct regmap_config ssd130x_i2c_regmap_config = {
     20	.reg_bits = 8,
     21	.val_bits = 8,
     22};
     23
     24static int ssd130x_i2c_probe(struct i2c_client *client)
     25{
     26	struct ssd130x_device *ssd130x;
     27	struct regmap *regmap;
     28
     29	regmap = devm_regmap_init_i2c(client, &ssd130x_i2c_regmap_config);
     30	if (IS_ERR(regmap))
     31		return PTR_ERR(regmap);
     32
     33	ssd130x = ssd130x_probe(&client->dev, regmap);
     34	if (IS_ERR(ssd130x))
     35		return PTR_ERR(ssd130x);
     36
     37	i2c_set_clientdata(client, ssd130x);
     38
     39	return 0;
     40}
     41
     42static int ssd130x_i2c_remove(struct i2c_client *client)
     43{
     44	struct ssd130x_device *ssd130x = i2c_get_clientdata(client);
     45
     46	ssd130x_remove(ssd130x);
     47
     48	return 0;
     49}
     50
     51static void ssd130x_i2c_shutdown(struct i2c_client *client)
     52{
     53	struct ssd130x_device *ssd130x = i2c_get_clientdata(client);
     54
     55	ssd130x_shutdown(ssd130x);
     56}
     57
     58static const struct of_device_id ssd130x_of_match[] = {
     59	{
     60		.compatible = "sinowealth,sh1106",
     61		.data = &ssd130x_variants[SH1106_ID],
     62	},
     63	{
     64		.compatible = "solomon,ssd1305",
     65		.data = &ssd130x_variants[SSD1305_ID],
     66	},
     67	{
     68		.compatible = "solomon,ssd1306",
     69		.data = &ssd130x_variants[SSD1306_ID],
     70	},
     71	{
     72		.compatible = "solomon,ssd1307",
     73		.data = &ssd130x_variants[SSD1307_ID],
     74	},
     75	{
     76		.compatible = "solomon,ssd1309",
     77		.data = &ssd130x_variants[SSD1309_ID],
     78	},
     79	/* Deprecated but kept for backward compatibility */
     80	{
     81		.compatible = "solomon,ssd1305fb-i2c",
     82		.data = &ssd130x_variants[SSD1305_ID],
     83	},
     84	{
     85		.compatible = "solomon,ssd1306fb-i2c",
     86		.data = &ssd130x_variants[SSD1306_ID],
     87	},
     88	{
     89		.compatible = "solomon,ssd1307fb-i2c",
     90		.data = &ssd130x_variants[SSD1307_ID],
     91	},
     92	{
     93		.compatible = "solomon,ssd1309fb-i2c",
     94		.data = &ssd130x_variants[SSD1309_ID],
     95	},
     96	{ /* sentinel */ }
     97};
     98MODULE_DEVICE_TABLE(of, ssd130x_of_match);
     99
    100static struct i2c_driver ssd130x_i2c_driver = {
    101	.driver = {
    102		.name = DRIVER_NAME,
    103		.of_match_table = ssd130x_of_match,
    104	},
    105	.probe_new = ssd130x_i2c_probe,
    106	.remove = ssd130x_i2c_remove,
    107	.shutdown = ssd130x_i2c_shutdown,
    108};
    109module_i2c_driver(ssd130x_i2c_driver);
    110
    111MODULE_DESCRIPTION(DRIVER_DESC);
    112MODULE_AUTHOR("Javier Martinez Canillas <javierm@redhat.com>");
    113MODULE_LICENSE("GPL v2");
    114MODULE_IMPORT_NS(DRM_SSD130X);