drivers/gpu/drm/sitronix/st7571-i2c.c
Source file repositories/reference/linux-study-clean/drivers/gpu/drm/sitronix/st7571-i2c.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/gpu/drm/sitronix/st7571-i2c.c- Extension
.c- Size
- 4558 bytes
- Lines
- 159
- 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/i2c.hlinux/module.hlinux/regmap.hst7571.h
Detected Declarations
struct st7571_i2c_transportfunction st7571_i2c_regmap_writefunction st7571_i2c_regmap_readfunction st7571_i2c_probefunction st7571_i2c_remove
Annotated Snippet
struct st7571_i2c_transport {
struct i2c_client *client;
/*
* Depending on the hardware design, the acknowledge signal may be hard to
* recognize as a valid logic "0" level.
* Therefor, ignore NAK if possible to stay compatible with most hardware designs
* and off-the-shelf panels out there.
*
* From section 6.4 MICROPOCESSOR INTERFACE section in the datasheet:
*
* "By connecting SDA_OUT to SDA_IN externally, the SDA line becomes fully
* I2C interface compatible.
* Separating acknowledge-output from serial data
* input is advantageous for chip-on-glass (COG) applications. In COG
* applications, the ITO resistance and the pull-up resistor will form a
* voltage divider, which affects acknowledge-signal level. Larger ITO
* resistance will raise the acknowledged-signal level and system cannot
* recognize this level as a valid logic “0” level. By separating SDA_IN from
* SDA_OUT, the IC can be used in a mode that ignores the acknowledge-bit.
* For applications which check acknowledge-bit, it is necessary to minimize
* the ITO resistance of the SDA_OUT trace to guarantee a valid low level."
*
*/
bool ignore_nak;
};
static int st7571_i2c_regmap_write(void *context, const void *data, size_t count)
{
struct st7571_i2c_transport *t = context;
int ret;
struct i2c_msg msg = {
.addr = t->client->addr,
.flags = t->ignore_nak ? I2C_M_IGNORE_NAK : 0,
.len = count,
.buf = (u8 *)data
};
ret = i2c_transfer(t->client->adapter, &msg, 1);
/*
* Unfortunately, there is no way to check if the transfer failed because of
* a NAK or something else as I2C bus drivers use different return values for NAK.
*
* However, if the transfer fails and ignore_nak is set, we know it is an error.
*/
if (ret < 0 && t->ignore_nak)
return ret;
return 0;
}
/* The st7571 driver does not read registers but regmap expects a .read */
static int st7571_i2c_regmap_read(void *context, const void *reg_buf,
size_t reg_size, void *val_buf, size_t val_size)
{
return -EOPNOTSUPP;
}
static const struct regmap_bus st7571_i2c_regmap_bus = {
.read = st7571_i2c_regmap_read,
.write = st7571_i2c_regmap_write,
};
static const struct regmap_config st7571_i2c_regmap_config = {
.reg_bits = 8,
.val_bits = 8,
.use_single_write = true,
};
static int st7571_i2c_probe(struct i2c_client *client)
{
struct st7571_device *st7571;
struct st7571_i2c_transport *t;
struct regmap *regmap;
t = devm_kzalloc(&client->dev, sizeof(*t), GFP_KERNEL);
if (!t)
return -ENOMEM;
t->client = client;
/*
* The hardware design could make it hard to detect a NAK on the I2C bus.
* If the adapter does not support protocol mangling do
* not set the I2C_M_IGNORE_NAK flag at the expense * of possible
* cruft in the logs.
*/
if (i2c_check_functionality(client->adapter, I2C_FUNC_PROTOCOL_MANGLING))
Annotation
- Immediate include surface: `linux/i2c.h`, `linux/module.h`, `linux/regmap.h`, `st7571.h`.
- Detected declarations: `struct st7571_i2c_transport`, `function st7571_i2c_regmap_write`, `function st7571_i2c_regmap_read`, `function st7571_i2c_probe`, `function st7571_i2c_remove`.
- 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.