Minor, cosmetic changes from review of last comment.
This commit is contained in:
parent
ed61c49530
commit
7858ed834b
@ -321,12 +321,12 @@ int mmcl_initialize(int minor, FAR struct mtd_dev_s *mtd)
|
|||||||
{
|
{
|
||||||
struct mmcl_dev_s *dev;
|
struct mmcl_dev_s *dev;
|
||||||
const char *devname[CONFIG_MTD_DEV_MAX] =
|
const char *devname[CONFIG_MTD_DEV_MAX] =
|
||||||
{
|
{
|
||||||
CONFIG_MTD_DEVPATH0,
|
CONFIG_MTD_DEVPATH0,
|
||||||
#if CONFIG_MTD_DEV_MAX > 1
|
#if CONFIG_MTD_DEV_MAX > 1
|
||||||
CONFIG_MTD_DEVPATH1,
|
CONFIG_MTD_DEVPATH1,
|
||||||
#endif
|
#endif
|
||||||
};
|
};
|
||||||
int ret = -ENOMEM;
|
int ret = -ENOMEM;
|
||||||
|
|
||||||
/* Sanity check */
|
/* Sanity check */
|
||||||
|
@ -316,6 +316,7 @@ static int lc823450_ioctl(FAR struct mtd_dev_s *dev, int cmd, unsigned long arg)
|
|||||||
FAR struct lc823450_mtd_dev_s *priv = (FAR struct lc823450_mtd_dev_s *)dev;
|
FAR struct lc823450_mtd_dev_s *priv = (FAR struct lc823450_mtd_dev_s *)dev;
|
||||||
FAR struct mtd_geometry_s *geo;
|
FAR struct mtd_geometry_s *geo;
|
||||||
FAR void **ppv;
|
FAR void **ppv;
|
||||||
|
|
||||||
finfo("cmd=%xh, arg=%xh\n", cmd, arg);
|
finfo("cmd=%xh, arg=%xh\n", cmd, arg);
|
||||||
|
|
||||||
mtd_semtake(&priv->sem);
|
mtd_semtake(&priv->sem);
|
||||||
@ -343,6 +344,7 @@ static int lc823450_ioctl(FAR struct mtd_dev_s *dev, int cmd, unsigned long arg)
|
|||||||
geo->neraseblocks = priv->nblocks;
|
geo->neraseblocks = priv->nblocks;
|
||||||
ret = OK;
|
ret = OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
finfo("blocksize=%d erasesize=%d neraseblocks=%d\n", geo->blocksize,
|
finfo("blocksize=%d erasesize=%d neraseblocks=%d\n", geo->blocksize,
|
||||||
geo->erasesize, geo->neraseblocks);
|
geo->erasesize, geo->neraseblocks);
|
||||||
break;
|
break;
|
||||||
@ -364,7 +366,9 @@ static int lc823450_ioctl(FAR struct mtd_dev_s *dev, int cmd, unsigned long arg)
|
|||||||
|
|
||||||
case MTDIOC_BULKERASE:
|
case MTDIOC_BULKERASE:
|
||||||
finfo("MTDIOC_BULKERASE\n");
|
finfo("MTDIOC_BULKERASE\n");
|
||||||
|
|
||||||
/* Erase the entire device */
|
/* Erase the entire device */
|
||||||
|
|
||||||
ret = OK;
|
ret = OK;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@ -400,6 +404,7 @@ static int mtd_mediainitialize(FAR struct lc823450_mtd_dev_s *dev)
|
|||||||
unsigned long nblocks;
|
unsigned long nblocks;
|
||||||
unsigned long blocksize;
|
unsigned long blocksize;
|
||||||
uint32_t sysclk = lc823450_get_ahb();
|
uint32_t sysclk = lc823450_get_ahb();
|
||||||
|
|
||||||
finfo("enter\n");
|
finfo("enter\n");
|
||||||
|
|
||||||
mtd_semtake(&dev->sem);
|
mtd_semtake(&dev->sem);
|
||||||
@ -447,11 +452,11 @@ static int mtd_mediainitialize(FAR struct lc823450_mtd_dev_s *dev)
|
|||||||
|
|
||||||
ret = lc823450_sdc_changespeedmode(dev->channel, 1);
|
ret = lc823450_sdc_changespeedmode(dev->channel, 1);
|
||||||
|
|
||||||
if (0 == ret)
|
if (0 == ret)
|
||||||
{
|
{
|
||||||
ret = lc823450_sdc_setclock(dev->channel, 40000000, sysclk);
|
ret = lc823450_sdc_setclock(dev->channel, 40000000, sysclk);
|
||||||
finfo("ch=%d HS mode ret=%d \n", dev->channel, ret);
|
finfo("ch=%d HS mode ret=%d \n", dev->channel, ret);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef CONFIG_LC823450_SDC_UHS1
|
#ifdef CONFIG_LC823450_SDC_UHS1
|
||||||
@ -464,6 +469,7 @@ get_card_size:
|
|||||||
finfo("ERROR: No media found\n");
|
finfo("ERROR: No media found\n");
|
||||||
goto exit_with_error;
|
goto exit_with_error;
|
||||||
}
|
}
|
||||||
|
|
||||||
finfo("blocksize=%d nblocks=%d\n", blocksize, nblocks);
|
finfo("blocksize=%d nblocks=%d\n", blocksize, nblocks);
|
||||||
|
|
||||||
dev->nblocks = nblocks;
|
dev->nblocks = nblocks;
|
||||||
@ -502,7 +508,8 @@ static FAR struct mtd_dev_s *lc823450_mtd_allocdev(uint32_t channel)
|
|||||||
|
|
||||||
/* Create an instance of the LC823450 MTD device state structure */
|
/* Create an instance of the LC823450 MTD device state structure */
|
||||||
|
|
||||||
priv = (FAR struct lc823450_mtd_dev_s *)kmm_zalloc(sizeof(struct lc823450_mtd_dev_s));
|
priv = (FAR struct lc823450_mtd_dev_s *)
|
||||||
|
kmm_zalloc(sizeof(struct lc823450_mtd_dev_s));
|
||||||
if (!priv)
|
if (!priv)
|
||||||
{
|
{
|
||||||
finfo("Failed to allocate the LC823450 MTD devicestructure\n");
|
finfo("Failed to allocate the LC823450 MTD devicestructure\n");
|
||||||
@ -668,13 +675,14 @@ int lc823450_mtd_initialize(uint32_t devno)
|
|||||||
}
|
}
|
||||||
|
|
||||||
ret = mmcl_createpartition(devno, partno, g_mtdpart[i]);
|
ret = mmcl_createpartition(devno, partno, g_mtdpart[i]);
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
{
|
{
|
||||||
finfo("%s(): mmcl_initialize part%d failed: %d\n", __func__, partno, ret);
|
finfo("%s(): mmcl_initialize part%d failed: %d\n",
|
||||||
mtd_semgive(&g_sem);
|
__func__, partno, ret);
|
||||||
DEBUGASSERT(0);
|
mtd_semgive(&g_sem);
|
||||||
return ret;
|
DEBUGASSERT(0);
|
||||||
}
|
return ret;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
mtd_semgive(&g_sem);
|
mtd_semgive(&g_sem);
|
||||||
|
@ -58,6 +58,7 @@
|
|||||||
* Partition #9: cache
|
* Partition #9: cache
|
||||||
* Partition #10: contents
|
* Partition #10: contents
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#define LC823450_NPARTS 10 /* Number of partitions */
|
#define LC823450_NPARTS 10 /* Number of partitions */
|
||||||
#define LC823450_PART1_START 0 /* Start sector of partition 1 */
|
#define LC823450_PART1_START 0 /* Start sector of partition 1 */
|
||||||
#define LC823450_PART1_NBLOCKS 1024 /* Number of sectors of partition 1 */
|
#define LC823450_PART1_NBLOCKS 1024 /* Number of sectors of partition 1 */
|
||||||
@ -81,7 +82,7 @@
|
|||||||
#define LC823450_PART10_NBLOCKS 0 /* 0 means all remaining sectors */
|
#define LC823450_PART10_NBLOCKS 0 /* 0 means all remaining sectors */
|
||||||
|
|
||||||
#if CONFIG_MTD_CP_STARTBLOCK != LC823450_PART10_START
|
#if CONFIG_MTD_CP_STARTBLOCK != LC823450_PART10_START
|
||||||
#error "Start sector of contents patrition missmatched"
|
# error "Start sector of contents patrition missmatched"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
|
@ -86,7 +86,8 @@ static sem_t _sdc_sem[2] =
|
|||||||
static SdDrCfg SdCh0;
|
static SdDrCfg SdCh0;
|
||||||
static SdDrCfg SdCh1;
|
static SdDrCfg SdCh1;
|
||||||
|
|
||||||
static SdDrCfg *cfg[2] = {
|
static SdDrCfg *cfg[2] =
|
||||||
|
{
|
||||||
&SdCh0,
|
&SdCh0,
|
||||||
&SdCh1
|
&SdCh1
|
||||||
};
|
};
|
||||||
@ -102,7 +103,6 @@ static uint32_t _sec_cache[512/4];
|
|||||||
static uint32_t _sec_cache_add = 0xffffffff;
|
static uint32_t _sec_cache_add = 0xffffffff;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Public Data
|
* Public Data
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
@ -122,8 +122,10 @@ extern void sddep_voltage_switch(SdDrCfg *cfg);
|
|||||||
extern void sddep_set_clk(SdDrCfg *);
|
extern void sddep_set_clk(SdDrCfg *);
|
||||||
extern SINT_T sddep_wait(UI_32, SdDrCfg *);
|
extern SINT_T sddep_wait(UI_32, SdDrCfg *);
|
||||||
extern SINT_T sddep_wait_status(UI_32 req, UI_32 *status, SdDrCfg *cfg);
|
extern SINT_T sddep_wait_status(UI_32 req, UI_32 *status, SdDrCfg *cfg);
|
||||||
extern SINT_T sddep_read(void *src, void *dst, UI_32 size, SINT_T type, SdDrCfg *cfg);
|
extern SINT_T sddep_read(void *src, void *dst, UI_32 size, SINT_T type,
|
||||||
extern SINT_T sddep_write(void *src, void *dst, UI_32 size, SINT_T type, SdDrCfg *cfg);
|
SdDrCfg *cfg);
|
||||||
|
extern SINT_T sddep_write(void *src, void *dst, UI_32 size, SINT_T type,
|
||||||
|
SdDrCfg *cfg);
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Private Functions
|
* Private Functions
|
||||||
@ -186,7 +188,6 @@ static void lc823450_sdc_access_led(uint32_t ch, unsigned long sector)
|
|||||||
# define lc823450_sdc_access_led(a,b)
|
# define lc823450_sdc_access_led(a,b)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Public Functions
|
* Public Functions
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
@ -221,6 +222,8 @@ int lc823450_sdc_clearcardinfo(uint32_t ch)
|
|||||||
|
|
||||||
int lc823450_sdc_initialize(uint32_t ch)
|
int lc823450_sdc_initialize(uint32_t ch)
|
||||||
{
|
{
|
||||||
|
int ret;
|
||||||
|
|
||||||
/* Only ES2 is supported */
|
/* Only ES2 is supported */
|
||||||
|
|
||||||
ASSERT(1 == cpu_ver);
|
ASSERT(1 == cpu_ver);
|
||||||
@ -267,7 +270,7 @@ int lc823450_sdc_initialize(uint32_t ch)
|
|||||||
|
|
||||||
mcinfo("++++ start \n");
|
mcinfo("++++ start \n");
|
||||||
_sdc_semtake(&_sdc_sem[ch]);
|
_sdc_semtake(&_sdc_sem[ch]);
|
||||||
int ret = SdDrInitialize(cfg[ch]);
|
ret = SdDrInitialize(cfg[ch]);
|
||||||
_sdc_semgive(&_sdc_sem[ch]);
|
_sdc_semgive(&_sdc_sem[ch]);
|
||||||
mcinfo("---- end ret=%d \n", ret);
|
mcinfo("---- end ret=%d \n", ret);
|
||||||
|
|
||||||
@ -280,11 +283,14 @@ int lc823450_sdc_initialize(uint32_t ch)
|
|||||||
|
|
||||||
int lc823450_sdc_finalize(uint32_t ch)
|
int lc823450_sdc_finalize(uint32_t ch)
|
||||||
{
|
{
|
||||||
|
int ret;
|
||||||
|
|
||||||
mcinfo("++++ start ch=%ld \n", ch);
|
mcinfo("++++ start ch=%ld \n", ch);
|
||||||
_sdc_semtake(&_sdc_sem[ch]);
|
_sdc_semtake(&_sdc_sem[ch]);
|
||||||
int ret = SdDrFinalize(cfg[ch]);
|
ret = SdDrFinalize(cfg[ch]);
|
||||||
_sdc_semgive(&_sdc_sem[ch]);
|
_sdc_semgive(&_sdc_sem[ch]);
|
||||||
mcinfo("---- end ret=%d \n", ret);
|
mcinfo("---- end ret=%d \n", ret);
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -294,10 +300,12 @@ int lc823450_sdc_finalize(uint32_t ch)
|
|||||||
|
|
||||||
int lc823450_sdc_identifycard(uint32_t ch)
|
int lc823450_sdc_identifycard(uint32_t ch)
|
||||||
{
|
{
|
||||||
|
int ret;
|
||||||
|
|
||||||
mcinfo("++++ start \n");
|
mcinfo("++++ start \n");
|
||||||
_sdc_semtake(&_sdc_sem[ch]);
|
_sdc_semtake(&_sdc_sem[ch]);
|
||||||
|
|
||||||
int ret = SdDrIdentifyCard(cfg[ch]);
|
ret = SdDrIdentifyCard(cfg[ch]);
|
||||||
|
|
||||||
#ifdef CONFIG_LC823450_SDC_CACHE
|
#ifdef CONFIG_LC823450_SDC_CACHE
|
||||||
if (ch)
|
if (ch)
|
||||||
@ -318,15 +326,17 @@ int lc823450_sdc_identifycard(uint32_t ch)
|
|||||||
|
|
||||||
int lc823450_sdc_setclock(uint32_t ch, uint32_t limitClk, uint32_t sysClk)
|
int lc823450_sdc_setclock(uint32_t ch, uint32_t limitClk, uint32_t sysClk)
|
||||||
{
|
{
|
||||||
|
int ret;
|
||||||
|
|
||||||
mcinfo("++++ start ch=%ld limitClk=%ld sysClk=%ld\n", ch, limitClk, sysClk);
|
mcinfo("++++ start ch=%ld limitClk=%ld sysClk=%ld\n", ch, limitClk, sysClk);
|
||||||
_sdc_semtake(&_sdc_sem[ch]);
|
_sdc_semtake(&_sdc_sem[ch]);
|
||||||
int ret = SdDrSetClock(limitClk, sysClk, cfg[ch]);
|
ret = SdDrSetClock(limitClk, sysClk, cfg[ch]);
|
||||||
_sdc_semgive(&_sdc_sem[ch]);
|
_sdc_semgive(&_sdc_sem[ch]);
|
||||||
mcinfo("---- end ret=%d \n", ret);
|
mcinfo("---- end ret=%d \n", ret);
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Name: lc823450_sdc_refmediatype
|
* Name: lc823450_sdc_refmediatype
|
||||||
*
|
*
|
||||||
@ -335,11 +345,14 @@ int lc823450_sdc_setclock(uint32_t ch, uint32_t limitClk, uint32_t sysClk)
|
|||||||
|
|
||||||
int lc823450_sdc_refmediatype(uint32_t ch)
|
int lc823450_sdc_refmediatype(uint32_t ch)
|
||||||
{
|
{
|
||||||
|
int ret;
|
||||||
|
|
||||||
mcinfo("++++ start \n");
|
mcinfo("++++ start \n");
|
||||||
_sdc_semtake(&_sdc_sem[ch]);
|
_sdc_semtake(&_sdc_sem[ch]);
|
||||||
int ret = SdDrRefMediaType(cfg[ch]);
|
ret = SdDrRefMediaType(cfg[ch]);
|
||||||
_sdc_semgive(&_sdc_sem[ch]);
|
_sdc_semgive(&_sdc_sem[ch]);
|
||||||
mcinfo("---- end ret=%d \n", ret);
|
mcinfo("---- end ret=%d \n", ret);
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -350,10 +363,12 @@ int lc823450_sdc_refmediatype(uint32_t ch)
|
|||||||
int lc823450_sdc_getcardsize(uint32_t ch,
|
int lc823450_sdc_getcardsize(uint32_t ch,
|
||||||
unsigned long *pSecNum, unsigned long *pSecSize)
|
unsigned long *pSecNum, unsigned long *pSecSize)
|
||||||
{
|
{
|
||||||
|
int ret;
|
||||||
|
|
||||||
mcinfo("++++ start \n");
|
mcinfo("++++ start \n");
|
||||||
_sdc_semtake(&_sdc_sem[ch]);
|
_sdc_semtake(&_sdc_sem[ch]);
|
||||||
|
|
||||||
int ret = SdDrGetCardSize(pSecNum, pSecSize, cfg[ch]);
|
ret = SdDrGetCardSize(pSecNum, pSecSize, cfg[ch]);
|
||||||
|
|
||||||
_sdc_semgive(&_sdc_sem[ch]);
|
_sdc_semgive(&_sdc_sem[ch]);
|
||||||
mcinfo("---- end ret=%d \n", ret);
|
mcinfo("---- end ret=%d \n", ret);
|
||||||
@ -368,15 +383,15 @@ int lc823450_sdc_readsector(uint32_t ch,
|
|||||||
unsigned long addr, unsigned short cnt,
|
unsigned long addr, unsigned short cnt,
|
||||||
void *pbuf, unsigned long type)
|
void *pbuf, unsigned long type)
|
||||||
{
|
{
|
||||||
|
int ret = 0;
|
||||||
|
int i = 0;
|
||||||
|
|
||||||
_sdc_semtake(&_sdc_sem[ch]);
|
_sdc_semtake(&_sdc_sem[ch]);
|
||||||
|
|
||||||
#ifdef CONFIG_LC823450_SDC_LOG
|
#ifdef CONFIG_LC823450_SDC_LOG
|
||||||
mcinfo("++++ start ch=%d, addr=%ld, cnt=%d \n", ch, addr, cnt);
|
mcinfo("++++ start ch=%d, addr=%ld, cnt=%d \n", ch, addr, cnt);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
int ret = 0;
|
|
||||||
int i = 0;
|
|
||||||
|
|
||||||
#ifdef CONFIG_LC823450_SDC_CACHE
|
#ifdef CONFIG_LC823450_SDC_CACHE
|
||||||
if (ch && _sec_cache_enabled && 1 == cnt && addr == _sec_cache_add)
|
if (ch && _sec_cache_enabled && 1 == cnt && addr == _sec_cache_add)
|
||||||
{
|
{
|
||||||
@ -402,7 +417,9 @@ int lc823450_sdc_readsector(uint32_t ch,
|
|||||||
{
|
{
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
mcinfo("ret=%d ch=%d add=%ld cnt=%d i=%d \n", ret, ch, addr, cnt, i);
|
|
||||||
|
mcinfo("ret=%d ch=%d add=%ld cnt=%d i=%d \n",
|
||||||
|
ret, ch, addr, cnt, i);
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef CONFIG_LC823450_SDC_CACHE
|
#ifdef CONFIG_LC823450_SDC_CACHE
|
||||||
@ -417,6 +434,7 @@ int lc823450_sdc_readsector(uint32_t ch,
|
|||||||
_sec_cache_enabled = 1;
|
_sec_cache_enabled = 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (_sec_cache_enabled)
|
if (_sec_cache_enabled)
|
||||||
{
|
{
|
||||||
if (1 == cnt && 0 == ret)
|
if (1 == cnt && 0 == ret)
|
||||||
@ -447,6 +465,8 @@ int lc823450_sdc_writesector(uint32_t ch,
|
|||||||
unsigned long addr, unsigned short cnt,
|
unsigned long addr, unsigned short cnt,
|
||||||
void *pbuf, unsigned long type)
|
void *pbuf, unsigned long type)
|
||||||
{
|
{
|
||||||
|
int ret;
|
||||||
|
|
||||||
_sdc_semtake(&_sdc_sem[ch]);
|
_sdc_semtake(&_sdc_sem[ch]);
|
||||||
|
|
||||||
#ifdef CONFIG_LC823450_SDC_LOG
|
#ifdef CONFIG_LC823450_SDC_LOG
|
||||||
@ -466,7 +486,7 @@ int lc823450_sdc_writesector(uint32_t ch,
|
|||||||
sched_add_bo((uint64_t)cnt);
|
sched_add_bo((uint64_t)cnt);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
int ret = SdDrWriteSector(addr, cnt, pbuf, type, cfg[ch]);
|
ret = SdDrWriteSector(addr, cnt, pbuf, type, cfg[ch]);
|
||||||
|
|
||||||
if (0 > ret)
|
if (0 > ret)
|
||||||
{
|
{
|
||||||
@ -494,6 +514,8 @@ int lc823450_sdc_checktrim(uint32_t ch)
|
|||||||
|
|
||||||
int lc823450_sdc_trimsector(uint32_t ch, unsigned long addr, unsigned short cnt)
|
int lc823450_sdc_trimsector(uint32_t ch, unsigned long addr, unsigned short cnt)
|
||||||
{
|
{
|
||||||
|
int ret;
|
||||||
|
|
||||||
_sdc_semtake(&_sdc_sem[ch]);
|
_sdc_semtake(&_sdc_sem[ch]);
|
||||||
|
|
||||||
#ifdef CONFIG_LC823450_SDC_LOG
|
#ifdef CONFIG_LC823450_SDC_LOG
|
||||||
@ -506,8 +528,7 @@ int lc823450_sdc_trimsector(uint32_t ch, unsigned long addr, unsigned short cnt)
|
|||||||
sched_add_bt((uint64_t)cnt);
|
sched_add_bt((uint64_t)cnt);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
int ret = SdDrEraseSeq(0x00000001, addr, cnt, cfg[ch]);
|
ret = SdDrEraseSeq(0x00000001, addr, cnt, cfg[ch]);
|
||||||
|
|
||||||
if (0 > ret)
|
if (0 > ret)
|
||||||
{
|
{
|
||||||
mcinfo("ret=%d ch=%d add=%ld cnt=%d \n", ret, ch, addr, cnt);
|
mcinfo("ret=%d ch=%d add=%ld cnt=%d \n", ret, ch, addr, cnt);
|
||||||
@ -525,10 +546,12 @@ int lc823450_sdc_trimsector(uint32_t ch, unsigned long addr, unsigned short cnt)
|
|||||||
|
|
||||||
int lc823450_sdc_cachectl(uint32_t ch, int ctrl)
|
int lc823450_sdc_cachectl(uint32_t ch, int ctrl)
|
||||||
{
|
{
|
||||||
|
int ret;
|
||||||
|
|
||||||
mcinfo("++++ ch=%d, ctrl=%d \n", ch, ctrl);
|
mcinfo("++++ ch=%d, ctrl=%d \n", ch, ctrl);
|
||||||
_sdc_semtake(&_sdc_sem[ch]);
|
_sdc_semtake(&_sdc_sem[ch]);
|
||||||
|
|
||||||
int ret = SdDrCacheCtrl(ctrl, cfg[ch]);
|
ret = SdDrCacheCtrl(ctrl, cfg[ch]);
|
||||||
|
|
||||||
_sdc_semgive(&_sdc_sem[ch]);
|
_sdc_semgive(&_sdc_sem[ch]);
|
||||||
mcinfo("---- end ret=%d \n", ret);
|
mcinfo("---- end ret=%d \n", ret);
|
||||||
@ -541,10 +564,12 @@ int lc823450_sdc_cachectl(uint32_t ch, int ctrl)
|
|||||||
|
|
||||||
int lc823450_sdc_changespeedmode(uint32_t ch, int mode)
|
int lc823450_sdc_changespeedmode(uint32_t ch, int mode)
|
||||||
{
|
{
|
||||||
|
int ret;
|
||||||
|
|
||||||
mcinfo("++++ ch=%d, mode=%d \n", ch, mode);
|
mcinfo("++++ ch=%d, mode=%d \n", ch, mode);
|
||||||
_sdc_semtake(&_sdc_sem[ch]);
|
_sdc_semtake(&_sdc_sem[ch]);
|
||||||
|
|
||||||
int ret = SdDrChangeSpeedMode(mode, cfg[ch]);
|
ret = SdDrChangeSpeedMode(mode, cfg[ch]);
|
||||||
|
|
||||||
if (0 == ret)
|
if (0 == ret)
|
||||||
{
|
{
|
||||||
@ -575,22 +600,27 @@ int lc823450_sdc_changespeedmode(uint32_t ch, int mode)
|
|||||||
|
|
||||||
int lc823450_sdc_getcid(uint32_t ch, char *cidstr, int length)
|
int lc823450_sdc_getcid(uint32_t ch, char *cidstr, int length)
|
||||||
{
|
{
|
||||||
|
uint8_t cid[16];
|
||||||
|
int ret;
|
||||||
|
|
||||||
mcinfo("++++ ch=%d \n", ch);
|
mcinfo("++++ ch=%d \n", ch);
|
||||||
_sdc_semtake(&_sdc_sem[ch]);
|
_sdc_semtake(&_sdc_sem[ch]);
|
||||||
|
|
||||||
uint8_t cid[16];
|
ret = SdDrGetCid((UI_32 *)cid, cfg[ch]);
|
||||||
int ret = SdDrGetCid((UI_32 *)cid, cfg[ch]);
|
|
||||||
|
|
||||||
if (0 == ret && length >= (2 * sizeof(cid) + 1))
|
if (0 == ret && length >= (2 * sizeof(cid) + 1))
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
for (i = 15; i >= 0; i--)
|
for (i = 15; i >= 0; i--)
|
||||||
{
|
{
|
||||||
snprintf(cidstr, 3, "%02x", cid[i]);
|
snprintf(cidstr, 3, "%02x", cid[i]);
|
||||||
cidstr += 2;
|
cidstr += 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
*cidstr = '\0';
|
*cidstr = '\0';
|
||||||
}
|
}
|
||||||
|
|
||||||
_sdc_semgive(&_sdc_sem[ch]);
|
_sdc_semgive(&_sdc_sem[ch]);
|
||||||
mcinfo("---- end ret=%d \n", ret);
|
mcinfo("---- end ret=%d \n", ret);
|
||||||
return ret;
|
return ret;
|
||||||
@ -602,7 +632,10 @@ int lc823450_sdc_getcid(uint32_t ch, char *cidstr, int length)
|
|||||||
|
|
||||||
int lc823450_sdc_locked(void)
|
int lc823450_sdc_locked(void)
|
||||||
{
|
{
|
||||||
int i, val, ret;
|
int val;
|
||||||
|
int ret;
|
||||||
|
int i;
|
||||||
|
|
||||||
ret = 0;
|
ret = 0;
|
||||||
|
|
||||||
for (i = 0; i < 2; i++)
|
for (i = 0; i < 2; i++)
|
||||||
@ -614,6 +647,6 @@ int lc823450_sdc_locked(void)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -33,7 +33,6 @@
|
|||||||
*
|
*
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
|
|
||||||
#ifndef __ARCH_ARM_SRC_LC823450_LC823450_SDC_H
|
#ifndef __ARCH_ARM_SRC_LC823450_LC823450_SDC_H
|
||||||
#define __ARCH_ARM_SRC_LC823450_LC823450_SDC_H
|
#define __ARCH_ARM_SRC_LC823450_LC823450_SDC_H
|
||||||
|
|
||||||
|
@ -85,7 +85,6 @@ static sem_t SemWWait[2];
|
|||||||
|
|
||||||
static uint64_t _sddep_timeout = (10 * 100); /* 10sec (in tick) */
|
static uint64_t _sddep_timeout = (10 * 100); /* 10sec (in tick) */
|
||||||
|
|
||||||
|
|
||||||
#ifndef CONFIG_HOTPLUG_SDC
|
#ifndef CONFIG_HOTPLUG_SDC
|
||||||
extern void sdif_powerctrl(bool);
|
extern void sdif_powerctrl(bool);
|
||||||
#endif
|
#endif
|
||||||
@ -102,12 +101,15 @@ static int _get_ch_from_cfg(SdDrCfg *cfg)
|
|||||||
case SDIF0_BASE:
|
case SDIF0_BASE:
|
||||||
ch = 0;
|
ch = 0;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case SDIF1_BASE:
|
case SDIF1_BASE:
|
||||||
ch = 1;
|
ch = 1;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
ASSERT(false);
|
ASSERT(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
return ch;
|
return ch;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -152,8 +154,8 @@ SINT_T sddep0_hw_init(SdDrCfg *cfg)
|
|||||||
/* set EMMC */
|
/* set EMMC */
|
||||||
|
|
||||||
modifyreg32(SDCTL,
|
modifyreg32(SDCTL,
|
||||||
0,
|
0,
|
||||||
SDCTL_COREVLT | SDCTL_MMCVLT0_18V | SDCTL_SDMMC0_MMC);
|
SDCTL_COREVLT | SDCTL_MMCVLT0_18V | SDCTL_SDMMC0_MMC);
|
||||||
|
|
||||||
|
|
||||||
/* pull-up SDCMD0/SDAT00-03 */
|
/* pull-up SDCMD0/SDAT00-03 */
|
||||||
@ -176,6 +178,8 @@ SINT_T sddep0_hw_init(SdDrCfg *cfg)
|
|||||||
#ifdef CONFIG_LC823450_SDIF_SDC
|
#ifdef CONFIG_LC823450_SDIF_SDC
|
||||||
SINT_T sddep1_hw_init(SdDrCfg *cfg)
|
SINT_T sddep1_hw_init(SdDrCfg *cfg)
|
||||||
{
|
{
|
||||||
|
int i;
|
||||||
|
|
||||||
/* wait 15ms */
|
/* wait 15ms */
|
||||||
|
|
||||||
usleep(15000);
|
usleep(15000);
|
||||||
@ -185,7 +189,6 @@ SINT_T sddep1_hw_init(SdDrCfg *cfg)
|
|||||||
/* pull up SDCMD1/SDDATA10-13 which correspond to GPIO23-27 */
|
/* pull up SDCMD1/SDDATA10-13 which correspond to GPIO23-27 */
|
||||||
/* NOTE: SDCLK1 is not changed (i.e. none) */
|
/* NOTE: SDCLK1 is not changed (i.e. none) */
|
||||||
|
|
||||||
int i;
|
|
||||||
for (i = 3; i <= 7; i++)
|
for (i = 3; i <= 7; i++)
|
||||||
{
|
{
|
||||||
lc823450_gpio_config(GPIO_PORT2 | (GPIO_PIN0 + i) |
|
lc823450_gpio_config(GPIO_PORT2 | (GPIO_PIN0 + i) |
|
||||||
@ -334,6 +337,7 @@ SINT_T sddep_wait(UI_32 ms, SdDrCfg *cfg)
|
|||||||
usleep(ms * 1000);
|
usleep(ms * 1000);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -373,6 +377,7 @@ SINT_T sddep_wait_status(UI_32 req_status, UI_32 *status, SdDrCfg *cfg)
|
|||||||
}
|
}
|
||||||
(void)sched_yield();
|
(void)sched_yield();
|
||||||
}
|
}
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -42,7 +42,7 @@
|
|||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
#ifndef NULL
|
#ifndef NULL
|
||||||
#define NULL ( (void * ) 0 )
|
# define NULL ((void * ) 0)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define TRUE_T (1) /* true */
|
#define TRUE_T (1) /* true */
|
||||||
|
@ -41,7 +41,6 @@
|
|||||||
* Pre-processor Definitions
|
* Pre-processor Definitions
|
||||||
************************************************************************************/
|
************************************************************************************/
|
||||||
|
|
||||||
|
|
||||||
#define LC823450_UART0_REGBASE 0x4008b000
|
#define LC823450_UART0_REGBASE 0x4008b000
|
||||||
#define LC823450_UART1_REGBASE 0x4008c000
|
#define LC823450_UART1_REGBASE 0x4008c000
|
||||||
#define LC823450_UART2_REGBASE 0x4008d000
|
#define LC823450_UART2_REGBASE 0x4008d000
|
||||||
|
@ -51,7 +51,7 @@
|
|||||||
#include <queue.h>
|
#include <queue.h>
|
||||||
#include <stddef.h>
|
#include <stddef.h>
|
||||||
#ifdef CONFIG_SYSTEM_PROPERTY
|
#ifdef CONFIG_SYSTEM_PROPERTY
|
||||||
#include <system_property.h>
|
# include <system_property.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <nuttx/arch.h>
|
#include <nuttx/arch.h>
|
||||||
@ -60,14 +60,14 @@
|
|||||||
#include <nuttx/usb/usbdev.h>
|
#include <nuttx/usb/usbdev.h>
|
||||||
#include <nuttx/usb/usbdev_trace.h>
|
#include <nuttx/usb/usbdev_trace.h>
|
||||||
#ifdef CONFIG_BATTERY
|
#ifdef CONFIG_BATTERY
|
||||||
#include <nuttx/power/battery.h>
|
# include <nuttx/power/battery.h>
|
||||||
#endif
|
#endif
|
||||||
#include <nuttx/power/pm.h>
|
#include <nuttx/power/pm.h>
|
||||||
#ifdef CONFIG_OFFDEEPSLEEP
|
#ifdef CONFIG_OFFDEEPSLEEP
|
||||||
#include <nuttx/power/offdeepsleep.h>
|
# include <nuttx/power/offdeepsleep.h>
|
||||||
#endif
|
#endif
|
||||||
#ifdef CONFIG_WAKELOCK
|
#ifdef CONFIG_WAKELOCK
|
||||||
#include <nuttx/wakelock.h>
|
# include <nuttx/wakelock.h>
|
||||||
#endif
|
#endif
|
||||||
#include <nuttx/wqueue.h>
|
#include <nuttx/wqueue.h>
|
||||||
|
|
||||||
@ -89,21 +89,22 @@
|
|||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
#ifndef MIN
|
#ifndef MIN
|
||||||
#define MIN(a, b) ((a) > (b) ? (b) : (a))
|
# define MIN(a, b) ((a) > (b) ? (b) : (a))
|
||||||
#endif /* MIN */
|
#endif /* MIN */
|
||||||
|
|
||||||
#ifndef MAX
|
#ifndef MAX
|
||||||
#define MAX(a, b) ((a) > (b) ? (a) : (b))
|
# define MAX(a, b) ((a) > (b) ? (a) : (b))
|
||||||
#endif /* MIN */
|
#endif /* MIN */
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
#define DPRINTF(fmt, args...) uinfo(fmt, ##args)
|
# define DPRINTF(fmt, args...) uinfo(fmt, ##args)
|
||||||
#else
|
#else
|
||||||
#define DPRINTF(fmt, args...) do {} while(0)
|
# define DPRINTF(fmt, args...) do {} while(0)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef container_of
|
#ifndef container_of
|
||||||
#define container_of(ptr, type, member) ((type *)((void *)(ptr) - offsetof(type, member)))
|
# define container_of(ptr, type, member) \
|
||||||
|
((type *)((void *)(ptr) - offsetof(type, member)))
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
@ -153,11 +154,10 @@ struct lc823450_usbdev_s
|
|||||||
#endif /* CONFIG_USBDEV_CHARGER */
|
#endif /* CONFIG_USBDEV_CHARGER */
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
* Private Functions
|
* Private Functions
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
|
|
||||||
static void lc823450_epack(int epnum, bool ack);
|
static void lc823450_epack(int epnum, bool ack);
|
||||||
static int epbuf_write(int epnum, void *buf, size_t len);
|
static int epbuf_write(int epnum, void *buf, size_t len);
|
||||||
static void epcmd_write(int epnum, uint32_t val);
|
static void epcmd_write(int epnum, uint32_t val);
|
||||||
@ -283,6 +283,7 @@ static void lc823450_epack(int epnum, bool ack)
|
|||||||
* read from RX Endpoint Buffer
|
* read from RX Endpoint Buffer
|
||||||
*
|
*
|
||||||
******************************************************************************/
|
******************************************************************************/
|
||||||
|
|
||||||
int epbuf_read(int epnum, void *buf, size_t len)
|
int epbuf_read(int epnum, void *buf, size_t len)
|
||||||
{
|
{
|
||||||
size_t fifolen;
|
size_t fifolen;
|
||||||
@ -305,7 +306,6 @@ int epbuf_read(int epnum, void *buf, size_t len)
|
|||||||
return len;
|
return len;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/******************************************************************************
|
/******************************************************************************
|
||||||
* Name: epbuf_write
|
* Name: epbuf_write
|
||||||
*
|
*
|
||||||
@ -313,6 +313,7 @@ int epbuf_read(int epnum, void *buf, size_t len)
|
|||||||
* Write to TX Endpoint Buffer
|
* Write to TX Endpoint Buffer
|
||||||
*
|
*
|
||||||
******************************************************************************/
|
******************************************************************************/
|
||||||
|
|
||||||
static int epbuf_write(int epnum, void *buf, size_t len)
|
static int epbuf_write(int epnum, void *buf, size_t len)
|
||||||
{
|
{
|
||||||
struct lc823450_ep_s *privep;
|
struct lc823450_ep_s *privep;
|
||||||
@ -369,6 +370,7 @@ cont:
|
|||||||
* Write to EP command register
|
* Write to EP command register
|
||||||
*
|
*
|
||||||
******************************************************************************/
|
******************************************************************************/
|
||||||
|
|
||||||
static void epcmd_write(int epnum, uint32_t val)
|
static void epcmd_write(int epnum, uint32_t val)
|
||||||
{
|
{
|
||||||
while (getreg32(USB_EPCMD(epnum)) & USB_EPCMD_BUSY);
|
while (getreg32(USB_EPCMD(epnum)) & USB_EPCMD_BUSY);
|
||||||
@ -376,7 +378,6 @@ static void epcmd_write(int epnum, uint32_t val)
|
|||||||
putreg32(val, USB_EPCMD(epnum));
|
putreg32(val, USB_EPCMD(epnum));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/******************************************************************************
|
/******************************************************************************
|
||||||
* Name: lc823450_epconfigure
|
* Name: lc823450_epconfigure
|
||||||
*
|
*
|
||||||
@ -391,9 +392,10 @@ static void epcmd_write(int epnum, uint32_t val)
|
|||||||
* configured.
|
* configured.
|
||||||
*
|
*
|
||||||
******************************************************************************/
|
******************************************************************************/
|
||||||
|
|
||||||
static int lc823450_epconfigure(struct usbdev_ep_s *ep,
|
static int lc823450_epconfigure(struct usbdev_ep_s *ep,
|
||||||
const struct usb_epdesc_s *desc,
|
const struct usb_epdesc_s *desc,
|
||||||
bool last)
|
bool last)
|
||||||
{
|
{
|
||||||
int epnum;
|
int epnum;
|
||||||
struct lc823450_ep_s *privep = (struct lc823450_ep_s *)ep;
|
struct lc823450_ep_s *privep = (struct lc823450_ep_s *)ep;
|
||||||
@ -419,6 +421,7 @@ static int lc823450_epconfigure(struct usbdev_ep_s *ep,
|
|||||||
* IDX6: EP3
|
* IDX6: EP3
|
||||||
* ...
|
* ...
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if (epnum == 0)
|
if (epnum == 0)
|
||||||
{
|
{
|
||||||
putreg32(0 << USB_EPCONF_CIDX_SHIFT |
|
putreg32(0 << USB_EPCONF_CIDX_SHIFT |
|
||||||
@ -470,7 +473,6 @@ static int lc823450_epconfigure(struct usbdev_ep_s *ep,
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/******************************************************************************
|
/******************************************************************************
|
||||||
* Name: lc823450_epdisable
|
* Name: lc823450_epdisable
|
||||||
*
|
*
|
||||||
@ -478,6 +480,7 @@ static int lc823450_epconfigure(struct usbdev_ep_s *ep,
|
|||||||
* The endpoint will no longer be used
|
* The endpoint will no longer be used
|
||||||
*
|
*
|
||||||
******************************************************************************/
|
******************************************************************************/
|
||||||
|
|
||||||
static int lc823450_epclearreq(struct usbdev_ep_s *ep)
|
static int lc823450_epclearreq(struct usbdev_ep_s *ep)
|
||||||
{
|
{
|
||||||
struct lc823450_ep_s *privep = (struct lc823450_ep_s *)ep;
|
struct lc823450_ep_s *privep = (struct lc823450_ep_s *)ep;
|
||||||
@ -488,18 +491,22 @@ static int lc823450_epclearreq(struct usbdev_ep_s *ep)
|
|||||||
{
|
{
|
||||||
struct usbdev_req_s *req;
|
struct usbdev_req_s *req;
|
||||||
sq_entry_t *q_ent;
|
sq_entry_t *q_ent;
|
||||||
|
|
||||||
/* Dequeue from Reqbuf poll */
|
/* Dequeue from Reqbuf poll */
|
||||||
|
|
||||||
q_ent = sq_remlast(&privep->req_q);
|
q_ent = sq_remlast(&privep->req_q);
|
||||||
req = &container_of(q_ent, struct lc823450_req_s, q_ent)->req;
|
req = &container_of(q_ent, struct lc823450_req_s, q_ent)->req;
|
||||||
|
|
||||||
/* return reqbuf to funciton driver */
|
/* return reqbuf to funciton driver */
|
||||||
|
|
||||||
req->result = -ESHUTDOWN;
|
req->result = -ESHUTDOWN;
|
||||||
req->callback(ep, req);
|
req->callback(ep, req);
|
||||||
}
|
}
|
||||||
|
|
||||||
leave_critical_section(flags);
|
leave_critical_section(flags);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/******************************************************************************
|
/******************************************************************************
|
||||||
* Name: lc823450_epdisable
|
* Name: lc823450_epdisable
|
||||||
*
|
*
|
||||||
@ -507,6 +514,7 @@ static int lc823450_epclearreq(struct usbdev_ep_s *ep)
|
|||||||
* The endpoint will no longer be used
|
* The endpoint will no longer be used
|
||||||
*
|
*
|
||||||
******************************************************************************/
|
******************************************************************************/
|
||||||
|
|
||||||
static int lc823450_epdisable(struct usbdev_ep_s *ep)
|
static int lc823450_epdisable(struct usbdev_ep_s *ep)
|
||||||
{
|
{
|
||||||
struct lc823450_ep_s *privep = (struct lc823450_ep_s *)ep;
|
struct lc823450_ep_s *privep = (struct lc823450_ep_s *)ep;
|
||||||
@ -543,9 +551,11 @@ static int lc823450_epdisable(struct usbdev_ep_s *ep)
|
|||||||
* Allocate an I/O request
|
* Allocate an I/O request
|
||||||
*
|
*
|
||||||
******************************************************************************/
|
******************************************************************************/
|
||||||
|
|
||||||
static struct usbdev_req_s *lc823450_epallocreq(struct usbdev_ep_s *ep)
|
static struct usbdev_req_s *lc823450_epallocreq(struct usbdev_ep_s *ep)
|
||||||
{
|
{
|
||||||
struct lc823450_req_s *privreq;
|
struct lc823450_req_s *privreq;
|
||||||
|
|
||||||
#ifdef CONFIG_DEBUG
|
#ifdef CONFIG_DEBUG
|
||||||
if (!ep)
|
if (!ep)
|
||||||
{
|
{
|
||||||
@ -553,6 +563,7 @@ static struct usbdev_req_s *lc823450_epallocreq(struct usbdev_ep_s *ep)
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
usbtrace(TRACE_EPALLOCREQ, ((struct lc823450_ep_s *)ep)->epphy);
|
usbtrace(TRACE_EPALLOCREQ, ((struct lc823450_ep_s *)ep)->epphy);
|
||||||
|
|
||||||
privreq = (struct lc823450_req_s *)kmm_malloc(sizeof(struct lc823450_req_s));
|
privreq = (struct lc823450_req_s *)kmm_malloc(sizeof(struct lc823450_req_s));
|
||||||
@ -566,7 +577,6 @@ static struct usbdev_req_s *lc823450_epallocreq(struct usbdev_ep_s *ep)
|
|||||||
return &privreq->req;
|
return &privreq->req;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/******************************************************************************
|
/******************************************************************************
|
||||||
* Name: lc823450_epfreereq
|
* Name: lc823450_epfreereq
|
||||||
*
|
*
|
||||||
@ -574,6 +584,7 @@ static struct usbdev_req_s *lc823450_epallocreq(struct usbdev_ep_s *ep)
|
|||||||
* Free an I/O request
|
* Free an I/O request
|
||||||
*
|
*
|
||||||
******************************************************************************/
|
******************************************************************************/
|
||||||
|
|
||||||
static void lc823450_epfreereq(struct usbdev_ep_s *ep, struct usbdev_req_s *req)
|
static void lc823450_epfreereq(struct usbdev_ep_s *ep, struct usbdev_req_s *req)
|
||||||
{
|
{
|
||||||
struct lc823450_req_s *privreq = (struct lc823450_req_s *)req;
|
struct lc823450_req_s *privreq = (struct lc823450_req_s *)req;
|
||||||
@ -585,11 +596,11 @@ static void lc823450_epfreereq(struct usbdev_ep_s *ep, struct usbdev_req_s *req)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
usbtrace(TRACE_EPFREEREQ, ((struct lc823450_ep_s *)ep)->epphy);
|
usbtrace(TRACE_EPFREEREQ, ((struct lc823450_ep_s *)ep)->epphy);
|
||||||
kmm_free(privreq);
|
kmm_free(privreq);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#ifdef CONFIG_USBDEV_DMA
|
#ifdef CONFIG_USBDEV_DMA
|
||||||
/******************************************************************************
|
/******************************************************************************
|
||||||
* Name: lc823450_epallocbuffer
|
* Name: lc823450_epallocbuffer
|
||||||
@ -598,6 +609,7 @@ static void lc823450_epfreereq(struct usbdev_ep_s *ep, struct usbdev_req_s *req)
|
|||||||
* Allocate an I/O buffer
|
* Allocate an I/O buffer
|
||||||
*
|
*
|
||||||
******************************************************************************/
|
******************************************************************************/
|
||||||
|
|
||||||
static void *lc823450_epallocbuffer(struct usbdev_ep_s *ep, uint16_t bytes)
|
static void *lc823450_epallocbuffer(struct usbdev_ep_s *ep, uint16_t bytes)
|
||||||
{
|
{
|
||||||
usbtrace(TRACE_EPALLOCBUFFER, privep->epphy);
|
usbtrace(TRACE_EPALLOCBUFFER, privep->epphy);
|
||||||
@ -618,6 +630,7 @@ static void *lc823450_epallocbuffer(struct usbdev_ep_s *ep, uint16_t bytes)
|
|||||||
* Free an I/O buffer
|
* Free an I/O buffer
|
||||||
*
|
*
|
||||||
******************************************************************************/
|
******************************************************************************/
|
||||||
|
|
||||||
static void lc823450_epfreebuffer(struct usbdev_ep_s *ep, void *buf)
|
static void lc823450_epfreebuffer(struct usbdev_ep_s *ep, void *buf)
|
||||||
{
|
{
|
||||||
usbtrace(TRACE_EPFREEBUFFER, privep->epphy);
|
usbtrace(TRACE_EPFREEBUFFER, privep->epphy);
|
||||||
@ -637,6 +650,7 @@ static void lc823450_epfreebuffer(struct usbdev_ep_s *ep, void *buf)
|
|||||||
* Submit an I/O request to the endpoint
|
* Submit an I/O request to the endpoint
|
||||||
*
|
*
|
||||||
******************************************************************************/
|
******************************************************************************/
|
||||||
|
|
||||||
static int lc823450_epsubmit(struct usbdev_ep_s *ep, struct usbdev_req_s *req)
|
static int lc823450_epsubmit(struct usbdev_ep_s *ep, struct usbdev_req_s *req)
|
||||||
{
|
{
|
||||||
struct lc823450_req_s *privreq = (struct lc823450_req_s *)req;
|
struct lc823450_req_s *privreq = (struct lc823450_req_s *)req;
|
||||||
@ -659,6 +673,7 @@ static int lc823450_epsubmit(struct usbdev_ep_s *ep, struct usbdev_req_s *req)
|
|||||||
else if (privep->in)
|
else if (privep->in)
|
||||||
{
|
{
|
||||||
/* Send packet requst from function driver */
|
/* Send packet requst from function driver */
|
||||||
|
|
||||||
flags = enter_critical_section();
|
flags = enter_critical_section();
|
||||||
|
|
||||||
if ((getreg32(USB_EPCOUNT(privep->epphy * 2)) &
|
if ((getreg32(USB_EPCOUNT(privep->epphy * 2)) &
|
||||||
@ -678,6 +693,7 @@ static int lc823450_epsubmit(struct usbdev_ep_s *ep, struct usbdev_req_s *req)
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
/* receive packet buffer from function driver */
|
/* receive packet buffer from function driver */
|
||||||
|
|
||||||
flags = enter_critical_section();
|
flags = enter_critical_section();
|
||||||
sq_addfirst(&privreq->q_ent, &privep->req_q); /* non block */
|
sq_addfirst(&privreq->q_ent, &privep->req_q); /* non block */
|
||||||
leave_critical_section(flags);
|
leave_critical_section(flags);
|
||||||
@ -694,12 +710,14 @@ static int lc823450_epsubmit(struct usbdev_ep_s *ep, struct usbdev_req_s *req)
|
|||||||
* Cancel an I/O request previously sent to an endpoint
|
* Cancel an I/O request previously sent to an endpoint
|
||||||
*
|
*
|
||||||
******************************************************************************/
|
******************************************************************************/
|
||||||
|
|
||||||
static int lc823450_epcancel(struct usbdev_ep_s *ep, struct usbdev_req_s *req)
|
static int lc823450_epcancel(struct usbdev_ep_s *ep, struct usbdev_req_s *req)
|
||||||
{
|
{
|
||||||
struct lc823450_req_s *privreq = (struct lc823450_req_s *)req;
|
struct lc823450_req_s *privreq = (struct lc823450_req_s *)req;
|
||||||
struct lc823450_ep_s *privep = (struct lc823450_ep_s *)ep;
|
struct lc823450_ep_s *privep = (struct lc823450_ep_s *)ep;
|
||||||
|
|
||||||
/* remove request from req_queue */
|
/* remove request from req_queue */
|
||||||
|
|
||||||
sq_remafter(&privreq->q_ent, &privep->req_q);
|
sq_remafter(&privreq->q_ent, &privep->req_q);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@ -711,6 +729,7 @@ static int lc823450_epcancel(struct usbdev_ep_s *ep, struct usbdev_req_s *req)
|
|||||||
* Stall or resume and endpoint
|
* Stall or resume and endpoint
|
||||||
*
|
*
|
||||||
******************************************************************************/
|
******************************************************************************/
|
||||||
|
|
||||||
static int lc823450_epstall(struct usbdev_ep_s *ep, bool resume)
|
static int lc823450_epstall(struct usbdev_ep_s *ep, bool resume)
|
||||||
{
|
{
|
||||||
struct lc823450_ep_s *privep = (struct lc823450_ep_s *)ep;
|
struct lc823450_ep_s *privep = (struct lc823450_ep_s *)ep;
|
||||||
@ -764,6 +783,7 @@ void up_epignore_clear_stall(struct usbdev_ep_s *ep, bool ignore)
|
|||||||
* USB_EP_ATTR_XFER_INT}
|
* USB_EP_ATTR_XFER_INT}
|
||||||
*
|
*
|
||||||
******************************************************************************/
|
******************************************************************************/
|
||||||
|
|
||||||
static struct usbdev_ep_s *lc823450_allocep(struct usbdev_s *dev, uint8_t eplog,
|
static struct usbdev_ep_s *lc823450_allocep(struct usbdev_s *dev, uint8_t eplog,
|
||||||
bool in, uint8_t eptype)
|
bool in, uint8_t eptype)
|
||||||
{
|
{
|
||||||
@ -774,6 +794,7 @@ static struct usbdev_ep_s *lc823450_allocep(struct usbdev_s *dev, uint8_t eplog,
|
|||||||
usbtrace(TRACE_DEVALLOCEP, (uint16_t)eplog);
|
usbtrace(TRACE_DEVALLOCEP, (uint16_t)eplog);
|
||||||
|
|
||||||
/* Ignore any direction bits in the logical address */
|
/* Ignore any direction bits in the logical address */
|
||||||
|
|
||||||
epphy = USB_EPNO(eplog);
|
epphy = USB_EPNO(eplog);
|
||||||
|
|
||||||
if (priv->used & 1 << epphy)
|
if (priv->used & 1 << epphy)
|
||||||
@ -800,6 +821,7 @@ static struct usbdev_ep_s *lc823450_allocep(struct usbdev_s *dev, uint8_t eplog,
|
|||||||
* Free the previously allocated endpoint
|
* Free the previously allocated endpoint
|
||||||
*
|
*
|
||||||
******************************************************************************/
|
******************************************************************************/
|
||||||
|
|
||||||
static void lc823450_freeep(struct usbdev_s *dev, struct usbdev_ep_s *ep)
|
static void lc823450_freeep(struct usbdev_s *dev, struct usbdev_ep_s *ep)
|
||||||
{
|
{
|
||||||
struct lc823450_usbdev_s *priv = (struct lc823450_usbdev_s *)dev;
|
struct lc823450_usbdev_s *priv = (struct lc823450_usbdev_s *)dev;
|
||||||
@ -812,7 +834,6 @@ static void lc823450_freeep(struct usbdev_s *dev, struct usbdev_ep_s *ep)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/******************************************************************************
|
/******************************************************************************
|
||||||
* Name: lc823450_getframe
|
* Name: lc823450_getframe
|
||||||
*
|
*
|
||||||
@ -820,6 +841,7 @@ static void lc823450_freeep(struct usbdev_s *dev, struct usbdev_ep_s *ep)
|
|||||||
* Returns the current frame number
|
* Returns the current frame number
|
||||||
*
|
*
|
||||||
******************************************************************************/
|
******************************************************************************/
|
||||||
|
|
||||||
static int lc823450_getframe(struct usbdev_s *dev)
|
static int lc823450_getframe(struct usbdev_s *dev)
|
||||||
{
|
{
|
||||||
usbtrace(TRACE_DEVGETFRAME, 0);
|
usbtrace(TRACE_DEVGETFRAME, 0);
|
||||||
@ -827,7 +849,6 @@ static int lc823450_getframe(struct usbdev_s *dev)
|
|||||||
return (int)(getreg32(USB_TSTAMP));
|
return (int)(getreg32(USB_TSTAMP));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/******************************************************************************
|
/******************************************************************************
|
||||||
* Name: lc823450_wakeup
|
* Name: lc823450_wakeup
|
||||||
*
|
*
|
||||||
@ -835,6 +856,7 @@ static int lc823450_getframe(struct usbdev_s *dev)
|
|||||||
* Tries to wake up the host connected to this device
|
* Tries to wake up the host connected to this device
|
||||||
*
|
*
|
||||||
******************************************************************************/
|
******************************************************************************/
|
||||||
|
|
||||||
static int lc823450_wakeup(struct usbdev_s *dev)
|
static int lc823450_wakeup(struct usbdev_s *dev)
|
||||||
{
|
{
|
||||||
usbtrace(TRACE_DEVWAKEUP, 0);
|
usbtrace(TRACE_DEVWAKEUP, 0);
|
||||||
@ -850,6 +872,7 @@ static int lc823450_wakeup(struct usbdev_s *dev)
|
|||||||
* Sets/clears the device selfpowered feature
|
* Sets/clears the device selfpowered feature
|
||||||
*
|
*
|
||||||
******************************************************************************/
|
******************************************************************************/
|
||||||
|
|
||||||
static int lc823450_selfpowered(struct usbdev_s *dev, bool selfpowered)
|
static int lc823450_selfpowered(struct usbdev_s *dev, bool selfpowered)
|
||||||
{
|
{
|
||||||
return OK;
|
return OK;
|
||||||
@ -862,6 +885,7 @@ static int lc823450_selfpowered(struct usbdev_s *dev, bool selfpowered)
|
|||||||
* Software-controlled connect to/disconnect from USB host
|
* Software-controlled connect to/disconnect from USB host
|
||||||
*
|
*
|
||||||
******************************************************************************/
|
******************************************************************************/
|
||||||
|
|
||||||
int lc823450_usbpullup(struct usbdev_s *dev, bool enable)
|
int lc823450_usbpullup(struct usbdev_s *dev, bool enable)
|
||||||
{
|
{
|
||||||
if (enable)
|
if (enable)
|
||||||
@ -883,6 +907,7 @@ int lc823450_usbpullup(struct usbdev_s *dev, bool enable)
|
|||||||
* USB dev interrupt sub handler
|
* USB dev interrupt sub handler
|
||||||
*
|
*
|
||||||
******************************************************************************/
|
******************************************************************************/
|
||||||
|
|
||||||
static void usb_suspend_work_func(void *arg)
|
static void usb_suspend_work_func(void *arg)
|
||||||
{
|
{
|
||||||
struct lc823450_usbdev_s *priv = arg;
|
struct lc823450_usbdev_s *priv = arg;
|
||||||
@ -918,11 +943,13 @@ static void usb_suspend_work_func(void *arg)
|
|||||||
/******************************************************************************
|
/******************************************************************************
|
||||||
* Name: usb_reset_work_func
|
* Name: usb_reset_work_func
|
||||||
******************************************************************************/
|
******************************************************************************/
|
||||||
|
|
||||||
static void usb_reset_work_func(void *arg)
|
static void usb_reset_work_func(void *arg)
|
||||||
{
|
{
|
||||||
if (g_usbdev.charger)
|
if (g_usbdev.charger)
|
||||||
{
|
{
|
||||||
/* Disconnect Charger */
|
/* Disconnect Charger */
|
||||||
|
|
||||||
# if defined(CONFIG_HOTPLUG) && defined(CONFIG_HOTPLUG_USB)
|
# if defined(CONFIG_HOTPLUG) && defined(CONFIG_HOTPLUG_USB)
|
||||||
hotplug_start_usbemu(false);
|
hotplug_start_usbemu(false);
|
||||||
# endif
|
# endif
|
||||||
@ -934,6 +961,7 @@ static void usb_reset_work_func(void *arg)
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
/* Connect Host */
|
/* Connect Host */
|
||||||
|
|
||||||
# if defined(CONFIG_HOTPLUG) && defined(CONFIG_HOTPLUG_USB)
|
# if defined(CONFIG_HOTPLUG) && defined(CONFIG_HOTPLUG_USB)
|
||||||
hotplug_start_usbemu(true);
|
hotplug_start_usbemu(true);
|
||||||
# endif
|
# endif
|
||||||
@ -944,6 +972,7 @@ static void usb_reset_work_func(void *arg)
|
|||||||
/******************************************************************************
|
/******************************************************************************
|
||||||
* Name: subintr_usbdev
|
* Name: subintr_usbdev
|
||||||
******************************************************************************/
|
******************************************************************************/
|
||||||
|
|
||||||
static void subintr_usbdev(void)
|
static void subintr_usbdev(void)
|
||||||
{
|
{
|
||||||
uint32_t devs;
|
uint32_t devs;
|
||||||
@ -957,7 +986,9 @@ static void subintr_usbdev(void)
|
|||||||
{
|
{
|
||||||
work_cancel(HPWORK, &usb_reset_work);
|
work_cancel(HPWORK, &usb_reset_work);
|
||||||
work_queue(HPWORK, &usb_reset_work, usb_reset_work_func, NULL, 0);
|
work_queue(HPWORK, &usb_reset_work, usb_reset_work_func, NULL, 0);
|
||||||
|
|
||||||
/* Disable interrupts */
|
/* Disable interrupts */
|
||||||
|
|
||||||
up_disable_irq(LC823450_IRQ_USBDEV);
|
up_disable_irq(LC823450_IRQ_USBDEV);
|
||||||
putreg32(~devs, USB_DEVS);
|
putreg32(~devs, USB_DEVS);
|
||||||
return;
|
return;
|
||||||
@ -1040,6 +1071,7 @@ static void subintr_usbdev(void)
|
|||||||
* Endpoint0 interrupt sub handler
|
* Endpoint0 interrupt sub handler
|
||||||
*
|
*
|
||||||
******************************************************************************/
|
******************************************************************************/
|
||||||
|
|
||||||
static void subintr_ep0(void)
|
static void subintr_ep0(void)
|
||||||
{
|
{
|
||||||
uint32_t epctrl;
|
uint32_t epctrl;
|
||||||
@ -1058,6 +1090,7 @@ static void subintr_ep0(void)
|
|||||||
epcmd_write(0, USB_EPCMD_READYO_CLR);
|
epcmd_write(0, USB_EPCMD_READYO_CLR);
|
||||||
|
|
||||||
/* NULL RESP */
|
/* NULL RESP */
|
||||||
|
|
||||||
if (!len)
|
if (!len)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
@ -1068,138 +1101,143 @@ static void subintr_ep0(void)
|
|||||||
ctrl.type, ctrl.req, ctrl.value[0], ctrl.value[1],
|
ctrl.type, ctrl.req, ctrl.value[0], ctrl.value[1],
|
||||||
ctrl.index[0], ctrl.index[1], ctrl.len[0], ctrl.len[1]);
|
ctrl.index[0], ctrl.index[1], ctrl.len[0], ctrl.len[1]);
|
||||||
|
|
||||||
if ((ctrl.type & USB_REQ_TYPE_MASK) == USB_REQ_TYPE_STANDARD)
|
if ((ctrl.type & USB_REQ_TYPE_MASK) == USB_REQ_TYPE_STANDARD)
|
||||||
{
|
{
|
||||||
switch (ctrl.req)
|
switch (ctrl.req)
|
||||||
{
|
{
|
||||||
case USB_REQ_GETSTATUS:
|
case USB_REQ_GETSTATUS:
|
||||||
resp[1] = 0;
|
resp[1] = 0;
|
||||||
switch (ctrl.type & USB_REQ_RECIPIENT_MASK)
|
switch (ctrl.type & USB_REQ_RECIPIENT_MASK)
|
||||||
{
|
{
|
||||||
case USB_REQ_RECIPIENT_ENDPOINT:
|
case USB_REQ_RECIPIENT_ENDPOINT:
|
||||||
epnum = USB_EPNO(ctrl.index[0]);
|
epnum = USB_EPNO(ctrl.index[0]);
|
||||||
if (epnum < LC823450_NPHYSENDPOINTS &&
|
if (epnum < LC823450_NPHYSENDPOINTS &&
|
||||||
priv->eplist[epnum].stalled == 0)
|
priv->eplist[epnum].stalled == 0)
|
||||||
|
{
|
||||||
|
resp[0] = 0; /* bit0: halt */
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
resp[0] = 1; /* bit0: halt */
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
case USB_REQ_RECIPIENT_DEVICE:
|
||||||
|
resp[0] = 0; /* bit0: selfpowerd, bit1: remote wakeup */
|
||||||
|
break;
|
||||||
|
|
||||||
|
case USB_REQ_RECIPIENT_INTERFACE:
|
||||||
|
resp[0] = 0; /* reserved */
|
||||||
|
break;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
epbuf_write(0, &resp, 2);
|
||||||
|
handled = 1;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case USB_REQ_SETADDRESS:
|
||||||
|
modifyreg32(USB_FADDR, USB_FADDR_ADDR_MASK, ctrl.value[0]);
|
||||||
|
epbuf_write(0, &resp, 0);
|
||||||
|
handled = 1;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case USB_REQ_SETCONFIGURATION:
|
||||||
|
modifyreg32(USB_FADDR, 0, USB_FADDR_CONFD);
|
||||||
|
#ifdef CONFIG_WAKELOCK
|
||||||
|
wake_lock(&priv->wlock);
|
||||||
|
#endif
|
||||||
|
#if defined(CONFIG_BATTERY) && !defined(CONFIG_BATTERY_DISABLE_CHARGE)
|
||||||
|
battery_sendevent(BATTERY_USBEV_CHG);
|
||||||
|
#endif
|
||||||
|
break;
|
||||||
|
|
||||||
|
case USB_REQ_SETFEATURE:
|
||||||
|
if (ctrl.value[0] == USB_FEATURE_TESTMODE)
|
||||||
|
{
|
||||||
|
epbuf_write(0, &resp, 0);
|
||||||
|
up_udelay(1000);
|
||||||
|
|
||||||
|
if (ctrl.index[1] == 0x4)
|
||||||
{
|
{
|
||||||
resp[0] = 0; /* bit0: halt */
|
/* TestPacket */
|
||||||
|
|
||||||
|
putreg32(1 << 0 | USB_TESTC_FORCE_HS, USB_TESTC);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
resp[0] = 1; /* bit0: halt */
|
putreg32(1 << ctrl.index[1] | USB_TESTC_FORCE_HS, USB_TESTC);
|
||||||
}
|
}
|
||||||
break;
|
|
||||||
case USB_REQ_RECIPIENT_DEVICE:
|
|
||||||
resp[0] = 0; /* bit0: selfpowerd, bit1: remote wakeup */
|
|
||||||
break;
|
|
||||||
case USB_REQ_RECIPIENT_INTERFACE:
|
|
||||||
resp[0] = 0; /* reserved */
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
epbuf_write(0, &resp, 2);
|
|
||||||
handled = 1;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case USB_REQ_SETADDRESS:
|
handled = 1;
|
||||||
modifyreg32(USB_FADDR, USB_FADDR_ADDR_MASK, ctrl.value[0]);
|
|
||||||
epbuf_write(0, &resp, 0);
|
|
||||||
handled = 1;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case USB_REQ_SETCONFIGURATION:
|
|
||||||
modifyreg32(USB_FADDR, 0, USB_FADDR_CONFD);
|
|
||||||
#ifdef CONFIG_WAKELOCK
|
|
||||||
wake_lock(&priv->wlock);
|
|
||||||
#endif
|
|
||||||
#if defined(CONFIG_BATTERY) && !defined(CONFIG_BATTERY_DISABLE_CHARGE)
|
|
||||||
battery_sendevent(BATTERY_USBEV_CHG);
|
|
||||||
#endif
|
|
||||||
break;
|
|
||||||
|
|
||||||
case USB_REQ_SETFEATURE:
|
|
||||||
if (ctrl.value[0] == USB_FEATURE_TESTMODE)
|
|
||||||
{
|
|
||||||
epbuf_write(0, &resp, 0);
|
|
||||||
up_udelay(1000);
|
|
||||||
|
|
||||||
if (ctrl.index[1] == 0x4)
|
|
||||||
{
|
|
||||||
/* TestPacket */
|
|
||||||
putreg32(1 << 0 | USB_TESTC_FORCE_HS, USB_TESTC);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
putreg32(1 << ctrl.index[1] | USB_TESTC_FORCE_HS, USB_TESTC);
|
|
||||||
}
|
|
||||||
|
|
||||||
handled = 1;
|
|
||||||
}
|
|
||||||
else if (ctrl.value[0] == USB_FEATURE_ENDPOINTHALT)
|
|
||||||
{
|
|
||||||
epnum = USB_EPNO(ctrl.index[0]);
|
|
||||||
if (epnum < LC823450_NPHYSENDPOINTS)
|
|
||||||
{
|
|
||||||
lc823450_epstall(&priv->eplist[epnum].ep, false);
|
|
||||||
epbuf_write(0, &resp, 0);
|
|
||||||
handled = 1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
|
|
||||||
case USB_REQ_CLEARFEATURE:
|
|
||||||
if (ctrl.value[0] == USB_FEATURE_ENDPOINTHALT)
|
|
||||||
{
|
|
||||||
epnum = USB_EPNO(ctrl.index[0]);
|
|
||||||
if (epnum < LC823450_NPHYSENDPOINTS)
|
|
||||||
{
|
|
||||||
epbuf_write(0, &resp, 0);
|
|
||||||
#ifdef CONFIG_USBMSC_IGNORE_CLEAR_STALL
|
|
||||||
if (!priv->eplist[epnum].ignore_clear_stall)
|
|
||||||
#endif
|
|
||||||
{
|
|
||||||
lc823450_epstall(&priv->eplist[epnum].ep, true);
|
|
||||||
}
|
|
||||||
handled = 1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!handled)
|
|
||||||
{
|
|
||||||
uint8_t ctrldat[16];
|
|
||||||
int ctrldat_len;
|
|
||||||
|
|
||||||
ctrldat_len = MIN(GETUINT16(ctrl.len), sizeof(ctrldat));
|
|
||||||
if (ctrldat_len)
|
|
||||||
{
|
|
||||||
int tout = 1000;
|
|
||||||
do
|
|
||||||
{
|
|
||||||
if (getreg32(USB_EPCMD(0)) & USB_EPCMD_READYO_CLR)
|
|
||||||
{
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
up_udelay(10);
|
else if (ctrl.value[0] == USB_FEATURE_ENDPOINTHALT)
|
||||||
}
|
{
|
||||||
while (tout--);
|
epnum = USB_EPNO(ctrl.index[0]);
|
||||||
|
if (epnum < LC823450_NPHYSENDPOINTS)
|
||||||
|
{
|
||||||
|
lc823450_epstall(&priv->eplist[epnum].ep, false);
|
||||||
|
epbuf_write(0, &resp, 0);
|
||||||
|
handled = 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
if (tout)
|
case USB_REQ_CLEARFEATURE:
|
||||||
{
|
if (ctrl.value[0] == USB_FEATURE_ENDPOINTHALT)
|
||||||
ctrldat_len = epbuf_read(0, &ctrldat, ctrldat_len);
|
{
|
||||||
}
|
epnum = USB_EPNO(ctrl.index[0]);
|
||||||
}
|
if (epnum < LC823450_NPHYSENDPOINTS)
|
||||||
if (CLASS_SETUP(priv->driver, &priv->usbdev, &ctrl,
|
{
|
||||||
(uint8_t *)&ctrldat, ctrldat_len) < 0)
|
epbuf_write(0, &resp, 0);
|
||||||
{
|
#ifdef CONFIG_USBMSC_IGNORE_CLEAR_STALL
|
||||||
lc823450_epstall(&priv->eplist[0].ep, false);
|
if (!priv->eplist[epnum].ignore_clear_stall)
|
||||||
}
|
#endif
|
||||||
}
|
{
|
||||||
|
lc823450_epstall(&priv->eplist[epnum].ep, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
handled = 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!handled)
|
||||||
|
{
|
||||||
|
uint8_t ctrldat[16];
|
||||||
|
int ctrldat_len;
|
||||||
|
|
||||||
|
ctrldat_len = MIN(GETUINT16(ctrl.len), sizeof(ctrldat));
|
||||||
|
if (ctrldat_len)
|
||||||
|
{
|
||||||
|
int tout = 1000;
|
||||||
|
do
|
||||||
|
{
|
||||||
|
if (getreg32(USB_EPCMD(0)) & USB_EPCMD_READYO_CLR)
|
||||||
|
{
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
up_udelay(10);
|
||||||
|
}
|
||||||
|
while (tout--);
|
||||||
|
|
||||||
|
if (tout)
|
||||||
|
{
|
||||||
|
ctrldat_len = epbuf_read(0, &ctrldat, ctrldat_len);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (CLASS_SETUP(priv->driver, &priv->usbdev, &ctrl,
|
||||||
|
(uint8_t *)&ctrldat, ctrldat_len) < 0)
|
||||||
|
{
|
||||||
|
lc823450_epstall(&priv->eplist[0].ep, false);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/******************************************************************************
|
/******************************************************************************
|
||||||
* Name: subintr_epin
|
* Name: subintr_epin
|
||||||
*
|
*
|
||||||
@ -1207,21 +1245,28 @@ static void subintr_ep0(void)
|
|||||||
* Endpoint interrupt sub handler
|
* Endpoint interrupt sub handler
|
||||||
*
|
*
|
||||||
******************************************************************************/
|
******************************************************************************/
|
||||||
|
|
||||||
static void subintr_epin(uint8_t epnum, struct lc823450_ep_s *privep)
|
static void subintr_epin(uint8_t epnum, struct lc823450_ep_s *privep)
|
||||||
{
|
{
|
||||||
/* Send packet done */
|
/* Send packet done */
|
||||||
|
|
||||||
if (privep->req_q.tail)
|
if (privep->req_q.tail)
|
||||||
{
|
{
|
||||||
struct usbdev_req_s *req;
|
struct usbdev_req_s *req;
|
||||||
sq_entry_t *q_ent;
|
sq_entry_t *q_ent;
|
||||||
|
|
||||||
/* Dequeue from TXQ */
|
/* Dequeue from TXQ */
|
||||||
|
|
||||||
q_ent = sq_remlast(&privep->req_q);
|
q_ent = sq_remlast(&privep->req_q);
|
||||||
req = &container_of(q_ent, struct lc823450_req_s, q_ent)->req;
|
req = &container_of(q_ent, struct lc823450_req_s, q_ent)->req;
|
||||||
|
|
||||||
/* Write to TX FIFO */
|
/* Write to TX FIFO */
|
||||||
/* int clear!! before epbuf write */
|
/* int clear!! before epbuf write */
|
||||||
|
|
||||||
epcmd_write(epnum, USB_EPCMD_EMPTY_CLR);
|
epcmd_write(epnum, USB_EPCMD_EMPTY_CLR);
|
||||||
req->xfrd = epbuf_write(epnum, req->buf, req->len);
|
req->xfrd = epbuf_write(epnum, req->buf, req->len);
|
||||||
req->callback(&privep->ep, req);
|
req->callback(&privep->ep, req);
|
||||||
|
|
||||||
/* int clear */
|
/* int clear */
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -1237,24 +1282,33 @@ static void subintr_epin(uint8_t epnum, struct lc823450_ep_s *privep)
|
|||||||
* Endpoint interrupt sub handler
|
* Endpoint interrupt sub handler
|
||||||
*
|
*
|
||||||
******************************************************************************/
|
******************************************************************************/
|
||||||
|
|
||||||
static void subintr_epout(uint8_t epnum, struct lc823450_ep_s *privep)
|
static void subintr_epout(uint8_t epnum, struct lc823450_ep_s *privep)
|
||||||
{
|
{
|
||||||
/* Packet receive from host */
|
/* Packet receive from host */
|
||||||
|
|
||||||
if (privep->req_q.tail)
|
if (privep->req_q.tail)
|
||||||
{
|
{
|
||||||
struct usbdev_req_s *req;
|
struct usbdev_req_s *req;
|
||||||
sq_entry_t *q_ent;
|
sq_entry_t *q_ent;
|
||||||
|
|
||||||
/* Dequeue from Reqbuf poll */
|
/* Dequeue from Reqbuf poll */
|
||||||
|
|
||||||
q_ent = sq_remlast(&privep->req_q);
|
q_ent = sq_remlast(&privep->req_q);
|
||||||
req = &container_of(q_ent, struct lc823450_req_s, q_ent)->req;
|
req = &container_of(q_ent, struct lc823450_req_s, q_ent)->req;
|
||||||
if (privep->req_q.tail == NULL)
|
if (privep->req_q.tail == NULL)
|
||||||
{
|
{
|
||||||
/* receive buffer exhaust */
|
/* receive buffer exhaust */
|
||||||
|
|
||||||
lc823450_epack(epnum, 0);
|
lc823450_epack(epnum, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* PIO */
|
/* PIO */
|
||||||
|
|
||||||
epcmd_write(epnum, USB_EPCMD_READY_CLR);
|
epcmd_write(epnum, USB_EPCMD_READY_CLR);
|
||||||
|
|
||||||
/* int clear!! before epbuf read */
|
/* int clear!! before epbuf read */
|
||||||
|
|
||||||
req->xfrd = epbuf_read(epnum, req->buf, req->len);
|
req->xfrd = epbuf_read(epnum, req->buf, req->len);
|
||||||
req->callback(&privep->ep, req);
|
req->callback(&privep->ep, req);
|
||||||
}
|
}
|
||||||
@ -1272,6 +1326,7 @@ static void subintr_epout(uint8_t epnum, struct lc823450_ep_s *privep)
|
|||||||
* Endpoint interrupt sub handler
|
* Endpoint interrupt sub handler
|
||||||
*
|
*
|
||||||
******************************************************************************/
|
******************************************************************************/
|
||||||
|
|
||||||
static void subintr_ep(uint8_t epnum)
|
static void subintr_ep(uint8_t epnum)
|
||||||
{
|
{
|
||||||
struct lc823450_usbdev_s *priv = &g_usbdev;
|
struct lc823450_usbdev_s *priv = &g_usbdev;
|
||||||
@ -1299,6 +1354,7 @@ static void subintr_ep(uint8_t epnum)
|
|||||||
* USB interrupt handler
|
* USB interrupt handler
|
||||||
*
|
*
|
||||||
******************************************************************************/
|
******************************************************************************/
|
||||||
|
|
||||||
static int lc823450_usbinterrupt(int irq, void *context, FAR void *arg)
|
static int lc823450_usbinterrupt(int irq, void *context, FAR void *arg)
|
||||||
{
|
{
|
||||||
uint32_t disr;
|
uint32_t disr;
|
||||||
@ -1328,13 +1384,14 @@ static int lc823450_usbinterrupt(int irq, void *context, FAR void *arg)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
putreg32(~disr, USB_INTS);
|
putreg32(~disr, USB_INTS);
|
||||||
return OK;
|
return OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Public Functions
|
* Public Functions
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Name: up_usbinitialize
|
* Name: up_usbinitialize
|
||||||
* Description:
|
* Description:
|
||||||
@ -1396,15 +1453,19 @@ int usbdev_register(struct usbdevclass_driver_s *driver)
|
|||||||
|
|
||||||
#ifdef CONFIG_LC823450_LSISTBY
|
#ifdef CONFIG_LC823450_LSISTBY
|
||||||
/* enable USB */
|
/* enable USB */
|
||||||
|
|
||||||
mod_stby_regs(LSISTBY_STBYE, 0);
|
mod_stby_regs(LSISTBY_STBYE, 0);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
g_usbdev.driver = driver;
|
g_usbdev.driver = driver;
|
||||||
|
|
||||||
/* Clock & Power & Reset */
|
/* Clock & Power & Reset */
|
||||||
|
|
||||||
modifyreg32(MCLKCNTBASIC, 0, MCLKCNTBASIC_USBDEV_CLKEN);
|
modifyreg32(MCLKCNTBASIC, 0, MCLKCNTBASIC_USBDEV_CLKEN);
|
||||||
modifyreg32(USBCNT, USBCNT_ANPD, 0);
|
modifyreg32(USBCNT, USBCNT_ANPD, 0);
|
||||||
|
|
||||||
/* USB PLL REFCLOCK */
|
/* USB PLL REFCLOCK */
|
||||||
|
|
||||||
if (XT1OSC_CLK == (24 * 1000 * 1000))
|
if (XT1OSC_CLK == (24 * 1000 * 1000))
|
||||||
{
|
{
|
||||||
modifyreg32(USBCNT, USBCNT_CLK_MASK, USBCNT_CLK24MHZ);
|
modifyreg32(USBCNT, USBCNT_CLK_MASK, USBCNT_CLK24MHZ);
|
||||||
@ -1425,12 +1486,15 @@ int usbdev_register(struct usbdevclass_driver_s *driver)
|
|||||||
modifyreg32(USBCNT, 0, USBCNT_VBUS_VALID);
|
modifyreg32(USBCNT, 0, USBCNT_VBUS_VALID);
|
||||||
|
|
||||||
/* SoftReset */
|
/* SoftReset */
|
||||||
|
|
||||||
modifyreg32(USB_CONF, 0, USB_CONF_SOFT_RESET);
|
modifyreg32(USB_CONF, 0, USB_CONF_SOFT_RESET);
|
||||||
while (getreg32(USB_CONF) & USB_CONF_SOFT_RESET);
|
while (getreg32(USB_CONF) & USB_CONF_SOFT_RESET);
|
||||||
|
|
||||||
|
|
||||||
putreg32(0, USB_CONF);
|
putreg32(0, USB_CONF);
|
||||||
|
|
||||||
/* RAM area init */
|
/* RAM area init */
|
||||||
|
|
||||||
for (i = 0; i < 16; i++)
|
for (i = 0; i < 16; i++)
|
||||||
{
|
{
|
||||||
if (i == 0)
|
if (i == 0)
|
||||||
@ -1441,6 +1505,7 @@ int usbdev_register(struct usbdevclass_driver_s *driver)
|
|||||||
{
|
{
|
||||||
putreg32(0x400, USB_EPCTRL(i));
|
putreg32(0x400, USB_EPCTRL(i));
|
||||||
}
|
}
|
||||||
|
|
||||||
putreg32(0, USB_EPCONF(i));
|
putreg32(0, USB_EPCONF(i));
|
||||||
putreg32(0, USB_EPCOUNT(i * 2));
|
putreg32(0, USB_EPCOUNT(i * 2));
|
||||||
putreg32(0, USB_EPCOUNT(i * 2 + 1));
|
putreg32(0, USB_EPCOUNT(i * 2 + 1));
|
||||||
@ -1449,9 +1514,11 @@ int usbdev_register(struct usbdevclass_driver_s *driver)
|
|||||||
g_usbdev.bufoffset = 0x180;
|
g_usbdev.bufoffset = 0x180;
|
||||||
|
|
||||||
/* Device mode enbale */
|
/* Device mode enbale */
|
||||||
|
|
||||||
modifyreg32(USB_MODE, 0, USB_MODE_DEV_EN);
|
modifyreg32(USB_MODE, 0, USB_MODE_DEV_EN);
|
||||||
|
|
||||||
/* auto address load mode */
|
/* auto address load mode */
|
||||||
|
|
||||||
modifyreg32(USB_MODE, 0, USB_MODE_ADDR_LDMOD);
|
modifyreg32(USB_MODE, 0, USB_MODE_ADDR_LDMOD);
|
||||||
modifyreg32(USB_MODE, 0, USB_MODE_DEV_INTMOD);
|
modifyreg32(USB_MODE, 0, USB_MODE_DEV_INTMOD);
|
||||||
|
|
||||||
@ -1466,15 +1533,19 @@ int usbdev_register(struct usbdevclass_driver_s *driver)
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
/* Bus Reset End interrupt */
|
/* Bus Reset End interrupt */
|
||||||
|
|
||||||
modifyreg32(USB_DEVC, 0, USB_DEVC_USBRSTE);
|
modifyreg32(USB_DEVC, 0, USB_DEVC_USBRSTE);
|
||||||
|
|
||||||
/* Setup start interrupt */
|
/* Setup start interrupt */
|
||||||
|
|
||||||
modifyreg32(USB_DEVC, 0, USB_DEVC_SETUP);
|
modifyreg32(USB_DEVC, 0, USB_DEVC_SETUP);
|
||||||
|
|
||||||
/* Setup sus/res interrupt */
|
/* Setup sus/res interrupt */
|
||||||
|
|
||||||
modifyreg32(USB_DEVC, 0, USB_DEVC_SUSPENDB | USB_DEVC_SUSPENDE);
|
modifyreg32(USB_DEVC, 0, USB_DEVC_SUSPENDB | USB_DEVC_SUSPENDE);
|
||||||
|
|
||||||
/* Enable USB controller interrupts */
|
/* Enable USB controller interrupts */
|
||||||
|
|
||||||
putreg32(0xffff0002, USB_INTEN);
|
putreg32(0xffff0002, USB_INTEN);
|
||||||
|
|
||||||
g_usbdev.eplist[0].type = 0;
|
g_usbdev.eplist[0].type = 0;
|
||||||
@ -1486,11 +1557,13 @@ int usbdev_register(struct usbdevclass_driver_s *driver)
|
|||||||
/* Detect AC-Charger */
|
/* Detect AC-Charger */
|
||||||
|
|
||||||
/* clear sof intr */
|
/* clear sof intr */
|
||||||
|
|
||||||
putreg32(~USB_DEVS_SOF, USB_DEVS);
|
putreg32(~USB_DEVS_SOF, USB_DEVS);
|
||||||
|
|
||||||
usleep(100000);
|
usleep(100000);
|
||||||
|
|
||||||
/* SOF is not arrived & D+/D- is HIGH */
|
/* SOF is not arrived & D+/D- is HIGH */
|
||||||
|
|
||||||
if (!(getreg32(USB_DEVS) & USB_DEVS_SOF) &&
|
if (!(getreg32(USB_DEVS) & USB_DEVS_SOF) &&
|
||||||
(getreg32(USBSTAT) & USBSTAT_LINESTE_MASK) ==
|
(getreg32(USBSTAT) & USBSTAT_LINESTE_MASK) ==
|
||||||
(USBSTAT_LINESTE_0 | USBSTAT_LINESTE_1))
|
(USBSTAT_LINESTE_0 | USBSTAT_LINESTE_1))
|
||||||
@ -1560,16 +1633,20 @@ int usbdev_unregister(struct usbdevclass_driver_s *driver)
|
|||||||
|
|
||||||
#ifdef CONFIG_WAKELOCK
|
#ifdef CONFIG_WAKELOCK
|
||||||
/* cancel USB suspend work */
|
/* cancel USB suspend work */
|
||||||
|
|
||||||
work_cancel(HPWORK, &usb_suspend_work);
|
work_cancel(HPWORK, &usb_suspend_work);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* Unbind the class driver */
|
/* Unbind the class driver */
|
||||||
|
|
||||||
CLASS_UNBIND(driver, &priv->usbdev);
|
CLASS_UNBIND(driver, &priv->usbdev);
|
||||||
|
|
||||||
/* Disable interrupts */
|
/* Disable interrupts */
|
||||||
|
|
||||||
up_disable_irq(LC823450_IRQ_USBDEV);
|
up_disable_irq(LC823450_IRQ_USBDEV);
|
||||||
|
|
||||||
/* Disconnect device */
|
/* Disconnect device */
|
||||||
|
|
||||||
lc823450_usbpullup(&priv->usbdev, false);
|
lc823450_usbpullup(&priv->usbdev, false);
|
||||||
|
|
||||||
/* Unhook the driver */
|
/* Unhook the driver */
|
||||||
@ -1592,6 +1669,7 @@ int usbdev_unregister(struct usbdevclass_driver_s *driver)
|
|||||||
|
|
||||||
#ifdef CONFIG_LC823450_LSISTBY
|
#ifdef CONFIG_LC823450_LSISTBY
|
||||||
/* disable USB */
|
/* disable USB */
|
||||||
|
|
||||||
mod_stby_regs(0, LSISTBY_STBYE);
|
mod_stby_regs(0, LSISTBY_STBYE);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -1602,12 +1680,12 @@ int usbdev_unregister(struct usbdevclass_driver_s *driver)
|
|||||||
return OK;
|
return OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* FOR USBMSC optimization */
|
/* FOR USBMSC optimization */
|
||||||
#ifdef CONFIG_USBMSC_OPT
|
#ifdef CONFIG_USBMSC_OPT
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Name: usbdev_msc_read_enter
|
* Name: usbdev_msc_read_enter
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
void usbdev_msc_read_enter()
|
void usbdev_msc_read_enter()
|
||||||
{
|
{
|
||||||
struct lc823450_ep_s *privep;
|
struct lc823450_ep_s *privep;
|
||||||
@ -1625,6 +1703,7 @@ void usbdev_msc_read_enter()
|
|||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Name: usbdev_msc_read_exit
|
* Name: usbdev_msc_read_exit
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
void usbdev_msc_read_exit()
|
void usbdev_msc_read_exit()
|
||||||
{
|
{
|
||||||
struct lc823450_ep_s *privep;
|
struct lc823450_ep_s *privep;
|
||||||
@ -1637,6 +1716,7 @@ void usbdev_msc_read_exit()
|
|||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Name: usbdev_dma_callback
|
* Name: usbdev_dma_callback
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
static void usbdev_dma_callback(DMA_HANDLE hd, void *arg, int result)
|
static void usbdev_dma_callback(DMA_HANDLE hd, void *arg, int result)
|
||||||
{
|
{
|
||||||
sem_t *waitsem = (sem_t *)arg;
|
sem_t *waitsem = (sem_t *)arg;
|
||||||
@ -1646,6 +1726,7 @@ static void usbdev_dma_callback(DMA_HANDLE hd, void *arg, int result)
|
|||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Name: usbdev_msc_epwrite
|
* Name: usbdev_msc_epwrite
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
int usbdev_msc_epwrite(void *buf, int len)
|
int usbdev_msc_epwrite(void *buf, int len)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
@ -1664,6 +1745,7 @@ int usbdev_msc_epwrite(void *buf, int len)
|
|||||||
LC823450_DMA_BS_64 << LC823450_DMA_DBS_SHIFT;
|
LC823450_DMA_BS_64 << LC823450_DMA_DBS_SHIFT;
|
||||||
|
|
||||||
/* create dma link list */
|
/* create dma link list */
|
||||||
|
|
||||||
for (i = 1; i < len / pksz; i++)
|
for (i = 1; i < len / pksz; i++)
|
||||||
{
|
{
|
||||||
dma_list[i - 1].srcaddr = (uint32_t)buf + i * pksz;
|
dma_list[i - 1].srcaddr = (uint32_t)buf + i * pksz;
|
||||||
@ -1671,6 +1753,7 @@ int usbdev_msc_epwrite(void *buf, int len)
|
|||||||
if (i == (len / pksz) - 1)
|
if (i == (len / pksz) - 1)
|
||||||
{
|
{
|
||||||
/* last link */
|
/* last link */
|
||||||
|
|
||||||
dma_list[i - 1].nextlli = 0;
|
dma_list[i - 1].nextlli = 0;
|
||||||
dma_list[i - 1].ctrl = ctrl | LC823450_DMA_ITC | pksz;
|
dma_list[i - 1].ctrl = ctrl | LC823450_DMA_ITC | pksz;
|
||||||
}
|
}
|
||||||
@ -1704,6 +1787,7 @@ int usbdev_msc_epwrite(void *buf, int len)
|
|||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Name: usbdev_msc_write_enter0
|
* Name: usbdev_msc_write_enter0
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
void usbdev_msc_write_enter0(void)
|
void usbdev_msc_write_enter0(void)
|
||||||
{
|
{
|
||||||
struct lc823450_ep_s *privep;
|
struct lc823450_ep_s *privep;
|
||||||
@ -1722,6 +1806,7 @@ void usbdev_msc_write_enter0(void)
|
|||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Name: usbdev_msc_write_enter
|
* Name: usbdev_msc_write_enter
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
void usbdev_msc_write_enter(void)
|
void usbdev_msc_write_enter(void)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
@ -1729,12 +1814,15 @@ void usbdev_msc_write_enter(void)
|
|||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Name: usbdev_msc_write_exit
|
* Name: usbdev_msc_write_exit
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
void usbdev_msc_write_exit(void)
|
void usbdev_msc_write_exit(void)
|
||||||
{
|
{
|
||||||
struct lc823450_ep_s *privep;
|
struct lc823450_ep_s *privep;
|
||||||
|
|
||||||
epcmd_write(CONFIG_USBMSC_EPBULKOUT, USB_EPCMD_READY_CLR);
|
epcmd_write(CONFIG_USBMSC_EPBULKOUT, USB_EPCMD_READY_CLR);
|
||||||
|
|
||||||
/* Discard garbage packet: for USBCV MSCTEST11 */
|
/* Discard garbage packet: for USBCV MSCTEST11 */
|
||||||
|
|
||||||
epcmd_write(CONFIG_USBMSC_EPBULKOUT, USB_EPCMD_BUFRD);
|
epcmd_write(CONFIG_USBMSC_EPBULKOUT, USB_EPCMD_BUFRD);
|
||||||
privep = &g_usbdev.eplist[CONFIG_USBMSC_EPBULKOUT];
|
privep = &g_usbdev.eplist[CONFIG_USBMSC_EPBULKOUT];
|
||||||
privep->epcmd |= USB_EPCMD_READY_EN;
|
privep->epcmd |= USB_EPCMD_READY_EN;
|
||||||
@ -1744,6 +1832,7 @@ void usbdev_msc_write_exit(void)
|
|||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Name: usbdev_msc_epread
|
* Name: usbdev_msc_epread
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
int usbdev_msc_epread(void *buf, int len)
|
int usbdev_msc_epread(void *buf, int len)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
@ -1762,6 +1851,7 @@ int usbdev_msc_epread(void *buf, int len)
|
|||||||
LC823450_DMA_BS_64 << LC823450_DMA_DBS_SHIFT;
|
LC823450_DMA_BS_64 << LC823450_DMA_DBS_SHIFT;
|
||||||
|
|
||||||
/* create dma link list */
|
/* create dma link list */
|
||||||
|
|
||||||
for (i = 1; i < len / pksz; i++)
|
for (i = 1; i < len / pksz; i++)
|
||||||
{
|
{
|
||||||
dma_list[i - 1].srcaddr = (uint32_t)privep->outbuf + 0x8000;
|
dma_list[i - 1].srcaddr = (uint32_t)privep->outbuf + 0x8000;
|
||||||
@ -1769,6 +1859,7 @@ int usbdev_msc_epread(void *buf, int len)
|
|||||||
if (i == (len / pksz) - 1)
|
if (i == (len / pksz) - 1)
|
||||||
{
|
{
|
||||||
/* last link */
|
/* last link */
|
||||||
|
|
||||||
dma_list[i - 1].nextlli = 0;
|
dma_list[i - 1].nextlli = 0;
|
||||||
dma_list[i - 1].ctrl = ctrl | LC823450_DMA_ITC | pksz;
|
dma_list[i - 1].ctrl = ctrl | LC823450_DMA_ITC | pksz;
|
||||||
}
|
}
|
||||||
@ -1805,7 +1896,6 @@ void usbdev_msc_stop(void)
|
|||||||
}
|
}
|
||||||
#endif /* CONFIG_USBMSC */
|
#endif /* CONFIG_USBMSC */
|
||||||
|
|
||||||
|
|
||||||
#ifdef CONFIG_USBDEV_CHARGER
|
#ifdef CONFIG_USBDEV_CHARGER
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Name: usbdev_is_usbcharger
|
* Name: usbdev_is_usbcharger
|
||||||
|
@ -41,14 +41,14 @@
|
|||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
#ifdef CONFIG_USBDEV_MAXENDPOINTS
|
#ifdef CONFIG_USBDEV_MAXENDPOINTS
|
||||||
#define LC823450_NLOGENDPOINTS CONFIG_USBDEV_MAXENDPOINTS
|
# define LC823450_NLOGENDPOINTS CONFIG_USBDEV_MAXENDPOINTS
|
||||||
#else /* CONFIG_USBDEV_MAXENDPOINTS */
|
#else /* CONFIG_USBDEV_MAXENDPOINTS */
|
||||||
#define LC823450_NLOGENDPOINTS (16) /* ep0-15 */
|
# define LC823450_NLOGENDPOINTS (16) /* ep0-15 */
|
||||||
#endif /* CONFIG_USBDEV_MAXENDPOINTS */
|
#endif /* CONFIG_USBDEV_MAXENDPOINTS */
|
||||||
#define LC823450_NPHYSENDPOINTS (LC823450_NLOGENDPOINTS * 2)
|
#define LC823450_NPHYSENDPOINTS (LC823450_NLOGENDPOINTS * 2)
|
||||||
|
|
||||||
|
|
||||||
/* Register define */
|
/* Register define */
|
||||||
|
|
||||||
#define USBDEV_BASE 0x40010000
|
#define USBDEV_BASE 0x40010000
|
||||||
|
|
||||||
#define USB_CONF (USBDEV_BASE + 0x0000)
|
#define USB_CONF (USBDEV_BASE + 0x0000)
|
||||||
|
@ -97,7 +97,6 @@ Please note that card hotplugging is not supported.
|
|||||||
nsh> msconn
|
nsh> msconn
|
||||||
nsh> msdis
|
nsh> msdis
|
||||||
|
|
||||||
|
|
||||||
TODO
|
TODO
|
||||||
^^^^
|
^^^^
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user