Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

of/pci: Add of_pci_get_max_link_speed() to parse max-link-speed from DT

This new helper function could be used by host drivers to get the limitaion
of max link speed provided by DT. If the property isn't assigned or is
invalid, it will return -EINVAL to the caller.

Signed-off-by: Shawn Lin <shawn.lin@rock-chips.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Acked-by: Rob Herring <robh@kernel.org>

authored by

Shawn Lin and committed by
Bjorn Helgaas
9a1dc389 2fa39159

+28
+21
drivers/of/of_pci.c
··· 120 120 EXPORT_SYMBOL_GPL(of_get_pci_domain_nr); 121 121 122 122 /** 123 + * This function will try to find the limitation of link speed by finding 124 + * a property called "max-link-speed" of the given device node. 125 + * 126 + * @node: device tree node with the max link speed information 127 + * 128 + * Returns the associated max link speed from DT, or a negative value if the 129 + * required property is not found or is invalid. 130 + */ 131 + int of_pci_get_max_link_speed(struct device_node *node) 132 + { 133 + u32 max_link_speed; 134 + 135 + if (of_property_read_u32(node, "max-link-speed", &max_link_speed) || 136 + max_link_speed > 4) 137 + return -EINVAL; 138 + 139 + return max_link_speed; 140 + } 141 + EXPORT_SYMBOL_GPL(of_pci_get_max_link_speed); 142 + 143 + /** 123 144 * of_pci_check_probe_only - Setup probe only mode if linux,pci-probe-only 124 145 * is present and valid 125 146 */
+7
include/linux/of_pci.h
··· 16 16 int of_irq_parse_and_map_pci(const struct pci_dev *dev, u8 slot, u8 pin); 17 17 int of_pci_parse_bus_range(struct device_node *node, struct resource *res); 18 18 int of_get_pci_domain_nr(struct device_node *node); 19 + int of_pci_get_max_link_speed(struct device_node *node); 19 20 void of_pci_check_probe_only(void); 20 21 int of_pci_map_rid(struct device_node *np, u32 rid, 21 22 const char *map_name, const char *map_mask_name, ··· 59 58 static inline int of_pci_map_rid(struct device_node *np, u32 rid, 60 59 const char *map_name, const char *map_mask_name, 61 60 struct device_node **target, u32 *id_out) 61 + { 62 + return -EINVAL; 63 + } 64 + 65 + static inline int 66 + of_pci_get_max_link_speed(struct device_node *node) 62 67 { 63 68 return -EINVAL; 64 69 }