diff options
author | Michael Sevakis <jethead71@rockbox.org> | 2017-01-26 21:08:55 -0500 |
---|---|---|
committer | Michael Sevakis <jethead71@rockbox.org> | 2017-11-21 07:52:02 -0500 |
commit | f4c42213062170ddfcc706b3c5ed19f47517c253 (patch) | |
tree | 65f8058970e97d939660cf1e39f844a06df66f84 /firmware/target/arm/as3525/ascodec-as3525.c | |
parent | 12bc24adbf919dc945928b2dcda74d51d33708f7 (diff) | |
download | rockbox-f4c42213062170ddfcc706b3c5ed19f47517c253.tar.gz rockbox-f4c42213062170ddfcc706b3c5ed19f47517c253.zip |
Convert i.MX31 and AMS target to use RTC interrupt
Instead of checking ticks, set a sticky dirty flag that indicates
that the RTC needs to be read. This gives a timely update and more
accurate readout without actually reading the RTC until it changes.
The implementation should atomically read the flag and clear it.
Setting the flag would typically happen in an RTC tick ISR.
Change-Id: I6fd325f22845029a485c502c884812d3676026ea
Diffstat (limited to 'firmware/target/arm/as3525/ascodec-as3525.c')
-rw-r--r-- | firmware/target/arm/as3525/ascodec-as3525.c | 35 |
1 files changed, 26 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 | ||
132 | static void ascodec_wait_cb(struct ascodec_request *req); | 132 | static 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 */ | ||
593 | bool 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 | } |