Lines Matching refs:fm3130
45 struct fm3130 { struct
67 struct fm3130 *fm3130 = dev_get_drvdata(dev); in fm3130_rtc_mode() local
69 fm3130->regs[FM3130_RTC_CONTROL] = in fm3130_rtc_mode()
70 i2c_smbus_read_byte_data(fm3130->client, FM3130_RTC_CONTROL); in fm3130_rtc_mode()
73 fm3130->regs[FM3130_RTC_CONTROL] &= in fm3130_rtc_mode()
78 fm3130->regs[FM3130_RTC_CONTROL] |= FM3130_RTC_CONTROL_BIT_WRITE; in fm3130_rtc_mode()
81 fm3130->regs[FM3130_RTC_CONTROL] |= FM3130_RTC_CONTROL_BIT_READ; in fm3130_rtc_mode()
88 i2c_smbus_write_byte_data(fm3130->client, in fm3130_rtc_mode()
89 FM3130_RTC_CONTROL, fm3130->regs[FM3130_RTC_CONTROL]); in fm3130_rtc_mode()
94 struct fm3130 *fm3130 = dev_get_drvdata(dev); in fm3130_get_time() local
97 if (!fm3130->data_valid) { in fm3130_get_time()
107 tmp = i2c_transfer(fm3130->client->adapter, fm3130->msg, 2); in fm3130_get_time()
115 dev_dbg(dev, "%s: %15ph\n", "read", fm3130->regs); in fm3130_get_time()
117 t->tm_sec = bcd2bin(fm3130->regs[FM3130_RTC_SECONDS] & 0x7f); in fm3130_get_time()
118 t->tm_min = bcd2bin(fm3130->regs[FM3130_RTC_MINUTES] & 0x7f); in fm3130_get_time()
119 tmp = fm3130->regs[FM3130_RTC_HOURS] & 0x3f; in fm3130_get_time()
121 t->tm_wday = bcd2bin(fm3130->regs[FM3130_RTC_DAY] & 0x07) - 1; in fm3130_get_time()
122 t->tm_mday = bcd2bin(fm3130->regs[FM3130_RTC_DATE] & 0x3f); in fm3130_get_time()
123 tmp = fm3130->regs[FM3130_RTC_MONTHS] & 0x1f; in fm3130_get_time()
127 t->tm_year = bcd2bin(fm3130->regs[FM3130_RTC_YEARS]) + 100; in fm3130_get_time()
141 struct fm3130 *fm3130 = dev_get_drvdata(dev); in fm3130_set_time() local
143 u8 *buf = fm3130->regs; in fm3130_set_time()
169 i2c_smbus_write_byte_data(fm3130->client, in fm3130_set_time()
171 fm3130->regs[FM3130_RTC_SECONDS + i]); in fm3130_set_time()
177 if (!fm3130->data_valid) in fm3130_set_time()
178 fm3130->data_valid = 1; in fm3130_set_time()
184 struct fm3130 *fm3130 = dev_get_drvdata(dev); in fm3130_read_alarm() local
188 if (!fm3130->alarm_valid) { in fm3130_read_alarm()
199 tmp = i2c_transfer(fm3130->client->adapter, &fm3130->msg[2], 2); in fm3130_read_alarm()
205 fm3130->regs[FM3130_ALARM_SECONDS], in fm3130_read_alarm()
206 fm3130->regs[FM3130_ALARM_MINUTES], in fm3130_read_alarm()
207 fm3130->regs[FM3130_ALARM_HOURS], in fm3130_read_alarm()
208 fm3130->regs[FM3130_ALARM_DATE], in fm3130_read_alarm()
209 fm3130->regs[FM3130_ALARM_MONTHS]); in fm3130_read_alarm()
211 tm->tm_sec = bcd2bin(fm3130->regs[FM3130_ALARM_SECONDS] & 0x7F); in fm3130_read_alarm()
212 tm->tm_min = bcd2bin(fm3130->regs[FM3130_ALARM_MINUTES] & 0x7F); in fm3130_read_alarm()
213 tm->tm_hour = bcd2bin(fm3130->regs[FM3130_ALARM_HOURS] & 0x3F); in fm3130_read_alarm()
214 tm->tm_mday = bcd2bin(fm3130->regs[FM3130_ALARM_DATE] & 0x3F); in fm3130_read_alarm()
215 tm->tm_mon = bcd2bin(fm3130->regs[FM3130_ALARM_MONTHS] & 0x1F); in fm3130_read_alarm()
227 fm3130->regs[FM3130_RTC_CONTROL] = in fm3130_read_alarm()
228 i2c_smbus_read_byte_data(fm3130->client, FM3130_RTC_CONTROL); in fm3130_read_alarm()
230 if ((fm3130->regs[FM3130_RTC_CONTROL] & FM3130_RTC_CONTROL_BIT_AEN) && in fm3130_read_alarm()
231 (~fm3130->regs[FM3130_RTC_CONTROL] & in fm3130_read_alarm()
241 struct fm3130 *fm3130 = dev_get_drvdata(dev); in fm3130_set_alarm() local
251 fm3130->regs[FM3130_ALARM_SECONDS] = in fm3130_set_alarm()
254 fm3130->regs[FM3130_ALARM_MINUTES] = in fm3130_set_alarm()
257 fm3130->regs[FM3130_ALARM_HOURS] = in fm3130_set_alarm()
260 fm3130->regs[FM3130_ALARM_DATE] = in fm3130_set_alarm()
263 fm3130->regs[FM3130_ALARM_MONTHS] = in fm3130_set_alarm()
267 fm3130->regs[FM3130_ALARM_SECONDS], in fm3130_set_alarm()
268 fm3130->regs[FM3130_ALARM_MINUTES], in fm3130_set_alarm()
269 fm3130->regs[FM3130_ALARM_HOURS], in fm3130_set_alarm()
270 fm3130->regs[FM3130_ALARM_DATE], in fm3130_set_alarm()
271 fm3130->regs[FM3130_ALARM_MONTHS]); in fm3130_set_alarm()
274 i2c_smbus_write_byte_data(fm3130->client, in fm3130_set_alarm()
276 fm3130->regs[FM3130_ALARM_SECONDS + i]); in fm3130_set_alarm()
278 fm3130->regs[FM3130_RTC_CONTROL] = in fm3130_set_alarm()
279 i2c_smbus_read_byte_data(fm3130->client, FM3130_RTC_CONTROL); in fm3130_set_alarm()
283 i2c_smbus_write_byte_data(fm3130->client, FM3130_RTC_CONTROL, in fm3130_set_alarm()
284 (fm3130->regs[FM3130_RTC_CONTROL] & in fm3130_set_alarm()
288 i2c_smbus_write_byte_data(fm3130->client, FM3130_RTC_CONTROL, in fm3130_set_alarm()
289 fm3130->regs[FM3130_RTC_CONTROL] & in fm3130_set_alarm()
295 if (!fm3130->alarm_valid) in fm3130_set_alarm()
296 fm3130->alarm_valid = 1; in fm3130_set_alarm()
303 struct fm3130 *fm3130 = dev_get_drvdata(dev); in fm3130_alarm_irq_enable() local
306 fm3130->regs[FM3130_RTC_CONTROL] = in fm3130_alarm_irq_enable()
307 i2c_smbus_read_byte_data(fm3130->client, FM3130_RTC_CONTROL); in fm3130_alarm_irq_enable()
310 enabled, fm3130->regs[FM3130_RTC_CONTROL]); in fm3130_alarm_irq_enable()
314 ret = i2c_smbus_write_byte_data(fm3130->client, in fm3130_alarm_irq_enable()
315 FM3130_RTC_CONTROL, fm3130->regs[FM3130_RTC_CONTROL] & in fm3130_alarm_irq_enable()
320 ret = i2c_smbus_write_byte_data(fm3130->client, in fm3130_alarm_irq_enable()
321 FM3130_RTC_CONTROL, (fm3130->regs[FM3130_RTC_CONTROL] & in fm3130_alarm_irq_enable()
345 struct fm3130 *fm3130; in fm3130_probe() local
354 fm3130 = devm_kzalloc(&client->dev, sizeof(struct fm3130), GFP_KERNEL); in fm3130_probe()
356 if (!fm3130) in fm3130_probe()
359 fm3130->client = client; in fm3130_probe()
360 i2c_set_clientdata(client, fm3130); in fm3130_probe()
361 fm3130->reg_addr_time = FM3130_RTC_SECONDS; in fm3130_probe()
362 fm3130->reg_addr_alarm = FM3130_ALARM_SECONDS; in fm3130_probe()
365 fm3130->msg[0].addr = client->addr; in fm3130_probe()
366 fm3130->msg[0].flags = 0; in fm3130_probe()
367 fm3130->msg[0].len = 1; in fm3130_probe()
368 fm3130->msg[0].buf = &fm3130->reg_addr_time; in fm3130_probe()
370 fm3130->msg[1].addr = client->addr; in fm3130_probe()
371 fm3130->msg[1].flags = I2C_M_RD; in fm3130_probe()
372 fm3130->msg[1].len = FM3130_CLOCK_REGS; in fm3130_probe()
373 fm3130->msg[1].buf = &fm3130->regs[FM3130_RTC_SECONDS]; in fm3130_probe()
376 fm3130->msg[2].addr = client->addr; in fm3130_probe()
377 fm3130->msg[2].flags = 0; in fm3130_probe()
378 fm3130->msg[2].len = 1; in fm3130_probe()
379 fm3130->msg[2].buf = &fm3130->reg_addr_alarm; in fm3130_probe()
381 fm3130->msg[3].addr = client->addr; in fm3130_probe()
382 fm3130->msg[3].flags = I2C_M_RD; in fm3130_probe()
383 fm3130->msg[3].len = FM3130_ALARM_REGS; in fm3130_probe()
384 fm3130->msg[3].buf = &fm3130->regs[FM3130_ALARM_SECONDS]; in fm3130_probe()
386 fm3130->alarm_valid = 0; in fm3130_probe()
387 fm3130->data_valid = 0; in fm3130_probe()
389 tmp = i2c_transfer(adapter, fm3130->msg, 4); in fm3130_probe()
396 fm3130->regs[FM3130_RTC_CONTROL] = in fm3130_probe()
398 fm3130->regs[FM3130_CAL_CONTROL] = in fm3130_probe()
402 if (fm3130->regs[FM3130_RTC_CONTROL] & FM3130_RTC_CONTROL_BIT_CAL) { in fm3130_probe()
404 fm3130->regs[FM3130_RTC_CONTROL] & in fm3130_probe()
410 if (fm3130->regs[FM3130_RTC_CONTROL] & FM3130_RTC_CONTROL_BIT_WRITE || in fm3130_probe()
411 fm3130->regs[FM3130_RTC_CONTROL] & FM3130_RTC_CONTROL_BIT_READ) { in fm3130_probe()
413 fm3130->regs[FM3130_RTC_CONTROL] & in fm3130_probe()
420 if (fm3130->regs[FM3130_CAL_CONTROL] & FM3130_CAL_CONTROL_BIT_nOSCEN) in fm3130_probe()
422 fm3130->regs[FM3130_CAL_CONTROL] & in fm3130_probe()
426 if (fm3130->regs[FM3130_RTC_CONTROL] & FM3130_RTC_CONTROL_BIT_LB) { in fm3130_probe()
428 fm3130->regs[FM3130_RTC_CONTROL] & in fm3130_probe()
434 if (fm3130->regs[FM3130_RTC_CONTROL] & FM3130_RTC_CONTROL_BIT_POR) { in fm3130_probe()
436 fm3130->regs[FM3130_RTC_CONTROL] & in fm3130_probe()
444 tmp = bcd2bin(fm3130->regs[FM3130_RTC_SECONDS] & 0x7f); in fm3130_probe()
448 tmp = bcd2bin(fm3130->regs[FM3130_RTC_MINUTES] & 0x7f); in fm3130_probe()
452 tmp = bcd2bin(fm3130->regs[FM3130_RTC_HOURS] & 0x3f); in fm3130_probe()
456 tmp = bcd2bin(fm3130->regs[FM3130_RTC_DATE] & 0x3f); in fm3130_probe()
460 tmp = bcd2bin(fm3130->regs[FM3130_RTC_MONTHS] & 0x1f); in fm3130_probe()
464 fm3130->alarm_valid = 1; in fm3130_probe()
469 tmp = bcd2bin(fm3130->regs[FM3130_RTC_SECONDS] & 0x7f); in fm3130_probe()
473 tmp = bcd2bin(fm3130->regs[FM3130_RTC_MINUTES] & 0x7f); in fm3130_probe()
477 tmp = bcd2bin(fm3130->regs[FM3130_RTC_HOURS] & 0x3f); in fm3130_probe()
481 tmp = bcd2bin(fm3130->regs[FM3130_RTC_DAY] & 0x7); in fm3130_probe()
485 tmp = bcd2bin(fm3130->regs[FM3130_RTC_DATE] & 0x3f); in fm3130_probe()
489 tmp = bcd2bin(fm3130->regs[FM3130_RTC_MONTHS] & 0x1f); in fm3130_probe()
493 fm3130->data_valid = 1; in fm3130_probe()
497 if (!fm3130->data_valid || !fm3130->alarm_valid) in fm3130_probe()
499 fm3130->regs); in fm3130_probe()
503 fm3130->rtc = devm_rtc_device_register(&client->dev, client->name, in fm3130_probe()
505 if (IS_ERR(fm3130->rtc)) { in fm3130_probe()
506 err = PTR_ERR(fm3130->rtc); in fm3130_probe()