On 15:49-20241028, Markus Schneider-Pargmann wrote: > Hi Nishanth, > > On Fri, Oct 25, 2024 at 12:42:04PM GMT, Nishanth Menon wrote: > > On 16:39-20241012, Markus Schneider-Pargmann wrote: > > [...] > > > > > > The possible wakeup devices are found by checking which devices are > > > powered by the regulator supplying the "vddshv_canuart" line. These are > > > considered possible wakeup sources. Only wakeup sources that are > > > actually enabled by the user will be considered as a an active wakeup > > > source. If none of the wakeup sources are enabled the system will do a > > > normal poweroff. If at least one wakeup source is enabled it will > > > instead send a TI_SCI_MSG_PREPARE_SLEEP message from the sys_off > > > handler. Sending this message will result in an immediate shutdown of > > > the system. No execution is expected after this point. The code will > > > wait for 5s and do an emergency_restart afterwards if Partial-IO wasn't > > > entered at that point. > > > > > [...] > > > > > +static bool tisci_canuart_wakeup_enabled(struct ti_sci_info *info) > > > +{ > > > + static const char canuart_name[] = "vddshv_canuart"; > > > + struct device_node *wakeup_node = NULL; > > > + > > > + for (wakeup_node = of_find_node_with_property(NULL, "vio-supply"); > > > + wakeup_node; > > > + wakeup_node = of_find_node_with_property(wakeup_node, "vio-supply")) { > > > + struct device_node *supply_node; > > > + const char *supply_name; > > > + struct platform_device *pdev; > > > + int ret; > > > + > > > + supply_node = of_parse_phandle(wakeup_node, "vio-supply", 0); > > > + if (!supply_node) > > > + continue; > > > + > > > + ret = of_property_read_string(supply_node, "regulator-name", &supply_name); > > > + of_node_put(supply_node); > > > + if (ret) { > > > + dev_warn(info->dev, "Failed to parse vio-supply phandle at %pOF %d\n", > > > + wakeup_node, ret); > > > + continue; > > > + } > > > + > > > + if (strncmp(canuart_name, supply_name, strlen(canuart_name))) > > > + continue; > > > + > > > + pdev = of_find_device_by_node(wakeup_node); > > > + if (!pdev) > > > + continue; > > > + > > > + if (device_may_wakeup(&pdev->dev)) { > > > + dev_dbg(info->dev, "%pOF identified as wakeup source for Partial-IO\n", > > > + wakeup_node); > > > + put_device(&pdev->dev); > > > + of_node_put(wakeup_node); > > > + return true; > > > + } > > > + put_device(&pdev->dev); > > > + } > > > + > > > + return false; > > > +} > > > + > > > > What is the binding that supports this? I just do not think that > > scanning the entire tree for vio-supply implies you will get thr right > > property here. > > > > Just giving an example to illustrate this point: > > Documentation/devicetree/bindings/net/wireless/ti,wl1251.txt says it > > needs vio-supply -> so i have a node with the wireless supply as > > vio-supply -> Since we are scanning from NULL for vio-supply, we hit > > that, that is a bad choice for enabling io-retention. > > There is no bining that specifically supports this as I think it is not > needed. The devices that are capable to wakeup the system from > Partial-IO are all powered through one supply line that is always-on. It > is called 'vddshv_canuart' and the name of this supply is checked > in the above code as well. Yes I am using 'vio-supply', but only to In effect, you are looking for nodes that have vio-supply pointing to a regulator called vddshv_canuart. Not only is it too specific to a device, but a board as well. Without documentation in binding, users who don't have sufficient information is bound to mess this up. Further, vddshv_canuart may not even be a regulator - there will need to be checks for that on top of just a strncmp. > search for the potential consumers of this supply. > So wl1251 will be skipped in above code at > > if (strncmp(canuart_name, supply_name, strlen(canuart_name))) Aah, thanks, but sorry, but I would prefer the drivers handle the specifics. If a new peripheral comes on to the list for a different device, or a different regulator name appears for can, we would be dealing with name mapping etc. -- Regards, Nishanth Menon Key (0xDDB5849D1736249D) / Fingerprint: F8A2 8693 54EB 8232 17A3 1A34 DDB5 849D 1736 249D