Lines Matching +full:start +full:- +full:year
1 // SPDX-License-Identifier: GPL-2.0-only
3 * TI LP8788 MFD - rtc driver
100 return LP8788_WDAY_SET << (tm_wday - 1); in _to_lp8788_wday()
112 struct lp8788 *lp = rtc->lp; in lp8788_rtc_read_time()
122 tm->tm_sec = data[LPTIME_SEC]; in lp8788_rtc_read_time()
123 tm->tm_min = data[LPTIME_MIN]; in lp8788_rtc_read_time()
124 tm->tm_hour = data[LPTIME_HOUR]; in lp8788_rtc_read_time()
125 tm->tm_mday = data[LPTIME_MDAY]; in lp8788_rtc_read_time()
126 tm->tm_mon = data[LPTIME_MON] - LP8788_MONTH_OFFSET; in lp8788_rtc_read_time()
127 tm->tm_year = data[LPTIME_YEAR] + LP8788_BASE_YEAR - 1900; in lp8788_rtc_read_time()
128 tm->tm_wday = _to_tm_wday(data[LPTIME_WDAY]); in lp8788_rtc_read_time()
136 struct lp8788 *lp = rtc->lp; in lp8788_rtc_set_time()
137 u8 data[LPTIME_MAX - 1]; in lp8788_rtc_set_time()
138 int ret, i, year; in lp8788_rtc_set_time() local
140 year = tm->tm_year + 1900 - LP8788_BASE_YEAR; in lp8788_rtc_set_time()
141 if (year < 0) { in lp8788_rtc_set_time()
142 dev_err(lp->dev, "invalid year: %d\n", year); in lp8788_rtc_set_time()
143 return -EINVAL; in lp8788_rtc_set_time()
147 data[LPTIME_SEC] = tm->tm_sec; in lp8788_rtc_set_time()
148 data[LPTIME_MIN] = tm->tm_min; in lp8788_rtc_set_time()
149 data[LPTIME_HOUR] = tm->tm_hour; in lp8788_rtc_set_time()
150 data[LPTIME_MDAY] = tm->tm_mday; in lp8788_rtc_set_time()
151 data[LPTIME_MON] = tm->tm_mon + LP8788_MONTH_OFFSET; in lp8788_rtc_set_time()
152 data[LPTIME_YEAR] = year; in lp8788_rtc_set_time()
166 struct lp8788 *lp = rtc->lp; in lp8788_read_alarm()
167 struct rtc_time *tm = &alarm->time; in lp8788_read_alarm()
171 addr = addr_alarm_sec[rtc->alarm]; in lp8788_read_alarm()
176 tm->tm_sec = data[LPTIME_SEC]; in lp8788_read_alarm()
177 tm->tm_min = data[LPTIME_MIN]; in lp8788_read_alarm()
178 tm->tm_hour = data[LPTIME_HOUR]; in lp8788_read_alarm()
179 tm->tm_mday = data[LPTIME_MDAY]; in lp8788_read_alarm()
180 tm->tm_mon = data[LPTIME_MON] - LP8788_MONTH_OFFSET; in lp8788_read_alarm()
181 tm->tm_year = data[LPTIME_YEAR] + LP8788_BASE_YEAR - 1900; in lp8788_read_alarm()
182 tm->tm_wday = _to_tm_wday(data[LPTIME_WDAY]); in lp8788_read_alarm()
183 alarm->enabled = data[LPTIME_WDAY] & LP8788_ALM_EN_M; in lp8788_read_alarm()
191 struct lp8788 *lp = rtc->lp; in lp8788_set_alarm()
192 struct rtc_time *tm = &alarm->time; in lp8788_set_alarm()
194 int ret, i, year; in lp8788_set_alarm() local
196 year = tm->tm_year + 1900 - LP8788_BASE_YEAR; in lp8788_set_alarm()
197 if (year < 0) { in lp8788_set_alarm()
198 dev_err(lp->dev, "invalid year: %d\n", year); in lp8788_set_alarm()
199 return -EINVAL; in lp8788_set_alarm()
202 data[LPTIME_SEC] = tm->tm_sec; in lp8788_set_alarm()
203 data[LPTIME_MIN] = tm->tm_min; in lp8788_set_alarm()
204 data[LPTIME_HOUR] = tm->tm_hour; in lp8788_set_alarm()
205 data[LPTIME_MDAY] = tm->tm_mday; in lp8788_set_alarm()
206 data[LPTIME_MON] = tm->tm_mon + LP8788_MONTH_OFFSET; in lp8788_set_alarm()
207 data[LPTIME_YEAR] = year; in lp8788_set_alarm()
208 data[LPTIME_WDAY] = _to_lp8788_wday(tm->tm_wday); in lp8788_set_alarm()
211 addr = addr_alarm_sec[rtc->alarm] + i; in lp8788_set_alarm()
217 alarm->enabled = 1; in lp8788_set_alarm()
218 addr = addr_alarm_en[rtc->alarm]; in lp8788_set_alarm()
221 alarm->enabled << LP8788_ALM_EN_S); in lp8788_set_alarm()
227 struct lp8788 *lp = rtc->lp; in lp8788_alarm_irq_enable()
230 if (!rtc->irq) in lp8788_alarm_irq_enable()
231 return -EIO; in lp8788_alarm_irq_enable()
233 mask = mask_alarm_en[rtc->alarm]; in lp8788_alarm_irq_enable()
234 shift = shift_alarm_en[rtc->alarm]; in lp8788_alarm_irq_enable()
251 rtc_update_irq(rtc->rdev, 1, ALARM_IRQ_FLAG); in lp8788_alarm_irq_handler()
259 struct lp8788 *lp = rtc->lp; in lp8788_alarm_irq_register()
260 struct irq_domain *irqdm = lp->irqdm; in lp8788_alarm_irq_register()
263 rtc->irq = 0; in lp8788_alarm_irq_register()
270 if (rtc->alarm == LP8788_ALARM_1) in lp8788_alarm_irq_register()
271 irq = r->start; in lp8788_alarm_irq_register()
273 irq = r->end; in lp8788_alarm_irq_register()
275 rtc->irq = irq_create_mapping(irqdm, irq); in lp8788_alarm_irq_register()
277 return devm_request_threaded_irq(&pdev->dev, rtc->irq, NULL, in lp8788_alarm_irq_register()
284 struct lp8788 *lp = dev_get_drvdata(pdev->dev.parent); in lp8788_rtc_probe()
286 struct device *dev = &pdev->dev; in lp8788_rtc_probe()
290 return -ENOMEM; in lp8788_rtc_probe()
292 rtc->lp = lp; in lp8788_rtc_probe()
293 rtc->alarm = lp->pdata ? lp->pdata->alarm_sel : DEFAULT_ALARM_SEL; in lp8788_rtc_probe()
298 rtc->rdev = devm_rtc_device_register(dev, "lp8788_rtc", in lp8788_rtc_probe()
300 if (IS_ERR(rtc->rdev)) { in lp8788_rtc_probe()
302 return PTR_ERR(rtc->rdev); in lp8788_rtc_probe()
306 dev_warn(lp->dev, "no rtc irq handler\n"); in lp8788_rtc_probe()
322 MODULE_ALIAS("platform:lp8788-rtc");