int mmc_send_cid(struct mmc_host *host, u32 *cid) { int ret, i; u32 *cid_tmp; if (!mmc_host_is_spi(host)) { if (!host->card) return -EINVAL; return mmc_send_cxd_native(host, host->card->rca << 16, cid, MMC_SEND_CID); } cid_tmp = kmalloc(16, GFP_KERNEL); if (!cid_tmp) return -ENOMEM; ret = mmc_send_cxd_data(NULL, host, MMC_SEND_CID, cid_tmp, 16); if (ret) goto err; for (i = 0;i < 4;i++) cid[i] = be32_to_cpu(cid_tmp[i]); err: kfree(cid_tmp); return ret; }
int mmc_send_cid(struct mmc_host *host, u32 *cid) { int ret, i; if (!mmc_host_is_spi(host)) { if (!host->card) return -EINVAL; #ifdef CONFIG_ARCH_EMXX return mmc_send_cxd_native(host, host->card[0]->rca << 16, cid, MMC_SEND_CID); #else return mmc_send_cxd_native(host, host->card->rca << 16, cid, MMC_SEND_CID); #endif } ret = mmc_send_cxd_data(NULL, host, MMC_SEND_CID, cid, 16); if (ret) return ret; for (i = 0; i < 4; i++) cid[i] = be32_to_cpu(cid[i]); return 0; }
int mmc_send_csd(struct mmc_card *card, u32 *csd) { int ret, i; u32 *csd_tmp; if (!mmc_host_is_spi(card->host)) return mmc_send_cxd_native(card->host, card->rca << 16, csd, MMC_SEND_CSD); csd_tmp = kmalloc(16, GFP_KERNEL); if (!csd_tmp) return -ENOMEM; ret = mmc_send_cxd_data(card, card->host, MMC_SEND_CSD, csd_tmp, 16); if (ret) goto err; for (i = 0;i < 4;i++) csd[i] = be32_to_cpu(csd_tmp[i]); err: kfree(csd_tmp); return ret; }
int mmc_get_ext_csd(struct mmc_card *card, u8 **new_ext_csd) { int err; u8 *ext_csd; if (!card || !new_ext_csd) return -EINVAL; if (!mmc_can_ext_csd(card)) return -EOPNOTSUPP; /* * As the ext_csd is so large and mostly unused, we don't store the * raw block in mmc_card. */ ext_csd = kzalloc(512, GFP_KERNEL); if (!ext_csd) return -ENOMEM; err = mmc_send_cxd_data(card, card->host, MMC_SEND_EXT_CSD, ext_csd, 512); if (err) kfree(ext_csd); else *new_ext_csd = ext_csd; return err; }
int mmc_send_cid(struct mmc_host *host, u32 *cid) { int ret, i; DBG("[%s] s\n",__func__); if (!mmc_host_is_spi(host)) { if (!host->card) { DBG("[%s] e1\n",__func__); return -EINVAL; } ret = mmc_send_cxd_native(host, host->card->rca << 16, cid, MMC_SEND_CID); DBG("[%s] e2\n",__func__); return ret; } ret = mmc_send_cxd_data(NULL, host, MMC_SEND_CID, cid, 16); if (ret) { DBG("[%s] e3\n",__func__); return ret; } for (i = 0;i < 4;i++) cid[i] = be32_to_cpu(cid[i]); DBG("[%s] e3\n",__func__); return 0; }
int mmc_send_ext_csd(struct mmc_card *card, u8 *ext_csd) { int ret; DBG("[%s] s\n",__func__); ret = mmc_send_cxd_data(card, card->host, MMC_SEND_EXT_CSD, ext_csd, 512); DBG("[%s] e\n",__func__); return ret; }
int mmc_send_csd(struct mmc_card *card, u32 *csd) { int ret, i; if (!mmc_host_is_spi(card->host)) return mmc_send_cxd_native(card->host, card->rca << 16, csd, MMC_SEND_CSD); ret = mmc_send_cxd_data(card, card->host, MMC_SEND_CSD, csd, 16); if (ret) return ret; for (i = 0; i < 4; i++) csd[i] = be32_to_cpu(csd[i]); return 0; }
static int print_write_protect_status(struct mmc_card *card, char *buffer) { struct another_mmc_csd csd; u32 write_protect_group_size; u32 group_count; u32 status; u32 address; int error; int ret = 0; mmc_claim_host(card->host); get_csd(card, &csd); write_protect_group_size = (csd.erase_grp_size + 1) * (csd.erase_grp_mult + 1) * (csd.wp_grp_size + 1); group_count = card->ext_csd.sectors / write_protect_group_size; error = get_card_status(card, &status); if (error) { mmc_release_host(card->host); return 0; } for (address = 0; address < group_count; address += WRITE_PROTECT_INFO_BITS) { u64 write_protect_status; error = mmc_send_cxd_data(card, card->host, CMD31_SEND_WRITE_PROT_TYPE, address * write_protect_group_size, MMC_CMD_ADTC | MMC_RSP_R1, &write_protect_status, sizeof(write_protect_status)); if (error) { printk(KERN_ERR "Failed to get write protect status %x\n", error); mmc_release_host(card->host); return ret; } ret += sprintf(buffer + ret, "0x%08x (0x%016llx)\n", address * write_protect_group_size, write_protect_status); } mmc_release_host(card->host); return ret; }
int mmc_send_csd(struct mmc_card *card, u32 *csd) { int ret, i; DBG("[%s] s\n",__func__); if (!mmc_host_is_spi(card->host)) { ret = mmc_send_cxd_native(card->host, card->rca << 16, csd, MMC_SEND_CSD); DBG("[%s] e1\n",__func__); return ret; } ret = mmc_send_cxd_data(card, card->host, MMC_SEND_CSD, csd, 16); if (ret) { DBG("[%s] e2\n",__func__); return ret; } for (i = 0;i < 4;i++) csd[i] = be32_to_cpu(csd[i]); DBG("[%s] e3\n",__func__); return 0; }
int mmc_send_ext_csd(struct mmc_card *card, u8 *ext_csd) { return mmc_send_cxd_data(card, card->host, MMC_SEND_EXT_CSD, ext_csd, 512); }