drivers/rtc/rtc-rs5c313.c
Source file repositories/reference/linux-study-clean/drivers/rtc/rtc-rs5c313.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/rtc/rtc-rs5c313.c- Extension
.c- Size
- 10402 bytes
- Lines
- 393
- 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/err.hlinux/rtc.hlinux/platform_device.hlinux/bcd.hlinux/delay.hlinux/io.h
Detected Declarations
function rs5c313_init_portfunction rs5c313_write_datafunction rs5c313_read_datafunction rs5c313_read_regfunction rs5c313_write_regfunction rs5c313_read_cntregfunction rs5c313_write_cntregfunction rs5c313_write_intintvregfunction rs5c313_rtc_read_timefunction rs5c313_rtc_set_timefunction rs5c313_check_xstp_bitfunction rs5c313_rtc_probe
Annotated Snippet
if (i == 0) {
scsptr1_data |= SDA_OEN; /* SDA:output enable */
__raw_writeb(scsptr1_data, SCSPTR1);
}
ndelay(700);
scsptr1_data &= ~SCL; /* SCL:L */
__raw_writeb(scsptr1_data, SCSPTR1);
ndelay(700);
scsptr1_data |= SCL; /* SCL:H */
__raw_writeb(scsptr1_data, SCSPTR1);
}
scsptr1_data &= ~SDA_OEN; /* SDA:output disable */
__raw_writeb(scsptr1_data, SCSPTR1);
}
static unsigned char rs5c313_read_data(void)
{
int i;
unsigned char data = 0;
for (i = 0; i < 8; i++) {
ndelay(700);
/* SDA:Read Data */
data |= ((__raw_readb(SCSPTR1) & SDA) >> 2) << (7 - i);
scsptr1_data &= ~SCL; /* SCL:L */
__raw_writeb(scsptr1_data, SCSPTR1);
ndelay(700);
scsptr1_data |= SCL; /* SCL:H */
__raw_writeb(scsptr1_data, SCSPTR1);
}
return data & 0x0F;
}
#endif /* CONFIG_SH_LANDISK */
/*****************************************************/
/* machine independence part of RS5C313 */
/*****************************************************/
/* RICOH RS5C313 address */
#define RS5C313_ADDR_SEC 0x00
#define RS5C313_ADDR_SEC10 0x01
#define RS5C313_ADDR_MIN 0x02
#define RS5C313_ADDR_MIN10 0x03
#define RS5C313_ADDR_HOUR 0x04
#define RS5C313_ADDR_HOUR10 0x05
#define RS5C313_ADDR_WEEK 0x06
#define RS5C313_ADDR_INTINTVREG 0x07
#define RS5C313_ADDR_DAY 0x08
#define RS5C313_ADDR_DAY10 0x09
#define RS5C313_ADDR_MON 0x0A
#define RS5C313_ADDR_MON10 0x0B
#define RS5C313_ADDR_YEAR 0x0C
#define RS5C313_ADDR_YEAR10 0x0D
#define RS5C313_ADDR_CNTREG 0x0E
#define RS5C313_ADDR_TESTREG 0x0F
/* RICOH RS5C313 control register */
#define RS5C313_CNTREG_ADJ_BSY 0x01
#define RS5C313_CNTREG_WTEN_XSTP 0x02
#define RS5C313_CNTREG_12_24 0x04
#define RS5C313_CNTREG_CTFG 0x08
/* RICOH RS5C313 test register */
#define RS5C313_TESTREG_TEST 0x01
/* RICOH RS5C313 control bit */
#define RS5C313_CNTBIT_READ 0x40
#define RS5C313_CNTBIT_AD 0x20
#define RS5C313_CNTBIT_DT 0x10
static unsigned char rs5c313_read_reg(unsigned char addr)
{
rs5c313_write_data(addr | RS5C313_CNTBIT_READ | RS5C313_CNTBIT_AD);
return rs5c313_read_data();
}
static void rs5c313_write_reg(unsigned char addr, unsigned char data)
{
data &= 0x0f;
rs5c313_write_data(addr | RS5C313_CNTBIT_AD);
rs5c313_write_data(data | RS5C313_CNTBIT_DT);
return;
}
static inline unsigned char rs5c313_read_cntreg(void)
{
return rs5c313_read_reg(RS5C313_ADDR_CNTREG);
Annotation
- Immediate include surface: `linux/module.h`, `linux/err.h`, `linux/rtc.h`, `linux/platform_device.h`, `linux/bcd.h`, `linux/delay.h`, `linux/io.h`.
- Detected declarations: `function rs5c313_init_port`, `function rs5c313_write_data`, `function rs5c313_read_data`, `function rs5c313_read_reg`, `function rs5c313_write_reg`, `function rs5c313_read_cntreg`, `function rs5c313_write_cntreg`, `function rs5c313_write_intintvreg`, `function rs5c313_rtc_read_time`, `function rs5c313_rtc_set_time`.
- 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.