drivers/fsi/fsi-master-gpio.c
Source file repositories/reference/linux-study-clean/drivers/fsi/fsi-master-gpio.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/fsi/fsi-master-gpio.c- Extension
.c- Size
- 21457 bytes
- Lines
- 897
- Domain
- Driver Families
- Bucket
- drivers/fsi
- 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.
- Uses kernel synchronization; read lock ordering, sleepability, and interrupt context assumptions before translating.
- 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/crc4.hlinux/delay.hlinux/device.hlinux/fsi.hlinux/gpio/consumer.hlinux/io.hlinux/irqflags.hlinux/module.hlinux/of.hlinux/platform_device.hlinux/slab.hfsi-master.htrace/events/fsi_master_gpio.h
Detected Declarations
struct fsi_master_gpiostruct fsi_gpio_msgfunction clock_togglefunction sda_clock_infunction sda_outfunction set_sda_inputfunction set_sda_outputfunction clock_zerosfunction echo_delayfunction serial_infunction serial_outfunction msg_push_bitsfunction msg_push_crcfunction check_same_addressfunction check_relative_addressfunction last_address_updatefunction build_ar_commandfunction build_dpoll_commandfunction build_epoll_commandfunction build_term_commandfunction read_one_responsefunction issue_termfunction poll_for_responsefunction send_requestfunction fsi_master_gpio_xferfunction fsi_master_gpio_readfunction fsi_master_gpio_writefunction fsi_master_gpio_termfunction fsi_master_gpio_breakfunction fsi_master_gpio_initfunction fsi_master_gpio_init_externalfunction fsi_master_gpio_link_enablefunction fsi_master_gpio_link_configfunction external_mode_showfunction external_mode_storefunction fsi_master_gpio_releasefunction fsi_master_gpio_probefunction fsi_master_gpio_remove
Annotated Snippet
struct fsi_master_gpio {
struct fsi_master master;
struct device *dev;
struct mutex cmd_lock; /* mutex for command ordering */
struct gpio_desc *gpio_clk;
struct gpio_desc *gpio_data;
struct gpio_desc *gpio_trans; /* Voltage translator */
struct gpio_desc *gpio_enable; /* FSI enable */
struct gpio_desc *gpio_mux; /* Mux control */
bool external_mode;
bool no_delays;
uint32_t last_addr;
uint8_t t_send_delay;
uint8_t t_echo_delay;
};
#define CREATE_TRACE_POINTS
#include <trace/events/fsi_master_gpio.h>
#define to_fsi_master_gpio(m) container_of(m, struct fsi_master_gpio, master)
struct fsi_gpio_msg {
uint64_t msg;
uint8_t bits;
};
static void clock_toggle(struct fsi_master_gpio *master, int count)
{
int i;
for (i = 0; i < count; i++) {
if (!master->no_delays)
ndelay(FSI_GPIO_STD_DLY);
gpiod_set_value(master->gpio_clk, 0);
if (!master->no_delays)
ndelay(FSI_GPIO_STD_DLY);
gpiod_set_value(master->gpio_clk, 1);
}
}
static int sda_clock_in(struct fsi_master_gpio *master)
{
int in;
if (!master->no_delays)
ndelay(FSI_GPIO_STD_DLY);
gpiod_set_value(master->gpio_clk, 0);
/* Dummy read to feed the synchronizers */
gpiod_get_value(master->gpio_data);
/* Actual data read */
in = gpiod_get_value(master->gpio_data);
if (!master->no_delays)
ndelay(FSI_GPIO_STD_DLY);
gpiod_set_value(master->gpio_clk, 1);
return in ? 1 : 0;
}
static void sda_out(struct fsi_master_gpio *master, int value)
{
gpiod_set_value(master->gpio_data, value);
}
static void set_sda_input(struct fsi_master_gpio *master)
{
gpiod_direction_input(master->gpio_data);
gpiod_set_value(master->gpio_trans, 0);
}
static void set_sda_output(struct fsi_master_gpio *master, int value)
{
gpiod_set_value(master->gpio_trans, 1);
gpiod_direction_output(master->gpio_data, value);
}
static void clock_zeros(struct fsi_master_gpio *master, int count)
{
trace_fsi_master_gpio_clock_zeros(master, count);
set_sda_output(master, 1);
clock_toggle(master, count);
}
static void echo_delay(struct fsi_master_gpio *master)
{
clock_zeros(master, master->t_echo_delay);
}
static void serial_in(struct fsi_master_gpio *master, struct fsi_gpio_msg *msg,
Annotation
- Immediate include surface: `linux/crc4.h`, `linux/delay.h`, `linux/device.h`, `linux/fsi.h`, `linux/gpio/consumer.h`, `linux/io.h`, `linux/irqflags.h`, `linux/module.h`.
- Detected declarations: `struct fsi_master_gpio`, `struct fsi_gpio_msg`, `function clock_toggle`, `function sda_clock_in`, `function sda_out`, `function set_sda_input`, `function set_sda_output`, `function clock_zeros`, `function echo_delay`, `function serial_in`.
- Atlas domain: Driver Families / drivers/fsi.
- Implementation status: source implementation candidate.
- Synchronization appears in or near this file; preserve lock ordering, sleepability, and interrupt-context constraints.
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.