mirror of
https://github.com/torvalds/linux.git
synced 2024-12-01 00:21:32 +00:00
b5ea47570b
Now that the SPDX tag is in all USB files, that identifies the license in a specific and legally-defined manner. So the extra GPL text wording can be removed as it is no longer needed at all. This is done on a quest to remove the 700+ different ways that files in the kernel describe the GPL license text. And there's unneeded stuff like the address (sometimes incorrect) for the FSF which is never needed. No copyright headers or other non-license-description text was removed. Cc: Kukjin Kim <kgene@kernel.org> Cc: Krzysztof Kozlowski <krzk@kernel.org> Cc: Patrice Chotard <patrice.chotard@st.com> Acked-by: Felipe Balbi <felipe.balbi@linux.intel.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
75 lines
1.5 KiB
C
75 lines
1.5 KiB
C
// SPDX-License-Identifier: GPL-2.0
|
|
/**
|
|
* drd.c - DesignWare USB3 DRD Controller Dual-role support
|
|
*
|
|
* Copyright (C) 2017 Texas Instruments Incorporated - http://www.ti.com
|
|
*
|
|
* Authors: Roger Quadros <rogerq@ti.com>
|
|
*/
|
|
|
|
#include <linux/extcon.h>
|
|
|
|
#include "debug.h"
|
|
#include "core.h"
|
|
#include "gadget.h"
|
|
|
|
static void dwc3_drd_update(struct dwc3 *dwc)
|
|
{
|
|
int id;
|
|
|
|
id = extcon_get_state(dwc->edev, EXTCON_USB_HOST);
|
|
if (id < 0)
|
|
id = 0;
|
|
|
|
dwc3_set_mode(dwc, id ?
|
|
DWC3_GCTL_PRTCAP_HOST :
|
|
DWC3_GCTL_PRTCAP_DEVICE);
|
|
}
|
|
|
|
static int dwc3_drd_notifier(struct notifier_block *nb,
|
|
unsigned long event, void *ptr)
|
|
{
|
|
struct dwc3 *dwc = container_of(nb, struct dwc3, edev_nb);
|
|
|
|
dwc3_set_mode(dwc, event ?
|
|
DWC3_GCTL_PRTCAP_HOST :
|
|
DWC3_GCTL_PRTCAP_DEVICE);
|
|
|
|
return NOTIFY_DONE;
|
|
}
|
|
|
|
int dwc3_drd_init(struct dwc3 *dwc)
|
|
{
|
|
int ret;
|
|
|
|
if (dwc->dev->of_node) {
|
|
if (of_property_read_bool(dwc->dev->of_node, "extcon"))
|
|
dwc->edev = extcon_get_edev_by_phandle(dwc->dev, 0);
|
|
|
|
if (IS_ERR(dwc->edev))
|
|
return PTR_ERR(dwc->edev);
|
|
|
|
dwc->edev_nb.notifier_call = dwc3_drd_notifier;
|
|
ret = extcon_register_notifier(dwc->edev, EXTCON_USB_HOST,
|
|
&dwc->edev_nb);
|
|
if (ret < 0) {
|
|
dev_err(dwc->dev, "couldn't register cable notifier\n");
|
|
return ret;
|
|
}
|
|
}
|
|
|
|
dwc3_drd_update(dwc);
|
|
|
|
return 0;
|
|
}
|
|
|
|
void dwc3_drd_exit(struct dwc3 *dwc)
|
|
{
|
|
extcon_unregister_notifier(dwc->edev, EXTCON_USB_HOST,
|
|
&dwc->edev_nb);
|
|
|
|
dwc3_set_mode(dwc, DWC3_GCTL_PRTCAP_DEVICE);
|
|
flush_work(&dwc->drd_work);
|
|
dwc3_gadget_exit(dwc);
|
|
}
|