mmc: core: support HPI send command
[pandora-kernel.git] / drivers / mmc / core / mmc_ops.c
index 770c3d0..007863e 100644 (file)
@@ -233,7 +233,7 @@ static int
 mmc_send_cxd_data(struct mmc_card *card, struct mmc_host *host,
                u32 opcode, void *buf, unsigned len)
 {
-       struct mmc_request mrq = {0};
+       struct mmc_request mrq = {NULL};
        struct mmc_command cmd = {0};
        struct mmc_data data = {0};
        struct scatterlist sg;
@@ -414,7 +414,7 @@ int mmc_switch(struct mmc_card *card, u8 set, u8 index, u8 value,
                        return -EBADMSG;
        } else {
                if (status & 0xFDFFA000)
-                       printk(KERN_WARNING "%s: unexpected status %#x after "
+                       pr_warning("%s: unexpected status %#x after "
                               "switch", mmc_hostname(card->host), status);
                if (status & R1_SWITCH_ERROR)
                        return -EBADMSG;
@@ -454,7 +454,7 @@ static int
 mmc_send_bus_test(struct mmc_card *card, struct mmc_host *host, u8 opcode,
                  u8 len)
 {
-       struct mmc_request mrq = {0};
+       struct mmc_request mrq = {NULL};
        struct mmc_command cmd = {0};
        struct mmc_data data = {0};
        struct scatterlist sg;
@@ -476,7 +476,7 @@ mmc_send_bus_test(struct mmc_card *card, struct mmc_host *host, u8 opcode,
        else if (len == 4)
                test_buf = testdata_4bit;
        else {
-               printk(KERN_ERR "%s: Invalid bus_width %d\n",
+               pr_err("%s: Invalid bus_width %d\n",
                       mmc_hostname(host), len);
                kfree(data_buf);
                return -EINVAL;
@@ -547,3 +547,34 @@ int mmc_bus_test(struct mmc_card *card, u8 bus_width)
        err = mmc_send_bus_test(card, card->host, MMC_BUS_TEST_R, width);
        return err;
 }
+
+int mmc_send_hpi_cmd(struct mmc_card *card, u32 *status)
+{
+       struct mmc_command cmd = {0};
+       unsigned int opcode;
+       unsigned int flags;
+       int err;
+
+       opcode = card->ext_csd.hpi_cmd;
+       if (opcode == MMC_STOP_TRANSMISSION)
+               flags = MMC_RSP_R1 | MMC_CMD_AC;
+       else if (opcode == MMC_SEND_STATUS)
+               flags = MMC_RSP_R1 | MMC_CMD_AC;
+
+       cmd.opcode = opcode;
+       cmd.arg = card->rca << 16 | 1;
+       cmd.flags = flags;
+       cmd.cmd_timeout_ms = card->ext_csd.out_of_int_time;
+
+       err = mmc_wait_for_cmd(card->host, &cmd, 0);
+       if (err) {
+               pr_warn("%s: error %d interrupting operation. "
+                       "HPI command response %#x\n", mmc_hostname(card->host),
+                       err, cmd.resp[0]);
+               return err;
+       }
+       if (status)
+               *status = cmd.resp[0];
+
+       return 0;
+}