Lines Matching +full:start +full:- +full:year

1 // SPDX-License-Identifier: GPL-2.0-or-later
3 * Driver for the SGS-Thomson M48T35 Timekeeper RAM chip
28 u8 year; member
40 u8 year; member
64 * by the RTC when initially set to a non-zero value. in m48t35_read_time()
66 spin_lock_irq(&priv->lock); in m48t35_read_time()
67 control = readb(&priv->reg->control); in m48t35_read_time()
68 writeb(control | M48T35_RTC_READ, &priv->reg->control); in m48t35_read_time()
69 tm->tm_sec = readb(&priv->reg->sec); in m48t35_read_time()
70 tm->tm_min = readb(&priv->reg->min); in m48t35_read_time()
71 tm->tm_hour = readb(&priv->reg->hour); in m48t35_read_time()
72 tm->tm_mday = readb(&priv->reg->date); in m48t35_read_time()
73 tm->tm_mon = readb(&priv->reg->month); in m48t35_read_time()
74 tm->tm_year = readb(&priv->reg->year); in m48t35_read_time()
75 writeb(control, &priv->reg->control); in m48t35_read_time()
76 spin_unlock_irq(&priv->lock); in m48t35_read_time()
78 tm->tm_sec = bcd2bin(tm->tm_sec); in m48t35_read_time()
79 tm->tm_min = bcd2bin(tm->tm_min); in m48t35_read_time()
80 tm->tm_hour = bcd2bin(tm->tm_hour); in m48t35_read_time()
81 tm->tm_mday = bcd2bin(tm->tm_mday); in m48t35_read_time()
82 tm->tm_mon = bcd2bin(tm->tm_mon); in m48t35_read_time()
83 tm->tm_year = bcd2bin(tm->tm_year); in m48t35_read_time()
89 tm->tm_year += 70; in m48t35_read_time()
90 if (tm->tm_year <= 69) in m48t35_read_time()
91 tm->tm_year += 100; in m48t35_read_time()
93 tm->tm_mon--; in m48t35_read_time()
104 yrs = tm->tm_year + 1900; in m48t35_set_time()
105 mon = tm->tm_mon + 1; /* tm_mon starts at zero */ in m48t35_set_time()
106 day = tm->tm_mday; in m48t35_set_time()
107 hrs = tm->tm_hour; in m48t35_set_time()
108 min = tm->tm_min; in m48t35_set_time()
109 sec = tm->tm_sec; in m48t35_set_time()
112 return -EINVAL; in m48t35_set_time()
114 yrs -= 1970; in m48t35_set_time()
116 return -EINVAL; in m48t35_set_time()
119 return -EINVAL; in m48t35_set_time()
122 yrs -= 100; in m48t35_set_time()
131 spin_lock_irq(&priv->lock); in m48t35_set_time()
132 control = readb(&priv->reg->control); in m48t35_set_time()
133 writeb(control | M48T35_RTC_SET, &priv->reg->control); in m48t35_set_time()
134 writeb(yrs, &priv->reg->year); in m48t35_set_time()
135 writeb(mon, &priv->reg->month); in m48t35_set_time()
136 writeb(day, &priv->reg->date); in m48t35_set_time()
137 writeb(hrs, &priv->reg->hour); in m48t35_set_time()
138 writeb(min, &priv->reg->min); in m48t35_set_time()
139 writeb(sec, &priv->reg->sec); in m48t35_set_time()
140 writeb(control, &priv->reg->control); in m48t35_set_time()
141 spin_unlock_irq(&priv->lock); in m48t35_set_time()
157 return -ENODEV; in m48t35_probe()
158 priv = devm_kzalloc(&pdev->dev, sizeof(struct m48t35_priv), GFP_KERNEL); in m48t35_probe()
160 return -ENOMEM; in m48t35_probe()
162 priv->size = resource_size(res); in m48t35_probe()
163 if (!devm_request_mem_region(&pdev->dev, res->start, priv->size, in m48t35_probe()
164 pdev->name)) in m48t35_probe()
165 return -EBUSY; in m48t35_probe()
167 priv->baseaddr = res->start; in m48t35_probe()
168 priv->reg = devm_ioremap(&pdev->dev, priv->baseaddr, priv->size); in m48t35_probe()
169 if (!priv->reg) in m48t35_probe()
170 return -ENOMEM; in m48t35_probe()
172 spin_lock_init(&priv->lock); in m48t35_probe()
176 priv->rtc = devm_rtc_device_register(&pdev->dev, "m48t35", in m48t35_probe()
178 return PTR_ERR_OR_ZERO(priv->rtc); in m48t35_probe()
183 .name = "rtc-m48t35",
193 MODULE_ALIAS("platform:rtc-m48t35");