summaryrefslogtreecommitdiff
path: root/firmware/target/arm/imx31/gigabeat-s
diff options
context:
space:
mode:
Diffstat (limited to 'firmware/target/arm/imx31/gigabeat-s')
-rw-r--r--firmware/target/arm/imx31/gigabeat-s/adc-gigabeat-s.c4
-rw-r--r--firmware/target/arm/imx31/gigabeat-s/adc-target.h1
-rw-r--r--firmware/target/arm/imx31/gigabeat-s/button-gigabeat-s.c8
-rw-r--r--firmware/target/arm/imx31/gigabeat-s/button-target.h2
-rw-r--r--firmware/target/arm/imx31/gigabeat-s/fmradio-i2c-gigabeat-s.c41
-rw-r--r--firmware/target/arm/imx31/gigabeat-s/gpio-gigabeat-s.c52
-rw-r--r--firmware/target/arm/imx31/gigabeat-s/gpio-target.h51
-rw-r--r--firmware/target/arm/imx31/gigabeat-s/headphone-gigabeat-s.c5
-rw-r--r--firmware/target/arm/imx31/gigabeat-s/mc13783-gigabeat-s.c86
-rw-r--r--firmware/target/arm/imx31/gigabeat-s/mc13783-target.h44
-rw-r--r--firmware/target/arm/imx31/gigabeat-s/power-gigabeat-s.c6
-rw-r--r--firmware/target/arm/imx31/gigabeat-s/power-gigabeat-s.h1
-rw-r--r--firmware/target/arm/imx31/gigabeat-s/usb-gigabeat-s.c6
13 files changed, 96 insertions, 211 deletions
diff --git a/firmware/target/arm/imx31/gigabeat-s/adc-gigabeat-s.c b/firmware/target/arm/imx31/gigabeat-s/adc-gigabeat-s.c
index b46fc2f63f..2a89a82e46 100644
--- a/firmware/target/arm/imx31/gigabeat-s/adc-gigabeat-s.c
+++ b/firmware/target/arm/imx31/gigabeat-s/adc-gigabeat-s.c
@@ -111,7 +111,7 @@ bool adc_enable_channel(int channel, bool enable)
111} 111}
112 112
113/* ADC conversion complete event - called from PMIC ISR */ 113/* ADC conversion complete event - called from PMIC ISR */
114void adc_done(void) 114void MC13783_EVENT_CB_ADCDONE(void)
115{ 115{
116 semaphore_release(&adc_done_signal); 116 semaphore_release(&adc_done_signal);
117} 117}
@@ -132,5 +132,5 @@ void adc_init(void)
132 132
133 /* Enable ADCDONE event */ 133 /* Enable ADCDONE event */
134 mc13783_write(MC13783_INTERRUPT_STATUS0, MC13783_ADCDONEI); 134 mc13783_write(MC13783_INTERRUPT_STATUS0, MC13783_ADCDONEI);
135 mc13783_enable_event(MC13783_ADCDONE_EVENT, true); 135 mc13783_enable_event(MC13783_INT_ID_ADCDONE, true);
136} 136}
diff --git a/firmware/target/arm/imx31/gigabeat-s/adc-target.h b/firmware/target/arm/imx31/gigabeat-s/adc-target.h
index 00027e05df..dbca920b26 100644
--- a/firmware/target/arm/imx31/gigabeat-s/adc-target.h
+++ b/firmware/target/arm/imx31/gigabeat-s/adc-target.h
@@ -46,7 +46,6 @@
46#define ADC_UNREG_POWER ADC_BATTERY /* For compatibility */ 46#define ADC_UNREG_POWER ADC_BATTERY /* For compatibility */
47#define ADC_READ_ERROR 0xFFFF 47#define ADC_READ_ERROR 0xFFFF
48 48
49void adc_done(void);
50/* Enable conversion of specified channel (if switchoff is possible) */ 49/* Enable conversion of specified channel (if switchoff is possible) */
51bool adc_enable_channel(int channel, bool enable); 50bool adc_enable_channel(int channel, bool enable);
52 51
diff --git a/firmware/target/arm/imx31/gigabeat-s/button-gigabeat-s.c b/firmware/target/arm/imx31/gigabeat-s/button-gigabeat-s.c
index 3972e5722f..cdd6da041b 100644
--- a/firmware/target/arm/imx31/gigabeat-s/button-gigabeat-s.c
+++ b/firmware/target/arm/imx31/gigabeat-s/button-gigabeat-s.c
@@ -157,9 +157,9 @@ static void power_button_update(bool pressed)
157} 157}
158 158
159/* Power button event - called from PMIC ISR */ 159/* Power button event - called from PMIC ISR */
160void button_power_event(void) 160void MC13783_EVENT_CB_ONOFD1(void)
161{ 161{
162 power_button_update(!mc13783_event_sense(MC13783_ONOFD1_EVENT)); 162 power_button_update(!mc13783_event_sense());
163} 163}
164 164
165void button_init_device(void) 165void button_init_device(void)
@@ -197,7 +197,7 @@ void button_init_device(void)
197 197
198 power_button_update(!(mc13783_read(MC13783_INTERRUPT_SENSE1) 198 power_button_update(!(mc13783_read(MC13783_INTERRUPT_SENSE1)
199 & MC13783_ONOFD1S)); 199 & MC13783_ONOFD1S));
200 mc13783_enable_event(MC13783_ONOFD1_EVENT, true); 200 mc13783_enable_event(MC13783_INT_ID_ONOFD1, true);
201 201
202#ifdef HAVE_HEADPHONE_DETECTION 202#ifdef HAVE_HEADPHONE_DETECTION
203 headphone_init(); 203 headphone_init();
@@ -213,7 +213,7 @@ void button_close_device(void)
213 /* Assumes HP detection is not available */ 213 /* Assumes HP detection is not available */
214 initialized = false; 214 initialized = false;
215 215
216 mc13783_enable_event(MC13783_ONOFD1_EVENT, false); 216 mc13783_enable_event(MC13783_INT_ID_ONOFD1, false);
217 ext_btn = BUTTON_NONE; 217 ext_btn = BUTTON_NONE;
218} 218}
219#endif /* BUTTON_DRIVER_CLOSE */ 219#endif /* BUTTON_DRIVER_CLOSE */
diff --git a/firmware/target/arm/imx31/gigabeat-s/button-target.h b/firmware/target/arm/imx31/gigabeat-s/button-target.h
index ce624ed6cc..fba02d5dd2 100644
--- a/firmware/target/arm/imx31/gigabeat-s/button-target.h
+++ b/firmware/target/arm/imx31/gigabeat-s/button-target.h
@@ -30,8 +30,6 @@
30#endif 30#endif
31 31
32void button_close_device(void); 32void button_close_device(void);
33void button_power_event(void);
34void headphone_detect_event(void);
35void headphone_init(void); 33void headphone_init(void);
36void button_headphone_set(int button); 34void button_headphone_set(int button);
37 35
diff --git a/firmware/target/arm/imx31/gigabeat-s/fmradio-i2c-gigabeat-s.c b/firmware/target/arm/imx31/gigabeat-s/fmradio-i2c-gigabeat-s.c
index 108a6d0944..ee91b99c0f 100644
--- a/firmware/target/arm/imx31/gigabeat-s/fmradio-i2c-gigabeat-s.c
+++ b/firmware/target/arm/imx31/gigabeat-s/fmradio-i2c-gigabeat-s.c
@@ -26,7 +26,7 @@
26#include "thread.h" 26#include "thread.h"
27#include "mc13783.h" 27#include "mc13783.h"
28#include "iomuxc-imx31.h" 28#include "iomuxc-imx31.h"
29#include "gpio-imx31.h" 29#include "gpio-target.h"
30#include "i2c-imx31.h" 30#include "i2c-imx31.h"
31#include "fmradio_i2c.h" 31#include "fmradio_i2c.h"
32#include "rds.h" 32#include "rds.h"
@@ -139,20 +139,25 @@ static struct si4700_i2c_transfer_desc
139 .xfer = { .node = &si4700_i2c_node } 139 .xfer = { .node = &si4700_i2c_node }
140}; 140};
141 141
142static bool int_restore;
143
142static void si4700_rds_read_raw_callback(struct i2c_transfer_desc *xfer) 144static void si4700_rds_read_raw_callback(struct i2c_transfer_desc *xfer)
143{ 145{
144 struct si4700_i2c_transfer_desc *xf = 146 struct si4700_i2c_transfer_desc *xf =
145 (struct si4700_i2c_transfer_desc *)xfer; 147 (struct si4700_i2c_transfer_desc *)xfer;
146 148
147 if (xfer->rxcount != 0) 149 if (xfer->rxcount == 0)
148 return; /* Read didn't finish */ 150 {
149 151 uint16_t rds_data[4];
150 uint16_t rds_data[4]; 152 si4700_rds_read_raw_async_complete(xf->regbuf, rds_data);
151 153
152 si4700_rds_read_raw_async_complete(xf->regbuf, rds_data); 154 if (rds_process(rds_data))
155 si4700_rds_set_event();
156 }
157 /* else read didn't finish */
153 158
154 if (rds_process(rds_data)) 159 if (int_restore)
155 si4700_rds_set_event(); 160 gpio_int_enable(SI4700_EVENT_ID);
156} 161}
157 162
158/* Callback from si4700_rds_read_raw to execute the read */ 163/* Callback from si4700_rds_read_raw to execute the read */
@@ -169,10 +174,13 @@ void si4700_read_raw_async(int count)
169} 174}
170 175
171/* RDS GPIO interrupt handler - start RDS data read */ 176/* RDS GPIO interrupt handler - start RDS data read */
172void si4700_stc_rds_event(void) 177void INT_SI4700_RDS(void)
173{ 178{
174 /* read and clear the interrupt */ 179 /* mask and clear the interrupt */
175 SI4700_GPIO_STC_RDS_ISR = (1ul << SI4700_GPIO_STC_RDS_LINE); 180 gpio_int_disable(SI4700_EVENT_ID);
181 gpio_int_clear(SI4700_EVENT_ID);
182
183 /* read the RDS data */
176 si4700_rds_read_raw_async(); 184 si4700_rds_read_raw_async();
177} 185}
178 186
@@ -180,13 +188,10 @@ void si4700_stc_rds_event(void)
180 powering down */ 188 powering down */
181void si4700_rds_powerup(bool on) 189void si4700_rds_powerup(bool on)
182{ 190{
183 gpio_disable_event(SI4700_STC_RDS_EVENT_ID); 191 int_restore = on;
184 192 gpio_int_disable(SI4700_EVENT_ID);
185 if (on) 193 gpio_int_clear(SI4700_EVENT_ID);
186 { 194 gpio_enable_event(SI4700_EVENT_ID, on);
187 SI4700_GPIO_STC_RDS_ISR = (1ul << SI4700_GPIO_STC_RDS_LINE);
188 gpio_enable_event(SI4700_STC_RDS_EVENT_ID);
189 }
190} 195}
191 196
192/* One-time RDS init at startup */ 197/* One-time RDS init at startup */
diff --git a/firmware/target/arm/imx31/gigabeat-s/gpio-gigabeat-s.c b/firmware/target/arm/imx31/gigabeat-s/gpio-gigabeat-s.c
deleted file mode 100644
index 51446934aa..0000000000
--- a/firmware/target/arm/imx31/gigabeat-s/gpio-gigabeat-s.c
+++ /dev/null
@@ -1,52 +0,0 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
9 *
10 * Copyright (c) 2008 by Michael Sevakis
11 *
12 * Gigabeat S GPIO interrupt event descriptions
13 *
14 * This program is free software; you can redistribute it and/or
15 * modify it under the terms of the GNU General Public License
16 * as published by the Free Software Foundation; either version 2
17 * of the License, or (at your option) any later version.
18 *
19 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
20 * KIND, either express or implied.
21 *
22 ****************************************************************************/
23#include "config.h"
24#include "system.h"
25#include "avic-imx31.h"
26#include "gpio-imx31.h"
27
28/* Gigabeat S definitions for static GPIO event registration */
29
30/* Describes single events for each GPIO1 pin */
31const struct gpio_event gpio1_events[] =
32{
33 /* mc13783 keeps the PRIINT high (no low pulse) if other unmasked
34 * interrupts become active when clearing them or if a source being
35 * cleared becomes active at that time. Edge-detection will not get
36 * a rising edge in that case so use high-level sense. */
37 [MC13783_EVENT_ID-GPIO1_EVENT_FIRST] =
38 {
39 .mask = 1 << MC13783_GPIO_LINE,
40 .sense = GPIO_SENSE_HIGH_LEVEL,
41 .callback = mc13783_event,
42 },
43#ifndef BOOTLOADER
44 /* Generates a 5ms low pulse on the line - detect the falling edge */
45 [SI4700_STC_RDS_EVENT_ID] =
46 {
47 .mask = 1 << SI4700_GPIO_STC_RDS_LINE,
48 .sense = GPIO_SENSE_FALLING,
49 .callback = si4700_stc_rds_event,
50 },
51#endif
52};
diff --git a/firmware/target/arm/imx31/gigabeat-s/gpio-target.h b/firmware/target/arm/imx31/gigabeat-s/gpio-target.h
index 4903d0f631..543b25f244 100644
--- a/firmware/target/arm/imx31/gigabeat-s/gpio-target.h
+++ b/firmware/target/arm/imx31/gigabeat-s/gpio-target.h
@@ -23,34 +23,33 @@
23#ifndef GPIO_TARGET_H 23#ifndef GPIO_TARGET_H
24#define GPIO_TARGET_H 24#define GPIO_TARGET_H
25 25
26/* MC13783 GPIO pin info for this target */ 26/* Gigabeat S definitions for static GPIO event registration */
27#define MC13783_GPIO_IMR GPIO1_IMR 27#include "gpio-imx31.h"
28#define MC13783_GPIO_NUM GPIO1_NUM 28
29#define MC13783_GPIO_ISR GPIO1_ISR 29#ifdef DEFINE_GPIO_VECTOR_TABLE
30#define MC13783_GPIO_LINE 31 30
31 31GPIO_VECTOR_TBL_START()
32/* SI4700 GPIO STC/RDS pin info for this target */ 32 /* mc13783 keeps the PRIINT high (no low pulse) if other unmasked
33#define SI4700_GPIO_STC_RDS_IMR GPIO1_IMR 33 * interrupts become active when clearing them or if a source being
34#define SI4700_GPIO_STC_RDS_NUM GPIO1_NUM 34 * cleared becomes active at that time. Edge-detection will not get
35#define SI4700_GPIO_STC_RDS_ISR GPIO1_ISR 35 * a rising edge in that case so use high-level sense. */
36#define SI4700_GPIO_STC_RDS_LINE 27 36 GPIO_EVENT_VECTOR(GPIO1_31, GPIO_SENSE_HIGH_LEVEL)
37#if CONFIG_TUNER
38 /* Generates a 5ms low pulse on the line - detect the falling edge */
39 GPIO_EVENT_VECTOR(GPIO1_27, GPIO_SENSE_FALLING)
40#endif /* CONFIG_TUNER */
41GPIO_VECTOR_TBL_END()
37 42
38#define GPIO1_INT_PRIO INT_PRIO_DEFAULT 43#define GPIO1_INT_PRIO INT_PRIO_DEFAULT
39 44
40/* Declare event indexes in priority order in a packed array */ 45#endif /* DEFINE_GPIO_VECTOR_TABLE */
41enum gpio_event_ids 46
42{ 47#define INT_MC13783 GPIO1_31_EVENT_CB
43 /* GPIO1 event IDs */ 48#define MC13783_EVENT_ID GPIO1_31_ID
44 MC13783_EVENT_ID = GPIO1_EVENT_FIRST, 49
45 SI4700_STC_RDS_EVENT_ID, 50#if CONFIG_TUNER
46 GPIO1_NUM_EVENTS = 2, 51#define INT_SI4700_RDS GPIO1_27_EVENT_CB
47 /* GPIO2 event IDs */ 52#define SI4700_EVENT_ID GPIO1_27_ID
48 /* none defined */ 53#endif /* CONFIG_TUNER */
49 /* GPIO3 event IDs */
50 /* none defined */
51};
52
53void mc13783_event(void);
54void si4700_stc_rds_event(void);
55 54
56#endif /* GPIO_TARGET_H */ 55#endif /* GPIO_TARGET_H */
diff --git a/firmware/target/arm/imx31/gigabeat-s/headphone-gigabeat-s.c b/firmware/target/arm/imx31/gigabeat-s/headphone-gigabeat-s.c
index 6fdde32185..cf0a378fc7 100644
--- a/firmware/target/arm/imx31/gigabeat-s/headphone-gigabeat-s.c
+++ b/firmware/target/arm/imx31/gigabeat-s/headphone-gigabeat-s.c
@@ -25,7 +25,6 @@
25#include "kernel.h" 25#include "kernel.h"
26#include "thread.h" 26#include "thread.h"
27#include "mc13783.h" 27#include "mc13783.h"
28#include "mc13783-target.h"
29#include "adc.h" 28#include "adc.h"
30#include "button.h" 29#include "button.h"
31 30
@@ -146,7 +145,7 @@ static void NORETURN_ATTR headphone_thread(void)
146} 145}
147 146
148/* HP plugged/unplugged event - called from PMIC ISR */ 147/* HP plugged/unplugged event - called from PMIC ISR */
149void headphone_detect_event(void) 148void MC13783_EVENT_CB_ONOFD2(void)
150{ 149{
151 /* Trigger the thread immediately. */ 150 /* Trigger the thread immediately. */
152 semaphore_release(&headphone_wakeup); 151 semaphore_release(&headphone_wakeup);
@@ -170,5 +169,5 @@ void INIT_ATTR headphone_init(void)
170 IF_COP(, CPU)); 169 IF_COP(, CPU));
171 170
172 /* Enable PMIC event */ 171 /* Enable PMIC event */
173 mc13783_enable_event(MC13783_ONOFD2_EVENT, true); 172 mc13783_enable_event(MC13783_INT_ID_ONOFD2, true);
174} 173}
diff --git a/firmware/target/arm/imx31/gigabeat-s/mc13783-gigabeat-s.c b/firmware/target/arm/imx31/gigabeat-s/mc13783-gigabeat-s.c
deleted file mode 100644
index 76001dddd6..0000000000
--- a/firmware/target/arm/imx31/gigabeat-s/mc13783-gigabeat-s.c
+++ /dev/null
@@ -1,86 +0,0 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
9 *
10 * Copyright (c) 2008 by Michael Sevakis
11 *
12 * Gigabeat S MC13783 event descriptions
13 *
14 * This program is free software; you can redistribute it and/or
15 * modify it under the terms of the GNU General Public License
16 * as published by the Free Software Foundation; either version 2
17 * of the License, or (at your option) any later version.
18 *
19 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
20 * KIND, either express or implied.
21 *
22 ****************************************************************************/
23#include "config.h"
24#include "system.h"
25#include "spi-imx31.h"
26#include "mc13783.h"
27#include "mc13783-target.h"
28#include "adc-target.h"
29#include "button-target.h"
30#include "power-gigabeat-s.h"
31#include "powermgmt-target.h"
32
33/* Gigabeat S mc13783 serial interface node. */
34
35struct spi_node mc13783_spi =
36{
37 /* Based upon original firmware settings */
38 CSPI2_NUM, /* CSPI module 2 */
39 CSPI_CONREG_CHIP_SELECT_SS0 | /* Chip select 0 */
40 CSPI_CONREG_DRCTL_DONT_CARE | /* Don't care about CSPI_RDY */
41 CSPI_CONREG_DATA_RATE_DIV_32 | /* Clock = IPG_CLK/32 = 2,062,500Hz. */
42 CSPI_BITCOUNT(32-1) | /* All 32 bits are to be transferred */
43 CSPI_CONREG_SSPOL | /* SS active high */
44 CSPI_CONREG_SSCTL | /* Negate SS between SPI bursts */
45 CSPI_CONREG_MODE, /* Master mode */
46 0, /* SPI clock - no wait states */
47};
48
49
50/* Gigabeat S definitions for static MC13783 event registration */
51
52const struct mc13783_event mc13783_events[MC13783_NUM_EVENTS] =
53{
54 [MC13783_ADCDONE_EVENT] = /* ADC conversion complete */
55 {
56 .int_id = MC13783_INT_ID_ADCDONE,
57 .sense = 0,
58 .callback = adc_done,
59 },
60 [MC13783_ONOFD1_EVENT] = /* Power button */
61 {
62 .int_id = MC13783_INT_ID_ONOFD1,
63 .sense = MC13783_ONOFD1S,
64 .callback = button_power_event,
65 },
66 [MC13783_SE1_EVENT] = /* Main charger detection */
67 {
68 .int_id = MC13783_INT_ID_SE1,
69 .sense = MC13783_SE1S,
70 .callback = charger_main_detect_event,
71 },
72 [MC13783_USB_EVENT] = /* USB insertion/USB charger detection */
73 {
74 .int_id = MC13783_INT_ID_USB,
75 .sense = MC13783_USB4V4S,
76 .callback = usb_connect_event,
77 },
78#ifdef HAVE_HEADPHONE_DETECTION
79 [MC13783_ONOFD2_EVENT] = /* Headphone jack */
80 {
81 .int_id = MC13783_INT_ID_ONOFD2,
82 .sense = 0,
83 .callback = headphone_detect_event,
84 },
85#endif
86};
diff --git a/firmware/target/arm/imx31/gigabeat-s/mc13783-target.h b/firmware/target/arm/imx31/gigabeat-s/mc13783-target.h
index 48d634035a..179c65cad6 100644
--- a/firmware/target/arm/imx31/gigabeat-s/mc13783-target.h
+++ b/firmware/target/arm/imx31/gigabeat-s/mc13783-target.h
@@ -23,17 +23,41 @@
23#ifndef MC13783_TARGET_H 23#ifndef MC13783_TARGET_H
24#define MC13783_TARGET_H 24#define MC13783_TARGET_H
25 25
26/* Declare event indexes in priority order in a packed array */ 26#include "mc13783.h"
27enum mc13783_event_ids 27
28#ifdef DEFINE_MC13783_VECTOR_TABLE
29
30/* Gigabeat S mc13783 serial interface node. */
31static struct spi_node mc13783_spi =
28{ 32{
29 MC13783_ADCDONE_EVENT = 0, /* ADC conversion complete */ 33 /* Based upon original firmware settings */
30 MC13783_ONOFD1_EVENT, /* Power button */ 34 CSPI2_NUM, /* CSPI module 2 */
31#ifdef HAVE_HEADPHONE_DETECTION 35 CSPI_CONREG_CHIP_SELECT_SS0 | /* Chip select 0 */
32 MC13783_ONOFD2_EVENT, /* Headphone jack */ 36 CSPI_CONREG_DRCTL_DONT_CARE | /* Don't care about CSPI_RDY */
33#endif 37 CSPI_CONREG_DATA_RATE_DIV_32 | /* Clock = IPG_CLK/32 = 2,062,500Hz. */
34 MC13783_SE1_EVENT, /* Main charger detection */ 38 CSPI_BITCOUNT(32-1) | /* All 32 bits are to be transferred */
35 MC13783_USB_EVENT, /* USB insertion */ 39 CSPI_CONREG_SSPOL | /* SS active high */
36 MC13783_NUM_EVENTS, 40 CSPI_CONREG_SSCTL | /* Negate SS between SPI bursts */
41 CSPI_CONREG_MODE, /* Master mode */
42 0, /* SPI clock - no wait states */
37}; 43};
38 44
45/* Gigabeat S definitions for static MC13783 event registration */
46MC13783_EVENT_VECTOR_TBL_START()
47 /* ADC conversion complete */
48 MC13783_EVENT_VECTOR(ADCDONE, 0)
49 /* Power button */
50 MC13783_EVENT_VECTOR(ONOFD1, MC13783_ONOFD1S)
51 /* Main charger detection */
52 MC13783_EVENT_VECTOR(SE1, MC13783_SE1S)
53 /* USB insertion/USB charger detection */
54 MC13783_EVENT_VECTOR(USB, MC13783_USB4V4S)
55#ifdef HAVE_HEADPHONE_DETECTION
56 /* Headphone jack */
57 MC13783_EVENT_VECTOR(ONOFD2, 0)
58#endif /* HAVE_HEADPHONE_DETECTION */
59MC13783_EVENT_VECTOR_TBL_END()
60
61#endif /* DEFINE_MC13783_VECTOR_TABLE */
62
39#endif /* MC13783_TARGET_H */ 63#endif /* MC13783_TARGET_H */
diff --git a/firmware/target/arm/imx31/gigabeat-s/power-gigabeat-s.c b/firmware/target/arm/imx31/gigabeat-s/power-gigabeat-s.c
index 5d89802bc9..81f150acd7 100644
--- a/firmware/target/arm/imx31/gigabeat-s/power-gigabeat-s.c
+++ b/firmware/target/arm/imx31/gigabeat-s/power-gigabeat-s.c
@@ -66,9 +66,9 @@ static void update_main_charger(bool present)
66} 66}
67 67
68/* Detect changes in presence of the AC adaptor. Called from PMIC ISR. */ 68/* Detect changes in presence of the AC adaptor. Called from PMIC ISR. */
69void charger_main_detect_event(void) 69void MC13783_EVENT_CB_SE1(void)
70{ 70{
71 update_main_charger(mc13783_event_sense(MC13783_SE1_EVENT)); 71 update_main_charger(mc13783_event_sense());
72} 72}
73 73
74/* Detect changes in USB bus power. Called from usb connect event ISR. */ 74/* Detect changes in USB bus power. Called from usb connect event ISR. */
@@ -159,5 +159,5 @@ void power_init(void)
159 & MC13783_SE1S); 159 & MC13783_SE1S);
160 160
161 /* Enable detect event */ 161 /* Enable detect event */
162 mc13783_enable_event(MC13783_SE1_EVENT, true); 162 mc13783_enable_event(MC13783_INT_ID_SE1, true);
163} 163}
diff --git a/firmware/target/arm/imx31/gigabeat-s/power-gigabeat-s.h b/firmware/target/arm/imx31/gigabeat-s/power-gigabeat-s.h
index 9294de102c..2cd509267c 100644
--- a/firmware/target/arm/imx31/gigabeat-s/power-gigabeat-s.h
+++ b/firmware/target/arm/imx31/gigabeat-s/power-gigabeat-s.h
@@ -21,7 +21,6 @@
21#ifndef POWER_IMX31_H 21#ifndef POWER_IMX31_H
22#define POWER_IMX31_H 22#define POWER_IMX31_H
23 23
24void charger_main_detect_event(void);
25void charger_usb_detect_event(int status); 24void charger_usb_detect_event(int status);
26 25
27#endif /* POWER_IMX31_H */ 26#endif /* POWER_IMX31_H */
diff --git a/firmware/target/arm/imx31/gigabeat-s/usb-gigabeat-s.c b/firmware/target/arm/imx31/gigabeat-s/usb-gigabeat-s.c
index 9129568b7a..71e8342595 100644
--- a/firmware/target/arm/imx31/gigabeat-s/usb-gigabeat-s.c
+++ b/firmware/target/arm/imx31/gigabeat-s/usb-gigabeat-s.c
@@ -70,10 +70,10 @@ static void update_usb_status(bool sense)
70} 70}
71 71
72/* Detect presence of USB bus - called from PMIC ISR */ 72/* Detect presence of USB bus - called from PMIC ISR */
73void usb_connect_event(void) 73void MC13783_EVENT_CB_USB(void)
74{ 74{
75 /* Read the associated sense value */ 75 /* Read the associated sense value */
76 update_usb_status(mc13783_event_sense(MC13783_USB_EVENT)); 76 update_usb_status(mc13783_event_sense());
77} 77}
78 78
79int usb_detect(void) 79int usb_detect(void)
@@ -90,7 +90,7 @@ void usb_init_device(void)
90 update_usb_status(usb_plugged()); 90 update_usb_status(usb_plugged());
91 91
92 /* Enable PMIC event */ 92 /* Enable PMIC event */
93 mc13783_enable_event(MC13783_USB_EVENT, true); 93 mc13783_enable_event(MC13783_INT_ID_USB, true);
94} 94}
95 95
96void usb_enable(bool on) 96void usb_enable(bool on)