Skip to content

Commit 847832d

Browse files
Raffael Rostagnonashif
authored andcommitted
sdhc: esp32: Register writing macros cleanup
Macros to write specific peripheral registers were removed as a compile flag was added to hal_espressif requesting struct bitfields to have strict volatile access (thus 32-bit access), allowing for the cleanup. Signed-off-by: Raffael Rostagno <[email protected]>
1 parent 1857197 commit 847832d

File tree

1 file changed

+5
-16
lines changed

1 file changed

+5
-16
lines changed

drivers/sdhc/sdhc_esp32.c

Lines changed: 5 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -874,24 +874,13 @@ int sdmmc_host_set_bus_width(sdmmc_dev_t *sdio_hw, int slot, size_t width)
874874
}
875875

876876
const uint16_t mask = BIT(slot);
877-
uint16_t temp;
878877

879878
if (width == 1) {
880-
temp = sdio_hw->ctype.card_width_8 & ~mask;
881-
HAL_FORCE_MODIFY_U32_REG_FIELD(sdio_hw->ctype, card_width_8, temp);
882-
883-
temp = sdio_hw->ctype.card_width & ~mask;
884-
HAL_FORCE_MODIFY_U32_REG_FIELD(sdio_hw->ctype, card_width, temp);
885-
879+
sdio_hw->ctype.card_width_8 &= ~mask;
880+
sdio_hw->ctype.card_width &= ~mask;
886881
} else if (width == 4) {
887-
temp = sdio_hw->ctype.card_width_8 & ~mask;
888-
HAL_FORCE_MODIFY_U32_REG_FIELD(sdio_hw->ctype, card_width_8, temp);
889-
890-
temp = sdio_hw->ctype.card_width | mask;
891-
HAL_FORCE_MODIFY_U32_REG_FIELD(sdio_hw->ctype, card_width, temp);
892-
} else if (width == 8) {
893-
temp = sdio_hw->ctype.card_width_8 | mask;
894-
HAL_FORCE_MODIFY_U32_REG_FIELD(sdio_hw->ctype, card_width_8, temp);
882+
sdio_hw->ctype.card_width_8 &= ~mask;
883+
sdio_hw->ctype.card_width |= mask;
895884
} else {
896885
return ESP_ERR_INVALID_ARG;
897886
}
@@ -1198,7 +1187,7 @@ static int sdhc_esp32_request(const struct device *dev, struct sdhc_command *cmd
11981187
}
11991188

12001189
if ((ret_esp != 0) || esp_cmd.error) {
1201-
LOG_DBG("\nError for command: %u arg %08x ret_esp = 0x%x error = 0x%x\n",
1190+
LOG_DBG("Error command: %u arg %08x ret_esp = 0x%x error = 0x%x\n",
12021191
cmd->opcode, cmd->arg, ret_esp, esp_cmd.error);
12031192

12041193
ret_esp = (ret_esp > 0) ? ret_esp : esp_cmd.error;

0 commit comments

Comments
 (0)