summaryrefslogtreecommitdiff
path: root/firmware/target
diff options
context:
space:
mode:
Diffstat (limited to 'firmware/target')
-rw-r--r--firmware/target/arm/as3525/ascodec-as3525.c35
-rw-r--r--firmware/target/arm/as3525/rtc-target.h27
-rw-r--r--firmware/target/arm/imx31/gigabeat-s/mc13783-target.h4
-rw-r--r--firmware/target/arm/imx31/rtc-target.h27
4 files changed, 84 insertions, 9 deletions
diff --git a/firmware/target/arm/as3525/ascodec-as3525.c b/firmware/target/arm/as3525/ascodec-as3525.c
index 1bd07c57b1..a8ad9706f8 100644
--- a/firmware/target/arm/as3525/ascodec-as3525.c
+++ b/firmware/target/arm/as3525/ascodec-as3525.c
@@ -131,6 +131,16 @@ static unsigned long ascodec_enrd0_shadow = 0;
131 131
132static void ascodec_wait_cb(struct ascodec_request *req); 132static void ascodec_wait_cb(struct ascodec_request *req);
133 133
134/* RTC interrupt and status
135 * Caution: To avoid an extra variable, IRQ_RTC is used as a flag for
136 * ascodec_enrd0_shadow, which conflicts with RVDD_WASLOW, but we're not using
137 * that right now */
138#if CONFIG_RTC
139#define IFRTC_IRQ_RTC IRQ_RTC
140#else /* !CONFIG_RTC */
141#define IFRTC_IRQ_RTC 0
142#endif /* CONFIG_RTC */
143
134/** --debugging help-- **/ 144/** --debugging help-- **/
135 145
136#ifdef DEBUG 146#ifdef DEBUG
@@ -149,7 +159,6 @@ static struct int_audio_counters {
149 159
150#define COUNT_INT(x) IFDEBUG((int_audio_counters.int_##x)++) 160#define COUNT_INT(x) IFDEBUG((int_audio_counters.int_##x)++)
151 161
152
153/** --stock request and callback functionality -- **/ 162/** --stock request and callback functionality -- **/
154 163
155/* init for common request data (call before submitting) */ 164/* init for common request data (call before submitting) */
@@ -510,13 +519,12 @@ static void ascodec_int_audio_cb(struct ascodec_request *req)
510 } 519 }
511 } 520 }
512 521
522#if CONFIG_RTC
513 if (data[2] & IRQ_RTC) { /* rtc irq */ 523 if (data[2] & IRQ_RTC) { /* rtc irq */
514 /* 524 ascodec_enrd0_shadow |= IRQ_RTC;
515 * Can be configured for once per second or once per minute,
516 * default is once per second
517 */
518 COUNT_INT(rtc); 525 COUNT_INT(rtc);
519 } 526 }
527#endif /* CONFIG_RTC */
520 528
521 if (data[2] & IRQ_ADC) { /* adc finished */ 529 if (data[2] & IRQ_ADC) { /* adc finished */
522 COUNT_INT(adc); 530 COUNT_INT(adc);
@@ -580,6 +588,14 @@ int ascodec_read_charger(void)
580} 588}
581#endif /* CONFIG_CHARGING */ 589#endif /* CONFIG_CHARGING */
582 590
591#if CONFIG_RTC
592/* read sticky rtc dirty status */
593bool ascodec_rtc_dirty(void)
594{
595 return bitclr32(&ascodec_enrd0_shadow, IRQ_RTC) & IRQ_RTC;
596}
597#endif /* CONFIG_RTC */
598
583/* 599/*
584 * NOTE: 600 * NOTE:
585 * After the conversion to interrupts, ascodec_(lock|unlock) are only used by 601 * After the conversion to interrupts, ascodec_(lock|unlock) are only used by
@@ -635,8 +651,9 @@ void ascodec_init(void)
635 VIC_INT_ENABLE = INTERRUPT_I2C_AUDIO; 651 VIC_INT_ENABLE = INTERRUPT_I2C_AUDIO;
636 VIC_INT_ENABLE = INTERRUPT_AUDIO; 652 VIC_INT_ENABLE = INTERRUPT_AUDIO;
637 653
638 /* detect if USB was connected at startup since there is no transition */ 654 /* detect if USB was connected at startup since there is no transition;
639 ascodec_enrd0_shadow = ascodec_read(AS3514_IRQ_ENRD0); 655 force an initial read of the clock (if CONFIG_RTC) */
656 ascodec_enrd0_shadow = ascodec_read(AS3514_IRQ_ENRD0) | IFRTC_IRQ_RTC;
640 if(ascodec_enrd0_shadow & USB_STATUS) 657 if(ascodec_enrd0_shadow & USB_STATUS)
641 usb_insert_int(); 658 usb_insert_int();
642 659
@@ -651,10 +668,10 @@ void ascodec_init(void)
651 /* XIRQ = IRQ, active low reset signal, 6mA push-pull output */ 668 /* XIRQ = IRQ, active low reset signal, 6mA push-pull output */
652 ascodec_write_pmu(0x1a, 3, (1<<2)|3); /* 1A-3 = Out_Cntr3 register */ 669 ascodec_write_pmu(0x1a, 3, (1<<2)|3); /* 1A-3 = Out_Cntr3 register */
653 /* Generate irq on (rtc,) adc change */ 670 /* Generate irq on (rtc,) adc change */
654 ascodec_write(AS3514_IRQ_ENRD2, /*IRQ_RTC |*/ IRQ_ADC); 671 ascodec_write(AS3514_IRQ_ENRD2, IFRTC_IRQ_RTC | IRQ_ADC);
655#else 672#else
656 /* Generate irq for push-pull, active high, irq on rtc+adc change */ 673 /* Generate irq for push-pull, active high, irq on rtc+adc change */
657 ascodec_write(AS3514_IRQ_ENRD2, IRQ_PUSHPULL | IRQ_HIGHACTIVE | 674 ascodec_write(AS3514_IRQ_ENRD2, IRQ_PUSHPULL | IRQ_HIGHACTIVE |
658 /*IRQ_RTC |*/ IRQ_ADC); 675 IFRTC_IRQ_RTC | IRQ_ADC);
659#endif 676#endif
660} 677}
diff --git a/firmware/target/arm/as3525/rtc-target.h b/firmware/target/arm/as3525/rtc-target.h
new file mode 100644
index 0000000000..900aa357d0
--- /dev/null
+++ b/firmware/target/arm/as3525/rtc-target.h
@@ -0,0 +1,27 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
9 *
10 * Copyright (C) 2017 by Michael Sevakis
11 *
12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License
14 * as published by the Free Software Foundation; either version 2
15 * of the License, or (at your option) any later version.
16 *
17 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
18 * KIND, either express or implied.
19 *
20 ****************************************************************************/
21#ifndef RTC_TARGET_H
22#define RTC_TARGET_H
23
24bool ascodec_rtc_dirty(void);
25#define rtc_dirty ascodec_rtc_dirty
26
27#endif /* RTC_TARGET_H */
diff --git a/firmware/target/arm/imx31/gigabeat-s/mc13783-target.h b/firmware/target/arm/imx31/gigabeat-s/mc13783-target.h
index 179c65cad6..4bb148e36c 100644
--- a/firmware/target/arm/imx31/gigabeat-s/mc13783-target.h
+++ b/firmware/target/arm/imx31/gigabeat-s/mc13783-target.h
@@ -46,6 +46,10 @@ static struct spi_node mc13783_spi =
46MC13783_EVENT_VECTOR_TBL_START() 46MC13783_EVENT_VECTOR_TBL_START()
47 /* ADC conversion complete */ 47 /* ADC conversion complete */
48 MC13783_EVENT_VECTOR(ADCDONE, 0) 48 MC13783_EVENT_VECTOR(ADCDONE, 0)
49#if CONFIG_RTC
50 /* RTC tick */
51 MC13783_EVENT_VECTOR(1HZ, 0)
52#endif /* CONFIG_RTC */
49 /* Power button */ 53 /* Power button */
50 MC13783_EVENT_VECTOR(ONOFD1, MC13783_ONOFD1S) 54 MC13783_EVENT_VECTOR(ONOFD1, MC13783_ONOFD1S)
51 /* Main charger detection */ 55 /* Main charger detection */
diff --git a/firmware/target/arm/imx31/rtc-target.h b/firmware/target/arm/imx31/rtc-target.h
new file mode 100644
index 0000000000..b6dc46204d
--- /dev/null
+++ b/firmware/target/arm/imx31/rtc-target.h
@@ -0,0 +1,27 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
9 *
10 * Copyright (C) 2017 by Michael Sevakis
11 *
12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License
14 * as published by the Free Software Foundation; either version 2
15 * of the License, or (at your option) any later version.
16 *
17 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
18 * KIND, either express or implied.
19 *
20 ****************************************************************************/
21#ifndef RTC_TARGET_H
22#define RTC_TARGET_H
23
24bool rtc_mc13783_dirty(void);
25#define rtc_dirty rtc_mc13783_dirty
26
27#endif /* RTC_TARGET_H */