// SPDX-License-Identifier: GPL-2.0-only /* * DRM driver for Solomon SSD13xx OLED displays (SPI bus) * * Copyright 2022 Red Hat Inc. * Authors: Javier Martinez Canillas <[email protected]> */ #include <linux/spi/spi.h> #include <linux/module.h> #include "ssd130x.h" #define DRIVER_NAME … #define DRIVER_DESC … struct ssd130x_spi_transport { … }; /* * The regmap bus .write handler, it is just a wrapper around spi_write() * but toggling the Data/Command control pin (D/C#). Since for 4-wire SPI * a D/C# pin is used, in contrast with I2C where a control byte is sent, * prior to every data byte, that contains a bit with the D/C# value. * * These control bytes are considered registers by the ssd130x core driver * and can be used by the ssd130x SPI driver to determine if the data sent * is for a command register or for the Graphic Display Data RAM (GDDRAM). */ static int ssd130x_spi_write(void *context, const void *data, size_t count) { … } /* The ssd130x driver does not read registers but regmap expects a .read */ static int ssd130x_spi_read(void *context, const void *reg, size_t reg_size, void *val, size_t val_size) { … } static const struct regmap_config ssd130x_spi_regmap_config = …; static int ssd130x_spi_probe(struct spi_device *spi) { … } static void ssd130x_spi_remove(struct spi_device *spi) { … } static void ssd130x_spi_shutdown(struct spi_device *spi) { … } static const struct of_device_id ssd130x_of_match[] = …; MODULE_DEVICE_TABLE(of, ssd130x_of_match); #if IS_MODULE(CONFIG_DRM_SSD130X_SPI) /* * The SPI core always reports a MODALIAS uevent of the form "spi:<dev>", even * if the device was registered via OF. This means that the module will not be * auto loaded, unless it contains an alias that matches the MODALIAS reported. * * To workaround this issue, add a SPI device ID table. Even when this should * not be needed for this driver to match the registered SPI devices. */ static const struct spi_device_id ssd130x_spi_table[] = { /* ssd130x family */ { "sh1106", SH1106_ID }, { "ssd1305", SSD1305_ID }, { "ssd1306", SSD1306_ID }, { "ssd1307", SSD1307_ID }, { "ssd1309", SSD1309_ID }, /* ssd132x family */ { "ssd1322", SSD1322_ID }, { "ssd1325", SSD1325_ID }, { "ssd1327", SSD1327_ID }, /* ssd133x family */ { "ssd1331", SSD1331_ID }, { /* sentinel */ } }; MODULE_DEVICE_TABLE(spi, ssd130x_spi_table); #endif static struct spi_driver ssd130x_spi_driver = …; module_spi_driver(…) …; MODULE_DESCRIPTION(…); MODULE_AUTHOR(…) …; MODULE_LICENSE(…) …; MODULE_IMPORT_NS(…);