drivers/rtc/rtc-max6900.c
Source file repositories/reference/linux-study-clean/drivers/rtc/rtc-max6900.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/rtc/rtc-max6900.c- Extension
.c- Size
- 6125 bytes
- Lines
- 236
- 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.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/module.hlinux/i2c.hlinux/bcd.hlinux/rtc.hlinux/delay.h
Detected Declarations
function max6900_i2c_read_regsfunction max6900_i2c_write_regsfunction max6900_rtc_read_timefunction max6900_i2c_clear_write_protectfunction max6900_rtc_set_timefunction max6900_probe
Annotated Snippet
// SPDX-License-Identifier: GPL-2.0-only
/*
* rtc class driver for the Maxim MAX6900 chip
*
* Copyright (c) 2007 MontaVista, Software, Inc.
*
* Author: Dale Farnsworth <dale@farnsworth.org>
*
* based on previously existing rtc class drivers
*/
#include <linux/module.h>
#include <linux/i2c.h>
#include <linux/bcd.h>
#include <linux/rtc.h>
#include <linux/delay.h>
/*
* register indices
*/
#define MAX6900_REG_SC 0 /* seconds 00-59 */
#define MAX6900_REG_MN 1 /* minutes 00-59 */
#define MAX6900_REG_HR 2 /* hours 00-23 */
#define MAX6900_REG_DT 3 /* day of month 00-31 */
#define MAX6900_REG_MO 4 /* month 01-12 */
#define MAX6900_REG_DW 5 /* day of week 1-7 */
#define MAX6900_REG_YR 6 /* year 00-99 */
#define MAX6900_REG_CT 7 /* control */
/* register 8 is undocumented */
#define MAX6900_REG_CENTURY 9 /* century */
#define MAX6900_REG_LEN 10
#define MAX6900_BURST_LEN 8 /* can burst r/w first 8 regs */
#define MAX6900_REG_CT_WP (1 << 7) /* Write Protect */
/*
* register read/write commands
*/
#define MAX6900_REG_CONTROL_WRITE 0x8e
#define MAX6900_REG_CENTURY_WRITE 0x92
#define MAX6900_REG_CENTURY_READ 0x93
#define MAX6900_REG_RESERVED_READ 0x96
#define MAX6900_REG_BURST_WRITE 0xbe
#define MAX6900_REG_BURST_READ 0xbf
#define MAX6900_IDLE_TIME_AFTER_WRITE 3 /* specification says 2.5 mS */
static struct i2c_driver max6900_driver;
static int max6900_i2c_read_regs(struct i2c_client *client, u8 *buf)
{
u8 reg_burst_read[1] = { MAX6900_REG_BURST_READ };
u8 reg_century_read[1] = { MAX6900_REG_CENTURY_READ };
struct i2c_msg msgs[4] = {
{
.addr = client->addr,
.flags = 0, /* write */
.len = sizeof(reg_burst_read),
.buf = reg_burst_read}
,
{
.addr = client->addr,
.flags = I2C_M_RD,
.len = MAX6900_BURST_LEN,
.buf = buf}
,
{
.addr = client->addr,
.flags = 0, /* write */
.len = sizeof(reg_century_read),
.buf = reg_century_read}
,
{
.addr = client->addr,
.flags = I2C_M_RD,
.len = sizeof(buf[MAX6900_REG_CENTURY]),
.buf = &buf[MAX6900_REG_CENTURY]
}
};
int rc;
rc = i2c_transfer(client->adapter, msgs, ARRAY_SIZE(msgs));
if (rc != ARRAY_SIZE(msgs)) {
dev_err(&client->dev, "%s: register read failed\n", __func__);
return -EIO;
}
return 0;
}
Annotation
- Immediate include surface: `linux/module.h`, `linux/i2c.h`, `linux/bcd.h`, `linux/rtc.h`, `linux/delay.h`.
- Detected declarations: `function max6900_i2c_read_regs`, `function max6900_i2c_write_regs`, `function max6900_rtc_read_time`, `function max6900_i2c_clear_write_protect`, `function max6900_rtc_set_time`, `function max6900_probe`.
- Atlas domain: Driver Families / drivers/rtc.
- 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.