GK SDK 源码库: XMIPCLinuxV100R005C00SPC030 (kernel/tools/open_source excluded)
This commit is contained in:
@@ -0,0 +1,5 @@
|
||||
|
||||
ccflags-y += -I$(srctree)/product/update
|
||||
|
||||
obj-y += store_mmc.o
|
||||
obj-y += store_usb.o
|
||||
@@ -0,0 +1,59 @@
|
||||
// SPDX-License-Identifier: GPL-2.0
|
||||
/* Copyright (c) LOTUS. All rights reserved. */
|
||||
|
||||
#include <common.h>
|
||||
|
||||
#if (CONFIG_AUTO_SD_UPDATE == 1)
|
||||
#include <mmc.h>
|
||||
#include "update_comm.h"
|
||||
|
||||
int store_mmc_init(void)
|
||||
{
|
||||
struct mmc *mmc;
|
||||
unsigned int dev_num = 0;
|
||||
|
||||
agin:
|
||||
mmc = find_mmc_device(dev_num);
|
||||
if (mmc == NULL) {
|
||||
printf("No mmc driver found!\n");
|
||||
return UP_FAILURE;
|
||||
}
|
||||
|
||||
if (!IS_SD(mmc)) {
|
||||
dev_num++;
|
||||
goto agin;
|
||||
}
|
||||
|
||||
if (((unsigned long)mmc->block_dev.vendor[0] == 0) ||
|
||||
((unsigned long)mmc->block_dev.product[0] == 0)) {
|
||||
printf("*No SD card found!\n");
|
||||
return UP_FAILURE;
|
||||
}
|
||||
return UP_SUCCESS;
|
||||
}
|
||||
|
||||
void store_mmc_deinit(void)
|
||||
{
|
||||
}
|
||||
|
||||
int mmc_get_target_dev(void)
|
||||
{
|
||||
struct mmc *mmc = NULL;
|
||||
int dev_num = 0;
|
||||
|
||||
agin:
|
||||
mmc = find_mmc_device(dev_num);
|
||||
if (mmc == NULL) {
|
||||
printf("Error: No mmc driver found!\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (!IS_SD(mmc)) {
|
||||
dev_num++;
|
||||
goto agin;
|
||||
}
|
||||
|
||||
return dev_num;
|
||||
}
|
||||
|
||||
#endif // CONFIG_AUTO_SD_UPDATE
|
||||
@@ -0,0 +1,12 @@
|
||||
// SPDX-License-Identifier: GPL-2.0
|
||||
/* Copyright (c) LOTUS. All rights reserved. */
|
||||
|
||||
#ifndef __STORE_MMC_H__
|
||||
#define __STORE_MMC_H__
|
||||
|
||||
int store_mmc_init(void);
|
||||
|
||||
int store_mmc_deinit(void);
|
||||
|
||||
int mmc_get_target_dev(void);
|
||||
#endif
|
||||
@@ -0,0 +1,53 @@
|
||||
// SPDX-License-Identifier: GPL-2.0
|
||||
/* Copyright (c) LOTUS. All rights reserved. */
|
||||
|
||||
#include <common.h>
|
||||
|
||||
#if (CONFIG_AUTO_USB_UPDATE == 1)
|
||||
#include <usb.h>
|
||||
#include "update_comm.h"
|
||||
|
||||
int store_usb_init(void)
|
||||
{
|
||||
int ret;
|
||||
#ifndef CONFIG_XMEDIA_MC
|
||||
try_again:
|
||||
if (usb_stop() < 0) {
|
||||
debug("usb_stop failed\n");
|
||||
return UP_FAILURE;
|
||||
}
|
||||
/* delay for 1000 ms */
|
||||
mdelay(1000);
|
||||
ret = usb_init();
|
||||
if (ret == -ESRCH) {
|
||||
goto try_again;
|
||||
}
|
||||
|
||||
if (ret < 0) {
|
||||
debug("usb_init failed!\n");
|
||||
return UP_FAILURE;
|
||||
}
|
||||
|
||||
/*
|
||||
* check whether a storage device is attached (assume that it's
|
||||
* a USB memory stick, since nothing else should be attached).
|
||||
*/
|
||||
ret = usb_stor_scan(0);
|
||||
if (ret == -1) {
|
||||
debug("No USB device found. Not initialized!\n");
|
||||
return UP_FAILURE;
|
||||
} else {
|
||||
return UP_SUCCESS;
|
||||
}
|
||||
#endif
|
||||
return UP_FAILURE;
|
||||
}
|
||||
|
||||
void store_usb_deinit(void)
|
||||
{
|
||||
#ifndef CONFIG_XMEDIA_MC
|
||||
usb_stop();
|
||||
#endif
|
||||
}
|
||||
|
||||
#endif // CONFIG_AUTO_USB_UPDATE
|
||||
@@ -0,0 +1,11 @@
|
||||
// SPDX-License-Identifier: GPL-2.0
|
||||
/* Copyright (c) LOTUS. All rights reserved. */
|
||||
|
||||
#ifndef __STORE_USB_H__
|
||||
#define __STORE_USB_H__
|
||||
|
||||
int store_usb_init(void);
|
||||
|
||||
int store_usb_deinit(void);
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user