drivers/video/fbdev/savage/savagefb-i2c.c
Source file repositories/reference/linux-study-clean/drivers/video/fbdev/savage/savagefb-i2c.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/video/fbdev/savage/savagefb-i2c.c- Extension
.c- Size
- 5691 bytes
- Lines
- 242
- Domain
- Driver Families
- Bucket
- drivers/video
- 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.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/module.hlinux/kernel.hlinux/delay.hlinux/gfp.hlinux/pci.hlinux/fb.hasm/io.hsavagefb.h
Detected Declarations
function savage4_gpio_setsclfunction savage4_gpio_setsdafunction savage4_gpio_getsclfunction savage4_gpio_getsdafunction prosavage_gpio_setsclfunction prosavage_gpio_setsdafunction prosavage_gpio_getsclfunction prosavage_gpio_getsdafunction savage_setup_i2c_busfunction savagefb_create_i2c_bussesfunction savagefb_delete_i2c_bussesfunction savagefb_probe_i2c_connector
Annotated Snippet
#include <linux/module.h>
#include <linux/kernel.h>
#include <linux/delay.h>
#include <linux/gfp.h>
#include <linux/pci.h>
#include <linux/fb.h>
#include <asm/io.h>
#include "savagefb.h"
#define SAVAGE_DDC 0x50
#define VGA_CR_IX 0x3d4
#define VGA_CR_DATA 0x3d5
#define CR_SERIAL1 0xa0 /* I2C serial communications interface */
#define MM_SERIAL1 0xff20
#define CR_SERIAL2 0xb1 /* DDC2 monitor communications interface */
/* based on vt8365 documentation */
#define PROSAVAGE_I2C_ENAB 0x10
#define PROSAVAGE_I2C_SCL_OUT 0x01
#define PROSAVAGE_I2C_SDA_OUT 0x02
#define PROSAVAGE_I2C_SCL_IN 0x04
#define PROSAVAGE_I2C_SDA_IN 0x08
#define SAVAGE4_I2C_ENAB 0x00000020
#define SAVAGE4_I2C_SCL_OUT 0x00000001
#define SAVAGE4_I2C_SDA_OUT 0x00000002
#define SAVAGE4_I2C_SCL_IN 0x00000008
#define SAVAGE4_I2C_SDA_IN 0x00000010
static void savage4_gpio_setscl(void *data, int val)
{
struct savagefb_i2c_chan *chan = data;
unsigned int r;
r = readl(chan->ioaddr + chan->reg);
if(val)
r |= SAVAGE4_I2C_SCL_OUT;
else
r &= ~SAVAGE4_I2C_SCL_OUT;
writel(r, chan->ioaddr + chan->reg);
readl(chan->ioaddr + chan->reg); /* flush posted write */
}
static void savage4_gpio_setsda(void *data, int val)
{
struct savagefb_i2c_chan *chan = data;
unsigned int r;
r = readl(chan->ioaddr + chan->reg);
if(val)
r |= SAVAGE4_I2C_SDA_OUT;
else
r &= ~SAVAGE4_I2C_SDA_OUT;
writel(r, chan->ioaddr + chan->reg);
readl(chan->ioaddr + chan->reg); /* flush posted write */
}
static int savage4_gpio_getscl(void *data)
{
struct savagefb_i2c_chan *chan = data;
return (0 != (readl(chan->ioaddr + chan->reg) & SAVAGE4_I2C_SCL_IN));
}
static int savage4_gpio_getsda(void *data)
{
struct savagefb_i2c_chan *chan = data;
return (0 != (readl(chan->ioaddr + chan->reg) & SAVAGE4_I2C_SDA_IN));
}
static void prosavage_gpio_setscl(void* data, int val)
{
struct savagefb_i2c_chan *chan = data;
u32 r;
r = VGArCR(chan->reg, chan->par);
r |= PROSAVAGE_I2C_ENAB;
if (val) {
r |= PROSAVAGE_I2C_SCL_OUT;
} else {
r &= ~PROSAVAGE_I2C_SCL_OUT;
}
VGAwCR(chan->reg, r, chan->par);
}
Annotation
- Immediate include surface: `linux/module.h`, `linux/kernel.h`, `linux/delay.h`, `linux/gfp.h`, `linux/pci.h`, `linux/fb.h`, `asm/io.h`, `savagefb.h`.
- Detected declarations: `function savage4_gpio_setscl`, `function savage4_gpio_setsda`, `function savage4_gpio_getscl`, `function savage4_gpio_getsda`, `function prosavage_gpio_setscl`, `function prosavage_gpio_setsda`, `function prosavage_gpio_getscl`, `function prosavage_gpio_getsda`, `function savage_setup_i2c_bus`, `function savagefb_create_i2c_busses`.
- Atlas domain: Driver Families / drivers/video.
- 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.