You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by GitBox <gi...@apache.org> on 2020/12/31 07:22:02 UTC

[GitHub] [incubator-nuttx] xiaoxiang781216 commented on a change in pull request #2628: Add generic efuse driver for NuttX

xiaoxiang781216 commented on a change in pull request #2628:
URL: https://github.com/apache/incubator-nuttx/pull/2628#discussion_r550415972



##########
File path: include/nuttx/efuse/efuse.h
##########
@@ -0,0 +1,294 @@
+/****************************************************************************
+ * include/nuttx/efuse/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 __INCLUDE_NUTTX_EFUSE_EFUSE_H
+#define __INCLUDE_NUTTX_EFUSE_EFUSE_H
+
+/****************************************************************************
+ * Included Files
+ ****************************************************************************/
+
+#include <nuttx/config.h>
+#include <nuttx/fs/ioctl.h>
+
+#include <signal.h>
+#include <stdint.h>
+
+#ifdef CONFIG_EFUSE
+
+/****************************************************************************
+ * Pre-processor Definitions
+ ****************************************************************************/
+
+/* Command:     EFUSEIOC_READ_FIELD_BLOB
+ * Description: Read a blob of bits from an efuse field.
+ * Arguments:   A structure containing the field[], a dst pointer, and size
+ *              of bits to be read from efuses.
+ * Return:      Zero (OK) on success.  Minus one will be returned on failure
+ *              with the errno value set appropriately.
+ */
+
+#define EFUSEIOC_READ_FIELD_BLOB      _EFUSEIOC(0x0001)
+
+/* Command:     EFUSEIOC_READ_FIELD_BIT
+ * Description: Read of state of an efuse bit.
+ * Arguments:   A structure containing the field to be read.
+ * Return:      Zero (OK) on success.  Minus one will be returned on failure
+ *              with the errno value set appropriately.
+ */
+
+#define EFUSEIOC_READ_FIELD_BIT       _EFUSEIOC(0x0002)
+
+/* Command:     EFUSEIOC_WRITE_FIELD_BLOB
+ * Description: Write a blob of bits to an efuse's field
+ * Arguments:   A structure containing the field[], the src memory and the
+ *              amount of bits to write.
+ * Return:      Zero (OK) on success.  Minus one will be returned on failure
+ *              with the errno value set appropriately.
+ */
+
+#define EFUSEIOC_WRITE_FIELD_BLOB     _EFUSEIOC(0x0003)
+
+/* Command:     EFUSEIOC_WRITE_FIELD_BIT
+ * Description: Write a bit to an efuse (burn it).
+ * Arguments:   A structure containing bit field.
+ * Return:      Zero (OK) on success.  Minus one will be returned on failure
+ *              with the errno value set appropriately.
+ */
+
+#define EFUSEIOC_WRITE_FIELD_BIT      _EFUSEIOC(0x0004)
+
+/* Command:     EFUSEIOC_GET_FIELD_SIZE
+ * Description: Get the length of the field in bits.
+ * Arguments:   A structure containing the fields.
+ * Return:      Zero (OK) on success.  Minus one will be returned on failure
+ *              with the errno value set appropriately.
+ */
+
+#define EFUSEIOC_GET_FIELD_SIZE       _EFUSEIOC(0x0005)
+
+/* Command:     EFUSEIOC_READ_REG
+ * Description: Read an efuse register.
+ * Arguments:   A structure containing the block number and the register to
+ *              be read.
+ * Return:      Zero (OK) on success.  Minus one will be returned on failure
+ *              with the errno value set appropriately.
+ */
+
+#define EFUSEIOC_READ_REG             _EFUSEIOC(0x0006)
+
+/* Command:     EFUSEIOC_WRITE_REG
+ * Description: Write an efuse register.
+ * Arguments:   A structure containing the block number, the register to
+ *              write and value to be written.
+ * Return:      Zero (OK) on success.  Minus one will be returned on failure
+ *              with the errno value set appropriately.
+ */
+
+#define EFUSEIOC_WRITE_REG            _EFUSEIOC(0x0007)
+
+/* Command:     EFUSEIOC_READ_BLOCK
+ * Description: Read a key from efuse's block.
+ * Arguments:   A structure containing the block number, the dst_key pointer,
+ *              the offset in bits and the amount of bits to read.
+ * Return:      Zero (OK) on success.  Minus one will be returned on failure
+ *              with the errno value set appropriately.
+ */
+
+#define EFUSEIOC_READ_BLOCK           _EFUSEIOC(0x0008)

Review comment:
       @acassis what's difference between field/bit and block/reg? can we unify the read/write interface into one?

##########
File path: include/nuttx/efuse/efuse.h
##########
@@ -0,0 +1,294 @@
+/****************************************************************************
+ * include/nuttx/efuse/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 __INCLUDE_NUTTX_EFUSE_EFUSE_H
+#define __INCLUDE_NUTTX_EFUSE_EFUSE_H
+
+/****************************************************************************
+ * Included Files
+ ****************************************************************************/
+
+#include <nuttx/config.h>
+#include <nuttx/fs/ioctl.h>
+
+#include <signal.h>
+#include <stdint.h>
+
+#ifdef CONFIG_EFUSE
+
+/****************************************************************************
+ * Pre-processor Definitions
+ ****************************************************************************/
+
+/* Command:     EFUSEIOC_READ_FIELD_BLOB
+ * Description: Read a blob of bits from an efuse field.
+ * Arguments:   A structure containing the field[], a dst pointer, and size
+ *              of bits to be read from efuses.
+ * Return:      Zero (OK) on success.  Minus one will be returned on failure
+ *              with the errno value set appropriately.
+ */
+
+#define EFUSEIOC_READ_FIELD_BLOB      _EFUSEIOC(0x0001)
+
+/* Command:     EFUSEIOC_READ_FIELD_BIT
+ * Description: Read of state of an efuse bit.
+ * Arguments:   A structure containing the field to be read.
+ * Return:      Zero (OK) on success.  Minus one will be returned on failure
+ *              with the errno value set appropriately.
+ */
+
+#define EFUSEIOC_READ_FIELD_BIT       _EFUSEIOC(0x0002)
+
+/* Command:     EFUSEIOC_WRITE_FIELD_BLOB
+ * Description: Write a blob of bits to an efuse's field
+ * Arguments:   A structure containing the field[], the src memory and the
+ *              amount of bits to write.
+ * Return:      Zero (OK) on success.  Minus one will be returned on failure
+ *              with the errno value set appropriately.
+ */
+
+#define EFUSEIOC_WRITE_FIELD_BLOB     _EFUSEIOC(0x0003)
+
+/* Command:     EFUSEIOC_WRITE_FIELD_BIT
+ * Description: Write a bit to an efuse (burn it).
+ * Arguments:   A structure containing bit field.
+ * Return:      Zero (OK) on success.  Minus one will be returned on failure
+ *              with the errno value set appropriately.
+ */
+
+#define EFUSEIOC_WRITE_FIELD_BIT      _EFUSEIOC(0x0004)
+
+/* Command:     EFUSEIOC_GET_FIELD_SIZE
+ * Description: Get the length of the field in bits.
+ * Arguments:   A structure containing the fields.
+ * Return:      Zero (OK) on success.  Minus one will be returned on failure
+ *              with the errno value set appropriately.
+ */
+
+#define EFUSEIOC_GET_FIELD_SIZE       _EFUSEIOC(0x0005)
+
+/* Command:     EFUSEIOC_READ_REG
+ * Description: Read an efuse register.
+ * Arguments:   A structure containing the block number and the register to
+ *              be read.
+ * Return:      Zero (OK) on success.  Minus one will be returned on failure
+ *              with the errno value set appropriately.
+ */
+
+#define EFUSEIOC_READ_REG             _EFUSEIOC(0x0006)
+
+/* Command:     EFUSEIOC_WRITE_REG
+ * Description: Write an efuse register.
+ * Arguments:   A structure containing the block number, the register to
+ *              write and value to be written.
+ * Return:      Zero (OK) on success.  Minus one will be returned on failure
+ *              with the errno value set appropriately.
+ */
+
+#define EFUSEIOC_WRITE_REG            _EFUSEIOC(0x0007)
+
+/* Command:     EFUSEIOC_READ_BLOCK
+ * Description: Read a key from efuse's block.
+ * Arguments:   A structure containing the block number, the dst_key pointer,
+ *              the offset in bits and the amount of bits to read.
+ * Return:      Zero (OK) on success.  Minus one will be returned on failure
+ *              with the errno value set appropriately.
+ */
+
+#define EFUSEIOC_READ_BLOCK           _EFUSEIOC(0x0008)
+
+/* Command:     EFUSEIOC_WRITE_BLOCK
+ * Description: Write a key to efuse's block.
+ * Arguments:   A structure containing the block number, the src_key pointer,
+ *              the offset in bits and the amount of bits to write.
+ * Return:      Zero (OK) on success.  Minus one will be returned on failure
+ *              with the errno value set appropriately.
+ */
+
+#define EFUSEIOC_WRITE_BLOCK          _EFUSEIOC(0x0009)
+
+/* Command:     EFUSEIOC_BATCH_WRITE_BEGIN
+ * Description: Start a batch operation, the efuse bits will be burned after
+ *              a batch write commit operation.
+ * Arguments:   None
+ * Return:      Zero (OK) on success.  Minus one will be returned on failure
+ *              with the errno value set appropriately.
+ */
+
+#define EFUSEIOC_BATCH_WRITE_BEGIN    _EFUSEIOC(0x000a)
+
+/* Command:     EFUSEIOC_BATCH_WRITE_CANCEL
+ * Description: Cancel a started batch write operation in progress.
+ * Arguments:   None
+ * Return:      Zero (OK) on success.  Minus one will be returned on failure
+ *              with the errno value set appropriately.
+ */
+
+#define EFUSEIOC_BATCH_WRITE_CANCEL   _EFUSEIOC(0x000b)
+
+/* Command:     EFUSEIOC_BATCH_WRITE_COMMIT
+ * Description: Commit a batch operation that was in progress.
+ * Arguments:   None
+ * Return:      Zero (OK) on success.  Minus one will be returned on failure
+ *              with the errno value set appropriately.
+ */
+
+#define EFUSEIOC_BATCH_WRITE_COMMIT   _EFUSEIOC(0x000c)
+
+/****************************************************************************
+ * Public Types
+ ****************************************************************************/
+
+/* Structure eFuse field */
+
+struct efuse_desc_s
+{
+  uint16_t   efuse_block;    /* Block of eFuse */
+  uint16_t   bit_start;      /* Start bit [0..65535] */
+  uint16_t   bit_count;      /* Length of bit field [1..-] */
+};
+
+/* Type definition for an eFuse field */
+
+typedef struct efuse_desc_s efuse_desc_t;
+
+/* Structure range address by blocks */
+
+typedef struct
+{
+  uint32_t start;
+  uint32_t end;
+} efuse_range_addr_t;
+
+/* Structs with the parameters passed to the IOCTLs */
+
+struct efuse_par
+{
+  uint16_t block;
+  uint16_t reg;
+  size_t   bit_offset;
+  size_t   bit_size;
+  uint8_t *data;
+};
+
+struct efuse_par_id
+{
+  efuse_desc_t **field;
+  size_t  size;
+  uint8_t *data;
+};
+
+/* This structure provides the "lower-half" driver operations available to
+ * the "upper-half" driver.
+ */
+
+struct efuse_lowerhalf_s;
+struct efuse_ops_s
+{
+  /* Required methods *******************************************************/
+
+  /* Read an EFUSE bit */
+
+  CODE int (*read_bit)(FAR struct efuse_lowerhalf_s *lower,
+                       const efuse_desc_t *field[],

Review comment:
       why need an array of efuse_desc_t




----------------------------------------------------------------
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.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org