flash_SY7803:flashlight {
compatible = "qcom,leds-gpio-flash"; //匹配参数
status = "okay";
pinctrl-names = "flash_default";
pinctrl-0 = <&SY7803_default>;
qcom,flash-en = <&msm_gpio 31 0>;
qcom,flash-now = <&msm_gpio 32 0>;
qcom,op-seq = "flash_en", "flash_now";
qcom,torch-seq-val = <0 1>;
qcom,flash-seq-val = <1 0>;
linux,name = "flashlight"; //属性 linux,name
linux,default-trigger = "flashlight-trigger";
};
struct device_node *node = pdev->dev.of_node; //取得node
涉及到下边的一些用法,都是用来取得设备树中的信息的
1. int of_property_read_string(struct device_node *np, const char *propname,const char **out_string)
Find and read a string from a property
rc = of_property_read_string(node, "linux,default-trigger", &temp_str);
of_get_named_gpio
of_get_named_gpio(struct device_node *np,const char *propname, int index)
of_get_named_gpio(node, "qcom,flash-en", 0);
// 取得的值应当是31
of_property_read_string
int of_property_read_string(struct device_node *np, const char *propname,const char **out_string)
rc = of_property_read_string(node, "linux,name", &flash_led->cdev.name);
//flash_led->cdev.name = flashlight
of_property_read_u32_array
int of_property_read_u32_array(const struct device_node *np, const char *propname, u32 *out_values,size_t sz)
uint32_t array_flash_seq[2];
rc = of_property_read_u32_array(node, "qcom,flash-seq-val",array_flash_seq, 2);
array_flash_seq <1 0>
.of_property_read_string_index
int of_property_read_string_index(struct device_node *np, const char *propname,int index, const char **output)
rc = of_property_read_string_index(node, "qcom,op-seq", i, &seq_name);
//"flash_en", "flash_now";
of_match_table
明确驱动如何找到设备树,然后再驱动中找到相应的代码分析就可以了。