gustavonihei commented on a change in pull request #5827: URL: https://github.com/apache/incubator-nuttx/pull/5827#discussion_r833259224
########## File path: arch/xtensa/src/esp32s2/esp32s2_psram.c ########## @@ -0,0 +1,729 @@ +/**************************************************************************** + * arch/xtensa/src/esp32s2/esp32s2_psram.c + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. The + * ASF licenses this file to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance with the + * License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + * + ****************************************************************************/ + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include <stdint.h> +#include <stddef.h> +#include <errno.h> +#include <debug.h> +#include <assert.h> + +#include "esp32s2_gpio.h" +#include "esp32s2_psram.h" + +#include "rom/esp32s2_spiflash.h" +#include "rom/esp32s2_opi_flash.h" +#include "hardware/esp32s2_efuse.h" +#include "hardware/esp32s2_spi.h" +#include "hardware/esp32s2_spi_mem_reg.h" +#include "hardware/esp32s2_iomux.h" +#include "hardware/esp32s2_gpio_sigmap.h" + +/**************************************************************************** + * Pre-processor Prototypes + ****************************************************************************/ + +/* EFUSE */ + +#define ESP_ROM_EFUSE_FLASH_DEFAULT_SPI (0) + +/* Commands for PSRAM chip */ + +#define PSRAM_READ 0x03 +#define PSRAM_FAST_READ 0x0B +#define PSRAM_FAST_READ_QUAD 0xEB +#define PSRAM_WRITE 0x02 +#define PSRAM_QUAD_WRITE 0x38 +#define PSRAM_ENTER_QMODE 0x35 +#define PSRAM_EXIT_QMODE 0xF5 +#define PSRAM_RESET_EN 0x66 +#define PSRAM_RESET 0x99 +#define PSRAM_SET_BURST_LEN 0xC0 +#define PSRAM_DEVICE_ID 0x9F + +#define PSRAM_FAST_READ_DUMMY 4 +#define PSRAM_FAST_READ_QUAD_DUMMY 6 + +/* ID */ + +#define PSRAM_ID_KGD_M 0xff +#define PSRAM_ID_KGD_S 8 +#define PSRAM_ID_KGD 0x5d +#define PSRAM_ID_EID_M 0xff +#define PSRAM_ID_EID_S 16 + +/* Use the [7:5](bit7~bit5) of EID to distinguish the psram size: + * + * BIT7 | BIT6 | BIT5 | SIZE(MBIT) + * ------------------------------------- + * 0 | 0 | 0 | 16 + * 0 | 0 | 1 | 32 + * 0 | 1 | 0 | 64 + */ + +#define PSRAM_EID_SIZE_M 0x07 +#define PSRAM_EID_SIZE_S 5 + +#define PSRAM_KGD(id) (((id) >> PSRAM_ID_KGD_S) & PSRAM_ID_KGD_M) +#define PSRAM_EID(id) (((id) >> PSRAM_ID_EID_S) & PSRAM_ID_EID_M) +#define PSRAM_SIZE_ID(id) ((PSRAM_EID(id) >> PSRAM_EID_SIZE_S) & PSRAM_EID_SIZE_M) +#define PSRAM_IS_VALID(id) (PSRAM_KGD(id) == PSRAM_ID_KGD) + +/* For the old version 32Mbit psram, using the special driver */ Review comment: ```suggestion /* For the old version 32Mbit PSRAM, using the special driver */ ``` nit: For consistency, let's always refer to **PSRAM** in comments, in all caps. Please uniformize it throughout the PR -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: commits-unsubscr...@nuttx.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org