Skip to content

Commit

Permalink
mmcsd: add multi partitions support
Browse files Browse the repository at this point in the history
include boot0,boot1,gp1,gp2,gp3,gp4,rpmb

Signed-off-by: wanggang26 <[email protected]>
  • Loading branch information
wanggang26 committed Oct 11, 2024
1 parent 110ab50 commit b014b0e
Show file tree
Hide file tree
Showing 4 changed files with 328 additions and 65 deletions.
13 changes: 8 additions & 5 deletions drivers/mmcsd/mmcsd.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@
# undef CONFIG_MMCSD_DUMPALL
#endif

#define MMCSD_PART_COUNT 8

/* Card type */

#define MMCSD_CARDTYPE_UNKNOWN 0 /* Unknown card type */
Expand Down Expand Up @@ -70,11 +72,12 @@ struct mmcsd_part_s

struct mmcsd_state_s
{
FAR struct sdio_dev_s *dev; /* The SDIO device bound to this instance */
uint8_t crefs; /* Open references on the driver */
mutex_t lock; /* Assures mutually exclusive access to the slot */
int minor; /* Device number */
struct mmcsd_part_s part; /* Partition data */
FAR struct sdio_dev_s *dev; /* The SDIO device bound to this instance */
uint8_t crefs; /* Open references on the driver */
mutex_t lock; /* Assures mutually exclusive access to the slot */
int minor; /* Device number */
struct mmcsd_part_s part[MMCSD_PART_COUNT]; /* Partition data */
uint32_t partnum; /* Partition number */

/* Status flags */

Expand Down
76 changes: 76 additions & 0 deletions drivers/mmcsd/mmcsd_extcsd.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
/****************************************************************************
* drivers/mmcsd/mmcsd_extcsd.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 __DRIVERS_MMCSD_MMCSD_EXTCSD_H
#define __DRIVERS_MMCSD_MMCSD_EXTCSD_H

/****************************************************************************
* Included Files
****************************************************************************/

#include <nuttx/config.h>
#include <stdint.h>

/****************************************************************************
* Pre-processor Definitions
****************************************************************************/

/* The Extended CSD register defines the Device properties and selected
* modes. It is 512 bytes long. The most significant 320 bytes are the
* Properties segment, that defines the Device capabilities and cannot be
* modified by the host. The lower 192 bytes are the Modes segment, that
* defines the configuration the Device is working in. These modes can be
* changed by the host by means of the SWITCH command.
* Multi bytes field is interpreted in little endian byte order.
*/

#define MMCSD_PART_SETTING_COMPLETED 0x1
#define MMCSD_PART_SUPPORT_PART_EN 0x1

#define MMCSD_EXTCSD_GP_SIZE_MULT 143 /* R/W */
#define MMCSD_EXTCSD_PARTITION_SETTING_COMPLETED 155 /* R/W */
#define MMCSD_EXTCSD_PARTITION_SUPPORT 160 /* RO */
#define MMCSD_EXTCSD_RPMB_SIZE_MULT 168 /* RO */
#define MMCSD_EXTCSD_HC_WP_GRP_SIZE 221 /* RO */
#define MMCSD_EXTCSD_HC_ERASE_GRP_SIZE 224 /* RO */
#define MMCSD_EXTCSD_BOOT_SIZE_MULT 226 /* RO */

/****************************************************************************
* Public Types
****************************************************************************/

/****************************************************************************
* Public Functions Definitions
****************************************************************************/

#undef EXTERN
#if defined(__cplusplus)
#define EXTERN extern "C"
extern "C"
{
#else
#define EXTERN extern
#endif

#undef EXTERN
#if defined(__cplusplus)
}
#endif
#endif /* __DRIVERS_MMCSD_MMCSD_EXTCSD_H */
Loading

0 comments on commit b014b0e

Please sign in to comment.