tegrabl_error_t tegrabl_sd_get_platform_params(uint32_t *instance, struct tegrabl_sd_platform_params *params)
{
uint32_t i;
int32_t offset;
void *fdt = NULL;
tegrabl_error_t err = TEGRABL_NO_ERROR;
const char *temp;
const uint32_t *data;
int32_t len;
const char *name;
err = tegrabl_dt_get_fdt_handle(TEGRABL_DT_BL, &fdt);
if (err != TEGRABL_NO_ERROR) {
pr_error("Failed to get bl-dtb handle\n");
goto fail;
}
err = TEGRABL_ERROR(TEGRABL_ERR_NOT_FOUND, 0);
for (i = 0; i < ARRAY_SIZE(sdmmc_nodes); i++) {
name = fdt_get_alias(fdt, sdmmc_nodes[i]);
pr_info("!!!!!!!!SDMMC Name: %s\n", name);
if (name == NULL) {
continue;
}
offset = fdt_path_offset(fdt, name);
pr_info("!!!!!!!!SDMMC offset: %d\n", offset);
if (offset < 0) {
err = TEGRABL_ERROR(TEGRABL_ERR_NOT_FOUND, 1);
pr_error("Error while finding sdmmc node\n");
goto fail;
}
/* if node does not have status=ok, skip then try next node */
temp = fdt_getprop(fdt, offset, "status", NULL);
//pr_info("!!!!!!!!SDMMC Status: %s\n", temp);
if (temp != NULL) {
pr_info("sdmmc node status = %s\n", temp);
if (strcmp(temp, "okay")) {
pr_info("sdmmc node status is disabled\n");
continue;
}
}
/* if node has property named non-removable, skip then try next node */
temp = fdt_getprop(fdt, offset, "non-removable", NULL);
if (temp != NULL) {
pr_info("sdmmc node is non-removable\n");
continue;
}
*instance = i;
pr_info("sdcard instance = %d\n", i);
data = fdt_getprop(fdt, offset, "cd-gpios", &len);
if ((data == NULL) || (len < 0))
continue;
if (len != 12)
continue;
params->cd_gpio.handle = fdt32_to_cpu(data[0]);
params->cd_gpio.pin = fdt32_to_cpu(data[1]);
params->cd_gpio.flags = fdt32_to_cpu(data[2]);
pr_info("sdcard gpio handle 0x%x\n", params->cd_gpio.handle);
pr_info("sdcard gpio pin 0x%x\n", params->cd_gpio.pin);
pr_info("sdcard gpio flags 0x%x\n", params->cd_gpio.flags);
data = fdt_getprop(fdt, offset, "vmmc-supply", NULL);
if (data != NULL) {
params->vmmc_supply = fdt32_to_cpu(*data);
pr_trace("vmmc-supply 0x%x\n", params->vmmc_supply);
} else {
params->vmmc_supply = 0;
pr_error("no regulator info present for vmmc-supply\n");
return TEGRABL_ERROR(TEGRABL_ERR_INVALID_CONFIG, 0);
}
err = TEGRABL_NO_ERROR;
if (i == 1) {
break;
}
}
fail:
return err;
}
I modified the following function to not break from the loop after i=0 but now it seg faults when the loop continues.
Also I am using Jetpack 4.4.1 and CBoot 32.4.4
The other function that seems to point to a problem is sd_bdev_is_card_present. When the tegrabl_sd_get_platform_params function returns the first sdhci@3400000 and instance 0, the sd_bdev_is_card_present function prints “No sdcard” and it checks if it is present with the following line:
*is_present = (pin_state == GPIO_PIN_STATE_HIGH) ^ is_active_low;