+ switch (data->slot[0].bus_width) {
+ case 4:
+ select_peripheral(PA(13), PERIPH_A, 0); /* DATA1 */
+ select_peripheral(PA(14), PERIPH_A, 0); /* DATA2 */
+ select_peripheral(PA(15), PERIPH_A, 0); /* DATA3 */
+ /* fall through */
+ case 1:
+ select_peripheral(PA(11), PERIPH_A, 0); /* CMD */
+ select_peripheral(PA(12), PERIPH_A, 0); /* DATA0 */
+
+ if (gpio_is_valid(data->slot[0].detect_pin))
+ at32_select_gpio(data->slot[0].detect_pin, 0);
+ if (gpio_is_valid(data->slot[0].wp_pin))
+ at32_select_gpio(data->slot[0].wp_pin, 0);
+ break;
+ case 0:
+ /* Slot is unused */
+ break;
+ default:
+ goto fail;
+ }
+
+ switch (data->slot[1].bus_width) {
+ case 4:
+ select_peripheral(PB(8), PERIPH_B, 0); /* DATA1 */
+ select_peripheral(PB(9), PERIPH_B, 0); /* DATA2 */
+ select_peripheral(PB(10), PERIPH_B, 0); /* DATA3 */
+ /* fall through */
+ case 1:
+ select_peripheral(PB(6), PERIPH_B, 0); /* CMD */
+ select_peripheral(PB(7), PERIPH_B, 0); /* DATA0 */
+
+ if (gpio_is_valid(data->slot[1].detect_pin))
+ at32_select_gpio(data->slot[1].detect_pin, 0);
+ if (gpio_is_valid(data->slot[1].wp_pin))
+ at32_select_gpio(data->slot[1].wp_pin, 0);
+ break;
+ case 0:
+ /* Slot is unused */
+ break;
+ default:
+ if (!data->slot[0].bus_width)
+ goto fail;
+
+ data->slot[1].bus_width = 0;
+ break;
+ }