drivers/rtc/rtc-max31335.c
Source file repositories/reference/linux-study-clean/drivers/rtc/rtc-max31335.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/rtc/rtc-max31335.c- Extension
.c- Size
- 21079 bytes
- Lines
- 777
- Domain
- Driver Families
- Bucket
- drivers/rtc
- 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.
- Touches IRQ or DMA behavior; this matters for the representative real-device path.
- 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/unaligned.hlinux/bcd.hlinux/bitfield.hlinux/bitops.hlinux/clk.hlinux/clk-provider.hlinux/hwmon.hlinux/i2c.hlinux/interrupt.hlinux/kernel.hlinux/module.hlinux/of_device.hlinux/regmap.hlinux/rtc.hlinux/util_macros.h
Detected Declarations
struct chip_descstruct max31335_dataenum max_rtc_idsfunction max31335_volatile_regfunction max31335_read_timefunction max31335_set_timefunction max31335_read_alarmfunction max31335_set_alarmfunction max31335_alarm_irq_enablefunction max31335_handle_irqfunction max31335_trickle_charger_setupfunction max31335_clkout_recalc_ratefunction max31335_clkout_determine_ratefunction max31335_clkout_set_ratefunction max31335_clkout_enablefunction max31335_clkout_disablefunction max31335_clkout_is_enabledfunction max31335_nvmem_reg_readfunction max31335_nvmem_reg_writefunction max31335_read_tempfunction max31335_is_visiblefunction max31335_clkout_registerfunction max31335_probe
Annotated Snippet
struct chip_desc {
u8 sec_reg;
u8 alarm1_sec_reg;
u8 int_en_reg;
u8 int_status_reg;
u8 ram_reg;
u8 ram_size;
u8 temp_reg;
u8 trickle_reg;
u8 clkout_reg;
enum max_rtc_ids id;
};
struct max31335_data {
struct regmap *regmap;
struct rtc_device *rtc;
struct clk_hw clkout;
struct clk *clkin;
const struct chip_desc *chip;
int irq;
};
static const int max31335_clkout_freq[] = { 1, 64, 1024, 32768 };
static const struct chip_desc chip[MAX_RTC_ID_NR] = {
[ID_MAX31331] = {
.id = ID_MAX31331,
.int_en_reg = 0x01,
.int_status_reg = 0x00,
.sec_reg = 0x08,
.alarm1_sec_reg = 0x0F,
.ram_reg = 0x20,
.ram_size = 32,
.trickle_reg = 0x1B,
.clkout_reg = 0x04,
},
[ID_MAX31335] = {
.id = ID_MAX31335,
.int_en_reg = 0x01,
.int_status_reg = 0x00,
.sec_reg = 0x0A,
.alarm1_sec_reg = 0x11,
.ram_reg = 0x40,
.ram_size = 32,
.temp_reg = 0x35,
.trickle_reg = 0x1D,
.clkout_reg = 0x06,
},
};
static const u16 max31335_trickle_resistors[] = {3000, 6000, 11000};
static bool max31335_volatile_reg(struct device *dev, unsigned int reg)
{
struct max31335_data *max31335 = dev_get_drvdata(dev);
const struct chip_desc *chip = max31335->chip;
/* time keeping registers */
if (reg >= chip->sec_reg && reg < chip->sec_reg + MAX31335_TIME_SIZE)
return true;
/* interrupt status register */
if (reg == chip->int_status_reg)
return true;
/* temperature registers if valid */
if (chip->temp_reg && (reg == chip->temp_reg || reg == chip->temp_reg + 1))
return true;
return false;
}
static const struct regmap_config regmap_config = {
.reg_bits = 8,
.val_bits = 8,
.max_register = 0x5F,
.volatile_reg = max31335_volatile_reg,
};
static int max31335_read_time(struct device *dev, struct rtc_time *tm)
{
struct max31335_data *max31335 = dev_get_drvdata(dev);
u8 date[7];
int ret;
Annotation
- Immediate include surface: `linux/unaligned.h`, `linux/bcd.h`, `linux/bitfield.h`, `linux/bitops.h`, `linux/clk.h`, `linux/clk-provider.h`, `linux/hwmon.h`, `linux/i2c.h`.
- Detected declarations: `struct chip_desc`, `struct max31335_data`, `enum max_rtc_ids`, `function max31335_volatile_reg`, `function max31335_read_time`, `function max31335_set_time`, `function max31335_read_alarm`, `function max31335_set_alarm`, `function max31335_alarm_irq_enable`, `function max31335_handle_irq`.
- Atlas domain: Driver Families / drivers/rtc.
- Implementation status: source implementation candidate.
- Synchronization appears in or near this file; preserve lock ordering, sleepability, and interrupt-context constraints.
- IRQ or DMA behavior appears here, which is relevant to the selected PCIe/NVMe device path.
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.