/* Sends SD switch function CMD6. See table 4-32 in SD physical specification for argument details. When setting a function, we should set the 4 bit block of the command argument corresponding to that function to "value", and all other 4 bit blocks should be left as 0xF (no effect on current function)  */
static int sdmmc_switch(struct sd_card *card, enum sd_switch_arg mode, enum sd_group_num group, uint8_t value, uint8_t *response)
/* Sends SD switch function CMD6. See table 4-32 in SD physical specification for argument details. When setting a function, we should set the 4 bit block of the command argument corresponding to that function to "value", and all other 4 bit blocks should be left as 0xF (no effect on current function)  */
static int sdmmc_switch(struct sd_card *card, enum sd_switch_arg mode, enum sd_group_num group, uint8_t value, uint8_t *response)
{
	struct sdhc_command cmd = {0};
	struct sdhc_data data = {0};
	cmd.opcode = SD_SWITCH;
	cmd.arg = ((mode & 0x1) << 31) | 0x00FFFFFF;
	cmd.arg &= ~(0xFU << (group * 4));
	cmd.arg |= (value & 0xF) << (group * 4);
	cmd.response_type = (SD_RSP_TYPE_R1 | SD_SPI_RSP_TYPE_R1);
	cmd.timeout_ms = CONFIG_SD_CMD_TIMEOUT;
	data.block_size = 64U;
	data.blocks = 1;
	data.data = response;
	data.timeout_ms = CONFIG_SD_DATA_TIMEOUT;
	return sdhc_request(card->sdhc, &cmd, &data);
}