<p>laforge would like tsaitgaist to <strong>review</strong> this change.</p><p><a href="https://gerrit.osmocom.org/c/simtrace2/+/23618">View Change</a></p><pre style="font-family: monospace,monospace; white-space: pre-wrap;">make sim switch board specific<br><br>the simtrace board uses a bus switch not used on qmod and owhw to<br>switch the SIM between physical and virtual<br><br>Change-Id: Ieaf2ed4761fc3e04f33f9aac5c04a768c9a6f71e<br>---<br>M firmware/libboard/common/include/sim_switch.h<br>R firmware/libboard/owhw/source/sim_switch.c<br>C firmware/libboard/qmod/source/sim_switch.c<br>A firmware/libboard/simtrace/source/sim_switch.c<br>4 files changed, 71 insertions(+), 0 deletions(-)<br><br></pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;">git pull ssh://gerrit.osmocom.org:29418/simtrace2 refs/changes/18/23618/1</pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;"><span>diff --git a/firmware/libboard/common/include/sim_switch.h b/firmware/libboard/common/include/sim_switch.h</span><br><span>index 3d131f2..4439fa5 100644</span><br><span>--- a/firmware/libboard/common/include/sim_switch.h</span><br><span>+++ b/firmware/libboard/common/include/sim_switch.h</span><br><span>@@ -14,5 +14,13 @@</span><br><span>  */</span><br><span> #pragma once</span><br><span> </span><br><span style="color: hsl(120, 100%, 40%);">+/** switch card lines to use physical or emulated card</span><br><span style="color: hsl(120, 100%, 40%);">+ *  @param[in] nr card interface number (i.e. slot)</span><br><span style="color: hsl(120, 100%, 40%);">+ *  @param[in] physical which physical interface to switch to (e.g. 0: physical, 1: virtual)</span><br><span style="color: hsl(120, 100%, 40%);">+ *  @return 0 on success, negative else</span><br><span style="color: hsl(120, 100%, 40%);">+ */</span><br><span> int sim_switch_use_physical(unsigned int nr, int physical);</span><br><span style="color: hsl(120, 100%, 40%);">+/** initialise card switching capabilities</span><br><span style="color: hsl(120, 100%, 40%);">+ *  @return number of switchable card interfaces</span><br><span style="color: hsl(120, 100%, 40%);">+ */</span><br><span> int sim_switch_init(void);</span><br><span>diff --git a/firmware/libboard/common/source/sim_switch.c b/firmware/libboard/owhw/source/sim_switch.c</span><br><span>similarity index 100%</span><br><span>rename from firmware/libboard/common/source/sim_switch.c</span><br><span>rename to firmware/libboard/owhw/source/sim_switch.c</span><br><span>diff --git a/firmware/libboard/common/source/sim_switch.c b/firmware/libboard/qmod/source/sim_switch.c</span><br><span>similarity index 100%</span><br><span>copy from firmware/libboard/common/source/sim_switch.c</span><br><span>copy to firmware/libboard/qmod/source/sim_switch.c</span><br><span>diff --git a/firmware/libboard/simtrace/source/sim_switch.c b/firmware/libboard/simtrace/source/sim_switch.c</span><br><span>new file mode 100644</span><br><span>index 0000000..38886b1</span><br><span>--- /dev/null</span><br><span>+++ b/firmware/libboard/simtrace/source/sim_switch.c</span><br><span>@@ -0,0 +1,63 @@</span><br><span style="color: hsl(120, 100%, 40%);">+/* Code to switch between local (physical) and remote (emulated) SIM</span><br><span style="color: hsl(120, 100%, 40%);">+ *</span><br><span style="color: hsl(120, 100%, 40%);">+ * (C) 2015-2017 by Harald Welte <hwelte@hmw-consulting.de></span><br><span style="color: hsl(120, 100%, 40%);">+ * (C) 2018, sysmocom -s.f.m.c. GmbH, Author: Kevin Redon <kredon@sysmocom.de></span><br><span style="color: hsl(120, 100%, 40%);">+ * </span><br><span style="color: hsl(120, 100%, 40%);">+ * This program is free software; you can redistribute it and/or modify</span><br><span style="color: hsl(120, 100%, 40%);">+ * it under the terms of the GNU General Public License as published by</span><br><span style="color: hsl(120, 100%, 40%);">+ * the Free Software Foundation; either version 2 of the License, or</span><br><span style="color: hsl(120, 100%, 40%);">+ * (at your option) any later version.</span><br><span style="color: hsl(120, 100%, 40%);">+ *</span><br><span style="color: hsl(120, 100%, 40%);">+ * This program is distributed in the hope that it will be useful,</span><br><span style="color: hsl(120, 100%, 40%);">+ * but WITHOUT ANY WARRANTY; without even the implied warranty of</span><br><span style="color: hsl(120, 100%, 40%);">+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the</span><br><span style="color: hsl(120, 100%, 40%);">+ * GNU General Public License for more details.</span><br><span style="color: hsl(120, 100%, 40%);">+ *</span><br><span style="color: hsl(120, 100%, 40%);">+ * You should have received a copy of the GNU General Public License</span><br><span style="color: hsl(120, 100%, 40%);">+ * along with this program; if not, write to the Free Software</span><br><span style="color: hsl(120, 100%, 40%);">+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307, USA</span><br><span style="color: hsl(120, 100%, 40%);">+ */</span><br><span style="color: hsl(120, 100%, 40%);">+#include "board.h"</span><br><span style="color: hsl(120, 100%, 40%);">+#include "trace.h"</span><br><span style="color: hsl(120, 100%, 40%);">+#include "led.h"</span><br><span style="color: hsl(120, 100%, 40%);">+#include "sim_switch.h"</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+#ifdef PIN_SIM_SWITCH1</span><br><span style="color: hsl(120, 100%, 40%);">+static const Pin pin_conn_usim1 = {PIO_PA20, PIOA, ID_PIOA, PIO_OUTPUT_0, PIO_DEFAULT};</span><br><span style="color: hsl(120, 100%, 40%);">+#endif</span><br><span style="color: hsl(120, 100%, 40%);">+#ifdef PIN_SIM_SWITCH2</span><br><span style="color: hsl(120, 100%, 40%);">+static const Pin pin_conn_usim2 = {PIO_PA28, PIOA, ID_PIOA, PIO_OUTPUT_0, PIO_DEFAULT};</span><br><span style="color: hsl(120, 100%, 40%);">+#endif</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+static int initialized = 0;</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+int sim_switch_use_physical(unsigned int nr, int physical)</span><br><span style="color: hsl(120, 100%, 40%);">+{</span><br><span style="color: hsl(120, 100%, 40%);">+   const Pin pin_sc = PIN_SC_SW_DEFAULT; // pin to control bus switch for VCC/RST/CLK signals</span><br><span style="color: hsl(120, 100%, 40%);">+    const Pin pin_io = PIN_IO_SW_DEFAULT; // pin to control bus switch for I/O signal</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+   if (nr > 0) {</span><br><span style="color: hsl(120, 100%, 40%);">+              TRACE_ERROR("SIM interface for Modem %d can't be switched\r\n", nr);</span><br><span style="color: hsl(120, 100%, 40%);">+            return -1;</span><br><span style="color: hsl(120, 100%, 40%);">+    }</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+   TRACE_INFO("Modem %u: %s SIM\n\r", nr, physical ? "physical" : "virtual");</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+    if (physical) {</span><br><span style="color: hsl(120, 100%, 40%);">+               TRACE_INFO("%u: Use local/physical SIM\r\n", nr);</span><br><span style="color: hsl(120, 100%, 40%);">+           PIO_Set(&pin_sc);</span><br><span style="color: hsl(120, 100%, 40%);">+         PIO_Set(&pin_io);</span><br><span style="color: hsl(120, 100%, 40%);">+ } else {</span><br><span style="color: hsl(120, 100%, 40%);">+              TRACE_INFO("%u: Use remote/emulated SIM\r\n", nr);</span><br><span style="color: hsl(120, 100%, 40%);">+          PIO_Clear(&pin_sc);</span><br><span style="color: hsl(120, 100%, 40%);">+               PIO_Clear(&pin_io);</span><br><span style="color: hsl(120, 100%, 40%);">+       }</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+   return 0;</span><br><span style="color: hsl(120, 100%, 40%);">+}</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+int sim_switch_init(void)</span><br><span style="color: hsl(120, 100%, 40%);">+{</span><br><span style="color: hsl(120, 100%, 40%);">+  // the bus switch is already initialised</span><br><span style="color: hsl(120, 100%, 40%);">+      return 1; // SIMtrace hardware has only one switchable interface</span><br><span style="color: hsl(120, 100%, 40%);">+}</span><br><span></span><br></pre><p>To view, visit <a href="https://gerrit.osmocom.org/c/simtrace2/+/23618">change 23618</a>. To unsubscribe, or for help writing mail filters, visit <a href="https://gerrit.osmocom.org/settings">settings</a>.</p><div itemscope itemtype="http://schema.org/EmailMessage"><div itemscope itemprop="action" itemtype="http://schema.org/ViewAction"><link itemprop="url" href="https://gerrit.osmocom.org/c/simtrace2/+/23618"/><meta itemprop="name" content="View Change"/></div></div>

<div style="display:none"> Gerrit-Project: simtrace2 </div>
<div style="display:none"> Gerrit-Branch: master </div>
<div style="display:none"> Gerrit-Change-Id: Ieaf2ed4761fc3e04f33f9aac5c04a768c9a6f71e </div>
<div style="display:none"> Gerrit-Change-Number: 23618 </div>
<div style="display:none"> Gerrit-PatchSet: 1 </div>
<div style="display:none"> Gerrit-Owner: laforge <laforge@osmocom.org> </div>
<div style="display:none"> Gerrit-Reviewer: tsaitgaist <kredon@sysmocom.de> </div>
<div style="display:none"> Gerrit-MessageType: newchange </div>