From 8f2e1471afad984378e59e0b021e0325822c40d6 Mon Sep 17 00:00:00 2001 From: chenjianqiang Date: Wed, 13 Feb 2019 16:06:10 +0800 Subject: [PATCH] bugfix(psram): made some modifcations to support the psram driver backport --- components/esp32/Kconfig | 14 ++++++++++++++ components/esp32/spiram_psram.c | 21 +++++++++++++++++++++ 2 files changed, 35 insertions(+) diff --git a/components/esp32/Kconfig b/components/esp32/Kconfig index fe35029006..23fcf3f30e 100644 --- a/components/esp32/Kconfig +++ b/components/esp32/Kconfig @@ -213,6 +213,20 @@ config SPIRAM_ALLOW_BSS_SEG_EXTERNAL_MEMORY in PSRAM instead of internal memory, and placed most of variables of lwip,net802.11,pp,bluedroid library to external memory defaultly. +choice SPIRAM_OCCUPY_SPI_HOST + prompt "SPI host to use for 32MBit PSRAM" + default SPIRAM_OCCUPY_VSPI_HOST + depends on SPIRAM_SPEED_80M + help + When both flash and PSRAM is working under 80MHz, and the PSRAM is of type 32MBit, one of the HSPI/VSPI + host will be used to output the clock. Select which one to use here. + +config SPIRAM_OCCUPY_HSPI_HOST + bool "HSPI host (SPI2)" +config SPIRAM_OCCUPY_VSPI_HOST + bool "VSPI host (SPI3)" +endchoice + config PICO_PSRAM_CS_IO int "PSRAM CS IO for ESP32-PICO chip" depends on SPIRAM_SUPPORT diff --git a/components/esp32/spiram_psram.c b/components/esp32/spiram_psram.c index 87a327451e..2fc14b496d 100644 --- a/components/esp32/spiram_psram.c +++ b/components/esp32/spiram_psram.c @@ -149,6 +149,27 @@ typedef struct { #define _SPI_80M_CLK_DIV 1 #define _SPI_40M_CLK_DIV 2 +//For 4MB PSRAM, we need one more SPI host, select which one to use by kconfig +#ifdef CONFIG_SPIRAM_OCCUPY_HSPI_HOST +#define PSRAM_SPI_MODULE PERIPH_HSPI_MODULE +#define PSRAM_SPI_HOST HSPI_HOST +#define PSRAM_CLK_SIGNAL HSPICLK_OUT_IDX +#define PSRAM_SPI_NUM PSRAM_SPI_2 +#define PSRAM_SPICLKEN DPORT_SPI2_CLK_EN +#elif defined CONFIG_SPIRAM_OCCUPY_VSPI_HOST +#define PSRAM_SPI_MODULE PERIPH_VSPI_MODULE +#define PSRAM_SPI_HOST VSPI_HOST +#define PSRAM_CLK_SIGNAL VSPICLK_OUT_IDX +#define PSRAM_SPI_NUM PSRAM_SPI_3 +#define PSRAM_SPICLKEN DPORT_SPI3_CLK_EN +#else //set to SPI avoid HSPI and VSPI being used +#define PSRAM_SPI_MODULE PERIPH_SPI_MODULE +#define PSRAM_SPI_HOST SPI_HOST +#define PSRAM_CLK_SIGNAL SPICLK_OUT_IDX +#define PSRAM_SPI_NUM PSRAM_SPI_1 +#define PSRAM_SPICLKEN DPORT_SPI01_CLK_EN +#endif + static const char* TAG = "psram"; typedef enum { PSRAM_SPI_1 = 0x1, -- 2.40.0