~ubuntu-branches/ubuntu/quantal/linux-linaro-mx51/quantal

« back to all changes in this revision

Viewing changes to drivers/mmc/host/omap_hsmmc.c

  • Committer: Package Import Robot
  • Author(s): John Rigby, John Rigby
  • Date: 2011-09-26 10:44:23 UTC
  • Revision ID: package-import@ubuntu.com-20110926104423-3o58a3c1bj7x00rs
Tags: 3.0.0-1007.9
[ John Rigby ]

Enable crypto modules and remove crypto-modules from
exclude-module files
LP: #826021

Show diffs side-by-side

added added

removed removed

Lines of Context:
141
141
#define OMAP_HSMMC_WRITE(base, reg, val) \
142
142
        __raw_writel((val), (base) + OMAP_HSMMC_##reg)
143
143
 
144
 
struct omap_hsmmc_next {
145
 
        unsigned int    dma_len;
146
 
        s32             cookie;
147
 
};
148
 
 
149
144
struct omap_hsmmc_host {
150
145
        struct  device          *dev;
151
146
        struct  mmc_host        *mmc;
189
184
        int                     reqs_blocked;
190
185
        int                     use_reg;
191
186
        int                     req_in_progress;
192
 
        struct omap_hsmmc_next  next_data;
193
187
 
194
188
        struct  omap_mmc_platform_data  *pdata;
195
189
};
1352
1346
                return;
1353
1347
        }
1354
1348
 
1355
 
        if (!data->host_cookie)
1356
 
                dma_unmap_sg(mmc_dev(host->mmc), data->sg, data->sg_len,
1357
 
                             omap_hsmmc_get_dma_dir(host, data));
 
1349
        dma_unmap_sg(mmc_dev(host->mmc), data->sg, data->sg_len,
 
1350
                omap_hsmmc_get_dma_dir(host, data));
1358
1351
 
1359
1352
        req_in_progress = host->req_in_progress;
1360
1353
        dma_ch = host->dma_ch;
1372
1365
        }
1373
1366
}
1374
1367
 
1375
 
static int omap_hsmmc_pre_dma_transfer(struct omap_hsmmc_host *host,
1376
 
                                       struct mmc_data *data,
1377
 
                                       struct omap_hsmmc_next *next)
1378
 
{
1379
 
        int dma_len;
1380
 
 
1381
 
        if (!next && data->host_cookie &&
1382
 
            data->host_cookie != host->next_data.cookie) {
1383
 
                printk(KERN_WARNING "[%s] invalid cookie: data->host_cookie %d"
1384
 
                       " host->next_data.cookie %d\n",
1385
 
                       __func__, data->host_cookie, host->next_data.cookie);
1386
 
                data->host_cookie = 0;
1387
 
        }
1388
 
 
1389
 
        /* Check if next job is already prepared */
1390
 
        if (next ||
1391
 
            (!next && data->host_cookie != host->next_data.cookie)) {
1392
 
                dma_len = dma_map_sg(mmc_dev(host->mmc), data->sg,
1393
 
                                     data->sg_len,
1394
 
                                     omap_hsmmc_get_dma_dir(host, data));
1395
 
 
1396
 
        } else {
1397
 
                dma_len = host->next_data.dma_len;
1398
 
                host->next_data.dma_len = 0;
1399
 
        }
1400
 
 
1401
 
 
1402
 
        if (dma_len == 0)
1403
 
                return -EINVAL;
1404
 
 
1405
 
        if (next) {
1406
 
                next->dma_len = dma_len;
1407
 
                data->host_cookie = ++next->cookie < 0 ? 1 : next->cookie;
1408
 
        } else
1409
 
                host->dma_len = dma_len;
1410
 
 
1411
 
        return 0;
1412
 
}
1413
 
 
1414
1368
/*
1415
1369
 * Routine to configure and start DMA for the MMC card
1416
1370
 */
1444
1398
                        mmc_hostname(host->mmc), ret);
1445
1399
                return ret;
1446
1400
        }
1447
 
        ret = omap_hsmmc_pre_dma_transfer(host, data, NULL);
1448
 
        if (ret)
1449
 
                return ret;
1450
1401
 
 
1402
        host->dma_len = dma_map_sg(mmc_dev(host->mmc), data->sg,
 
1403
                        data->sg_len, omap_hsmmc_get_dma_dir(host, data));
1451
1404
        host->dma_ch = dma_ch;
1452
1405
        host->dma_sg_idx = 0;
1453
1406
 
1527
1480
        return 0;
1528
1481
}
1529
1482
 
1530
 
static void omap_hsmmc_post_req(struct mmc_host *mmc, struct mmc_request *mrq,
1531
 
                                int err)
1532
 
{
1533
 
        struct omap_hsmmc_host *host = mmc_priv(mmc);
1534
 
        struct mmc_data *data = mrq->data;
1535
 
 
1536
 
        if (host->use_dma) {
1537
 
                dma_unmap_sg(mmc_dev(host->mmc), data->sg, data->sg_len,
1538
 
                             omap_hsmmc_get_dma_dir(host, data));
1539
 
                data->host_cookie = 0;
1540
 
        }
1541
 
}
1542
 
 
1543
 
static void omap_hsmmc_pre_req(struct mmc_host *mmc, struct mmc_request *mrq,
1544
 
                               bool is_first_req)
1545
 
{
1546
 
        struct omap_hsmmc_host *host = mmc_priv(mmc);
1547
 
 
1548
 
        if (mrq->data->host_cookie) {
1549
 
                mrq->data->host_cookie = 0;
1550
 
                return ;
1551
 
        }
1552
 
 
1553
 
        if (host->use_dma)
1554
 
                if (omap_hsmmc_pre_dma_transfer(host, mrq->data,
1555
 
                                                &host->next_data))
1556
 
                        mrq->data->host_cookie = 0;
1557
 
}
1558
 
 
1559
1483
/*
1560
1484
 * Request function. for read/write operation
1561
1485
 */
2004
1928
static const struct mmc_host_ops omap_hsmmc_ops = {
2005
1929
        .enable = omap_hsmmc_enable_fclk,
2006
1930
        .disable = omap_hsmmc_disable_fclk,
2007
 
        .post_req = omap_hsmmc_post_req,
2008
 
        .pre_req = omap_hsmmc_pre_req,
2009
1931
        .request = omap_hsmmc_request,
2010
1932
        .set_ios = omap_hsmmc_set_ios,
2011
1933
        .get_cd = omap_hsmmc_get_cd,
2155
2077
        host->mapbase   = res->start;
2156
2078
        host->base      = ioremap(host->mapbase, SZ_4K);
2157
2079
        host->power_mode = -1;
2158
 
        host->next_data.cookie = 1;
2159
2080
 
2160
2081
        platform_set_drvdata(pdev, host);
2161
2082
        INIT_WORK(&host->mmc_carddetect_work, omap_hsmmc_detect);