blob: bd2ab4980b1039be63f3781adddba897182983e0 [file] [log] [blame]
Harald Welteb7e326c2019-02-28 18:12:59 +01001/* Olimiex SAM3S-P256 board definition
2 *
3 * (C) 2019 by Harald Welte <hwelte@hmw-consulting.de>
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA
18 */
19#pragma once
20#include "board_common.h"
21#include "simtrace_usb.h"
22
23/* Name of the board */
24#define BOARD_NAME "SAM3S-P256"
25/* Board definition */
26#define simtrace
27
28/** oscillator used as main clock source (in Hz) */
29#define BOARD_MAINOSC 12000000
30/** desired main clock frequency (in Hz, based on BOARD_MAINOSC) */
31#define BOARD_MCK 58000000
32
33/** Pin configuration **/
34/* Button to force bootloader start (shorted to ground when pressed */
35#define PIN_BOOTLOADER_SW {PIO_PA20, PIOA, ID_PIOA, PIO_INPUT, PIO_DEFAULT}
36#if 0
37/* Enable powering the card using the second 3.3 V output of the LDO (active high) */
38#define SIM_PWEN_PIN {SIM_PWEN, PIOA, ID_PIOA, PIO_OUTPUT_1, PIO_DEFAULT}
39/* Enable powering the SIM card */
40#define PWR_PINS SIM_PWEN_PIN
41/* Card presence pin */
42#define SW_SIM PIO_PA8
43/* Pull card presence pin high (shorted to ground in card slot when card is present) */
44#define SMARTCARD_CONNECT_PIN {SW_SIM, PIOA, ID_PIOA, PIO_INPUT, PIO_PULLUP | PIO_DEBOUNCE | PIO_DEGLITCH | PIO_IT_EDGE }
45
46/** Smart card connection **/
47/* Card RST reset signal input (active low; RST_SIM in schematic) */
48#define PIN_SIM_RST {PIO_PA7, PIOA, ID_PIOA, PIO_OUTPUT_0, PIO_DEFAULT}
49/* Card I/O data signal input/output (I/O_SIM in schematic) */
50#define PIN_SIM_IO {PIO_PA6A_TXD0, PIOA, ID_PIOA, PIO_PERIPH_A, PIO_DEFAULT}
51/* Card CLK clock input (CLK_SIM in schematic) */
52#define PIN_SIM_CLK {PIO_PA2B_SCK0, PIOA, ID_PIOA, PIO_PERIPH_B, PIO_DEFAULT}
53/* Pin to measure card I/O timing (to start measuring the ETU on I/O activity; connected I/O_SIM in schematic) */
54#define PIN_SIM_IO_INPUT {PIO_PA1B_TIOB0, PIOA, ID_PIOA, PIO_PERIPH_B, PIO_DEFAULT}
55/* Pin used as clock input (to measure the ETU duration; connected to CLK_SIM in schematic) */
56#define PIN_SIM_CLK_INPUT {PIO_PA4B_TCLK0, PIOA, ID_PIOA, PIO_PERIPH_B, PIO_DEFAULT}
57/* Pins used to measure ETU timing (using timer counter) */
58#define PINS_TC PIN_SIM_IO_INPUT, PIN_SIM_CLK_INPUT
59
60/** Phone connection **/
61/* Phone USIM slot 1 VCC pin (VCC_PHONE in schematic) */
62#define PIN_USIM1_VCC {PIO_PA25, PIOA, ID_PIOA, PIO_INPUT, PIO_DEFAULT}
63/* Phone USIM slot 1 RST pin (active low; RST_PHONE in schematic) */
64#define PIN_USIM1_nRST {PIO_PA24, PIOA, ID_PIOA, PIO_INPUT, PIO_IT_RISE_EDGE | PIO_DEGLITCH }
65/* Phone I/O data signal input/output (I/O_PHONE in schematic) */
66#define PIN_PHONE_IO {PIO_PA22A_TXD1, PIOA, ID_PIOA, PIO_PERIPH_A, PIO_DEFAULT}
67/* Phone CLK clock input (CLK_PHONE in schematic) */
68#define PIN_PHONE_CLK {PIO_PA23A_SCK1, PIOA, ID_PIOA, PIO_PERIPH_A, PIO_DEFAULT}
69/* Pin used for phone USIM slot 1 communication */
70#define PINS_USIM1 PIN_PHONE_IO, PIN_PHONE_CLK, PIN_PHONE_CLK_INPUT, PIN_USIM1_VCC, PIN_PHONE_IO_INPUT, PIN_USIM1_nRST
71/* Phone I/O data signal input/output (unused USART RX input; connected to I/O_PHONE in schematic) */
72#define PIN_PHONE_IO_INPUT {PIO_PA21A_RXD1, PIOA, ID_PIOA, PIO_PERIPH_A, PIO_DEFAULT}
73/* Pin used as clock input (to measure the ETU duration; connected to CLK_PHONE in schematic) */
74#define PIN_PHONE_CLK_INPUT {PIO_PA29B_TCLK2, PIOA, ID_PIOA, PIO_PERIPH_B, PIO_DEFAULT}
75
76/** Default pin configuration **/
77/* Disconnect VPP, CLK, and RST lines between card and phone using bus switch (high sets bus switch to high-impedance) */
78#define PIN_SC_SW_DEFAULT {PIO_PA20, PIOA, ID_PIOA, PIO_OUTPUT_1, PIO_DEFAULT}
79/* Disconnect I/O line between card and phone using bus switch (high sets bus switch to high-impedance) */
80#define PIN_IO_SW_DEFAULT {PIO_PA19, PIOA, ID_PIOA, PIO_OUTPUT_1, PIO_DEFAULT}
81/* Disconnect all lines (VPP, CLK, RST, and I/O) between card and phone */
82#define PINS_BUS_DEFAULT PIN_SC_SW_DEFAULT, PIN_IO_SW_DEFAULT
83
84/** Sniffer configuration **/
85/* Connect VPP, CLK, and RST lines between card and phone using bus switch (low connects signals on bus switch) */
86#define PIN_SC_SW_SNIFF {PIO_PA20, PIOA, ID_PIOA, PIO_OUTPUT_0, PIO_DEFAULT}
87/* Connect I/O line between card and phone using bus switch (low connects signals on bus switch) */
88#define PIN_IO_SW_SNIFF {PIO_PA19, PIOA, ID_PIOA, PIO_OUTPUT_0, PIO_DEFAULT}
89/* Connect all lines (VPP, CLK, RST, and I/O) between card and phone */
90#define PINS_BUS_SNIFF PIN_SC_SW_SNIFF, PIN_IO_SW_SNIFF
91/* Card RST reset signal input (use as input since the phone will drive it) */
92#define PIN_SIM_RST_SNIFF {PIO_PA7, PIOA, ID_PIOA, PIO_INPUT, PIO_DEGLITCH | PIO_IT_EDGE}
93/* Pins used to sniff phone-card communication */
94#define PINS_SIM_SNIFF PIN_SIM_IO, PIN_SIM_CLK, PIN_SIM_RST_SNIFF
95/* Disable power converter 4.5-6V to 3.3V (active high) */
96#define PIN_SIM_PWEN_SNIFF {SIM_PWEN, PIOA, ID_PIOA, PIO_OUTPUT_0, PIO_DEFAULT}
97/* Enable power switch to forward VCC_PHONE to VCC_SIM (active high) */
98#define PIN_VCC_FWD_SNIFF {VCC_FWD, PIOA, ID_PIOA, PIO_OUTPUT_1, PIO_DEFAULT}
99/* Use phone VCC to power card */
100#define PINS_PWR_SNIFF PIN_SIM_PWEN_SNIFF, PIN_VCC_FWD_SNIFF
101
102/** CCID configuration */
103/* Card RST reset signal input (active low; RST_SIM in schematic) */
104#define PIN_ISO7816_RSTMC {PIO_PA7, PIOA, ID_PIOA, PIO_OUTPUT_0, PIO_DEFAULT}
105/* ISO7816-communication related pins */
106#define PINS_ISO7816 PIN_SIM_IO, PIN_SIM_CLK, PIN_ISO7816_RSTMC // SIM_PWEN_PIN, PIN_SIM_IO2, PIN_SIM_CLK2
107
108/** External SPI flash interface **/
109/* SPI MISO pin definition */
110#define PIN_SPI_MISO {PIO_PA12A_MISO, PIOA, PIOA, PIO_PERIPH_A, PIO_PULLUP}
111/* SPI MOSI pin definition */
112#define PIN_SPI_MOSI {PIO_PA13A_MOSI, PIOA, PIOA, PIO_PERIPH_A, PIO_DEFAULT}
113/* SPI SCK pin definition */
114#define PIN_SPI_SCK {PIO_PA14A_SPCK, PIOA, PIOA, PIO_PERIPH_A, PIO_DEFAULT}
115/* SPI pins definition. Contains MISO, MOSI & SCK */
116#define PINS_SPI PIN_SPI_MISO, PIN_SPI_MOSI, PIN_SPI_SCK
117/* SPI chip select 0 pin definition */
118#define PIN_SPI_NPCS0 {PIO_PA11A_NPCS0, PIOA, PIOA, PIO_PERIPH_A, PIO_DEFAULT}
119/* SPI flash write protect pin (active low, pulled low) */
120#define PIN_SPI_WP {PA15, PIOA, ID_PIOA, PIO_OUTPUT_0, PIO_DEFAULT}
121#endif
122
123/** Pin configuration to control USB pull-up on D+
124 * @details the USB pull-up on D+ is enable by default on the board but can be disabled by setting PA16 high
125 */
126#define PIN_USB_PULLUP {PIO_PA16, PIOA, ID_PIOA, PIO_OUTPUT_0, PIO_DEFAULT}
127
128/** USB definitions */
129/* OpenMoko SIMtrace 2 USB vendor ID */
130#define BOARD_USB_VENDOR_ID USB_VENDOR_OPENMOKO
131/* OpenMoko SIMtrace 2 USB product ID (main application/runtime mode) */
132#define BOARD_USB_PRODUCT_ID USB_PRODUCT_SIMTRACE2
133/* OpenMoko SIMtrace 2 DFU USB product ID (DFU bootloader/DFU mode) */
134#define BOARD_DFU_USB_PRODUCT_ID USB_PRODUCT_SIMTRACE2_DFU
135/* USB release number (bcdDevice, shown as 0.00) */
136#define BOARD_USB_RELEASE 0x000
137/* Indicate SIMtrace is bus power in USB attributes */
138#define BOARD_USB_BMATTRIBUTES USBConfigurationDescriptor_BUSPOWERED_NORWAKEUP
139
140/** Supported modes */
141/* SIMtrace board supports sniffer mode */
142#define HAVE_SNIFFER
143/* SIMtrace board supports CCID mode */
144//#define HAVE_CCID
145/* SIMtrace board supports card emulation mode */
146//#define HAVE_CARDEM
147/* SIMtrace board supports man-in-the-middle mode */
148//#define HAVE_MITM