forked from len0rd/rockbox
MC13783 (Gigabeat S PMIC): Complete the header file. Distinguish status, sense and mask bit defines to avoid conflicts within the definitions. Much care taken but give a double check before making new use of anything.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@17534 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
parent
16c8f060e6
commit
cda664b701
5 changed files with 1046 additions and 384 deletions
|
@ -254,9 +254,9 @@ bool rtc_check_alarm_flag(void)
|
||||||
bool rtc_enable_alarm(bool enable)
|
bool rtc_enable_alarm(bool enable)
|
||||||
{
|
{
|
||||||
if (enable)
|
if (enable)
|
||||||
mc13783_clear(MC13783_INTERRUPT_MASK1, MC13783_TODA);
|
mc13783_clear(MC13783_INTERRUPT_MASK1, MC13783_TODAM);
|
||||||
else
|
else
|
||||||
mc13783_set(MC13783_INTERRUPT_MASK1, MC13783_TODA);
|
mc13783_set(MC13783_INTERRUPT_MASK1, MC13783_TODAM);
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -102,5 +102,5 @@ void adc_init(void)
|
||||||
mc13783_write(MC13783_ADC1, MC13783_ADEN);
|
mc13783_write(MC13783_ADC1, MC13783_ADEN);
|
||||||
/* Enable the ADCDONE interrupt - notifications are dispatched by
|
/* Enable the ADCDONE interrupt - notifications are dispatched by
|
||||||
* event handler. */
|
* event handler. */
|
||||||
mc13783_clear(MC13783_INTERRUPT_MASK0, MC13783_ADCDONE);
|
mc13783_clear(MC13783_INTERRUPT_MASK0, MC13783_ADCDONEM);
|
||||||
}
|
}
|
||||||
|
|
|
@ -74,18 +74,18 @@ static void mc13783_interrupt_thread(void)
|
||||||
|
|
||||||
gpio_enable_event(MC13783_GPIO_NUM, MC13783_EVENT_ID);
|
gpio_enable_event(MC13783_GPIO_NUM, MC13783_EVENT_ID);
|
||||||
|
|
||||||
if (pending[1] & MC13783_TODA) /* only needs to be polled on startup */
|
if (pending[1] & MC13783_TODAI) /* only needs to be polled on startup */
|
||||||
mc13783_alarm_start();
|
mc13783_alarm_start();
|
||||||
|
|
||||||
/* Check initial states for events with a sense bit */
|
/* Check initial states for events with a sense bit */
|
||||||
value = mc13783_read(MC13783_INTERRUPT_SENSE0);
|
value = mc13783_read(MC13783_INTERRUPT_SENSE0);
|
||||||
usb_set_status(value & MC13783_USB4V4);
|
usb_set_status(value & MC13783_USB4V4S);
|
||||||
set_charger_inserted(value & MC13783_CHGDET);
|
set_charger_inserted(value & MC13783_CHGDETS);
|
||||||
|
|
||||||
value = mc13783_read(MC13783_INTERRUPT_SENSE1);
|
value = mc13783_read(MC13783_INTERRUPT_SENSE1);
|
||||||
button_power_set_state((value & MC13783_ONOFD1) == 0);
|
button_power_set_state((value & MC13783_ONOFD1S) == 0);
|
||||||
#ifdef HAVE_HEADPHONE_DETECTION
|
#ifdef HAVE_HEADPHONE_DETECTION
|
||||||
set_headphones_inserted((value & MC13783_ONOFD2) == 0);
|
set_headphones_inserted((value & MC13783_ONOFD2S) == 0);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
pending[0] = pending[1] = 0xffffff;
|
pending[0] = pending[1] = 0xffffff;
|
||||||
|
@ -93,8 +93,9 @@ static void mc13783_interrupt_thread(void)
|
||||||
|
|
||||||
/* Enable desired PMIC interrupts - some are unmasked in the drivers that
|
/* Enable desired PMIC interrupts - some are unmasked in the drivers that
|
||||||
* handle a specific task */
|
* handle a specific task */
|
||||||
mc13783_clear(MC13783_INTERRUPT_MASK0, MC13783_CHGDET);
|
mc13783_clear(MC13783_INTERRUPT_MASK0, MC13783_CHGDETM);
|
||||||
mc13783_clear(MC13783_INTERRUPT_MASK1, MC13783_ONOFD1 | MC13783_ONOFD2);
|
mc13783_clear(MC13783_INTERRUPT_MASK1, MC13783_ONOFD1M |
|
||||||
|
MC13783_ONOFD2M);
|
||||||
|
|
||||||
while (1)
|
while (1)
|
||||||
{
|
{
|
||||||
|
@ -116,20 +117,20 @@ static void mc13783_interrupt_thread(void)
|
||||||
/* Handle ...PENDING0 */
|
/* Handle ...PENDING0 */
|
||||||
|
|
||||||
/* Handle interrupts without a sense bit */
|
/* Handle interrupts without a sense bit */
|
||||||
if (pending[0] & MC13783_ADCDONE)
|
if (pending[0] & MC13783_ADCDONEI)
|
||||||
adc_done();
|
adc_done();
|
||||||
|
|
||||||
/* Handle interrupts that have a sense bit that needs to
|
/* Handle interrupts that have a sense bit that needs to
|
||||||
* be checked */
|
* be checked */
|
||||||
if (pending[0] & (MC13783_CHGDET | MC13783_USB4V4))
|
if (pending[0] & (MC13783_CHGDETI | MC13783_USB4V4I))
|
||||||
{
|
{
|
||||||
value = mc13783_read(MC13783_INTERRUPT_SENSE0);
|
value = mc13783_read(MC13783_INTERRUPT_SENSE0);
|
||||||
|
|
||||||
if (pending[0] & MC13783_CHGDET)
|
if (pending[0] & MC13783_CHGDETI)
|
||||||
set_charger_inserted(value & MC13783_CHGDET);
|
set_charger_inserted(value & MC13783_CHGDETS);
|
||||||
|
|
||||||
if (pending[0] & MC13783_USB4V4)
|
if (pending[0] & MC13783_USB4V4I)
|
||||||
usb_set_status(value & MC13783_USB4V4);
|
usb_set_status(value & MC13783_USB4V4S);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -142,15 +143,15 @@ static void mc13783_interrupt_thread(void)
|
||||||
|
|
||||||
/* Handle interrupts that have a sense bit that needs to
|
/* Handle interrupts that have a sense bit that needs to
|
||||||
* be checked */
|
* be checked */
|
||||||
if (pending[1] & (MC13783_ONOFD1 | MC13783_ONOFD2))
|
if (pending[1] & (MC13783_ONOFD1I | MC13783_ONOFD2I))
|
||||||
{
|
{
|
||||||
value = mc13783_read(MC13783_INTERRUPT_SENSE1);
|
value = mc13783_read(MC13783_INTERRUPT_SENSE1);
|
||||||
|
|
||||||
if (pending[1] & MC13783_ONOFD1)
|
if (pending[1] & MC13783_ONOFD1I)
|
||||||
button_power_set_state((value & MC13783_ONOFD1) == 0);
|
button_power_set_state((value & MC13783_ONOFD1S) == 0);
|
||||||
#ifdef HAVE_HEADPHONE_DETECTION
|
#ifdef HAVE_HEADPHONE_DETECTION
|
||||||
if (pending[1] & MC13783_ONOFD2)
|
if (pending[1] & MC13783_ONOFD2I)
|
||||||
set_headphones_inserted((value & MC13783_ONOFD2) == 0);
|
set_headphones_inserted((value & MC13783_ONOFD2S) == 0);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -61,7 +61,7 @@ int usb_detect(void)
|
||||||
/* Read the immediate state of the cable from the PMIC */
|
/* Read the immediate state of the cable from the PMIC */
|
||||||
bool usb_plugged(void)
|
bool usb_plugged(void)
|
||||||
{
|
{
|
||||||
return mc13783_read(MC13783_INTERRUPT_SENSE0) & MC13783_USB4V4;
|
return mc13783_read(MC13783_INTERRUPT_SENSE0) & MC13783_USB4V4S;
|
||||||
}
|
}
|
||||||
|
|
||||||
void usb_init_device(void)
|
void usb_init_device(void)
|
||||||
|
@ -73,7 +73,7 @@ void usb_init_device(void)
|
||||||
/* Module will be turned off later after firmware init */
|
/* Module will be turned off later after firmware init */
|
||||||
usb_drv_startup();
|
usb_drv_startup();
|
||||||
|
|
||||||
mc13783_clear(MC13783_INTERRUPT_MASK0, MC13783_USB4V4);
|
mc13783_clear(MC13783_INTERRUPT_MASK0, MC13783_USB4V4M);
|
||||||
}
|
}
|
||||||
|
|
||||||
void usb_enable(bool on)
|
void usb_enable(bool on)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue