Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -424,3 +424,9 @@
[submodule "frozen/Adafruit_CircuitPython_BLE_File_Transfer"]
path = frozen/Adafruit_CircuitPython_BLE_File_Transfer
url = https://github.com/adafruit/Adafruit_CircuitPython_BLE_File_Transfer.git
[submodule "frozen/Adafruit_CircuitPython_CS42L42"]
path = frozen/Adafruit_CircuitPython_CS42L42
url = https://github.com/adafruit/Adafruit_CircuitPython_CS42L42.git
[submodule "frozen/Adafruit_CircuitPython_TAS2505"]
path = frozen/Adafruit_CircuitPython_TAS2505
url = https://github.com/adafruit/Adafruit_CircuitPython_TAS2505.git
1 change: 1 addition & 0 deletions frozen/Adafruit_CircuitPython_CS42L42
1 change: 1 addition & 0 deletions frozen/Adafruit_CircuitPython_TAS2505
26 changes: 19 additions & 7 deletions ports/nordic/boards/teenage_engineering_sp1/board.c
Original file line number Diff line number Diff line change
Expand Up @@ -25,16 +25,19 @@
#include "board.h"
#include "common-hal/microcontroller/Pin.h"
#include "flash_protect.h"
#include "peripherals/nrf/pins.h"
#include "power_off.h"
#include "py/misc.h"
#include "supervisor/shared/safe_mode.h"
#include "shared-module/emmcio/__init__.h"
#include "wdt.h"
#include "nrfx/drivers/include/nrfx_rtc.h"
#include "nrfx/hal/nrf_gpio.h"

#define PIN_EMMC_RESET (DEFAULT_EMMC_RESET->number) // active low
#define PIN_EMMC_VCCQ_EN (DEFAULT_EMMC_VCCQ->number) // eMMC I/O rail

// Pins this file drives directly.
#define PIN_EMMC_RESET NRF_GPIO_PIN_MAP(1, 8) // eMMC, active low
#define PIN_EMMC_VCCQ_EN NRF_GPIO_PIN_MAP(0, 14) // eMMC I/O rail
#define PIN_OSC_EN NRF_GPIO_PIN_MAP(0, 13) // 3.072 MHz oscillator
#define PIN_TAS_RESET NRF_GPIO_PIN_MAP(0, 9) // TAS2505, active low
#define PIN_CS42_RESET NRF_GPIO_PIN_MAP(0, 15) // CS42L42, active low
Expand Down Expand Up @@ -211,11 +214,6 @@ static const uint8_t default_low_pins[] = {
PIN_CS42_RESET,
PIN_BT_RESET,

// eMMC held in reset with its VCCQ rail off. The contents of the chip are
// unaffected; this only keeps the rail from floating.
PIN_EMMC_RESET,
PIN_EMMC_VCCQ_EN,

// Rail feeding the faders and both button ladders. Off unless something is
// actually reading them.
PIN_CONTROL_RAIL,
Expand Down Expand Up @@ -246,6 +244,18 @@ static bool apply_pin_default(uint8_t pin_number) {
}
}

// eMMC held in reset with its VCCQ rail off. The contents of the chip are
// unaffected; this only keeps the rail from floating. The exception is a
// card the supervisor has automounted: it is a live filesystem between
// runs, so leave its reset and rail exactly as the driver left them.
if (pin_number == PIN_EMMC_RESET || pin_number == PIN_EMMC_VCCQ_EN) {
if (!emmcio_is_automounted()) {
nrf_gpio_cfg_output(pin_number);
nrf_gpio_pin_clear(pin_number);
}
return true;
}

for (size_t i = 0; i < MP_ARRAY_SIZE(default_low_pins); i++) {
if (default_low_pins[i] == pin_number) {
nrf_gpio_cfg_output(pin_number);
Expand All @@ -260,6 +270,8 @@ static bool apply_pin_default(uint8_t pin_number) {
// Put every pin this board has an opinion about into its resting state at once.
static void apply_all_pin_defaults(void) {
apply_pin_default(PIN_FUNCTION_BUTTON);
apply_pin_default(PIN_EMMC_RESET);
apply_pin_default(PIN_EMMC_VCCQ_EN);
for (size_t i = 0; i < MP_ARRAY_SIZE(led_pins); i++) {
apply_pin_default(led_pins[i]);
}
Expand Down
7 changes: 7 additions & 0 deletions ports/nordic/boards/teenage_engineering_sp1/mpconfigboard.h
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,13 @@
// No SD card LUN. There is no card slot on this device.
#define CIRCUITPY_SDCARD_USB (0)

// The 4 GB eMMC
#define DEFAULT_EMMC_CLOCK (&pin_P0_06)
#define DEFAULT_EMMC_COMMAND (&pin_P0_08)
#define DEFAULT_EMMC_DATA (&pin_P0_07)
#define DEFAULT_EMMC_RESET (&pin_P1_08)
#define DEFAULT_EMMC_VCCQ (&pin_P0_14)

// TWIM to the CS42L42 (0x48) and TAS2505 (0x18).
#define DEFAULT_I2C_BUS_SCL (&pin_P1_11)
#define DEFAULT_I2C_BUS_SDA (&pin_P1_07)
Expand Down
9 changes: 9 additions & 0 deletions ports/nordic/boards/teenage_engineering_sp1/mpconfigboard.mk
Original file line number Diff line number Diff line change
Expand Up @@ -50,4 +50,13 @@ SRC_C += boards/$(BOARD)/power_off.c
# bootloader does not set up for itself.
SRC_C += boards/$(BOARD)/flash_protect.c

# The soldered-down eMMC, and the supervisor mount that puts it on /sd and on
# USB as a second drive.
CIRCUITPY_EMMCIO = 1
CIRCUITPY_EMMC_USB = 1

FROZEN_MPY_DIRS += $(TOP)/frozen/Adafruit_CircuitPython_Register
FROZEN_MPY_DIRS += $(TOP)/frozen/Adafruit_CircuitPython_CS42L42
FROZEN_MPY_DIRS += $(TOP)/frozen/Adafruit_CircuitPython_TAS2505

CIRCUITPY_REQUIRE_I2C_PULLUPS = 0
8 changes: 0 additions & 8 deletions ports/nordic/common-hal/emmcio/EMMC.c
Original file line number Diff line number Diff line change
Expand Up @@ -510,14 +510,6 @@ bool common_hal_emmcio_emmc_read_ext_csd(uint8_t *buf) {

#define EMMC_BUSY_LEADIN_CLOCKS 16

// run_bg says whether a long stall may run background tasks.
// true -- the wait is between transfers, so it is safe to let the rest of
// the system have a turn.
// false -- the wait is inside a write, with the card mid-program. Nothing
// runs, so no background task can re-enter this driver or change
// the board's state out from under a programming card. The stall
// is bounded (<=500 ms) and background tasks resume between
// blocks and between calls.
static bool dat0_busy_wait(uint32_t timeout_us, bool run_bg) {
DAT0_IN(); // never drive against a busy card
for (int i = 0; i < EMMC_BUSY_LEADIN_CLOCKS; i++) {
Expand Down
Loading