SD card

[kernel 如何解析cd-gpio]

1.dts:

  一般dts里会被配置SD card

 

 

 2.解析:

  

mmc_of_parse(mmc);   -->if (device_property_read_bool(dev, "non-removable")) {  host->caps |= MMC_CAP_NONREMOVABLE; } else {           xxx           ret = mmc_gpiod_request_cd(host, "cd", 0, false,      cd_debounce_delay_ms * 1000);
    }
    -->
devm_gpiod_get_index(host->parent, con_id, idx, GPIOD_IN);
      -->
gpiod_get_index(dev, con_id, idx, flags);
        if (is_of_node(fwnode)) {
dev_dbg(dev, "using device tree for GPIO lookup\n");
            desc = of_find_gpio(dev, con_id, idx, &lookupflags);
        -->
of_find_gpio(dev, con_id, idx, &lookupflags);
      
/* Try GPIO property "foo-gpios" and "foo-gpio" */
for (i = 0; i < ARRAY_SIZE(gpio_suffixes); i++) {
		if (con_id)
			snprintf(prop_name, sizeof(prop_name), "%s-%s", con_id,
				 gpio_suffixes[i]);
		else
			snprintf(prop_name, sizeof(prop_name), "%s",
				 gpio_suffixes[i]);

		desc = of_get_named_gpiod_flags(dev->of_node, prop_name, idx,
						&of_flags);
/* gpio suffixes used for ACPI and device tree lookup */
static __maybe_unused const char * const gpio_suffixes[] = { "gpios", "gpio" };
由上可以看出,
1.只要dts没有配置"non-removable",就会去解析”cd“。
2.dts里配置cd-gpio或cd-gpios都可以被正确解析到。
 
 
 
 
 
 
上一篇:Visual Studio插件CodeRush 2021新版首发——v20.2.7


下一篇:VS插件CodeRush for Visual Studio全新发布v19.1.7|附下载