common.c (6ea24cf79e055f0a62a64baa8587e2254a493c7b) | common.c (ce15ed4c5dfb3f7757e6611902aed5db253af977) |
---|---|
1/* 2 * Provides code common for host and device side USB. 3 * 4 * This program is free software; you can redistribute it and/or 5 * modify it under the terms of the GNU General Public License as 6 * published by the Free Software Foundation, version 2. 7 * 8 * If either host side (ie. CONFIG_USB=y) or device side USB stack --- 117 unchanged lines hidden (view full) --- 126} 127EXPORT_SYMBOL_GPL(usb_get_dr_mode); 128 129#ifdef CONFIG_OF 130/** 131 * of_usb_get_dr_mode_by_phy - Get dual role mode for the controller device 132 * which is associated with the given phy device_node 133 * @np: Pointer to the given phy device_node | 1/* 2 * Provides code common for host and device side USB. 3 * 4 * This program is free software; you can redistribute it and/or 5 * modify it under the terms of the GNU General Public License as 6 * published by the Free Software Foundation, version 2. 7 * 8 * If either host side (ie. CONFIG_USB=y) or device side USB stack --- 117 unchanged lines hidden (view full) --- 126} 127EXPORT_SYMBOL_GPL(usb_get_dr_mode); 128 129#ifdef CONFIG_OF 130/** 131 * of_usb_get_dr_mode_by_phy - Get dual role mode for the controller device 132 * which is associated with the given phy device_node 133 * @np: Pointer to the given phy device_node |
134 * @arg0: phandle args[0] for phy's with #phy-cells >= 1, or -1 for 135 * phys which do not have phy-cells |
|
134 * 135 * In dts a usb controller associates with phy devices. The function gets 136 * the string from property 'dr_mode' of the controller associated with the 137 * given phy device node, and returns the correspondig enum usb_dr_mode. 138 */ | 136 * 137 * In dts a usb controller associates with phy devices. The function gets 138 * the string from property 'dr_mode' of the controller associated with the 139 * given phy device node, and returns the correspondig enum usb_dr_mode. 140 */ |
139enum usb_dr_mode of_usb_get_dr_mode_by_phy(struct device_node *phy_np) | 141enum usb_dr_mode of_usb_get_dr_mode_by_phy(struct device_node *np, int arg0) |
140{ 141 struct device_node *controller = NULL; | 142{ 143 struct device_node *controller = NULL; |
142 struct device_node *phy; | 144 struct of_phandle_args args; |
143 const char *dr_mode; 144 int index; 145 int err; 146 147 do { 148 controller = of_find_node_with_property(controller, "phys"); 149 index = 0; 150 do { | 145 const char *dr_mode; 146 int index; 147 int err; 148 149 do { 150 controller = of_find_node_with_property(controller, "phys"); 151 index = 0; 152 do { |
151 phy = of_parse_phandle(controller, "phys", index); 152 of_node_put(phy); 153 if (phy == phy_np) | 153 if (arg0 == -1) { 154 args.np = of_parse_phandle(controller, "phys", 155 index); 156 args.args_count = 0; 157 } else { 158 err = of_parse_phandle_with_args(controller, 159 "phys", "#phy-cells", 160 index, &args); 161 if (err) 162 break; 163 } 164 165 of_node_put(args.np); 166 if (args.np == np && (args.args_count == 0 || 167 args.args[0] == arg0)) |
154 goto finish; 155 index++; | 168 goto finish; 169 index++; |
156 } while (phy); | 170 } while (args.np); |
157 } while (controller); 158 159finish: 160 err = of_property_read_string(controller, "dr_mode", &dr_mode); 161 of_node_put(controller); 162 163 if (err < 0) 164 return USB_DR_MODE_UNKNOWN; --- 79 unchanged lines hidden --- | 171 } while (controller); 172 173finish: 174 err = of_property_read_string(controller, "dr_mode", &dr_mode); 175 of_node_put(controller); 176 177 if (err < 0) 178 return USB_DR_MODE_UNKNOWN; --- 79 unchanged lines hidden --- |