drivers/gpu/drm/solomon/ssd130x-spi.c
Source file repositories/reference/linux-study-clean/drivers/gpu/drm/solomon/ssd130x-spi.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/gpu/drm/solomon/ssd130x-spi.c- Extension
.c- Size
- 5034 bytes
- Lines
- 194
- Domain
- Driver Families
- Bucket
- drivers/gpu
- Inferred role
- Driver Families: implementation source
- Status
- source implementation candidate
Why This File Exists
Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.
- Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.
- Allocates kernel memory; connect allocation flags and lifetime to context constraints.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/spi/spi.hlinux/module.hssd130x.h
Detected Declarations
struct ssd130x_spi_transportfunction RAMfunction ssd130x_spi_readfunction ssd130x_spi_probefunction ssd130x_spi_removefunction ssd130x_spi_shutdown
Annotated Snippet
struct ssd130x_spi_transport {
struct spi_device *spi;
struct gpio_desc *dc;
};
/*
* 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)
{
struct ssd130x_spi_transport *t = context;
struct spi_device *spi = t->spi;
const u8 *reg = data;
if (*reg == SSD13XX_COMMAND)
gpiod_set_value_cansleep(t->dc, 0);
if (*reg == SSD13XX_DATA)
gpiod_set_value_cansleep(t->dc, 1);
/* Remove control byte since is not used in a 4-wire SPI interface */
return spi_write(spi, reg + 1, count - 1);
}
/* 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)
{
return -EOPNOTSUPP;
}
static const struct regmap_config ssd130x_spi_regmap_config = {
.reg_bits = 8,
.val_bits = 8,
.write = ssd130x_spi_write,
.read = ssd130x_spi_read,
.can_multi_write = true,
};
static int ssd130x_spi_probe(struct spi_device *spi)
{
struct ssd130x_spi_transport *t;
struct ssd130x_device *ssd130x;
struct regmap *regmap;
struct gpio_desc *dc;
struct device *dev = &spi->dev;
dc = devm_gpiod_get(dev, "dc", GPIOD_OUT_LOW);
if (IS_ERR(dc))
return dev_err_probe(dev, PTR_ERR(dc),
"Failed to get dc gpio\n");
t = devm_kzalloc(dev, sizeof(*t), GFP_KERNEL);
if (!t)
return -ENOMEM;
t->spi = spi;
t->dc = dc;
regmap = devm_regmap_init(dev, NULL, t, &ssd130x_spi_regmap_config);
if (IS_ERR(regmap))
return PTR_ERR(regmap);
ssd130x = ssd130x_probe(dev, regmap);
if (IS_ERR(ssd130x))
return PTR_ERR(ssd130x);
spi_set_drvdata(spi, ssd130x);
return 0;
}
static void ssd130x_spi_remove(struct spi_device *spi)
{
struct ssd130x_device *ssd130x = spi_get_drvdata(spi);
ssd130x_remove(ssd130x);
}
static void ssd130x_spi_shutdown(struct spi_device *spi)
{
struct ssd130x_device *ssd130x = spi_get_drvdata(spi);
Annotation
- Immediate include surface: `linux/spi/spi.h`, `linux/module.h`, `ssd130x.h`.
- Detected declarations: `struct ssd130x_spi_transport`, `function RAM`, `function ssd130x_spi_read`, `function ssd130x_spi_probe`, `function ssd130x_spi_remove`, `function ssd130x_spi_shutdown`.
- Atlas domain: Driver Families / drivers/gpu.
- Implementation status: source implementation candidate.
Implementation Notes
- This generated page is the file-by-file coverage layer; curated subsystem chapters should link here when they synthesize a multi-file control flow.
- Core OS pages should be promoted from atlas-only to deep-reviewed when they explain data structures, invariants, locking, lifecycle, and C implementation snippets.
- Driver-family pages are intentionally pattern-oriented unless they are part of the selected PCIe/NVMe representative device path.