From db3dca00622c1c390e46315c0caaf93e3ed7bded Mon Sep 17 00:00:00 2001
From: Harald Welte <laforge@gnumonks.org>
Date: Tue, 21 Jun 2011 09:32:28 +0200
Subject: simtrace: add VCC_PHINE IRQ detection

---
 firmware/src/simtrace/sim_switch.c | 19 +++++++++++++++++++
 1 file changed, 19 insertions(+)

(limited to 'firmware/src')

diff --git a/firmware/src/simtrace/sim_switch.c b/firmware/src/simtrace/sim_switch.c
index 118437a..f83290f 100644
--- a/firmware/src/simtrace/sim_switch.c
+++ b/firmware/src/simtrace/sim_switch.c
@@ -57,6 +57,14 @@ static void sw_sim_irq(u_int32_t pio)
 		DEBUGPCR("SIM card removed");
 }
 
+static void vcc_phone_irq(u_int32_t pio)
+{
+	if (!AT91F_PIO_IsInputSet(AT91C_BASE_PIOA, pio))
+		DEBUGPCR("VCC_PHONE off");
+	else
+		DEBUGPCR("VCC_PHONE on");
+}
+
 void sim_switch_init(void)
 {
 	DEBUGPCR("ISO_SW Initializing");
@@ -73,4 +81,15 @@ void sim_switch_init(void)
 	AT91F_PIO_CfgInputFilter(AT91C_BASE_PIOA, SIMTRACE_PIO_SW_SIM);
 	pio_irq_register(SIMTRACE_PIO_SW_SIM, &sw_sim_irq);
 	pio_irq_enable(SIMTRACE_PIO_SW_SIM);
+	/* configure VCC_PHONE detection */
+	AT91F_PIO_CfgInput(AT91C_BASE_PIOA, SIMTRACE_PIO_VCC_PHONE);
+	AT91F_PIO_CfgPullupDis(AT91C_BASE_PIOA, SIMTRACE_PIO_VCC_PHONE);
+	AT91F_PIO_CfgInputFilter(AT91C_BASE_PIOA, SIMTRACE_PIO_VCC_PHONE);
+	pio_irq_register(SIMTRACE_PIO_VCC_PHONE, &vcc_phone_irq);
+	pio_irq_enable(SIMTRACE_PIO_VCC_PHONE);
+
+#if 0
+	AT91F_ADC_CfgPMC();
+	AT91F_ADC_EnableChannel(AT91C_BASE_ADC, AT91C_ADC_CH7);
+#endif
 }
-- 
cgit v1.2.3