Lines Matching +full:low +full:-

1 // SPDX-License-Identifier: GPL-2.0-only
5 * Copyright (C) 2009-2010 Marvell International Ltd.
77 max8925_set_bits(info->rtc, MAX8925_ALARM0_CNTL, 0x7f, 0); in rtc_update_handler()
78 rtc_update_irq(info->rtc_dev, 1, RTC_IRQF | RTC_AF); in rtc_update_handler()
85 return -EINVAL; in tm_calc()
86 tm->tm_year = (buf[RTC_YEAR2] >> 4) * 1000 in tm_calc()
90 tm->tm_year -= 1900; in tm_calc()
91 tm->tm_mon = ((buf[RTC_MONTH] >> 4) & 0x01) * 10 in tm_calc()
93 tm->tm_mday = ((buf[RTC_DATE] >> 4) & 0x03) * 10 in tm_calc()
95 tm->tm_wday = buf[RTC_WEEKDAY] & 0x07; in tm_calc()
97 tm->tm_hour = ((buf[RTC_HOUR] >> 4) & 0x1) * 10 in tm_calc()
100 tm->tm_hour += 12; in tm_calc()
102 tm->tm_hour = ((buf[RTC_HOUR] >> 4) & 0x03) * 10 in tm_calc()
104 tm->tm_min = ((buf[RTC_MIN] >> 4) & 0x7) * 10 in tm_calc()
106 tm->tm_sec = ((buf[RTC_SEC] >> 4) & 0x7) * 10 in tm_calc()
113 unsigned char high, low; in data_calc() local
116 return -EINVAL; in data_calc()
118 high = (tm->tm_year + 1900) / 1000; in data_calc()
119 low = (tm->tm_year + 1900) / 100; in data_calc()
120 low = low - high * 10; in data_calc()
121 buf[RTC_YEAR2] = (high << 4) + low; in data_calc()
122 high = (tm->tm_year + 1900) / 10; in data_calc()
123 low = tm->tm_year + 1900; in data_calc()
124 low = low - high * 10; in data_calc()
125 high = high - (high / 10) * 10; in data_calc()
126 buf[RTC_YEAR1] = (high << 4) + low; in data_calc()
127 high = tm->tm_mon / 10; in data_calc()
128 low = tm->tm_mon; in data_calc()
129 low = low - high * 10; in data_calc()
130 buf[RTC_MONTH] = (high << 4) + low; in data_calc()
131 high = tm->tm_mday / 10; in data_calc()
132 low = tm->tm_mday; in data_calc()
133 low = low - high * 10; in data_calc()
134 buf[RTC_DATE] = (high << 4) + low; in data_calc()
135 buf[RTC_WEEKDAY] = tm->tm_wday; in data_calc()
136 high = tm->tm_hour / 10; in data_calc()
137 low = tm->tm_hour; in data_calc()
138 low = low - high * 10; in data_calc()
139 buf[RTC_HOUR] = (high << 4) + low; in data_calc()
140 high = tm->tm_min / 10; in data_calc()
141 low = tm->tm_min; in data_calc()
142 low = low - high * 10; in data_calc()
143 buf[RTC_MIN] = (high << 4) + low; in data_calc()
144 high = tm->tm_sec / 10; in data_calc()
145 low = tm->tm_sec; in data_calc()
146 low = low - high * 10; in data_calc()
147 buf[RTC_SEC] = (high << 4) + low; in data_calc()
157 ret = max8925_bulk_read(info->rtc, MAX8925_RTC_SEC, TIME_NUM, buf); in max8925_rtc_read_time()
174 ret = max8925_bulk_write(info->rtc, MAX8925_RTC_SEC, TIME_NUM, buf); in max8925_rtc_set_time()
185 ret = max8925_bulk_read(info->rtc, MAX8925_ALARM0_SEC, TIME_NUM, buf); in max8925_rtc_read_alarm()
188 ret = tm_calc(&alrm->time, buf, TIME_NUM); in max8925_rtc_read_alarm()
191 ret = max8925_reg_read(info->rtc, MAX8925_RTC_IRQ_MASK); in max8925_rtc_read_alarm()
195 alrm->enabled = 0; in max8925_rtc_read_alarm()
197 ret = max8925_reg_read(info->rtc, MAX8925_ALARM0_CNTL); in max8925_rtc_read_alarm()
201 alrm->enabled = 0; in max8925_rtc_read_alarm()
203 alrm->enabled = 1; in max8925_rtc_read_alarm()
205 ret = max8925_reg_read(info->rtc, MAX8925_RTC_STATUS); in max8925_rtc_read_alarm()
209 alrm->pending = 1; in max8925_rtc_read_alarm()
211 alrm->pending = 0; in max8925_rtc_read_alarm()
223 ret = data_calc(buf, &alrm->time, TIME_NUM); in max8925_rtc_set_alarm()
226 ret = max8925_bulk_write(info->rtc, MAX8925_ALARM0_SEC, TIME_NUM, buf); in max8925_rtc_set_alarm()
229 if (alrm->enabled) in max8925_rtc_set_alarm()
231 ret = max8925_reg_write(info->rtc, MAX8925_ALARM0_CNTL, 0x77); in max8925_rtc_set_alarm()
233 ret = max8925_reg_write(info->rtc, MAX8925_ALARM0_CNTL, 0x0); in max8925_rtc_set_alarm()
247 struct max8925_chip *chip = dev_get_drvdata(pdev->dev.parent); in max8925_rtc_probe()
251 info = devm_kzalloc(&pdev->dev, sizeof(struct max8925_rtc_info), in max8925_rtc_probe()
254 return -ENOMEM; in max8925_rtc_probe()
255 info->chip = chip; in max8925_rtc_probe()
256 info->rtc = chip->rtc; in max8925_rtc_probe()
257 info->dev = &pdev->dev; in max8925_rtc_probe()
258 info->irq = platform_get_irq(pdev, 0); in max8925_rtc_probe()
260 ret = devm_request_threaded_irq(&pdev->dev, info->irq, NULL, in max8925_rtc_probe()
262 "rtc-alarm0", info); in max8925_rtc_probe()
264 dev_err(chip->dev, "Failed to request IRQ: #%d: %d\n", in max8925_rtc_probe()
265 info->irq, ret); in max8925_rtc_probe()
269 dev_set_drvdata(&pdev->dev, info); in max8925_rtc_probe()
270 /* XXX - isn't this redundant? */ in max8925_rtc_probe()
273 device_init_wakeup(&pdev->dev, 1); in max8925_rtc_probe()
275 info->rtc_dev = devm_rtc_device_register(&pdev->dev, "max8925-rtc", in max8925_rtc_probe()
277 ret = PTR_ERR(info->rtc_dev); in max8925_rtc_probe()
278 if (IS_ERR(info->rtc_dev)) { in max8925_rtc_probe()
279 dev_err(&pdev->dev, "Failed to register RTC device: %d\n", ret); in max8925_rtc_probe()
290 struct max8925_chip *chip = dev_get_drvdata(pdev->dev.parent); in max8925_rtc_suspend()
293 chip->wakeup_flag |= 1 << MAX8925_IRQ_RTC_ALARM0; in max8925_rtc_suspend()
299 struct max8925_chip *chip = dev_get_drvdata(pdev->dev.parent); in max8925_rtc_resume()
302 chip->wakeup_flag &= ~(1 << MAX8925_IRQ_RTC_ALARM0); in max8925_rtc_resume()
311 .name = "max8925-rtc",