greybus: sdio: convert vdd kernel values to greybus
authorRui Miguel Silva <rui.silva@linaro.org>
Tue, 19 Jul 2016 14:41:29 +0000 (15:41 +0100)
committerGreg Kroah-Hartman <gregkh@google.com>
Tue, 19 Jul 2016 23:38:24 +0000 (16:38 -0700)
We need to convert vdd kernel values to greybus ones. And we get this by
shifting the kernel values by 8.

Signed-off-by: Rui Miguel Silva <rui.silva@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
drivers/staging/greybus/sdio.c

index 8d2de7d..5e5de04 100644 (file)
@@ -43,6 +43,9 @@ struct gb_sdio_host {
 #define GB_SDIO_RSP_R1B                (GB_SDIO_RSP_PRESENT | GB_SDIO_RSP_CRC | \
                                 GB_SDIO_RSP_OPCODE | GB_SDIO_RSP_BUSY)
 
+/* kernel vdd starts at 0x80 and we need to translate to greybus ones 0x01 */
+#define GB_SDIO_VDD_SHIFT      8
+
 static inline bool single_op(struct mmc_command *cmd)
 {
        uint32_t opcode = cmd->opcode;
@@ -574,10 +577,14 @@ static void gb_mmc_set_ios(struct mmc_host *mmc, struct mmc_ios *ios)
        u8 timing;
        u8 signal_voltage;
        u8 drv_type;
+       u32 vdd = 0;
 
        mutex_lock(&host->lock);
        request.clock = cpu_to_le32(ios->clock);
-       request.vdd = cpu_to_le32(1 << ios->vdd);
+
+       if (ios->vdd)
+               vdd = 1 << (ios->vdd - GB_SDIO_VDD_SHIFT);
+       request.vdd = cpu_to_le32(vdd);
 
        request.bus_mode = (ios->bus_mode == MMC_BUSMODE_OPENDRAIN ?
                            GB_SDIO_BUSMODE_OPENDRAIN :