Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove support for CONFIG_FS_WRITABLE #602

Merged
merged 12 commits into from
Mar 22, 2020
Merged
Prev Previous commit
Run all .c and .h files in previous commits through nxstyle.
  • Loading branch information
gregory-nutt committed Mar 21, 2020
commit 62317ddb8be801f2f21ebe95bc35e4c36176cf7a
82 changes: 58 additions & 24 deletions arch/arm/src/cxd56xx/cxd56_emmc.c
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,10 @@
*
****************************************************************************/

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

#include <nuttx/config.h>

#include <sys/types.h>
Expand All @@ -55,6 +59,10 @@
#include "hardware/cxd56_emmc.h"
#include "cxd56_pinconfig.h"

/****************************************************************************
* Pre-processoro Definitions
****************************************************************************/

#define SECTOR_SIZE (512)

#define EMMC_DATA_WRITE 0
Expand All @@ -67,7 +75,27 @@
#define EMMC_RESP_R2 3
#define EMMC_RESP_R3 4

struct emmc_dma_desc_s {
#define EMMC_CLKDIV_UNDER_400KHZ (32u)
#define EMMC_CLKDIV_NON_DIV (0u)

#define EMMC_RCA (2) /* greater than 1 */

#define EMMC_DATA_TIMEOUT (0xFFFFFFu) /* max reg value */
#define EMMC_RESP_TIMEOUT (0xFFu) /* max reg value */

#define EMMC_MSIZE (6) /* Burst size is 512B */
#define EMMC_FIFO_DEPTH (0x100) /* FIFO size is 1KB */

#ifndef MIN
#define MIN(a, b) ((a) < (b) ? (a) : (b))
#endif

/****************************************************************************
* Private Types
****************************************************************************/

struct emmc_dma_desc_s
{
uint32_t ctrl;
uint32_t size;
uint32_t addr;
Expand All @@ -81,6 +109,10 @@ struct cxd56_emmc_state_s
uint32_t total_sectors;
};

/****************************************************************************
* Private Function Prototypes
****************************************************************************/

/* Block driver interfaces **************************************************/

static int cxd56_emmc_open(FAR struct inode *inode);
Expand All @@ -98,6 +130,10 @@ static int cxd56_emmc_geometry(FAR struct inode *inode,
struct geometry *geometry);
static int emmc_interrupt(int irq, FAR void *context, FAR void *arg);

/****************************************************************************
* Private Data
****************************************************************************/

static const struct block_operations g_bops =
{
cxd56_emmc_open, /* open */
Expand All @@ -106,29 +142,18 @@ static const struct block_operations g_bops =
#if !defined(CONFIG_MMCSD_READONLY)
cxd56_emmc_write, /* write */
#else
NULL, /* write */
NULL, /* write */
#endif
cxd56_emmc_geometry, /* geometry */
NULL /* ioctl */
NULL /* ioctl */
};

static sem_t g_waitsem;
struct cxd56_emmc_state_s g_emmcdev;

#define EMMC_CLKDIV_UNDER_400KHZ (32u)
#define EMMC_CLKDIV_NON_DIV (0u)

#define EMMC_RCA (2) /* greater than 1 */

#define EMMC_DATA_TIMEOUT (0xFFFFFFu) /* max reg value */
#define EMMC_RESP_TIMEOUT (0xFFu) /* max reg value */

#define EMMC_MSIZE (6) /* Burst size is 512B */
#define EMMC_FIFO_DEPTH (0x100) /* FIFO size is 1KB */

#ifndef MIN
#define MIN(a, b) ((a) < (b) ? (a) : (b))
#endif
/****************************************************************************
* Private Functions
****************************************************************************/

static void emmc_takesem(FAR sem_t *sem)
{
Expand Down Expand Up @@ -308,9 +333,9 @@ static struct emmc_dma_desc_s *emmc_setupdma(void *buf, unsigned int nbytes)

/* Adjust first and last descriptor members */

descs[0].ctrl |= EMMC_IDMAC_DES0_FD;
descs[ndescs-1].ctrl |= EMMC_IDMAC_DES0_LD;
descs[ndescs-1].next = 0;
descs[0].ctrl |= EMMC_IDMAC_DES0_FD;
descs[ndescs - 1].ctrl |= EMMC_IDMAC_DES0_LD;
descs[ndescs - 1].next = 0;

#ifdef CONFIG_DEBUG_VERBOSE
for (i = 0, d = descs; i < ndescs; i++, d++)
Expand Down Expand Up @@ -341,6 +366,7 @@ static int emmc_checkresponse(void)
ferr("Response error %08x\n", resp);
return -EIO;
}

return OK;
}

Expand Down Expand Up @@ -454,6 +480,7 @@ static int emmc_is_powerup(void)
{
return 0;
}

up_mdelay(5);
}
while (--retry);
Expand Down Expand Up @@ -716,7 +743,7 @@ static int cxd56_emmc_readsectors(FAR struct cxd56_emmc_state_s *priv,
ret = -EIO;
}

finish:
finish:
emmc_givesem(&priv->excsem);
kmm_free(descs);

Expand Down Expand Up @@ -787,7 +814,7 @@ static int cxd56_emmc_writesectors(FAR struct cxd56_emmc_state_s *priv,

emmc_flushwritefifo();

finish:
finish:
emmc_givesem(&priv->excsem);
kmm_free(descs);

Expand Down Expand Up @@ -826,8 +853,9 @@ static int cxd56_emmc_close(FAR struct inode *inode)
return OK;
}

static ssize_t cxd56_emmc_read(FAR struct inode *inode, unsigned char *buffer,
size_t start_sector, unsigned int nsectors)
static ssize_t cxd56_emmc_read(FAR struct inode *inode,
unsigned char *buffer, size_t start_sector,
unsigned int nsectors)
{
FAR struct cxd56_emmc_state_s *priv;
int ret;
Expand Down Expand Up @@ -927,9 +955,11 @@ int cxd56_emmcinitialize(void)
kmm_free(buf);
return -EIO;
}

priv->total_sectors = *(FAR uint32_t *)&buf[EXTCSD_SEC_COUNT];
kmm_free(descs);
}

kmm_free(buf);
}

Expand All @@ -943,6 +973,10 @@ int cxd56_emmcinitialize(void)
return OK;
}

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

int emmc_uninitialize(void)
{
/* Send power off command */
Expand Down
23 changes: 15 additions & 8 deletions arch/arm/src/lc823450/lc823450_mmcl.c
Original file line number Diff line number Diff line change
Expand Up @@ -78,10 +78,13 @@ static int mmcl_open(FAR struct inode *inode);
static int mmcl_close(FAR struct inode *inode);
static ssize_t mmcl_read(FAR struct inode *inode, unsigned char *buffer,
size_t start_sector, unsigned int nsectors);
static ssize_t mmcl_write(FAR struct inode *inode, const unsigned char *buffer,
size_t start_sector, unsigned int nsectors);
static int mmcl_geometry(FAR struct inode *inode, struct geometry *geometry);
static int mmcl_ioctl(FAR struct inode *inode, int cmd, unsigned long arg);
static ssize_t mmcl_write(FAR struct inode *inode,
const unsigned char *buffer, size_t start_sector,
unsigned int nsectors);
static int mmcl_geometry(FAR struct inode *inode,
struct geometry *geometry);
static int mmcl_ioctl(FAR struct inode *inode, int cmd,
unsigned long arg);

/****************************************************************************
* Private Data
Expand Down Expand Up @@ -163,8 +166,9 @@ static ssize_t mmcl_read(FAR struct inode *inode, unsigned char *buffer,
*
****************************************************************************/

static ssize_t mmcl_write(FAR struct inode *inode, const unsigned char *buffer,
size_t start_sector, unsigned int nsectors)
static ssize_t mmcl_write(FAR struct inode *inode,
const unsigned char *buffer, size_t start_sector,
unsigned int nsectors)
{
ssize_t nwrite;
struct mmcl_dev_s *dev;
Expand Down Expand Up @@ -249,7 +253,8 @@ static int mmcl_ioctl(FAR struct inode *inode, int cmd, unsigned long arg)
* Name: mmcl_allocdev
****************************************************************************/

static FAR struct mmcl_dev_s *mmcl_allocdev(int number, FAR struct mtd_dev_s *mtd)
static FAR struct mmcl_dev_s *mmcl_allocdev(int number,
FAR struct mtd_dev_s *mtd)
{
struct mmcl_dev_s *dev;
int ret;
Expand All @@ -268,7 +273,8 @@ static FAR struct mmcl_dev_s *mmcl_allocdev(int number, FAR struct mtd_dev_s *mt
* from the size of a pointer).
*/

ret = MTD_IOCTL(mtd, MTDIOC_GEOMETRY, (unsigned long)((uintptr_t)&dev->geo));
ret = MTD_IOCTL(mtd, MTDIOC_GEOMETRY,
(unsigned long)((uintptr_t)&dev->geo));
if (ret < 0)
{
finfo("MTD ioctl(MTDIOC_GEOMETRY) failed: %d\n", ret);
Expand Down Expand Up @@ -317,6 +323,7 @@ int mmcl_initialize(int minor, FAR struct mtd_dev_s *mtd)
CONFIG_MTD_DEVPATH1,
#endif
};

int ret = -ENOMEM;

/* Sanity check */
Expand Down
59 changes: 30 additions & 29 deletions boards/arm/stm32l4/stm32l476vg-disco/src/stm32_appinit.c
Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,9 @@

#include "stm32l476vg-disco.h"

/* Conditional logic in stm32l476vg-disco.h will determine if certain features
* are supported. Tests for these features need to be made after including
* stm32l476vg-disco.h.
/* Conditional logic in stm32l476vg-disco.h will determine if certain
* features are supported. Tests for these features need to be made after
* including stm32l476vg-disco.h.
*/

#ifdef HAVE_RTC_DRIVER
Expand Down Expand Up @@ -129,7 +129,7 @@ int board_app_initialize(uintptr_t arg)
FAR struct rtc_lowerhalf_s *rtclower;
#endif
#if defined(HAVE_N25QXXX)
FAR struct mtd_dev_s *mtd_temp;
FAR struct mtd_dev_s *mtd_temp;
#endif
#if defined(HAVE_N25QXXX_CHARDEV)
char blockdev[18];
Expand Down Expand Up @@ -197,34 +197,35 @@ FAR struct mtd_dev_s *mtd_temp;
_err("ERROR: n25qxxx_initialize failed\n");
return ret;
}

g_mtd_fs = mtd_temp;

#ifdef CONFIG_MTD_PARTITION
{
FAR struct mtd_geometry_s geo;
off_t nblocks;

/* Setup a partition of 256KiB for our file system. */

ret = MTD_IOCTL(g_mtd_fs, MTDIOC_GEOMETRY,
(unsigned long)(uintptr_t)&geo);
if (ret < 0)
{
_err("ERROR: MTDIOC_GEOMETRY failed\n");
return ret;
}

nblocks = (256*1024) / geo.blocksize;

mtd_temp = mtd_partition(g_mtd_fs, 0, nblocks);
if (!mtd_temp)
{
_err("ERROR: mtd_partition failed\n");
return ret;
}

g_mtd_fs = mtd_temp;
}
{
FAR struct mtd_geometry_s geo;
off_t nblocks;

/* Setup a partition of 256KiB for our file system. */

ret = MTD_IOCTL(g_mtd_fs, MTDIOC_GEOMETRY,
(unsigned long)(uintptr_t)&geo);
if (ret < 0)
{
_err("ERROR: MTDIOC_GEOMETRY failed\n");
return ret;
}

nblocks = (256 * 1024) / geo.blocksize;

mtd_temp = mtd_partition(g_mtd_fs, 0, nblocks);
if (!mtd_temp)
{
_err("ERROR: mtd_partition failed\n");
return ret;
}

g_mtd_fs = mtd_temp;
}
#endif

#ifdef HAVE_N25QXXX_SMARTFS
Expand Down
Loading