Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- From d56302dadc3bb3a991bd8b0bd14013e8195a8aa5 Mon Sep 17 00:00:00 2001
- From: Kishon Vijay Abraham I <kishon@ti.com>
- Date: Mon, 6 May 2013 18:30:34 +0530
- Subject: [PATCH] usb: dwc3: use extcon fwrk to receive connect/disconnect
- notification
- Modified dwc3-omap to receive connect and disconnect notification using
- extcon framework. Also did the necessary cleanups required after
- adapting to extcon framework.
- Signed-off-by: Kishon Vijay Abraham I <kishon@ti.com>
- ---
- drivers/usb/dwc3/dwc3-omap.c | 53 +++++++++++++++++++++++++----------------
- include/linux/usb/dwc3-omap.h | 30 -----------------------
- 2 files changed, 32 insertions(+), 51 deletions(-)
- delete mode 100644 include/linux/usb/dwc3-omap.h
- diff --git a/drivers/usb/dwc3/dwc3-omap.c b/drivers/usb/dwc3/dwc3-omap.c
- index 34638b9..4dd51f3 100644
- --- a/drivers/usb/dwc3/dwc3-omap.c
- +++ b/drivers/usb/dwc3/dwc3-omap.c
- @@ -43,13 +43,14 @@
- #include <linux/spinlock.h>
- #include <linux/platform_device.h>
- #include <linux/platform_data/dwc3-omap.h>
- -#include <linux/usb/dwc3-omap.h>
- #include <linux/pm_runtime.h>
- #include <linux/dma-mapping.h>
- #include <linux/ioport.h>
- #include <linux/io.h>
- #include <linux/of.h>
- #include <linux/of_platform.h>
- +#include <linux/extcon.h>
- +#include <linux/extcon/extcon_palmas.h>
- #include <linux/usb/otg.h>
- @@ -124,10 +125,9 @@ struct dwc3_omap {
- u32 utmi_otg_status;
- u32 dma_status:1;
- + struct notifier_block nb;
- };
- -static struct dwc3_omap *_omap;
- -
- static inline u32 dwc3_omap_readl(void __iomem *base, u32 offset)
- {
- return readl(base + offset);
- @@ -138,16 +138,12 @@ static inline void dwc3_omap_writel(void __iomem *base, u32 offset, u32 value)
- writel(value, base + offset);
- }
- -int dwc3_omap_mailbox(enum omap_dwc3_vbus_id_status status)
- +static void dwc3_omap_set_mailbox(struct dwc3_omap *omap, int state)
- {
- u32 val;
- - struct dwc3_omap *omap = _omap;
- -
- - if (!omap)
- - return -EPROBE_DEFER;
- - switch (status) {
- - case OMAP_DWC3_ID_GROUND:
- + switch (state) {
- + case PALMAS_USB_STATE_ID:
- dev_dbg(omap->dev, "ID GND\n");
- val = dwc3_omap_readl(omap->base, USBOTGSS_UTMI_OTG_STATUS);
- @@ -159,7 +155,7 @@ int dwc3_omap_mailbox(enum omap_dwc3_vbus_id_status status)
- dwc3_omap_writel(omap->base, USBOTGSS_UTMI_OTG_STATUS, val);
- break;
- - case OMAP_DWC3_VBUS_VALID:
- + case PALMAS_USB_STATE_VBUS:
- dev_dbg(omap->dev, "VBUS Connect\n");
- val = dwc3_omap_readl(omap->base, USBOTGSS_UTMI_OTG_STATUS);
- @@ -171,8 +167,7 @@ int dwc3_omap_mailbox(enum omap_dwc3_vbus_id_status status)
- dwc3_omap_writel(omap->base, USBOTGSS_UTMI_OTG_STATUS, val);
- break;
- - case OMAP_DWC3_ID_FLOAT:
- - case OMAP_DWC3_VBUS_OFF:
- + case PALMAS_USB_STATE_DISCONNECT:
- dev_dbg(omap->dev, "VBUS Disconnect\n");
- val = dwc3_omap_readl(omap->base, USBOTGSS_UTMI_OTG_STATUS);
- @@ -187,10 +182,18 @@ int dwc3_omap_mailbox(enum omap_dwc3_vbus_id_status status)
- default:
- dev_dbg(omap->dev, "ID float\n");
- }
- +}
- - return 0;
- +static int dwc3_omap_mailbox_notifier(struct notifier_block *nb,
- + unsigned long event, void *ptr)
- +{
- + struct dwc3_omap *omap = container_of(nb, struct dwc3_omap, nb);
- + struct extcon_dev *edev = ptr;
- +
- + dwc3_omap_set_mailbox(omap, edev->state);
- +
- + return NOTIFY_DONE;
- }
- -EXPORT_SYMBOL_GPL(dwc3_omap_mailbox);
- static irqreturn_t dwc3_omap_interrupt(int irq, void *_omap)
- {
- @@ -289,6 +292,7 @@ static int dwc3_omap_probe(struct platform_device *pdev)
- struct dwc3_omap *omap;
- struct resource *res;
- struct device *dev = &pdev->dev;
- + struct extcon_dev *edev;
- int ret = -ENOMEM;
- int irq;
- @@ -330,19 +334,21 @@ static int dwc3_omap_probe(struct platform_device *pdev)
- return -ENOMEM;
- }
- + edev = extcon_get_extcon_dev("palmas_usb");
- + if (!edev) {
- + dev_dbg(dev, "couldn't get extcon device\n");
- + return -EPROBE_DEFER;
- + }
- +
- spin_lock_init(&omap->lock);
- omap->dev = dev;
- omap->irq = irq;
- omap->base = base;
- + omap->nb.notifier_call = dwc3_omap_mailbox_notifier;
- + extcon_register_notifier(edev, &omap->nb);
- dev->dma_mask = &dwc3_omap_dma_mask;
- - /*
- - * REVISIT if we ever have two instances of the wrapper, we will be
- - * in big trouble
- - */
- - _omap = omap;
- -
- pm_runtime_enable(dev);
- ret = pm_runtime_get_sync(dev);
- if (ret < 0) {
- @@ -387,6 +393,11 @@ static int dwc3_omap_probe(struct platform_device *pdev)
- return ret;
- }
- + if (extcon_get_cable_state(edev, "USB") == true)
- + dwc3_omap_set_mailbox(omap, PALMAS_USB_STATE_VBUS);
- + if (extcon_get_cable_state(edev, "USB-HOST") == true)
- + dwc3_omap_set_mailbox(omap, PALMAS_USB_STATE_ID);
- +
- return 0;
- }
- diff --git a/include/linux/usb/dwc3-omap.h b/include/linux/usb/dwc3-omap.h
- deleted file mode 100644
- index 5615f4d..0000000
- --- a/include/linux/usb/dwc3-omap.h
- +++ /dev/null
- @@ -1,30 +0,0 @@
- -/*
- - * Copyright (C) 2013 by Texas Instruments
- - *
- - * The Inventra Controller Driver for Linux is free software; you
- - * can redistribute it and/or modify it under the terms of the GNU
- - * General Public License version 2 as published by the Free Software
- - * Foundation.
- - */
- -
- -#ifndef __DWC3_OMAP_H__
- -#define __DWC3_OMAP_H__
- -
- -enum omap_dwc3_vbus_id_status {
- - OMAP_DWC3_UNKNOWN = 0,
- - OMAP_DWC3_ID_GROUND,
- - OMAP_DWC3_ID_FLOAT,
- - OMAP_DWC3_VBUS_VALID,
- - OMAP_DWC3_VBUS_OFF,
- -};
- -
- -#if (defined(CONFIG_USB_DWC3) || defined(CONFIG_USB_DWC3_MODULE))
- -extern int dwc3_omap_mailbox(enum omap_dwc3_vbus_id_status status);
- -#else
- -static inline int dwc3_omap_mailbox(enum omap_dwc3_vbus_id_status status)
- -{
- - return -ENODEV;
- -}
- -#endif
- -
- -#endif /* __DWC3_OMAP_H__ */
- --
- 1.7.10.4
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement