summaryrefslogtreecommitdiff
path: root/firmware
diff options
context:
space:
mode:
Diffstat (limited to 'firmware')
-rw-r--r--firmware/Makefile3
-rw-r--r--firmware/src/os/dbgu.c2
-rw-r--r--firmware/src/simtrace/main_simtrace.c11
-rw-r--r--firmware/src/simtrace/sim_switch.c76
-rw-r--r--firmware/src/simtrace/sim_switch.h7
5 files changed, 96 insertions, 3 deletions
diff --git a/firmware/Makefile b/firmware/Makefile
index 57c983e..9a95d44 100644
--- a/firmware/Makefile
+++ b/firmware/Makefile
@@ -115,7 +115,8 @@ endif
ifeq ($(BOARD), SIMTRACE)
SUBMDL = AT91SAM7S256
TARGET := main_simtrace
-SRCARM += src/simtrace/iso7816_uart.c src/simtrace/tc_etu.c
+SRCARM += src/simtrace/iso7816_uart.c src/simtrace/tc_etu.c \
+ src/simtrace/sim_switch.c
SRCARM += src/simtrace/$(TARGET).c
endif
diff --git a/firmware/src/os/dbgu.c b/firmware/src/os/dbgu.c
index 026b56b..28d86a4 100644
--- a/firmware/src/os/dbgu.c
+++ b/firmware/src/os/dbgu.c
@@ -147,7 +147,7 @@ void AT91F_DBGU_Init(void)
sysirq_register(AT91SAM7_SYSIRQ_DBGU, &DBGU_irq_handler);
AT91F_DBGU_Printk("\n\r");
- AT91F_DBGU_Printk("(C) 2006 by Harald Welte <hwelte@hmw-consulting.de>\n\r"
+ AT91F_DBGU_Printk("(C) 2006-2011 by Harald Welte <hwelte@hmw-consulting.de>\n\r"
"This software is FREE SOFTWARE licensed under GNU GPL\n\r");
AT91F_DBGU_Printk("Version " COMPILE_SVNREV
" compiled " COMPILE_DATE
diff --git a/firmware/src/simtrace/main_simtrace.c b/firmware/src/simtrace/main_simtrace.c
index 740d35d..581fd59 100644
--- a/firmware/src/simtrace/main_simtrace.c
+++ b/firmware/src/simtrace/main_simtrace.c
@@ -31,6 +31,7 @@
#include <simtrace/tc_etu.h>
#include <simtrace/iso7816_uart.h>
+#include <simtrace/sim_switch.h>
void _init_func(void)
{
@@ -38,6 +39,7 @@ void _init_func(void)
pio_irq_init();
iso_uart_init();
tc_etu_init();
+ sim_switch_init();
usbtest_init();
@@ -55,7 +57,9 @@ static void help(void)
"c: toggle clock master/slave\r\n"
"l: set nRST to low (active)\r\n"
"h: set nRST to high (inactive)\r\n"
- "o: set nRST to input\r\n");
+ "o: set nRST to input\r\n"
+ "s: disconnect SIM bus switch\r\n"
+ "S: connect SIM bus switch\r\n");
}
int _main_dbgu(char key)
@@ -64,6 +68,11 @@ int _main_dbgu(char key)
DEBUGPCRF("main_dbgu");
switch (key) {
+ case 's':
+ sim_switch_mode(0, 0);
+ break;
+ case 'S':
+ sim_switch_mode(1, 1);
case 'r':
iso_uart_rx_mode();
break;
diff --git a/firmware/src/simtrace/sim_switch.c b/firmware/src/simtrace/sim_switch.c
new file mode 100644
index 0000000..4f5621c
--- /dev/null
+++ b/firmware/src/simtrace/sim_switch.c
@@ -0,0 +1,76 @@
+/*
+ * (C) 2011 by Harald Welte <hwelte@hmw-consulting.de>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ *
+ */
+
+#include <errno.h>
+#include <string.h>
+#include <sys/types.h>
+#include <AT91SAM7.h>
+#include <lib_AT91SAM7.h>
+#include <openpcd.h>
+
+#include <simtrace_usb.h>
+
+#include <os/usb_handler.h>
+#include <os/dbgu.h>
+#include <os/pio_irq.h>
+
+#include "../simtrace.h"
+#include "../openpcd.h"
+
+#define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0]))
+
+void sim_switch_mode(int connect_io, int connect_misc)
+{
+ if (connect_io)
+ AT91F_PIO_SetOutput(AT91C_BASE_PIOA, SIMTRACE_PIO_IO_SW);
+ else
+ AT91F_PIO_ClearOutput(AT91C_BASE_PIOA, SIMTRACE_PIO_IO_SW);
+
+ if (connect_misc)
+ AT91F_PIO_SetOutput(AT91C_BASE_PIOA, SIMTRACE_PIO_SC_SW);
+ else
+ AT91F_PIO_ClearOutput(AT91C_BASE_PIOA, SIMTRACE_PIO_SC_SW);
+}
+
+static void sw_sim_irq(u_int32_t pio)
+{
+
+ if (!AT91F_PIO_IsInputSet(AT91C_BASE_PIOA, pio))
+ DEBUGPCR("SIM card inserted");
+ else
+ DEBUGPCR("SIM card removed");
+}
+
+void sim_switch_init(void)
+{
+ DEBUGPCR("ISO_SW Initializing");
+
+ /* make sure we get clock from the power management controller */
+ AT91F_US0_CfgPMC();
+
+ /* configure both signals as output */
+ AT91F_PIO_CfgOutput(AT91C_BASE_PIOA, SIMTRACE_PIO_SC_SW |
+ SIMTRACE_PIO_IO_SW);
+
+ /* configure sim card detect */
+ AT91F_PIO_CfgInput(AT91C_BASE_PIOA, SIMTRACE_PIO_SW_SIM);
+ 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);
+}
diff --git a/firmware/src/simtrace/sim_switch.h b/firmware/src/simtrace/sim_switch.h
new file mode 100644
index 0000000..01a6a66
--- /dev/null
+++ b/firmware/src/simtrace/sim_switch.h
@@ -0,0 +1,7 @@
+#ifndef SIMTRACE_ISO_SW_H
+#define SIMTRACE_ISO_SW_H
+
+void sim_switch_mode(int connect_io, int connect_misc);
+void sim_switch_init(void);
+
+#endif
personal git repositories of Harald Welte. Your mileage may vary