-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
USB: core: let USB device know device node
Although most of USB devices are hot-plug's, there are still some devices are hard wired on the board, eg, for HSIC and SSIC interface USB devices. If these kinds of USB devices are multiple functions, and they can supply other interfaces like i2c, gpios for other devices, we may need to describe these at device tree. In this commit, it uses "reg" in dts as physical port number to match the phyiscal port number decided by USB core, if they are the same, then the device node is for the device we are creating for USB core. Signed-off-by: Peter Chen <peter.chen@freescale.com> Acked-by: Philipp Zabel <p.zabel@pengutronix.de> Acked-by: Alan Stern <stern@rowland.harvard.edu> Acked-by: Rob Herring <robh@kernel.org> Acked-by: Arnd Bergmann <arnd@arndb.de> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
- Loading branch information
Peter Chen
authored and
Greg Kroah-Hartman
committed
Mar 5, 2016
1 parent
d883f52
commit 69bec72
Showing
5 changed files
with
93 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
Generic USB Device Properties | ||
|
||
Usually, we only use device tree for hard wired USB device. | ||
The reference binding doc is from: | ||
http://www.firmware.org/1275/bindings/usb/usb-1_0.ps | ||
|
||
Required properties: | ||
- compatible: usbVID,PID. The textual representation of VID, PID shall | ||
be in lower case hexadecimal with leading zeroes suppressed. The | ||
other compatible strings from the above standard binding could also | ||
be used, but a device adhering to this binding may leave out all except | ||
for usbVID,PID. | ||
- reg: the port number which this device is connecting to, the range | ||
is 1-31. | ||
|
||
Example: | ||
|
||
&usb1 { | ||
status = "okay"; | ||
|
||
#address-cells = <1>; | ||
#size-cells = <0>; | ||
|
||
hub: genesys@1 { | ||
compatible = "usb5e3,608"; | ||
reg = <1>; | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
/* | ||
* of.c The helpers for hcd device tree support | ||
* | ||
* Copyright (C) 2016 Freescale Semiconductor, Inc. | ||
* Author: Peter Chen <peter.chen@freescale.com> | ||
* | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License version 2 of | ||
* the License as published by the Free Software Foundation. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
#include <linux/of.h> | ||
|
||
/** | ||
* usb_of_get_child_node - Find the device node match port number | ||
* @parent: the parent device node | ||
* @portnum: the port number which device is connecting | ||
* | ||
* Find the node from device tree according to its port number. | ||
* | ||
* Return: On success, a pointer to the device node, %NULL on failure. | ||
*/ | ||
struct device_node *usb_of_get_child_node(struct device_node *parent, | ||
int portnum) | ||
{ | ||
struct device_node *node; | ||
u32 port; | ||
|
||
for_each_child_of_node(parent, node) { | ||
if (!of_property_read_u32(node, "reg", &port)) { | ||
if (port == portnum) | ||
return node; | ||
} | ||
} | ||
|
||
return NULL; | ||
} | ||
EXPORT_SYMBOL_GPL(usb_of_get_child_node); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters