Lines Matching +full:clkout +full:- +full:disable
1 // SPDX-License-Identifier: GPL-2.0-only
4 * Copyright 2005-06 Tower Technologies
7 * Maintainers: http://www.nslu2-linux.org/
11 * https://www.nxp.com/docs/en/data-sheet/PCF8563.pdf
14 #include <linux/clk-provider.h>
91 .addr = client->addr, in pcf8563_read_block_data()
96 .addr = client->addr, in pcf8563_read_block_data()
103 if ((i2c_transfer(client->adapter, msgs, 2)) != 2) { in pcf8563_read_block_data()
104 dev_err(&client->dev, "%s: read error\n", __func__); in pcf8563_read_block_data()
105 return -EIO; in pcf8563_read_block_data()
122 dev_err(&client->dev, in pcf8563_write_block_data()
125 return -EIO; in pcf8563_write_block_data()
150 dev_err(&client->dev, "%s: write error\n", __func__); in pcf8563_set_alarm_mode()
151 return -EIO; in pcf8563_set_alarm_mode()
181 err = pcf8563_get_alarm_mode(pcf8563->client, NULL, &pending); in pcf8563_irq()
186 rtc_update_irq(pcf8563->rtc, 1, RTC_IRQF | RTC_AF); in pcf8563_irq()
187 pcf8563_set_alarm_mode(pcf8563->client, 1); in pcf8563_irq()
196 * rtc_time -- month 0-11, hour 0-23, yr = calendar year-epoch.
210 dev_err(&client->dev, in pcf8563_rtc_read_time()
212 return -EINVAL; in pcf8563_rtc_read_time()
215 dev_dbg(&client->dev, in pcf8563_rtc_read_time()
224 tm->tm_sec = bcd2bin(buf[PCF8563_REG_SC] & 0x7F); in pcf8563_rtc_read_time()
225 tm->tm_min = bcd2bin(buf[PCF8563_REG_MN] & 0x7F); in pcf8563_rtc_read_time()
226 tm->tm_hour = bcd2bin(buf[PCF8563_REG_HR] & 0x3F); /* rtc hr 0-23 */ in pcf8563_rtc_read_time()
227 tm->tm_mday = bcd2bin(buf[PCF8563_REG_DM] & 0x3F); in pcf8563_rtc_read_time()
228 tm->tm_wday = buf[PCF8563_REG_DW] & 0x07; in pcf8563_rtc_read_time()
229 tm->tm_mon = bcd2bin(buf[PCF8563_REG_MO] & 0x1F) - 1; /* rtc mn 1-12 */ in pcf8563_rtc_read_time()
230 tm->tm_year = bcd2bin(buf[PCF8563_REG_YR]) + 100; in pcf8563_rtc_read_time()
232 pcf8563->c_polarity = (buf[PCF8563_REG_MO] & PCF8563_MO_C) ? in pcf8563_rtc_read_time()
233 (tm->tm_year >= 100) : (tm->tm_year < 100); in pcf8563_rtc_read_time()
235 dev_dbg(&client->dev, "%s: tm is secs=%d, mins=%d, hours=%d, " in pcf8563_rtc_read_time()
238 tm->tm_sec, tm->tm_min, tm->tm_hour, in pcf8563_rtc_read_time()
239 tm->tm_mday, tm->tm_mon, tm->tm_year, tm->tm_wday); in pcf8563_rtc_read_time()
250 dev_dbg(&client->dev, "%s: secs=%d, mins=%d, hours=%d, " in pcf8563_rtc_set_time()
253 tm->tm_sec, tm->tm_min, tm->tm_hour, in pcf8563_rtc_set_time()
254 tm->tm_mday, tm->tm_mon, tm->tm_year, tm->tm_wday); in pcf8563_rtc_set_time()
257 buf[PCF8563_REG_SC] = bin2bcd(tm->tm_sec); in pcf8563_rtc_set_time()
258 buf[PCF8563_REG_MN] = bin2bcd(tm->tm_min); in pcf8563_rtc_set_time()
259 buf[PCF8563_REG_HR] = bin2bcd(tm->tm_hour); in pcf8563_rtc_set_time()
261 buf[PCF8563_REG_DM] = bin2bcd(tm->tm_mday); in pcf8563_rtc_set_time()
263 /* month, 1 - 12 */ in pcf8563_rtc_set_time()
264 buf[PCF8563_REG_MO] = bin2bcd(tm->tm_mon + 1); in pcf8563_rtc_set_time()
267 buf[PCF8563_REG_YR] = bin2bcd(tm->tm_year - 100); in pcf8563_rtc_set_time()
268 if (pcf8563->c_polarity ? (tm->tm_year >= 100) : (tm->tm_year < 100)) in pcf8563_rtc_set_time()
271 buf[PCF8563_REG_DW] = tm->tm_wday & 0x07; in pcf8563_rtc_set_time()
274 9 - PCF8563_REG_SC, buf + PCF8563_REG_SC); in pcf8563_rtc_set_time()
291 return -ENOIOCTLCMD; in pcf8563_rtc_ioctl()
305 dev_dbg(&client->dev, in pcf8563_rtc_read_alarm()
309 tm->time.tm_sec = 0; in pcf8563_rtc_read_alarm()
310 tm->time.tm_min = bcd2bin(buf[0] & 0x7F); in pcf8563_rtc_read_alarm()
311 tm->time.tm_hour = bcd2bin(buf[1] & 0x3F); in pcf8563_rtc_read_alarm()
312 tm->time.tm_mday = bcd2bin(buf[2] & 0x3F); in pcf8563_rtc_read_alarm()
313 tm->time.tm_wday = bcd2bin(buf[3] & 0x7); in pcf8563_rtc_read_alarm()
315 err = pcf8563_get_alarm_mode(client, &tm->enabled, &tm->pending); in pcf8563_rtc_read_alarm()
319 dev_dbg(&client->dev, "%s: tm is mins=%d, hours=%d, mday=%d, wday=%d," in pcf8563_rtc_read_alarm()
320 " enabled=%d, pending=%d\n", __func__, tm->time.tm_min, in pcf8563_rtc_read_alarm()
321 tm->time.tm_hour, tm->time.tm_mday, tm->time.tm_wday, in pcf8563_rtc_read_alarm()
322 tm->enabled, tm->pending); in pcf8563_rtc_read_alarm()
333 buf[0] = bin2bcd(tm->time.tm_min); in pcf8563_rtc_set_alarm()
334 buf[1] = bin2bcd(tm->time.tm_hour); in pcf8563_rtc_set_alarm()
335 buf[2] = bin2bcd(tm->time.tm_mday); in pcf8563_rtc_set_alarm()
336 buf[3] = tm->time.tm_wday & 0x07; in pcf8563_rtc_set_alarm()
342 return pcf8563_set_alarm_mode(client, !!tm->enabled); in pcf8563_rtc_set_alarm()
353 * Handling of the clkout
369 struct i2c_client *client = pcf8563->client; in pcf8563_clkout_recalc_rate()
396 struct i2c_client *client = pcf8563->client; in pcf8563_clkout_set_rate()
414 return -EINVAL; in pcf8563_clkout_set_rate()
420 struct i2c_client *client = pcf8563->client; in pcf8563_clkout_control()
449 struct i2c_client *client = pcf8563->client; in pcf8563_clkout_is_prepared()
470 struct i2c_client *client = pcf8563->client; in pcf8563_clkout_register_clk()
471 struct device_node *node = client->dev.of_node; in pcf8563_clkout_register_clk()
477 /* disable the clkout output */ in pcf8563_clkout_register_clk()
483 init.name = "pcf8563-clkout"; in pcf8563_clkout_register_clk()
488 pcf8563->clkout_hw.init = &init; in pcf8563_clkout_register_clk()
491 of_property_read_string(node, "clock-output-names", &init.name); in pcf8563_clkout_register_clk()
494 clk = devm_clk_register(&client->dev, &pcf8563->clkout_hw); in pcf8563_clkout_register_clk()
518 dev_dbg(&client->dev, "%s\n", __func__); in pcf8563_probe()
520 if (!i2c_check_functionality(client->adapter, I2C_FUNC_I2C)) in pcf8563_probe()
521 return -ENODEV; in pcf8563_probe()
523 pcf8563 = devm_kzalloc(&client->dev, sizeof(struct pcf8563), in pcf8563_probe()
526 return -ENOMEM; in pcf8563_probe()
529 pcf8563->client = client; in pcf8563_probe()
530 device_set_wakeup_capable(&client->dev, 1); in pcf8563_probe()
536 dev_err(&client->dev, "%s: write error\n", __func__); in pcf8563_probe()
540 /* Clear flags and disable interrupts */ in pcf8563_probe()
544 dev_err(&client->dev, "%s: write error\n", __func__); in pcf8563_probe()
548 pcf8563->rtc = devm_rtc_allocate_device(&client->dev); in pcf8563_probe()
549 if (IS_ERR(pcf8563->rtc)) in pcf8563_probe()
550 return PTR_ERR(pcf8563->rtc); in pcf8563_probe()
552 pcf8563->rtc->ops = &pcf8563_rtc_ops; in pcf8563_probe()
554 set_bit(RTC_FEATURE_ALARM_RES_MINUTE, pcf8563->rtc->features); in pcf8563_probe()
555 clear_bit(RTC_FEATURE_UPDATE_INTERRUPT, pcf8563->rtc->features); in pcf8563_probe()
556 pcf8563->rtc->range_min = RTC_TIMESTAMP_BEGIN_2000; in pcf8563_probe()
557 pcf8563->rtc->range_max = RTC_TIMESTAMP_END_2099; in pcf8563_probe()
558 pcf8563->rtc->set_start_time = true; in pcf8563_probe()
560 if (client->irq > 0) { in pcf8563_probe()
563 if (dev_fwnode(&client->dev)) in pcf8563_probe()
566 err = devm_request_threaded_irq(&client->dev, client->irq, in pcf8563_probe()
571 dev_err(&client->dev, "unable to request IRQ %d\n", in pcf8563_probe()
572 client->irq); in pcf8563_probe()
576 clear_bit(RTC_FEATURE_ALARM, pcf8563->rtc->features); in pcf8563_probe()
579 err = devm_rtc_register_device(pcf8563->rtc); in pcf8563_probe()
612 .name = "rtc-pcf8563",