diff options
author | Uwe Kleine-König <u.kleine-koenig@pengutronix.de> | 2019-01-25 09:35:55 -0500 |
---|---|---|
committer | Alexandre Belloni <alexandre.belloni@bootlin.com> | 2019-02-07 14:55:41 -0500 |
commit | d0e3f61b08e222d3c6895085487cbb8b54448abd (patch) | |
tree | b00174bb0f8f96dac875d797bd544e4bab0ace94 | |
parent | 92cbf12fc200595611511fb3c5ab17d2627fa43c (diff) |
rtc: ds1307: forward declare chips array instead of a bunch of functions
There used to be 16 declarations for static functions. By just adding a
declaration for the chips array and reordering the functions the 16
function declarations can be dropped.
Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
-rw-r--r-- | drivers/rtc/rtc-ds1307.c | 622 |
1 files changed, 297 insertions, 325 deletions
diff --git a/drivers/rtc/rtc-ds1307.c b/drivers/rtc/rtc-ds1307.c index f7a47ee5cdf6..a4883d59d88d 100644 --- a/drivers/rtc/rtc-ds1307.c +++ b/drivers/rtc/rtc-ds1307.c | |||
@@ -184,289 +184,7 @@ struct chip_desc { | |||
184 | bool); | 184 | bool); |
185 | }; | 185 | }; |
186 | 186 | ||
187 | static int ds1307_get_time(struct device *dev, struct rtc_time *t); | 187 | static const struct chip_desc chips[last_ds_type]; |
188 | static int ds1307_set_time(struct device *dev, struct rtc_time *t); | ||
189 | static int ds1337_read_alarm(struct device *dev, struct rtc_wkalrm *t); | ||
190 | static int ds1337_set_alarm(struct device *dev, struct rtc_wkalrm *t); | ||
191 | static int ds1307_alarm_irq_enable(struct device *dev, unsigned int enabled); | ||
192 | static u8 do_trickle_setup_ds1339(struct ds1307 *, u32 ohms, bool diode); | ||
193 | static irqreturn_t rx8130_irq(int irq, void *dev_id); | ||
194 | static int rx8130_read_alarm(struct device *dev, struct rtc_wkalrm *t); | ||
195 | static int rx8130_set_alarm(struct device *dev, struct rtc_wkalrm *t); | ||
196 | static int rx8130_alarm_irq_enable(struct device *dev, unsigned int enabled); | ||
197 | static irqreturn_t mcp794xx_irq(int irq, void *dev_id); | ||
198 | static int mcp794xx_read_alarm(struct device *dev, struct rtc_wkalrm *t); | ||
199 | static int mcp794xx_set_alarm(struct device *dev, struct rtc_wkalrm *t); | ||
200 | static int mcp794xx_alarm_irq_enable(struct device *dev, unsigned int enabled); | ||
201 | static int m41txx_rtc_read_offset(struct device *dev, long *offset); | ||
202 | static int m41txx_rtc_set_offset(struct device *dev, long offset); | ||
203 | |||
204 | static const struct rtc_class_ops rx8130_rtc_ops = { | ||
205 | .read_time = ds1307_get_time, | ||
206 | .set_time = ds1307_set_time, | ||
207 | .read_alarm = rx8130_read_alarm, | ||
208 | .set_alarm = rx8130_set_alarm, | ||
209 | .alarm_irq_enable = rx8130_alarm_irq_enable, | ||
210 | }; | ||
211 | |||
212 | static const struct rtc_class_ops mcp794xx_rtc_ops = { | ||
213 | .read_time = ds1307_get_time, | ||
214 | .set_time = ds1307_set_time, | ||
215 | .read_alarm = mcp794xx_read_alarm, | ||
216 | .set_alarm = mcp794xx_set_alarm, | ||
217 | .alarm_irq_enable = mcp794xx_alarm_irq_enable, | ||
218 | }; | ||
219 | |||
220 | static const struct rtc_class_ops m41txx_rtc_ops = { | ||
221 | .read_time = ds1307_get_time, | ||
222 | .set_time = ds1307_set_time, | ||
223 | .read_alarm = ds1337_read_alarm, | ||
224 | .set_alarm = ds1337_set_alarm, | ||
225 | .alarm_irq_enable = ds1307_alarm_irq_enable, | ||
226 | .read_offset = m41txx_rtc_read_offset, | ||
227 | .set_offset = m41txx_rtc_set_offset, | ||
228 | }; | ||
229 | |||
230 | static const struct chip_desc chips[last_ds_type] = { | ||
231 | [ds_1307] = { | ||
232 | .nvram_offset = 8, | ||
233 | .nvram_size = 56, | ||
234 | }, | ||
235 | [ds_1308] = { | ||
236 | .nvram_offset = 8, | ||
237 | .nvram_size = 56, | ||
238 | }, | ||
239 | [ds_1337] = { | ||
240 | .alarm = 1, | ||
241 | .century_reg = DS1307_REG_MONTH, | ||
242 | .century_bit = DS1337_BIT_CENTURY, | ||
243 | }, | ||
244 | [ds_1338] = { | ||
245 | .nvram_offset = 8, | ||
246 | .nvram_size = 56, | ||
247 | }, | ||
248 | [ds_1339] = { | ||
249 | .alarm = 1, | ||
250 | .century_reg = DS1307_REG_MONTH, | ||
251 | .century_bit = DS1337_BIT_CENTURY, | ||
252 | .bbsqi_bit = DS1339_BIT_BBSQI, | ||
253 | .trickle_charger_reg = 0x10, | ||
254 | .do_trickle_setup = &do_trickle_setup_ds1339, | ||
255 | }, | ||
256 | [ds_1340] = { | ||
257 | .century_reg = DS1307_REG_HOUR, | ||
258 | .century_enable_bit = DS1340_BIT_CENTURY_EN, | ||
259 | .century_bit = DS1340_BIT_CENTURY, | ||
260 | .do_trickle_setup = &do_trickle_setup_ds1339, | ||
261 | .trickle_charger_reg = 0x08, | ||
262 | }, | ||
263 | [ds_1341] = { | ||
264 | .century_reg = DS1307_REG_MONTH, | ||
265 | .century_bit = DS1337_BIT_CENTURY, | ||
266 | }, | ||
267 | [ds_1388] = { | ||
268 | .offset = 1, | ||
269 | .trickle_charger_reg = 0x0a, | ||
270 | }, | ||
271 | [ds_3231] = { | ||
272 | .alarm = 1, | ||
273 | .century_reg = DS1307_REG_MONTH, | ||
274 | .century_bit = DS1337_BIT_CENTURY, | ||
275 | .bbsqi_bit = DS3231_BIT_BBSQW, | ||
276 | }, | ||
277 | [rx_8130] = { | ||
278 | .alarm = 1, | ||
279 | /* this is battery backed SRAM */ | ||
280 | .nvram_offset = 0x20, | ||
281 | .nvram_size = 4, /* 32bit (4 word x 8 bit) */ | ||
282 | .offset = 0x10, | ||
283 | .irq_handler = rx8130_irq, | ||
284 | .rtc_ops = &rx8130_rtc_ops, | ||
285 | }, | ||
286 | [m41t0] = { | ||
287 | .rtc_ops = &m41txx_rtc_ops, | ||
288 | }, | ||
289 | [m41t00] = { | ||
290 | .rtc_ops = &m41txx_rtc_ops, | ||
291 | }, | ||
292 | [m41t11] = { | ||
293 | /* this is battery backed SRAM */ | ||
294 | .nvram_offset = 8, | ||
295 | .nvram_size = 56, | ||
296 | .rtc_ops = &m41txx_rtc_ops, | ||
297 | }, | ||
298 | [mcp794xx] = { | ||
299 | .alarm = 1, | ||
300 | /* this is battery backed SRAM */ | ||
301 | .nvram_offset = 0x20, | ||
302 | .nvram_size = 0x40, | ||
303 | .irq_handler = mcp794xx_irq, | ||
304 | .rtc_ops = &mcp794xx_rtc_ops, | ||
305 | }, | ||
306 | }; | ||
307 | |||
308 | static const struct i2c_device_id ds1307_id[] = { | ||
309 | { "ds1307", ds_1307 }, | ||
310 | { "ds1308", ds_1308 }, | ||
311 | { "ds1337", ds_1337 }, | ||
312 | { "ds1338", ds_1338 }, | ||
313 | { "ds1339", ds_1339 }, | ||
314 | { "ds1388", ds_1388 }, | ||
315 | { "ds1340", ds_1340 }, | ||
316 | { "ds1341", ds_1341 }, | ||
317 | { "ds3231", ds_3231 }, | ||
318 | { "m41t0", m41t0 }, | ||
319 | { "m41t00", m41t00 }, | ||
320 | { "m41t11", m41t11 }, | ||
321 | { "mcp7940x", mcp794xx }, | ||
322 | { "mcp7941x", mcp794xx }, | ||
323 | { "pt7c4338", ds_1307 }, | ||
324 | { "rx8025", rx_8025 }, | ||
325 | { "isl12057", ds_1337 }, | ||
326 | { "rx8130", rx_8130 }, | ||
327 | { } | ||
328 | }; | ||
329 | MODULE_DEVICE_TABLE(i2c, ds1307_id); | ||
330 | |||
331 | #ifdef CONFIG_OF | ||
332 | static const struct of_device_id ds1307_of_match[] = { | ||
333 | { | ||
334 | .compatible = "dallas,ds1307", | ||
335 | .data = (void *)ds_1307 | ||
336 | }, | ||
337 | { | ||
338 | .compatible = "dallas,ds1308", | ||
339 | .data = (void *)ds_1308 | ||
340 | }, | ||
341 | { | ||
342 | .compatible = "dallas,ds1337", | ||
343 | .data = (void *)ds_1337 | ||
344 | }, | ||
345 | { | ||
346 | .compatible = "dallas,ds1338", | ||
347 | .data = (void *)ds_1338 | ||
348 | }, | ||
349 | { | ||
350 | .compatible = "dallas,ds1339", | ||
351 | .data = (void *)ds_1339 | ||
352 | }, | ||
353 | { | ||
354 | .compatible = "dallas,ds1388", | ||
355 | .data = (void *)ds_1388 | ||
356 | }, | ||
357 | { | ||
358 | .compatible = "dallas,ds1340", | ||
359 | .data = (void *)ds_1340 | ||
360 | }, | ||
361 | { | ||
362 | .compatible = "dallas,ds1341", | ||
363 | .data = (void *)ds_1341 | ||
364 | }, | ||
365 | { | ||
366 | .compatible = "maxim,ds3231", | ||
367 | .data = (void *)ds_3231 | ||
368 | }, | ||
369 | { | ||
370 | .compatible = "st,m41t0", | ||
371 | .data = (void *)m41t0 | ||
372 | }, | ||
373 | { | ||
374 | .compatible = "st,m41t00", | ||
375 | .data = (void *)m41t00 | ||
376 | }, | ||
377 | { | ||
378 | .compatible = "st,m41t11", | ||
379 | .data = (void *)m41t11 | ||
380 | }, | ||
381 | { | ||
382 | .compatible = "microchip,mcp7940x", | ||
383 | .data = (void *)mcp794xx | ||
384 | }, | ||
385 | { | ||
386 | .compatible = "microchip,mcp7941x", | ||
387 | .data = (void *)mcp794xx | ||
388 | }, | ||
389 | { | ||
390 | .compatible = "pericom,pt7c4338", | ||
391 | .data = (void *)ds_1307 | ||
392 | }, | ||
393 | { | ||
394 | .compatible = "epson,rx8025", | ||
395 | .data = (void *)rx_8025 | ||
396 | }, | ||
397 | { | ||
398 | .compatible = "isil,isl12057", | ||
399 | .data = (void *)ds_1337 | ||
400 | }, | ||
401 | { | ||
402 | .compatible = "epson,rx8130", | ||
403 | .data = (void *)rx_8130 | ||
404 | }, | ||
405 | { } | ||
406 | }; | ||
407 | MODULE_DEVICE_TABLE(of, ds1307_of_match); | ||
408 | #endif | ||
409 | |||
410 | #ifdef CONFIG_ACPI | ||
411 | static const struct acpi_device_id ds1307_acpi_ids[] = { | ||
412 | { .id = "DS1307", .driver_data = ds_1307 }, | ||
413 | { .id = "DS1308", .driver_data = ds_1308 }, | ||
414 | { .id = "DS1337", .driver_data = ds_1337 }, | ||
415 | { .id = "DS1338", .driver_data = ds_1338 }, | ||
416 | { .id = "DS1339", .driver_data = ds_1339 }, | ||
417 | { .id = "DS1388", .driver_data = ds_1388 }, | ||
418 | { .id = "DS1340", .driver_data = ds_1340 }, | ||
419 | { .id = "DS1341", .driver_data = ds_1341 }, | ||
420 | { .id = "DS3231", .driver_data = ds_3231 }, | ||
421 | { .id = "M41T0", .driver_data = m41t0 }, | ||
422 | { .id = "M41T00", .driver_data = m41t00 }, | ||
423 | { .id = "M41T11", .driver_data = m41t11 }, | ||
424 | { .id = "MCP7940X", .driver_data = mcp794xx }, | ||
425 | { .id = "MCP7941X", .driver_data = mcp794xx }, | ||
426 | { .id = "PT7C4338", .driver_data = ds_1307 }, | ||
427 | { .id = "RX8025", .driver_data = rx_8025 }, | ||
428 | { .id = "ISL12057", .driver_data = ds_1337 }, | ||
429 | { .id = "RX8130", .driver_data = rx_8130 }, | ||
430 | { } | ||
431 | }; | ||
432 | MODULE_DEVICE_TABLE(acpi, ds1307_acpi_ids); | ||
433 | #endif | ||
434 | |||
435 | /* | ||
436 | * The ds1337 and ds1339 both have two alarms, but we only use the first | ||
437 | * one (with a "seconds" field). For ds1337 we expect nINTA is our alarm | ||
438 | * signal; ds1339 chips have only one alarm signal. | ||
439 | */ | ||
440 | static irqreturn_t ds1307_irq(int irq, void *dev_id) | ||
441 | { | ||
442 | struct ds1307 *ds1307 = dev_id; | ||
443 | struct mutex *lock = &ds1307->rtc->ops_lock; | ||
444 | int stat, ret; | ||
445 | |||
446 | mutex_lock(lock); | ||
447 | ret = regmap_read(ds1307->regmap, DS1337_REG_STATUS, &stat); | ||
448 | if (ret) | ||
449 | goto out; | ||
450 | |||
451 | if (stat & DS1337_BIT_A1I) { | ||
452 | stat &= ~DS1337_BIT_A1I; | ||
453 | regmap_write(ds1307->regmap, DS1337_REG_STATUS, stat); | ||
454 | |||
455 | ret = regmap_update_bits(ds1307->regmap, DS1337_REG_CONTROL, | ||
456 | DS1337_BIT_A1IE, 0); | ||
457 | if (ret) | ||
458 | goto out; | ||
459 | |||
460 | rtc_update_irq(ds1307->rtc, 1, RTC_AF | RTC_IRQF); | ||
461 | } | ||
462 | |||
463 | out: | ||
464 | mutex_unlock(lock); | ||
465 | |||
466 | return IRQ_HANDLED; | ||
467 | } | ||
468 | |||
469 | /*----------------------------------------------------------------------*/ | ||
470 | 188 | ||
471 | static int ds1307_get_time(struct device *dev, struct rtc_time *t) | 189 | static int ds1307_get_time(struct device *dev, struct rtc_time *t) |
472 | { | 190 | { |
@@ -692,19 +410,28 @@ static int ds1307_alarm_irq_enable(struct device *dev, unsigned int enabled) | |||
692 | enabled ? DS1337_BIT_A1IE : 0); | 410 | enabled ? DS1337_BIT_A1IE : 0); |
693 | } | 411 | } |
694 | 412 | ||
695 | static const struct rtc_class_ops ds13xx_rtc_ops = { | 413 | static u8 do_trickle_setup_ds1339(struct ds1307 *ds1307, u32 ohms, bool diode) |
696 | .read_time = ds1307_get_time, | 414 | { |
697 | .set_time = ds1307_set_time, | 415 | u8 setup = (diode) ? DS1307_TRICKLE_CHARGER_DIODE : |
698 | .read_alarm = ds1337_read_alarm, | 416 | DS1307_TRICKLE_CHARGER_NO_DIODE; |
699 | .set_alarm = ds1337_set_alarm, | ||
700 | .alarm_irq_enable = ds1307_alarm_irq_enable, | ||
701 | }; | ||
702 | |||
703 | /*----------------------------------------------------------------------*/ | ||
704 | 417 | ||
705 | /* | 418 | switch (ohms) { |
706 | * Alarm support for rx8130 devices. | 419 | case 250: |
707 | */ | 420 | setup |= DS1307_TRICKLE_CHARGER_250_OHM; |
421 | break; | ||
422 | case 2000: | ||
423 | setup |= DS1307_TRICKLE_CHARGER_2K_OHM; | ||
424 | break; | ||
425 | case 4000: | ||
426 | setup |= DS1307_TRICKLE_CHARGER_4K_OHM; | ||
427 | break; | ||
428 | default: | ||
429 | dev_warn(ds1307->dev, | ||
430 | "Unsupported ohm value %u in dt\n", ohms); | ||
431 | return 0; | ||
432 | } | ||
433 | return setup; | ||
434 | } | ||
708 | 435 | ||
709 | static irqreturn_t rx8130_irq(int irq, void *dev_id) | 436 | static irqreturn_t rx8130_irq(int irq, void *dev_id) |
710 | { | 437 | { |
@@ -849,12 +576,6 @@ static int rx8130_alarm_irq_enable(struct device *dev, unsigned int enabled) | |||
849 | return regmap_write(ds1307->regmap, RX8130_REG_CONTROL0, reg); | 576 | return regmap_write(ds1307->regmap, RX8130_REG_CONTROL0, reg); |
850 | } | 577 | } |
851 | 578 | ||
852 | /*----------------------------------------------------------------------*/ | ||
853 | |||
854 | /* | ||
855 | * Alarm support for mcp794xx devices. | ||
856 | */ | ||
857 | |||
858 | static irqreturn_t mcp794xx_irq(int irq, void *dev_id) | 579 | static irqreturn_t mcp794xx_irq(int irq, void *dev_id) |
859 | { | 580 | { |
860 | struct ds1307 *ds1307 = dev_id; | 581 | struct ds1307 *ds1307 = dev_id; |
@@ -1050,6 +771,281 @@ static int m41txx_rtc_set_offset(struct device *dev, long offset) | |||
1050 | ctrl_reg); | 771 | ctrl_reg); |
1051 | } | 772 | } |
1052 | 773 | ||
774 | static const struct rtc_class_ops rx8130_rtc_ops = { | ||
775 | .read_time = ds1307_get_time, | ||
776 | .set_time = ds1307_set_time, | ||
777 | .read_alarm = rx8130_read_alarm, | ||
778 | .set_alarm = rx8130_set_alarm, | ||
779 | .alarm_irq_enable = rx8130_alarm_irq_enable, | ||
780 | }; | ||
781 | |||
782 | static const struct rtc_class_ops mcp794xx_rtc_ops = { | ||
783 | .read_time = ds1307_get_time, | ||
784 | .set_time = ds1307_set_time, | ||
785 | .read_alarm = mcp794xx_read_alarm, | ||
786 | .set_alarm = mcp794xx_set_alarm, | ||
787 | .alarm_irq_enable = mcp794xx_alarm_irq_enable, | ||
788 | }; | ||
789 | |||
790 | static const struct rtc_class_ops m41txx_rtc_ops = { | ||
791 | .read_time = ds1307_get_time, | ||
792 | .set_time = ds1307_set_time, | ||
793 | .read_alarm = ds1337_read_alarm, | ||
794 | .set_alarm = ds1337_set_alarm, | ||
795 | .alarm_irq_enable = ds1307_alarm_irq_enable, | ||
796 | .read_offset = m41txx_rtc_read_offset, | ||
797 | .set_offset = m41txx_rtc_set_offset, | ||
798 | }; | ||
799 | |||
800 | static const struct chip_desc chips[last_ds_type] = { | ||
801 | [ds_1307] = { | ||
802 | .nvram_offset = 8, | ||
803 | .nvram_size = 56, | ||
804 | }, | ||
805 | [ds_1308] = { | ||
806 | .nvram_offset = 8, | ||
807 | .nvram_size = 56, | ||
808 | }, | ||
809 | [ds_1337] = { | ||
810 | .alarm = 1, | ||
811 | .century_reg = DS1307_REG_MONTH, | ||
812 | .century_bit = DS1337_BIT_CENTURY, | ||
813 | }, | ||
814 | [ds_1338] = { | ||
815 | .nvram_offset = 8, | ||
816 | .nvram_size = 56, | ||
817 | }, | ||
818 | [ds_1339] = { | ||
819 | .alarm = 1, | ||
820 | .century_reg = DS1307_REG_MONTH, | ||
821 | .century_bit = DS1337_BIT_CENTURY, | ||
822 | .bbsqi_bit = DS1339_BIT_BBSQI, | ||
823 | .trickle_charger_reg = 0x10, | ||
824 | .do_trickle_setup = &do_trickle_setup_ds1339, | ||
825 | }, | ||
826 | [ds_1340] = { | ||
827 | .century_reg = DS1307_REG_HOUR, | ||
828 | .century_enable_bit = DS1340_BIT_CENTURY_EN, | ||
829 | .century_bit = DS1340_BIT_CENTURY, | ||
830 | .do_trickle_setup = &do_trickle_setup_ds1339, | ||
831 | .trickle_charger_reg = 0x08, | ||
832 | }, | ||
833 | [ds_1341] = { | ||
834 | .century_reg = DS1307_REG_MONTH, | ||
835 | .century_bit = DS1337_BIT_CENTURY, | ||
836 | }, | ||
837 | [ds_1388] = { | ||
838 | .offset = 1, | ||
839 | .trickle_charger_reg = 0x0a, | ||
840 | }, | ||
841 | [ds_3231] = { | ||
842 | .alarm = 1, | ||
843 | .century_reg = DS1307_REG_MONTH, | ||
844 | .century_bit = DS1337_BIT_CENTURY, | ||
845 | .bbsqi_bit = DS3231_BIT_BBSQW, | ||
846 | }, | ||
847 | [rx_8130] = { | ||
848 | .alarm = 1, | ||
849 | /* this is battery backed SRAM */ | ||
850 | .nvram_offset = 0x20, | ||
851 | .nvram_size = 4, /* 32bit (4 word x 8 bit) */ | ||
852 | .offset = 0x10, | ||
853 | .irq_handler = rx8130_irq, | ||
854 | .rtc_ops = &rx8130_rtc_ops, | ||
855 | }, | ||
856 | [m41t0] = { | ||
857 | .rtc_ops = &m41txx_rtc_ops, | ||
858 | }, | ||
859 | [m41t00] = { | ||
860 | .rtc_ops = &m41txx_rtc_ops, | ||
861 | }, | ||
862 | [m41t11] = { | ||
863 | /* this is battery backed SRAM */ | ||
864 | .nvram_offset = 8, | ||
865 | .nvram_size = 56, | ||
866 | .rtc_ops = &m41txx_rtc_ops, | ||
867 | }, | ||
868 | [mcp794xx] = { | ||
869 | .alarm = 1, | ||
870 | /* this is battery backed SRAM */ | ||
871 | .nvram_offset = 0x20, | ||
872 | .nvram_size = 0x40, | ||
873 | .irq_handler = mcp794xx_irq, | ||
874 | .rtc_ops = &mcp794xx_rtc_ops, | ||
875 | }, | ||
876 | }; | ||
877 | |||
878 | static const struct i2c_device_id ds1307_id[] = { | ||
879 | { "ds1307", ds_1307 }, | ||
880 | { "ds1308", ds_1308 }, | ||
881 | { "ds1337", ds_1337 }, | ||
882 | { "ds1338", ds_1338 }, | ||
883 | { "ds1339", ds_1339 }, | ||
884 | { "ds1388", ds_1388 }, | ||
885 | { "ds1340", ds_1340 }, | ||
886 | { "ds1341", ds_1341 }, | ||
887 | { "ds3231", ds_3231 }, | ||
888 | { "m41t0", m41t0 }, | ||
889 | { "m41t00", m41t00 }, | ||
890 | { "m41t11", m41t11 }, | ||
891 | { "mcp7940x", mcp794xx }, | ||
892 | { "mcp7941x", mcp794xx }, | ||
893 | { "pt7c4338", ds_1307 }, | ||
894 | { "rx8025", rx_8025 }, | ||
895 | { "isl12057", ds_1337 }, | ||
896 | { "rx8130", rx_8130 }, | ||
897 | { } | ||
898 | }; | ||
899 | MODULE_DEVICE_TABLE(i2c, ds1307_id); | ||
900 | |||
901 | #ifdef CONFIG_OF | ||
902 | static const struct of_device_id ds1307_of_match[] = { | ||
903 | { | ||
904 | .compatible = "dallas,ds1307", | ||
905 | .data = (void *)ds_1307 | ||
906 | }, | ||
907 | { | ||
908 | .compatible = "dallas,ds1308", | ||
909 | .data = (void *)ds_1308 | ||
910 | }, | ||
911 | { | ||
912 | .compatible = "dallas,ds1337", | ||
913 | .data = (void *)ds_1337 | ||
914 | }, | ||
915 | { | ||
916 | .compatible = "dallas,ds1338", | ||
917 | .data = (void *)ds_1338 | ||
918 | }, | ||
919 | { | ||
920 | .compatible = "dallas,ds1339", | ||
921 | .data = (void *)ds_1339 | ||
922 | }, | ||
923 | { | ||
924 | .compatible = "dallas,ds1388", | ||
925 | .data = (void *)ds_1388 | ||
926 | }, | ||
927 | { | ||
928 | .compatible = "dallas,ds1340", | ||
929 | .data = (void *)ds_1340 | ||
930 | }, | ||
931 | { | ||
932 | .compatible = "dallas,ds1341", | ||
933 | .data = (void *)ds_1341 | ||
934 | }, | ||
935 | { | ||
936 | .compatible = "maxim,ds3231", | ||
937 | .data = (void *)ds_3231 | ||
938 | }, | ||
939 | { | ||
940 | .compatible = "st,m41t0", | ||
941 | .data = (void *)m41t0 | ||
942 | }, | ||
943 | { | ||
944 | .compatible = "st,m41t00", | ||
945 | .data = (void *)m41t00 | ||
946 | }, | ||
947 | { | ||
948 | .compatible = "st,m41t11", | ||
949 | .data = (void *)m41t11 | ||
950 | }, | ||
951 | { | ||
952 | .compatible = "microchip,mcp7940x", | ||
953 | .data = (void *)mcp794xx | ||
954 | }, | ||
955 | { | ||
956 | .compatible = "microchip,mcp7941x", | ||
957 | .data = (void *)mcp794xx | ||
958 | }, | ||
959 | { | ||
960 | .compatible = "pericom,pt7c4338", | ||
961 | .data = (void *)ds_1307 | ||
962 | }, | ||
963 | { | ||
964 | .compatible = "epson,rx8025", | ||
965 | .data = (void *)rx_8025 | ||
966 | }, | ||
967 | { | ||
968 | .compatible = "isil,isl12057", | ||
969 | .data = (void *)ds_1337 | ||
970 | }, | ||
971 | { | ||
972 | .compatible = "epson,rx8130", | ||
973 | .data = (void *)rx_8130 | ||
974 | }, | ||
975 | { } | ||
976 | }; | ||
977 | MODULE_DEVICE_TABLE(of, ds1307_of_match); | ||
978 | #endif | ||
979 | |||
980 | #ifdef CONFIG_ACPI | ||
981 | static const struct acpi_device_id ds1307_acpi_ids[] = { | ||
982 | { .id = "DS1307", .driver_data = ds_1307 }, | ||
983 | { .id = "DS1308", .driver_data = ds_1308 }, | ||
984 | { .id = "DS1337", .driver_data = ds_1337 }, | ||
985 | { .id = "DS1338", .driver_data = ds_1338 }, | ||
986 | { .id = "DS1339", .driver_data = ds_1339 }, | ||
987 | { .id = "DS1388", .driver_data = ds_1388 }, | ||
988 | { .id = "DS1340", .driver_data = ds_1340 }, | ||
989 | { .id = "DS1341", .driver_data = ds_1341 }, | ||
990 | { .id = "DS3231", .driver_data = ds_3231 }, | ||
991 | { .id = "M41T0", .driver_data = m41t0 }, | ||
992 | { .id = "M41T00", .driver_data = m41t00 }, | ||
993 | { .id = "M41T11", .driver_data = m41t11 }, | ||
994 | { .id = "MCP7940X", .driver_data = mcp794xx }, | ||
995 | { .id = "MCP7941X", .driver_data = mcp794xx }, | ||
996 | { .id = "PT7C4338", .driver_data = ds_1307 }, | ||
997 | { .id = "RX8025", .driver_data = rx_8025 }, | ||
998 | { .id = "ISL12057", .driver_data = ds_1337 }, | ||
999 | { .id = "RX8130", .driver_data = rx_8130 }, | ||
1000 | { } | ||
1001 | }; | ||
1002 | MODULE_DEVICE_TABLE(acpi, ds1307_acpi_ids); | ||
1003 | #endif | ||
1004 | |||
1005 | /* | ||
1006 | * The ds1337 and ds1339 both have two alarms, but we only use the first | ||
1007 | * one (with a "seconds" field). For ds1337 we expect nINTA is our alarm | ||
1008 | * signal; ds1339 chips have only one alarm signal. | ||
1009 | */ | ||
1010 | static irqreturn_t ds1307_irq(int irq, void *dev_id) | ||
1011 | { | ||
1012 | struct ds1307 *ds1307 = dev_id; | ||
1013 | struct mutex *lock = &ds1307->rtc->ops_lock; | ||
1014 | int stat, ret; | ||
1015 | |||
1016 | mutex_lock(lock); | ||
1017 | ret = regmap_read(ds1307->regmap, DS1337_REG_STATUS, &stat); | ||
1018 | if (ret) | ||
1019 | goto out; | ||
1020 | |||
1021 | if (stat & DS1337_BIT_A1I) { | ||
1022 | stat &= ~DS1337_BIT_A1I; | ||
1023 | regmap_write(ds1307->regmap, DS1337_REG_STATUS, stat); | ||
1024 | |||
1025 | ret = regmap_update_bits(ds1307->regmap, DS1337_REG_CONTROL, | ||
1026 | DS1337_BIT_A1IE, 0); | ||
1027 | if (ret) | ||
1028 | goto out; | ||
1029 | |||
1030 | rtc_update_irq(ds1307->rtc, 1, RTC_AF | RTC_IRQF); | ||
1031 | } | ||
1032 | |||
1033 | out: | ||
1034 | mutex_unlock(lock); | ||
1035 | |||
1036 | return IRQ_HANDLED; | ||
1037 | } | ||
1038 | |||
1039 | /*----------------------------------------------------------------------*/ | ||
1040 | |||
1041 | static const struct rtc_class_ops ds13xx_rtc_ops = { | ||
1042 | .read_time = ds1307_get_time, | ||
1043 | .set_time = ds1307_set_time, | ||
1044 | .read_alarm = ds1337_read_alarm, | ||
1045 | .set_alarm = ds1337_set_alarm, | ||
1046 | .alarm_irq_enable = ds1307_alarm_irq_enable, | ||
1047 | }; | ||
1048 | |||
1053 | static ssize_t frequency_test_store(struct device *dev, | 1049 | static ssize_t frequency_test_store(struct device *dev, |
1054 | struct device_attribute *attr, | 1050 | struct device_attribute *attr, |
1055 | const char *buf, size_t count) | 1051 | const char *buf, size_t count) |
@@ -1137,30 +1133,6 @@ static int ds1307_nvram_write(void *priv, unsigned int offset, void *val, | |||
1137 | 1133 | ||
1138 | /*----------------------------------------------------------------------*/ | 1134 | /*----------------------------------------------------------------------*/ |
1139 | 1135 | ||
1140 | static u8 do_trickle_setup_ds1339(struct ds1307 *ds1307, | ||
1141 | u32 ohms, bool diode) | ||
1142 | { | ||
1143 | u8 setup = (diode) ? DS1307_TRICKLE_CHARGER_DIODE : | ||
1144 | DS1307_TRICKLE_CHARGER_NO_DIODE; | ||
1145 | |||
1146 | switch (ohms) { | ||
1147 | case 250: | ||
1148 | setup |= DS1307_TRICKLE_CHARGER_250_OHM; | ||
1149 | break; | ||
1150 | case 2000: | ||
1151 | setup |= DS1307_TRICKLE_CHARGER_2K_OHM; | ||
1152 | break; | ||
1153 | case 4000: | ||
1154 | setup |= DS1307_TRICKLE_CHARGER_4K_OHM; | ||
1155 | break; | ||
1156 | default: | ||
1157 | dev_warn(ds1307->dev, | ||
1158 | "Unsupported ohm value %u in dt\n", ohms); | ||
1159 | return 0; | ||
1160 | } | ||
1161 | return setup; | ||
1162 | } | ||
1163 | |||
1164 | static u8 ds1307_trickle_init(struct ds1307 *ds1307, | 1136 | static u8 ds1307_trickle_init(struct ds1307 *ds1307, |
1165 | const struct chip_desc *chip) | 1137 | const struct chip_desc *chip) |
1166 | { | 1138 | { |