/* * 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).
*/ staticint ssd130x_spi_write(void *context, constvoid *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 */ staticint ssd130x_spi_read(void *context, constvoid *reg, size_t reg_size, void *val, size_t val_size)
{ return -EOPNOTSUPP;
}
/* * 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.
*/ staticconststruct spi_device_id ssd130x_spi_id[] = { /* 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_id);
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.