| 59 | } |
| 60 | |
| 61 | static void thermal_ofw_setup(struct rt_ofw_node *np, struct rt_thermal_zone_device *zdev) |
| 62 | { |
| 63 | int i = 0; |
| 64 | rt_uint32_t delay, pdelay; |
| 65 | struct rt_ofw_cell_args args; |
| 66 | struct rt_ofw_node *tmp_np, *tz_np, *trip_np, *cm_np, *cdev_np; |
| 67 | |
| 68 | if (!np || !zdev) |
| 69 | { |
| 70 | return; |
| 71 | } |
| 72 | |
| 73 | tmp_np = rt_ofw_find_node_by_path("/thermal-zones"); |
| 74 | |
| 75 | if (!tmp_np) |
| 76 | { |
| 77 | return; |
| 78 | } |
| 79 | |
| 80 | rt_ofw_foreach_child_node(tmp_np, tz_np) |
| 81 | { |
| 82 | if (!rt_ofw_parse_phandle_cells(tz_np, "thermal-sensors", "#thermal-sensor-cells", 0, &args)) |
| 83 | { |
| 84 | if (args.data == np && (!args.args_count || args.args[0] == zdev->zone_id)) |
| 85 | { |
| 86 | rt_ofw_node_put(args.data); |
| 87 | |
| 88 | goto _found; |
| 89 | } |
| 90 | rt_ofw_node_put(args.data); |
| 91 | } |
| 92 | } |
| 93 | |
| 94 | return; |
| 95 | |
| 96 | _found: |
| 97 | rt_ofw_prop_read_u32(tz_np, "polling-delay-passive", &pdelay); |
| 98 | rt_ofw_prop_read_u32(tz_np, "polling-delay", &delay); |
| 99 | |
| 100 | zdev->passive_delay = rt_tick_from_millisecond(pdelay); |
| 101 | zdev->polling_delay = rt_tick_from_millisecond(delay); |
| 102 | |
| 103 | thermal_ofw_params_parse(tz_np, &zdev->params); |
| 104 | |
| 105 | if (zdev->trips_nr) |
| 106 | { |
| 107 | goto _scan_cooling; |
| 108 | } |
| 109 | |
| 110 | tmp_np = rt_ofw_get_child_by_tag(tz_np, "trips"); |
| 111 | if (!tmp_np) |
| 112 | { |
| 113 | goto _scan_cooling; |
| 114 | } |
| 115 | |
| 116 | zdev->trips_nr = rt_ofw_get_child_count(tmp_np); |
| 117 | if (!zdev->trips_nr) |
| 118 | { |
no test coverage detected