summaryrefslogtreecommitdiffstats
path: root/drivers/mci
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/mci')
-rw-r--r--drivers/mci/imx-esdhc.c22
-rw-r--r--drivers/mci/mci-core.c78
2 files changed, 65 insertions, 35 deletions
diff --git a/drivers/mci/imx-esdhc.c b/drivers/mci/imx-esdhc.c
index 951ac45..b2961cc 100644
--- a/drivers/mci/imx-esdhc.c
+++ b/drivers/mci/imx-esdhc.c
@@ -218,13 +218,10 @@ static int esdhc_setup_data(struct mci_host *mci, struct mci_data *data)
u32 wml_value;
if (IS_ENABLED(CONFIG_MCI_IMX_ESDHC_PIO)) {
- if (!(data->flags & MMC_DATA_READ)) {
- if ((esdhc_read32(regs + SDHCI_PRESENT_STATE) & PRSSTAT_WPSPL) == 0)
- goto err_locked;
+ if (!(data->flags & MMC_DATA_READ))
esdhc_write32(regs + SDHCI_DMA_ADDRESS, (u32)data->src);
- } else {
+ else
esdhc_write32(regs + SDHCI_DMA_ADDRESS, (u32)data->dest);
- }
} else {
wml_value = data->blocksize/4;
@@ -237,8 +234,6 @@ static int esdhc_setup_data(struct mci_host *mci, struct mci_data *data)
} else {
if (wml_value > 0x80)
wml_value = 0x80;
- if ((esdhc_read32(regs + SDHCI_PRESENT_STATE) & PRSSTAT_WPSPL) == 0)
- goto err_locked;
esdhc_clrsetbits32(regs + IMX_SDHCI_WML, WML_WR_WML_MASK,
wml_value << 16);
@@ -249,11 +244,6 @@ static int esdhc_setup_data(struct mci_host *mci, struct mci_data *data)
esdhc_write32(regs + SDHCI_BLOCK_SIZE__BLOCK_COUNT, data->blocks << 16 | data->blocksize);
return 0;
-
-err_locked:
- dev_err(host->dev, "Can not write to locked card.\n\n");
-
- return -ETIMEDOUT;
}
static int esdhc_do_data(struct mci_host *mci, struct mci_data *data)
@@ -630,6 +620,14 @@ static int fsl_esdhc_probe(struct device_d *dev)
host->clk = clk_get(dev, "per");
if (IS_ERR(host->clk))
return PTR_ERR(host->clk);
+ clk_enable(host->clk);
+
+ ret = clk_enable(host->clk);
+ if (ret) {
+ dev_err(dev, "Failed to enable clock: %s\n",
+ strerror(ret));
+ return ret;
+ }
host->dev = dev;
iores = dev_request_mem_resource(dev, 0);
diff --git a/drivers/mci/mci-core.c b/drivers/mci/mci-core.c
index 4e176f7..055a5e2 100644
--- a/drivers/mci/mci-core.c
+++ b/drivers/mci/mci-core.c
@@ -436,6 +436,7 @@ static void mci_part_add(struct mci *mci, uint64_t size,
part->blk.num_blocks = mci_calc_blk_cnt(size, part->blk.blockbits);
part->area_type = area_type;
part->part_cfg = part_cfg;
+ part->idx = idx;
if (area_type == MMC_BLK_DATA_AREA_MAIN)
part->blk.cdev.device_node = mci->host->hw_dev->device_node;
@@ -1573,6 +1574,59 @@ static const char *mci_boot_names[] = {
"user",
};
+static int mci_register_partition(struct mci_part *part)
+{
+ struct mci *mci = part->mci;
+ struct mci_host *host = mci->host;
+ const char *partnodename = NULL;
+ struct device_node *np;
+ int rc;
+
+ /*
+ * An MMC/SD card acts like an ordinary disk.
+ * So, re-use the disk driver to gain access to this media
+ */
+ part->blk.dev = &mci->dev;
+ part->blk.ops = &mci_ops;
+
+ rc = blockdevice_register(&part->blk);
+ if (rc != 0) {
+ dev_err(&mci->dev, "Failed to register MCI/SD blockdevice\n");
+ return rc;
+ }
+ dev_info(&mci->dev, "registered %s\n", part->blk.cdev.name);
+
+ np = host->hw_dev->device_node;
+
+ /* create partitions on demand */
+ switch (part->area_type) {
+ case MMC_BLK_DATA_AREA_BOOT:
+ if (part->idx == 0)
+ partnodename = "boot0-partitions";
+ else
+ partnodename = "boot1-partitions";
+
+ np = of_get_child_by_name(host->hw_dev->device_node,
+ partnodename);
+ break;
+ case MMC_BLK_DATA_AREA_MAIN:
+ break;
+ default:
+ return 0;
+ }
+
+ rc = parse_partition_table(&part->blk);
+ if (rc != 0) {
+ dev_warn(&mci->dev, "No partition table found\n");
+ rc = 0; /* it's not a failure */
+ }
+
+ if (np)
+ of_parse_partitions(&part->blk.cdev, np);
+
+ return 0;
+}
+
/**
* Probe an MCI card at the given host interface
* @param mci MCI device instance
@@ -1647,29 +1701,7 @@ static int mci_card_probe(struct mci *mci)
for (i = 0; i < mci->nr_parts; i++) {
struct mci_part *part = &mci->part[i];
- /*
- * An MMC/SD card acts like an ordinary disk.
- * So, re-use the disk driver to gain access to this media
- */
- part->blk.dev = &mci->dev;
- part->blk.ops = &mci_ops;
-
- rc = blockdevice_register(&part->blk);
- if (rc != 0) {
- dev_err(&mci->dev, "Failed to register MCI/SD blockdevice\n");
- goto on_error;
- }
- dev_info(&mci->dev, "registered %s\n", part->blk.cdev.name);
-
- /* create partitions on demand */
- if (part->area_type == MMC_BLK_DATA_AREA_MAIN) {
- rc = parse_partition_table(&part->blk);
- if (rc != 0) {
- dev_warn(&mci->dev, "No partition table found\n");
- rc = 0; /* it's not a failure */
- }
- of_parse_partitions(&part->blk.cdev, host->hw_dev->device_node);
- }
+ rc = mci_register_partition(part);
if (IS_ENABLED(CONFIG_MCI_MMC_BOOT_PARTITIONS) &&
part->area_type == MMC_BLK_DATA_AREA_BOOT &&