mirror of
https://github.com/apache/nuttx.git
synced 2026-05-23 23:28:29 +08:00
arch/xtensa/esp32s3: Update E-Fuse driver
Updates E-Fuse driver for ESP32S3, now sharing a common implementation across Xtensa devices. Signed-off-by: Filipe Cavalcanti <filipe.cavalcanti@espressif.com>
This commit is contained in:
committed by
Tiago Medicci Serrano
parent
384f788d18
commit
13e24e0c78
@@ -675,17 +675,14 @@ config ESP32S3_SPI
|
||||
bool
|
||||
default n
|
||||
|
||||
config ESP32S3_EFUSE
|
||||
bool
|
||||
select ESPRESSIF_EFUSE
|
||||
|
||||
config ESP32S3_WDT
|
||||
bool
|
||||
default n
|
||||
|
||||
config ESP32S3_EFUSE
|
||||
bool "EFUSE support"
|
||||
select EFUSE
|
||||
default n
|
||||
---help---
|
||||
Enable ESP32-S3 efuse support.
|
||||
|
||||
config ESP32S3_RNG
|
||||
bool "Random Number Generator (RNG)"
|
||||
default n
|
||||
|
||||
@@ -47,12 +47,6 @@ ifeq ($(CONFIG_SMP),y)
|
||||
CHIP_CSRCS += esp32s3_cpuidlestack.c esp32s3_cpustart.c esp32s3_intercpu_interrupt.c
|
||||
endif
|
||||
|
||||
ifeq ($(CONFIG_ESP32S3_EFUSE),y)
|
||||
CHIP_CSRCS += esp32s3_efuse.c
|
||||
CHIP_CSRCS += esp32s3_efuse_table.c
|
||||
CHIP_CSRCS += esp32s3_efuse_lowerhalf.c
|
||||
endif
|
||||
|
||||
ifeq ($(CONFIG_ESP32S3_RNG),y)
|
||||
CHIP_CSRCS += esp32s3_rng.c
|
||||
endif
|
||||
@@ -213,7 +207,7 @@ endif
|
||||
|
||||
ESP_HAL_3RDPARTY_REPO = esp-hal-3rdparty
|
||||
ifndef ESP_HAL_3RDPARTY_VERSION
|
||||
ESP_HAL_3RDPARTY_VERSION = e9a78c811578545e2bc673862d885a15bd6cbf67
|
||||
ESP_HAL_3RDPARTY_VERSION = 96185c5348c747d2e15baef639d0b2a842ecd504
|
||||
endif
|
||||
|
||||
ifndef ESP_HAL_3RDPARTY_URL
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,224 +0,0 @@
|
||||
/****************************************************************************
|
||||
* arch/xtensa/src/esp32s3/esp32s3_efuse.h
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef __ARCH_XTENSA_SRC_ESP32S3_ESP32S3_EFUSE_H
|
||||
#define __ARCH_XTENSA_SRC_ESP32S3_ESP32S3_EFUSE_H
|
||||
|
||||
/****************************************************************************
|
||||
* Included Files
|
||||
****************************************************************************/
|
||||
|
||||
#include <nuttx/efuse/efuse.h>
|
||||
|
||||
#ifndef __ASSEMBLY__
|
||||
|
||||
#undef EXTERN
|
||||
#if defined(__cplusplus)
|
||||
#define EXTERN extern "C"
|
||||
extern "C"
|
||||
{
|
||||
#else
|
||||
#define EXTERN extern
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Public Types
|
||||
****************************************************************************/
|
||||
|
||||
/* Type of eFuse blocks for ESP32S3 */
|
||||
|
||||
typedef enum
|
||||
{
|
||||
EFUSE_BLK0 = 0, /* Number of eFuse BLOCK0. REPEAT_DATA */
|
||||
|
||||
EFUSE_BLK1 = 1, /* Number of eFuse BLOCK1. MAC_SPI_8M_SYS */
|
||||
|
||||
EFUSE_BLK2 = 2, /* Number of eFuse BLOCK2. SYS_DATA_PART1 */
|
||||
EFUSE_BLK_SYS_DATA_PART1 = 2, /* Number of eFuse BLOCK2. SYS_DATA_PART1 */
|
||||
|
||||
EFUSE_BLK3 = 3, /* Number of eFuse BLOCK3. USER_DATA */
|
||||
EFUSE_BLK_USER_DATA = 3, /* Number of eFuse BLOCK3. USER_DATA */
|
||||
|
||||
EFUSE_BLK4 = 4, /* Number of eFuse BLOCK4. KEY0 */
|
||||
EFUSE_BLK_KEY0 = 4, /* Number of eFuse BLOCK4. KEY0 */
|
||||
|
||||
EFUSE_BLK5 = 5, /* Number of eFuse BLOCK5. KEY1 */
|
||||
EFUSE_BLK_KEY1 = 5, /* Number of eFuse BLOCK5. KEY1 */
|
||||
|
||||
EFUSE_BLK6 = 6, /* Number of eFuse BLOCK6. KEY2 */
|
||||
EFUSE_BLK_KEY2 = 6, /* Number of eFuse BLOCK6. KEY2 */
|
||||
|
||||
EFUSE_BLK7 = 7, /* Number of eFuse BLOCK7. KEY3 */
|
||||
EFUSE_BLK_KEY3 = 7, /* Number of eFuse BLOCK7. KEY3 */
|
||||
|
||||
EFUSE_BLK8 = 8, /* Number of eFuse BLOCK8. KEY4 */
|
||||
EFUSE_BLK_KEY4 = 8, /* Number of eFuse BLOCK8. KEY4 */
|
||||
|
||||
EFUSE_BLK9 = 9, /* Number of eFuse BLOCK9. KEY5 */
|
||||
EFUSE_BLK_KEY5 = 9, /* Number of eFuse BLOCK9. KEY5 */
|
||||
EFUSE_BLK_KEY_MAX = 10,
|
||||
|
||||
EFUSE_BLK10 = 10, /* Number of eFuse BLOCK10. SYS_DATA_PART2 */
|
||||
EFUSE_BLK_SYS_DATA_PART2 = 10, /* Number of eFuse BLOCK10. SYS_DATA_PART2 */
|
||||
|
||||
EFUSE_BLK_MAX
|
||||
} esp_efuse_block_t;
|
||||
|
||||
/****************************************************************************
|
||||
* Name: efuse_func_proc_t
|
||||
*
|
||||
* Description:
|
||||
* This is type of function that will handle the efuse field register.
|
||||
*
|
||||
* Input Parameters:
|
||||
* num_reg - The register number in the block.
|
||||
* bit_start - Start bit in the register.
|
||||
* bit_count - The number of bits used in the register.
|
||||
* arr - A pointer to an array or variable.
|
||||
* bits_counter - Counter bits.
|
||||
*
|
||||
* Returned Value:
|
||||
* Zero (OK) is returned on success. Otherwise -1 (ERROR).
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
typedef int (*efuse_func_proc_t) (uint32_t num_reg,
|
||||
int bit_start,
|
||||
int bit_count,
|
||||
void *arr, int *bits_counter);
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions Prototypes
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Name: esp32s3_efuse_read_field
|
||||
*
|
||||
* Description:
|
||||
* Read value from EFUSE, writing it into an array.
|
||||
*
|
||||
* Input Parameters:
|
||||
* field - A pointer to describing the fields of efuse
|
||||
* dst - A pointer to array that contains the data for reading
|
||||
* dst_size_bits - The number of bits required to read
|
||||
*
|
||||
* Returned Value:
|
||||
* Zero (OK) is returned on success. Otherwise -1 (ERROR).
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
int esp32s3_efuse_read_field(const efuse_desc_t *field[], void *dst,
|
||||
size_t dst_size_bits);
|
||||
|
||||
/****************************************************************************
|
||||
* Name: esp32s3_efuse_write_field
|
||||
*
|
||||
* Description:
|
||||
* Write array to EFUSE.
|
||||
*
|
||||
* Input Parameters:
|
||||
* field - A pointer to describing the fields of efuse
|
||||
* src - A pointer to array that contains the data for writing
|
||||
* src_size_bits - The number of bits required to write
|
||||
*
|
||||
* Returned Value:
|
||||
* Zero (OK) is returned on success. Otherwise -1 (ERROR).
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
int esp32s3_efuse_write_field(const efuse_desc_t *field[],
|
||||
const void *src, size_t src_size_bits);
|
||||
|
||||
/****************************************************************************
|
||||
* Name: esp32s3_efuse_burn_efuses
|
||||
*
|
||||
* Description:
|
||||
* Burn values written to the efuse write registers.
|
||||
*
|
||||
* Input Parameters:
|
||||
* None
|
||||
*
|
||||
* Returned Value:
|
||||
* None.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
void esp32s3_efuse_burn_efuses(void);
|
||||
|
||||
/****************************************************************************
|
||||
* Name: esp32s3_efuse_read_reg
|
||||
*
|
||||
* Description:
|
||||
* Read efuse register.
|
||||
*
|
||||
* Input Parameters:
|
||||
* blk - Block number of eFuse
|
||||
* num_reg - The register number in the block
|
||||
*
|
||||
* Returned Value:
|
||||
* Return the value in the efuse register.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
uint32_t esp32s3_efuse_read_reg(uint32_t blk, uint32_t num_reg);
|
||||
|
||||
/****************************************************************************
|
||||
* Name: esp32s3_efuse_write_reg
|
||||
*
|
||||
* Description:
|
||||
* Write value to efuse register.
|
||||
*
|
||||
* Input Parameters:
|
||||
* blk - Block number of eFuse
|
||||
* num_reg - The register number in the block
|
||||
* value - Value to write
|
||||
*
|
||||
* Returned Value:
|
||||
* None.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
void esp32s3_efuse_write_reg(uint32_t blk, uint32_t num_reg, uint32_t value);
|
||||
|
||||
/****************************************************************************
|
||||
* Name: esp32s3_efuse_initialize
|
||||
*
|
||||
* Description:
|
||||
* Initialize the efuse driver. The efuse is initialized
|
||||
* and registered as 'devpath'.
|
||||
*
|
||||
* Input Parameters:
|
||||
* devpath - The full path to the efuse device.
|
||||
* This should be of the form /dev/efuse
|
||||
*
|
||||
* Returned Value:
|
||||
* Zero (OK) is returned on success. Otherwise -1 (ERROR).
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
int esp32s3_efuse_initialize(const char *devpath);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#undef EXTERN
|
||||
|
||||
#endif /* __ASSEMBLY__ */
|
||||
#endif /* __ARCH_XTENSA_SRC_ESP32S3_ESP32S3_EFUSE_H */
|
||||
@@ -1,243 +0,0 @@
|
||||
/****************************************************************************
|
||||
* arch/xtensa/src/esp32s3/esp32s3_efuse_lowerhalf.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 <stdlib.h>
|
||||
#include <debug.h>
|
||||
#include <assert.h>
|
||||
|
||||
#include <nuttx/irq.h>
|
||||
#include <nuttx/kmalloc.h>
|
||||
#include <nuttx/efuse/efuse.h>
|
||||
|
||||
#include "hardware/esp32s3_soc.h"
|
||||
#include "esp32s3_efuse.h"
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
struct esp32s3_efuse_lowerhalf_s
|
||||
{
|
||||
const struct efuse_ops_s *ops; /* Lower half operations */
|
||||
void *upper; /* Pointer to efuse_upperhalf_s */
|
||||
};
|
||||
|
||||
/****************************************************************************
|
||||
* Private Functions Prototypes
|
||||
****************************************************************************/
|
||||
|
||||
/* "Lower half" driver methods */
|
||||
|
||||
static int esp32s3_efuse_lowerhalf_read(struct efuse_lowerhalf_s *lower,
|
||||
const efuse_desc_t *field[],
|
||||
uint8_t *data, size_t bits_len);
|
||||
static int esp32s3_efuse_lowerhalf_write(struct efuse_lowerhalf_s *lower,
|
||||
const efuse_desc_t *field[],
|
||||
const uint8_t *data,
|
||||
size_t bits_len);
|
||||
static int esp32s3_efuse_lowerhalf_ioctl(struct efuse_lowerhalf_s *lower,
|
||||
int cmd, unsigned long arg);
|
||||
|
||||
/****************************************************************************
|
||||
* Private Data
|
||||
****************************************************************************/
|
||||
|
||||
/* "Lower half" driver methods */
|
||||
|
||||
static const struct efuse_ops_s g_esp32s3_efuse_ops =
|
||||
{
|
||||
.read_field = esp32s3_efuse_lowerhalf_read,
|
||||
.write_field = esp32s3_efuse_lowerhalf_write,
|
||||
.ioctl = esp32s3_efuse_lowerhalf_ioctl,
|
||||
};
|
||||
|
||||
/* EFUSE lower-half */
|
||||
|
||||
static struct esp32s3_efuse_lowerhalf_s g_esp32s3_efuse_lowerhalf =
|
||||
{
|
||||
.ops = &g_esp32s3_efuse_ops,
|
||||
.upper = NULL,
|
||||
};
|
||||
|
||||
/****************************************************************************
|
||||
* Private functions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Name: esp32s3_efuse_lowerhalf_read
|
||||
*
|
||||
* Description:
|
||||
* Read value from EFUSE, writing it into an array.
|
||||
*
|
||||
* Input Parameters:
|
||||
* lower - A pointer the publicly visible representation of
|
||||
* the "lower-half" driver state structure
|
||||
* field - A pointer to describing the fields of efuse
|
||||
* dst - A pointer to array that contains the data for reading
|
||||
* bits_len - The number of bits required to read
|
||||
*
|
||||
* Returned Value:
|
||||
* Zero (OK) is returned on success. Otherwise -1 (ERROR).
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
static int esp32s3_efuse_lowerhalf_read(struct efuse_lowerhalf_s *lower,
|
||||
const efuse_desc_t *field[],
|
||||
uint8_t *data, size_t bits_len)
|
||||
{
|
||||
int ret = OK;
|
||||
|
||||
/* Read the requested field */
|
||||
|
||||
ret = esp32s3_efuse_read_field(field, data, bits_len);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Name: esp32s3_efuse_lowerhalf_write
|
||||
*
|
||||
* Description:
|
||||
* Write array to EFUSE.
|
||||
*
|
||||
* Input Parameters:
|
||||
* lower - A pointer the publicly visible representation of
|
||||
* the "lower-half" driver state structure
|
||||
* field - A pointer to describing the fields of efuse
|
||||
* data - A pointer to array that contains the data for writing
|
||||
* bits_len - The number of bits required to write
|
||||
*
|
||||
* Returned Value:
|
||||
* Zero (OK) is returned on success. Otherwise -1 (ERROR).
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
static int esp32s3_efuse_lowerhalf_write(struct efuse_lowerhalf_s *lower,
|
||||
const efuse_desc_t *field[],
|
||||
const uint8_t *data,
|
||||
size_t bits_len)
|
||||
{
|
||||
irqstate_t flags;
|
||||
int ret = OK;
|
||||
|
||||
flags = enter_critical_section();
|
||||
|
||||
/* Write the blob data to the field */
|
||||
|
||||
ret = esp32s3_efuse_write_field(field, data, bits_len);
|
||||
|
||||
/* Burn the EFUSEs */
|
||||
|
||||
esp32s3_efuse_burn_efuses();
|
||||
|
||||
leave_critical_section(flags);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Name: esp32s3_efuse_lowerhalf_ioctl
|
||||
*
|
||||
* Description:
|
||||
* Initialize the efuse driver. The efuse is initialized
|
||||
* and registered as 'devpath'.
|
||||
*
|
||||
* Input Parameters:
|
||||
* lower - A pointer the publicly visible representation of
|
||||
* the "lower-half" driver state structure
|
||||
* cmd - The ioctl command value
|
||||
* arg - The optional argument that accompanies the 'cmd'
|
||||
*
|
||||
* Returned Value:
|
||||
* Zero (OK) is returned on success. Otherwise -1 (ERROR).
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
static int esp32s3_efuse_lowerhalf_ioctl(struct efuse_lowerhalf_s *lower,
|
||||
int cmd, unsigned long arg)
|
||||
{
|
||||
int ret = OK;
|
||||
|
||||
switch (cmd)
|
||||
{
|
||||
/* We don't have proprietary EFUSE ioctls */
|
||||
|
||||
default:
|
||||
{
|
||||
minfo("Unrecognized cmd: %d\n", cmd);
|
||||
ret = -ENOTTY;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Name: esp32s3_efuse_initialize
|
||||
*
|
||||
* Description:
|
||||
* Initialize the efuse driver. The efuse is initialized
|
||||
* and registered as 'devpath'.
|
||||
*
|
||||
* Input Parameters:
|
||||
* devpath - The full path to the efuse device.
|
||||
* This should be of the form /dev/efuse
|
||||
*
|
||||
* Returned Value:
|
||||
* Zero (OK) is returned on success. Otherwise -1 (ERROR).
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
int esp32s3_efuse_initialize(const char *devpath)
|
||||
{
|
||||
struct esp32s3_efuse_lowerhalf_s *lower = NULL;
|
||||
int ret = OK;
|
||||
|
||||
DEBUGASSERT(devpath != NULL);
|
||||
|
||||
lower = &g_esp32s3_efuse_lowerhalf;
|
||||
|
||||
/* Register the efuse upper driver */
|
||||
|
||||
lower->upper = efuse_register(devpath,
|
||||
(struct efuse_lowerhalf_s *)lower);
|
||||
|
||||
if (lower->upper == NULL)
|
||||
{
|
||||
/* The actual cause of the failure may have been a failure to allocate
|
||||
* perhaps a failure to register the efuser driver (such as if the
|
||||
* 'devpath' were not unique). We know here but we return EEXIST to
|
||||
* indicate the failure (implying the non-unique devpath).
|
||||
*/
|
||||
|
||||
ret = -EEXIST;
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -99,6 +99,7 @@ CHIP_CSRCS += chip$(DELIM)$(ESP_HAL_3RDPARTY_REPO)$(DELIM)components$(DELIM)esp_
|
||||
CHIP_CSRCS += chip$(DELIM)$(ESP_HAL_3RDPARTY_REPO)$(DELIM)components$(DELIM)efuse$(DELIM)src$(DELIM)esp_efuse_api.c
|
||||
CHIP_CSRCS += chip$(DELIM)$(ESP_HAL_3RDPARTY_REPO)$(DELIM)components$(DELIM)efuse$(DELIM)src$(DELIM)esp_efuse_startup.c
|
||||
CHIP_CSRCS += chip$(DELIM)$(ESP_HAL_3RDPARTY_REPO)$(DELIM)components$(DELIM)efuse$(DELIM)src$(DELIM)esp_efuse_utility.c
|
||||
CHIP_CSRCS += chip$(DELIM)$(ESP_HAL_3RDPARTY_REPO)$(DELIM)components$(DELIM)efuse$(DELIM)src$(DELIM)efuse_controller$(DELIM)keys$(DELIM)with_key_purposes$(DELIM)esp_efuse_api_key.c
|
||||
CHIP_CSRCS += chip$(DELIM)$(ESP_HAL_3RDPARTY_REPO)$(DELIM)components$(DELIM)efuse$(DELIM)$(CHIP_SERIES)$(DELIM)esp_efuse_fields.c
|
||||
CHIP_CSRCS += chip$(DELIM)$(ESP_HAL_3RDPARTY_REPO)$(DELIM)components$(DELIM)efuse$(DELIM)$(CHIP_SERIES)$(DELIM)esp_efuse_rtc_calib.c
|
||||
CHIP_CSRCS += chip$(DELIM)$(ESP_HAL_3RDPARTY_REPO)$(DELIM)components$(DELIM)efuse$(DELIM)$(CHIP_SERIES)$(DELIM)esp_efuse_table.c
|
||||
@@ -215,7 +216,6 @@ ifeq ($(CONFIG_ESPRESSIF_SIMPLE_BOOT),y)
|
||||
CHIP_CSRCS += chip$(DELIM)$(ESP_HAL_3RDPARTY_REPO)$(DELIM)components$(DELIM)esp_rom$(DELIM)patches$(DELIM)esp_rom_systimer.c
|
||||
CHIP_CSRCS += chip$(DELIM)$(ESP_HAL_3RDPARTY_REPO)$(DELIM)components$(DELIM)esp_rom$(DELIM)patches$(DELIM)esp_rom_spiflash.c
|
||||
CHIP_CSRCS += chip$(DELIM)$(ESP_HAL_3RDPARTY_REPO)$(DELIM)components$(DELIM)efuse$(DELIM)src$(DELIM)esp_efuse_fields.c
|
||||
CHIP_CSRCS += chip$(DELIM)$(ESP_HAL_3RDPARTY_REPO)$(DELIM)components$(DELIM)efuse$(DELIM)src$(DELIM)efuse_controller$(DELIM)keys$(DELIM)with_key_purposes$(DELIM)esp_efuse_api_key.c
|
||||
|
||||
LDFLAGS += --wrap=bootloader_print_banner
|
||||
endif
|
||||
|
||||
@@ -28,7 +28,10 @@
|
||||
|
||||
#include <debug.h>
|
||||
#include <errno.h>
|
||||
#include <fcntl.h>
|
||||
#include <sys/ioctl.h>
|
||||
|
||||
#include <nuttx/efuse/efuse.h>
|
||||
#include <nuttx/irq.h>
|
||||
#include <nuttx/arch.h>
|
||||
#include <nuttx/board.h>
|
||||
@@ -36,7 +39,7 @@
|
||||
#include <arch/board/board.h>
|
||||
|
||||
#include "xtensa.h"
|
||||
#include "esp32s3_efuse.h"
|
||||
#include "espressif/esp_efuse.h"
|
||||
#include "esp32s3_gpio.h"
|
||||
#ifdef CONFIG_LAN9250_SPI
|
||||
#include "esp32s3_spi.h"
|
||||
@@ -48,6 +51,11 @@
|
||||
* Pre-processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
#define ESP_EFUSE_MAC_START 0
|
||||
#define ESP_EFUSE_MAC_OFFSET (ESP_EFUSE_BLK1 * ESP_EFUSE_BLK_LEN) + \
|
||||
ESP_EFUSE_MAC_START
|
||||
#define ESP_EFUSE_MAC_BITLEN 48
|
||||
|
||||
/****************************************************************************
|
||||
* Private Function Protototypes
|
||||
****************************************************************************/
|
||||
@@ -172,24 +180,50 @@ static void lan9250_disable(const struct lan9250_lower_s *lower)
|
||||
* mac - A pointer to a buffer where the MAC address will be stored.
|
||||
*
|
||||
* Returned Value:
|
||||
* None
|
||||
* Zero (OK) on success; a negated errno value on failure.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
static int lan9250_getmac(const struct lan9250_lower_s *lower, uint8_t *mac)
|
||||
{
|
||||
uint32_t regval[2];
|
||||
uint8_t *data = (uint8_t *)regval;
|
||||
int fd;
|
||||
int i;
|
||||
int ret;
|
||||
|
||||
regval[0] = esp32s3_efuse_read_reg(EFUSE_BLK1, 0);
|
||||
regval[1] = esp32s3_efuse_read_reg(EFUSE_BLK1, 1);
|
||||
struct efuse_param_s param;
|
||||
struct efuse_desc_s mac_addr =
|
||||
{
|
||||
.bit_offset = ESP_EFUSE_MAC_OFFSET,
|
||||
.bit_count = ESP_EFUSE_MAC_BITLEN
|
||||
};
|
||||
|
||||
for (i = 0; i < 6; i++)
|
||||
const efuse_desc_t *desc[] = {
|
||||
&mac_addr,
|
||||
NULL
|
||||
};
|
||||
|
||||
fd = open("/dev/efuse", O_RDWR);
|
||||
if (fd < 0)
|
||||
{
|
||||
mac[i] = data[5 - i];
|
||||
printf("Failed to open /dev/efuse, error = %d!\n", errno);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
param.field = desc;
|
||||
param.size = ESP_EFUSE_MAC_BITLEN;
|
||||
param.data = mac;
|
||||
|
||||
ret = ioctl(fd, EFUSEIOC_READ_FIELD, ¶m);
|
||||
if (ret < 0)
|
||||
{
|
||||
printf("Failed to run ioctl EFUSEIOC_READ_FIELD_BIT, error = %d!\n",
|
||||
errno);
|
||||
close(fd);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
close(fd);
|
||||
|
||||
#ifdef CONFIG_ESP32S3_UNIVERSAL_MAC_ADDRESSES_FOUR
|
||||
mac[5] += 3;
|
||||
#else
|
||||
@@ -319,4 +353,3 @@ int esp32s3_lan9250_uninitialize(int port)
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
@@ -52,8 +52,8 @@
|
||||
# include "esp32s3_rtc_lowerhalf.h"
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_ESP32S3_EFUSE
|
||||
# include "esp32s3_efuse.h"
|
||||
#ifdef CONFIG_ESPRESSIF_EFUSE
|
||||
# include "espressif/esp_efuse.h"
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_ESP32S3_PARTITION_TABLE
|
||||
@@ -144,8 +144,8 @@ int esp32s3_bringup(void)
|
||||
#endif /* CONFIG_ESPRESSIF_SPI_BITBANG */
|
||||
#endif /* CONFIG_ESP32S3_SPI && CONFIG_SPI_DRIVER*/
|
||||
|
||||
#if defined(CONFIG_ESP32S3_EFUSE)
|
||||
ret = esp32s3_efuse_initialize("/dev/efuse");
|
||||
#if defined(CONFIG_ESPRESSIF_EFUSE)
|
||||
ret = esp_efuse_initialize("/dev/efuse");
|
||||
if (ret < 0)
|
||||
{
|
||||
syslog(LOG_ERR, "ERROR: Failed to init EFUSE: %d\n", ret);
|
||||
|
||||
@@ -70,8 +70,8 @@
|
||||
# include "esp32s3_rtc_lowerhalf.h"
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_ESP32S3_EFUSE
|
||||
# include "esp32s3_efuse.h"
|
||||
#ifdef CONFIG_ESPRESSIF_EFUSE
|
||||
# include "espressif/esp_efuse.h"
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_ESP32S3_SPI
|
||||
@@ -107,8 +107,8 @@ int esp32s3_bringup(void)
|
||||
{
|
||||
int ret;
|
||||
|
||||
#if defined(CONFIG_ESP32S3_EFUSE)
|
||||
ret = esp32s3_efuse_initialize("/dev/efuse");
|
||||
#if defined(CONFIG_ESPRESSIF_EFUSE)
|
||||
ret = esp_efuse_initialize("/dev/efuse");
|
||||
if (ret < 0)
|
||||
{
|
||||
syslog(LOG_ERR, "ERROR: Failed to init EFUSE: %d\n", ret);
|
||||
|
||||
@@ -0,0 +1,47 @@
|
||||
#
|
||||
# This file is autogenerated: PLEASE DO NOT EDIT IT.
|
||||
#
|
||||
# You can use "make menuconfig" to make any modifications to the installed .config file.
|
||||
# You can then do "make savedefconfig" to generate a new defconfig file that includes your
|
||||
# modifications.
|
||||
#
|
||||
# CONFIG_ARCH_LEDS is not set
|
||||
# CONFIG_NSH_ARGCAT is not set
|
||||
# CONFIG_NSH_CMDOPT_HEXDUMP is not set
|
||||
CONFIG_ARCH="xtensa"
|
||||
CONFIG_ARCH_BOARD="esp32s3-devkit"
|
||||
CONFIG_ARCH_BOARD_COMMON=y
|
||||
CONFIG_ARCH_BOARD_ESP32S3_DEVKIT=y
|
||||
CONFIG_ARCH_CHIP="esp32s3"
|
||||
CONFIG_ARCH_CHIP_ESP32S3=y
|
||||
CONFIG_ARCH_CHIP_ESP32S3WROOM1N4=y
|
||||
CONFIG_ARCH_INTERRUPTSTACK=2048
|
||||
CONFIG_ARCH_STACKDUMP=y
|
||||
CONFIG_ARCH_XTENSA=y
|
||||
CONFIG_BOARD_LOOPSPERMSEC=16717
|
||||
CONFIG_BUILTIN=y
|
||||
CONFIG_ESP32S3_UART0=y
|
||||
CONFIG_ESPRESSIF_EFUSE=y
|
||||
CONFIG_FS_PROCFS=y
|
||||
CONFIG_HAVE_CXX=y
|
||||
CONFIG_HAVE_CXXINITIALIZE=y
|
||||
CONFIG_IDLETHREAD_STACKSIZE=3072
|
||||
CONFIG_INIT_ENTRYPOINT="nsh_main"
|
||||
CONFIG_INIT_STACKSIZE=3072
|
||||
CONFIG_INTELHEX_BINARY=y
|
||||
CONFIG_LINE_MAX=64
|
||||
CONFIG_NSH_ARCHINIT=y
|
||||
CONFIG_NSH_BUILTIN_APPS=y
|
||||
CONFIG_NSH_FILEIOSIZE=512
|
||||
CONFIG_NSH_READLINE=y
|
||||
CONFIG_PREALLOC_TIMERS=4
|
||||
CONFIG_RAM_SIZE=114688
|
||||
CONFIG_RAM_START=0x20000000
|
||||
CONFIG_RR_INTERVAL=200
|
||||
CONFIG_SCHED_WAITPID=y
|
||||
CONFIG_START_DAY=6
|
||||
CONFIG_START_MONTH=12
|
||||
CONFIG_START_YEAR=2011
|
||||
CONFIG_SYSLOG_BUFFER=y
|
||||
CONFIG_SYSTEM_NSH=y
|
||||
CONFIG_UART0_SERIAL_CONSOLE=y
|
||||
@@ -25,11 +25,11 @@ CONFIG_ARCH_XTENSA=y
|
||||
CONFIG_BOARD_LOOPSPERMSEC=16717
|
||||
CONFIG_BUILTIN=y
|
||||
CONFIG_DEFAULT_TASK_STACKSIZE=4096
|
||||
CONFIG_ESP32S3_EFUSE=y
|
||||
CONFIG_ESP32S3_GPIO_IRQ=y
|
||||
CONFIG_ESP32S3_SPI2=y
|
||||
CONFIG_ESP32S3_SPI_SWCS=y
|
||||
CONFIG_ESP32S3_UART0=y
|
||||
CONFIG_ESPRESSIF_EFUSE=y
|
||||
CONFIG_FS_PROCFS=y
|
||||
CONFIG_IDLETHREAD_STACKSIZE=3072
|
||||
CONFIG_INIT_ENTRYPOINT="nsh_main"
|
||||
|
||||
@@ -88,8 +88,8 @@
|
||||
#include <nuttx/video/fb.h>
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_ESP32S3_EFUSE
|
||||
# include "esp32s3_efuse.h"
|
||||
#ifdef CONFIG_ESPRESSIF_EFUSE
|
||||
# include "espressif/esp_efuse.h"
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_ESPRESSIF_LEDC
|
||||
@@ -236,8 +236,8 @@ int esp32s3_bringup(void)
|
||||
#endif /* CONFIG_ESPRESSIF_SPI_BITBANG */
|
||||
#endif /* CONFIG_ESP32S3_SPI && CONFIG_SPI_DRIVER*/
|
||||
|
||||
#if defined(CONFIG_ESP32S3_EFUSE)
|
||||
ret = esp32s3_efuse_initialize("/dev/efuse");
|
||||
#if defined(CONFIG_ESPRESSIF_EFUSE)
|
||||
ret = esp_efuse_initialize("/dev/efuse");
|
||||
if (ret < 0)
|
||||
{
|
||||
syslog(LOG_ERR, "ERROR: Failed to init EFUSE: %d\n", ret);
|
||||
|
||||
@@ -81,8 +81,8 @@
|
||||
# include "esp32s3_rtc_lowerhalf.h"
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_ESP32S3_EFUSE
|
||||
# include "esp32s3_efuse.h"
|
||||
#ifdef CONFIG_ESPRESSIF_EFUSE
|
||||
# include "espressif/esp_efuse.h"
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_ESPRESSIF_LEDC
|
||||
@@ -174,8 +174,8 @@ int esp32s3_bringup(void)
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if defined(CONFIG_ESP32S3_EFUSE)
|
||||
ret = esp32s3_efuse_initialize("/dev/efuse");
|
||||
#if defined(CONFIG_ESPRESSIF_EFUSE)
|
||||
ret = esp_efuse_initialize("/dev/efuse");
|
||||
if (ret < 0)
|
||||
{
|
||||
syslog(LOG_ERR, "ERROR: Failed to init EFUSE: %d\n", ret);
|
||||
|
||||
@@ -81,8 +81,8 @@
|
||||
# include "esp32s3_rtc_lowerhalf.h"
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_ESP32S3_EFUSE
|
||||
# include "esp32s3_efuse.h"
|
||||
#ifdef CONFIG_ESPRESSIF_EFUSE
|
||||
# include "espressif/esp_efuse.h"
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_ESP32S3_SPI
|
||||
@@ -118,8 +118,8 @@ int esp32s3_bringup(void)
|
||||
bool i2s_enable_rx;
|
||||
#endif
|
||||
|
||||
#if defined(CONFIG_ESP32S3_EFUSE)
|
||||
ret = esp32s3_efuse_initialize("/dev/efuse");
|
||||
#if defined(CONFIG_ESPRESSIF_EFUSE)
|
||||
ret = esp_efuse_initialize("/dev/efuse");
|
||||
if (ret < 0)
|
||||
{
|
||||
syslog(LOG_ERR, "ERROR: Failed to init EFUSE: %d\n", ret);
|
||||
|
||||
@@ -81,8 +81,8 @@
|
||||
#include <nuttx/video/fb.h>
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_ESP32S3_EFUSE
|
||||
# include "esp32s3_efuse.h"
|
||||
#ifdef CONFIG_ESPRESSIF_EFUSE
|
||||
# include "espressif/esp_efuse.h"
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_ESPRESSIF_LEDC
|
||||
@@ -193,8 +193,8 @@ int esp32s3_bringup(void)
|
||||
#endif /* CONFIG_ESPRESSIF_SPI_BITBANG */
|
||||
#endif /* CONFIG_ESP32S3_SPI && CONFIG_SPI_DRIVER*/
|
||||
|
||||
#if defined(CONFIG_ESP32S3_EFUSE)
|
||||
ret = esp32s3_efuse_initialize("/dev/efuse");
|
||||
#if defined(CONFIG_ESPRESSIF_EFUSE)
|
||||
ret = esp_efuse_initialize("/dev/efuse");
|
||||
if (ret < 0)
|
||||
{
|
||||
syslog(LOG_ERR, "ERROR: Failed to init EFUSE: %d\n", ret);
|
||||
|
||||
Reference in New Issue
Block a user