Merge branch 'master' into next
This commit is contained in:
commit
3170433558
2
Kconfig
2
Kconfig
|
@ -2,7 +2,7 @@
|
|||
# For a description of the syntax of this configuration file,
|
||||
# see Documentation/kbuild/kconfig-language.txt.
|
||||
#
|
||||
mainmenu "Linux/$ARCH $KERNELVERSION Barebox Configuration"
|
||||
mainmenu "Barebox/$ARCH $KERNELVERSION Configuration"
|
||||
|
||||
config SRCARCH
|
||||
string
|
||||
|
|
|
@ -169,7 +169,6 @@ BAREBOX_CMD_HELP_USAGE("addpart <device> <part_desc>\n")
|
|||
BAREBOX_CMD_HELP_SHORT("Add a partition description to a device.\n")
|
||||
BAREBOX_CMD_HELP_OPT ("-n", "no prefix. Do not prepend the device name as prefix before the partition name\n")
|
||||
BAREBOX_CMD_HELP_OPT ("<device>", "device being worked on\n")
|
||||
BAREBOX_CMD_HELP_OPT ("<device>", "device being worked on\n")
|
||||
BAREBOX_CMD_HELP_OPT ("<part_desc>", "size1[@offset1](name1)[ro],size2[@offset2](name2)[ro],...\n")
|
||||
BAREBOX_CMD_HELP_END
|
||||
|
||||
|
|
|
@ -89,10 +89,10 @@ enum filetype file_name_detect_type(const char *filename)
|
|||
if (fd < 0)
|
||||
return fd;
|
||||
|
||||
buf = xmalloc(512);
|
||||
buf = xzalloc(512);
|
||||
|
||||
ret = read(fd, buf, 512);
|
||||
if (ret != 512)
|
||||
if (ret < 0)
|
||||
goto err_out;
|
||||
|
||||
type = file_detect_type(buf);
|
||||
|
|
|
@ -25,6 +25,10 @@
|
|||
|
||||
#define DRIVER_NAME "pxa-mmc"
|
||||
|
||||
#define RX_TIMEOUT (100 * MSECOND)
|
||||
#define TX_TIMEOUT (250 * MSECOND)
|
||||
#define CMD_TIMEOUT (100 * MSECOND)
|
||||
|
||||
static void clk_enable(void)
|
||||
{
|
||||
CKEN |= CKEN_MMC;
|
||||
|
@ -38,6 +42,7 @@ static int pxamci_set_power(struct pxamci_host *host, int on)
|
|||
!!on ^ host->pdata->gpio_power_invert);
|
||||
else if (host->pdata && host->pdata->setpower)
|
||||
host->pdata->setpower(&host->mci, on);
|
||||
mdelay(250);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -54,7 +59,7 @@ static void pxamci_stop_clock(struct pxamci_host *host)
|
|||
stat = mmc_readl(MMC_STAT);
|
||||
if (stat & STAT_CLK_EN)
|
||||
writel(STOP_CLOCK, host->base + MMC_STRPCL);
|
||||
while (!is_timeout(start, 10 * MSECOND) && stat & STAT_CLK_EN)
|
||||
while (!is_timeout(start, CMD_TIMEOUT) && stat & STAT_CLK_EN)
|
||||
stat = mmc_readl(MMC_STAT);
|
||||
|
||||
if (stat & STAT_CLK_EN)
|
||||
|
@ -63,12 +68,12 @@ static void pxamci_stop_clock(struct pxamci_host *host)
|
|||
|
||||
static void pxamci_setup_data(struct pxamci_host *host, struct mci_data *data)
|
||||
{
|
||||
static const unsigned int timeout = 100000000; /* 10ms */
|
||||
static const unsigned int timeout_ns = 1000 * MSECOND; /* 1000 ms */
|
||||
|
||||
mci_dbg("nbblocks=%d, blocksize=%d\n", data->blocks, data->blocksize);
|
||||
mmc_writel(data->blocks, MMC_NOB);
|
||||
mmc_writel(data->blocksize, MMC_BLKLEN);
|
||||
mmc_writel((timeout + 255) / 256, MMC_RDTO);
|
||||
mmc_writel(DIV_ROUND_UP(timeout_ns, 13128), MMC_RDTO);
|
||||
}
|
||||
|
||||
static int pxamci_read_data(struct pxamci_host *host, unsigned char *dst,
|
||||
|
@ -83,9 +88,10 @@ static int pxamci_read_data(struct pxamci_host *host, unsigned char *dst,
|
|||
trf_len = min_t(int, len, MMC_FIFO_LENGTH);
|
||||
|
||||
for (start = get_time_ns(), ret = -ETIMEDOUT;
|
||||
ret && !is_timeout(start, 10 * MSECOND);)
|
||||
ret && !is_timeout(start, RX_TIMEOUT);)
|
||||
if (mmc_readl(MMC_I_REG) & RXFIFO_RD_REQ)
|
||||
ret = 0;
|
||||
|
||||
trf_len1 = trf_len % 4;
|
||||
trf_len4 = trf_len / 4;
|
||||
for (dst4 = (u32 *)dst; !ret && trf_len4 > 0; trf_len4--)
|
||||
|
@ -97,7 +103,7 @@ static int pxamci_read_data(struct pxamci_host *host, unsigned char *dst,
|
|||
|
||||
if (!ret)
|
||||
for (start = get_time_ns(), ret = -ETIMEDOUT;
|
||||
ret && !is_timeout(start, 10 * MSECOND);)
|
||||
ret && !is_timeout(start, RX_TIMEOUT);)
|
||||
if (mmc_readl(MMC_STAT) & STAT_DATA_TRAN_DONE)
|
||||
ret = 0;
|
||||
mci_dbg("ret=%d, remain=%d, stat=%x, mmc_i_reg=%x\n",
|
||||
|
@ -118,7 +124,7 @@ static int pxamci_write_data(struct pxamci_host *host, const unsigned char *src,
|
|||
partial = trf_len < MMC_FIFO_LENGTH;
|
||||
|
||||
for (start = get_time_ns(), ret = -ETIMEDOUT;
|
||||
ret && !is_timeout(start, 10 * MSECOND);)
|
||||
ret && !is_timeout(start, TX_TIMEOUT);)
|
||||
if (mmc_readl(MMC_I_REG) & TXFIFO_WR_REQ)
|
||||
ret = 0;
|
||||
for (; !ret && trf_len > 0; trf_len--, len--)
|
||||
|
@ -129,7 +135,7 @@ static int pxamci_write_data(struct pxamci_host *host, const unsigned char *src,
|
|||
|
||||
if (!ret)
|
||||
for (start = get_time_ns(), ret = -ETIMEDOUT;
|
||||
ret && !is_timeout(start, 100 * MSECOND);) {
|
||||
ret && !is_timeout(start, TX_TIMEOUT);) {
|
||||
stat = mmc_readl(MMC_STAT);
|
||||
stat &= STAT_DATA_TRAN_DONE | STAT_PRG_DONE;
|
||||
if (stat == (STAT_DATA_TRAN_DONE | STAT_PRG_DONE))
|
||||
|
@ -158,18 +164,19 @@ static int pxamci_transfer_data(struct pxamci_host *host,
|
|||
return ret;
|
||||
}
|
||||
|
||||
#define MMC_RSP_MASK (MMC_RSP_PRESENT | MMC_RSP_136 | MMC_RSP_CRC | \
|
||||
MMC_RSP_BUSY | MMC_RSP_OPCODE)
|
||||
static void pxamci_start_cmd(struct pxamci_host *host, struct mci_cmd *cmd,
|
||||
unsigned int cmdat)
|
||||
{
|
||||
mci_dbg("cmd=(idx=%d,type=%d,clkrt=%d)\n", cmd->cmdidx, cmd->resp_type,
|
||||
host->clkrt);
|
||||
if (cmd->resp_type & MMC_RSP_BUSY)
|
||||
cmdat |= CMDAT_BUSY;
|
||||
|
||||
switch (cmd->resp_type) {
|
||||
switch (cmd->resp_type & MMC_RSP_MASK) {
|
||||
/* r1, r1b, r6, r7 */
|
||||
case MMC_RSP_R1:
|
||||
case MMC_RSP_R1b:
|
||||
cmdat |= CMDAT_BUSY;
|
||||
case MMC_RSP_R1:
|
||||
cmdat |= CMDAT_RESP_SHORT;
|
||||
break;
|
||||
case MMC_RSP_R2:
|
||||
|
@ -182,10 +189,12 @@ static void pxamci_start_cmd(struct pxamci_host *host, struct mci_cmd *cmd,
|
|||
break;
|
||||
}
|
||||
|
||||
if (cmd->cmdidx == MMC_CMD_STOP_TRANSMISSION)
|
||||
cmdat |= CMDAT_STOP_TRAN;
|
||||
|
||||
mmc_writel(cmd->cmdidx, MMC_CMD);
|
||||
mmc_writel(cmd->cmdarg >> 16, MMC_ARGH);
|
||||
mmc_writel(cmd->cmdarg & 0xffff, MMC_ARGL);
|
||||
mmc_writel(host->clkrt, MMC_CLKRT);
|
||||
pxamci_start_clock(host);
|
||||
mmc_writel(cmdat, MMC_CMDAT);
|
||||
}
|
||||
|
@ -231,13 +240,17 @@ static int pxamci_cmd_response(struct pxamci_host *host, struct mci_cmd *cmd)
|
|||
static int pxamci_mmccmd(struct pxamci_host *host, struct mci_cmd *cmd,
|
||||
struct mci_data *data, unsigned int cmddat)
|
||||
{
|
||||
int ret = 0;
|
||||
int ret = 0, stat_mask;
|
||||
uint64_t start;
|
||||
|
||||
pxamci_start_cmd(host, cmd, cmddat);
|
||||
|
||||
stat_mask = STAT_END_CMD_RES;
|
||||
if (cmd->resp_type & MMC_RSP_BUSY)
|
||||
stat_mask |= STAT_PRG_DONE;
|
||||
for (start = get_time_ns(), ret = -ETIMEDOUT;
|
||||
ret && !is_timeout(start, 10 * MSECOND);)
|
||||
if (mmc_readl(MMC_STAT) & STAT_END_CMD_RES)
|
||||
ret && !is_timeout(start, CMD_TIMEOUT);)
|
||||
if ((mmc_readl(MMC_STAT) & stat_mask) == stat_mask)
|
||||
ret = 0;
|
||||
|
||||
if (!ret && data)
|
||||
|
@ -255,8 +268,6 @@ static int pxamci_request(struct mci_host *mci, struct mci_cmd *cmd,
|
|||
unsigned int cmdat;
|
||||
int ret;
|
||||
|
||||
pxamci_stop_clock(host);
|
||||
|
||||
cmdat = host->cmdat;
|
||||
host->cmdat &= ~CMDAT_INIT;
|
||||
|
||||
|
@ -306,8 +317,9 @@ static void pxamci_set_ios(struct mci_host *mci, struct mci_ios *ios)
|
|||
|
||||
host->cmdat |= CMDAT_INIT;
|
||||
|
||||
clk_enable();
|
||||
pxamci_set_power(host, 1);
|
||||
pxamci_stop_clock(host);
|
||||
mmc_writel(host->clkrt, MMC_CLKRT);
|
||||
}
|
||||
|
||||
static int pxamci_init(struct mci_host *mci, struct device_d *dev)
|
||||
|
@ -324,6 +336,7 @@ static int pxamci_probe(struct device_d *dev)
|
|||
struct pxamci_host *host;
|
||||
int gpio_power = -1;
|
||||
|
||||
clk_enable();
|
||||
host = xzalloc(sizeof(*host));
|
||||
host->base = dev_request_mem_region(dev, 0);
|
||||
|
||||
|
|
|
@ -40,6 +40,7 @@
|
|||
|
||||
#define MMC_CMDAT 0x0010
|
||||
#define CMDAT_SDIO_INT_EN (1 << 11)
|
||||
#define CMDAT_STOP_TRAN (1 << 10)
|
||||
#define CMDAT_SD_4DAT (1 << 8)
|
||||
#define CMDAT_DMAEN (1 << 7)
|
||||
#define CMDAT_INIT (1 << 6)
|
||||
|
|
|
@ -163,7 +163,7 @@ static void doc_read_data_area(struct docg3 *docg3, void *buf, int len,
|
|||
u8 data8, *dst8;
|
||||
|
||||
doc_dbg("doc_read_data_area(buf=%p, len=%d)\n", buf, len);
|
||||
cdr = len & 0x3;
|
||||
cdr = len & 0x1;
|
||||
len4 = len - cdr;
|
||||
|
||||
if (first)
|
||||
|
@ -395,9 +395,14 @@ err:
|
|||
}
|
||||
|
||||
static int doc_read_page_getbytes(struct docg3 *docg3, int len, u_char *buf,
|
||||
int first)
|
||||
int first, int last_odd)
|
||||
{
|
||||
doc_read_data_area(docg3, buf, len, first);
|
||||
if (last_odd && len > 0) {
|
||||
doc_read_data_area(docg3, buf, 1, first);
|
||||
doc_read_data_area(docg3, buf ? buf + 1 : buf, len - 1, 0);
|
||||
} else {
|
||||
doc_read_data_area(docg3, buf, len, first);
|
||||
}
|
||||
doc_delay(docg3, 2);
|
||||
return len;
|
||||
}
|
||||
|
@ -448,7 +453,7 @@ static int doc_read_oob(struct mtd_info *mtd, loff_t from,
|
|||
struct mtd_oob_ops *ops)
|
||||
{
|
||||
struct docg3 *docg3 = mtd->priv;
|
||||
int block0, block1, page, ret, ofs = 0;
|
||||
int block0, block1, page, ret, skip, ofs = 0;
|
||||
u8 *oobbuf = ops->oobbuf;
|
||||
u8 *buf = ops->datbuf;
|
||||
size_t len, ooblen, nbdata, nboob;
|
||||
|
@ -468,8 +473,7 @@ static int doc_read_oob(struct mtd_info *mtd, loff_t from,
|
|||
|
||||
doc_dbg("doc_read_oob(from=%lld, mode=%d, data=(%p:%zu), oob=(%p:%zu))\n",
|
||||
from, ops->mode, buf, len, oobbuf, ooblen);
|
||||
if ((len % DOC_LAYOUT_PAGE_SIZE) || (ooblen % DOC_LAYOUT_OOB_SIZE) ||
|
||||
(from % DOC_LAYOUT_PAGE_SIZE))
|
||||
if (ooblen % DOC_LAYOUT_OOB_SIZE)
|
||||
return -EINVAL;
|
||||
|
||||
ret = -EINVAL;
|
||||
|
@ -481,10 +485,11 @@ static int doc_read_oob(struct mtd_info *mtd, loff_t from,
|
|||
ops->oobretlen = 0;
|
||||
ops->retlen = 0;
|
||||
ret = 0;
|
||||
skip = from % DOC_LAYOUT_PAGE_SIZE;
|
||||
while (!ret && (len > 0 || ooblen > 0)) {
|
||||
calc_block_sector(from, &block0, &block1, &page, &ofs,
|
||||
docg3->reliable);
|
||||
nbdata = min_t(size_t, len, (size_t)DOC_LAYOUT_PAGE_SIZE);
|
||||
nbdata = min_t(size_t, len, DOC_LAYOUT_PAGE_SIZE - skip);
|
||||
nboob = min_t(size_t, ooblen, (size_t)DOC_LAYOUT_OOB_SIZE);
|
||||
ret = doc_read_page_prepare(docg3, block0, block1, page, ofs);
|
||||
if (ret < 0)
|
||||
|
@ -492,16 +497,20 @@ static int doc_read_oob(struct mtd_info *mtd, loff_t from,
|
|||
ret = doc_read_page_ecc_init(docg3, DOC_ECC_BCH_TOTAL_BYTES);
|
||||
if (ret < 0)
|
||||
goto err_in_read;
|
||||
ret = doc_read_page_getbytes(docg3, nbdata, buf, 1);
|
||||
ret = doc_read_page_getbytes(docg3, skip, NULL, 1, 0);
|
||||
if (ret < skip)
|
||||
goto err_in_read;
|
||||
ret = doc_read_page_getbytes(docg3, nbdata, buf, 0, skip % 2);
|
||||
if (ret < nbdata)
|
||||
goto err_in_read;
|
||||
doc_read_page_getbytes(docg3, DOC_LAYOUT_PAGE_SIZE - nbdata,
|
||||
NULL, 0);
|
||||
ret = doc_read_page_getbytes(docg3, nboob, oobbuf, 0);
|
||||
doc_read_page_getbytes(docg3,
|
||||
DOC_LAYOUT_PAGE_SIZE - nbdata - skip,
|
||||
NULL, 0, (skip + nbdata) % 2);
|
||||
ret = doc_read_page_getbytes(docg3, nboob, oobbuf, 0, 0);
|
||||
if (ret < nboob)
|
||||
goto err_in_read;
|
||||
doc_read_page_getbytes(docg3, DOC_LAYOUT_OOB_SIZE - nboob,
|
||||
NULL, 0);
|
||||
NULL, 0, nboob % 2);
|
||||
|
||||
doc_get_bch_hw_ecc(docg3, hwecc);
|
||||
eccconf1 = doc_register_readb(docg3, DOC_ECCCONF1);
|
||||
|
@ -549,6 +558,7 @@ static int doc_read_oob(struct mtd_info *mtd, loff_t from,
|
|||
len -= nbdata;
|
||||
ooblen -= nboob;
|
||||
from += DOC_LAYOUT_PAGE_SIZE;
|
||||
skip = 0;
|
||||
}
|
||||
|
||||
return ret;
|
||||
|
@ -589,7 +599,7 @@ static int doc_reload_bbt(struct docg3 *docg3)
|
|||
DOC_LAYOUT_PAGE_SIZE);
|
||||
if (!ret)
|
||||
doc_read_page_getbytes(docg3, DOC_LAYOUT_PAGE_SIZE,
|
||||
buf, 1);
|
||||
buf, 1, 0);
|
||||
buf += DOC_LAYOUT_PAGE_SIZE;
|
||||
}
|
||||
doc_read_page_finish(docg3);
|
||||
|
|
Loading…
Reference in New Issue