-
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: chipidea: usb OTG fsm initialization.
This patch adds OTG fsm related initialization when do otg init, add a seperate file for OTG fsm related utilities. Signed-off-by: Peter Chen <peter.chen@freescale.com> Signed-off-by: Li Jun <b47624@freescale.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
- Loading branch information
Li Jun
authored and
Greg Kroah-Hartman
committed
Apr 24, 2014
1 parent
be696aa
commit 57677be
Showing
5 changed files
with
114 additions
and
0 deletions.
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
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
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,63 @@ | ||
/* | ||
* otg_fsm.c - ChipIdea USB IP core OTG FSM driver | ||
* | ||
* Copyright (C) 2014 Freescale Semiconductor, Inc. | ||
* | ||
* Author: Jun Li | ||
* | ||
* This program 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. | ||
*/ | ||
|
||
/* | ||
* This file mainly handles OTG fsm, it includes OTG fsm operations | ||
* for HNP and SRP. | ||
*/ | ||
|
||
#include <linux/usb/otg.h> | ||
#include <linux/usb/gadget.h> | ||
#include <linux/usb/hcd.h> | ||
#include <linux/usb/chipidea.h> | ||
|
||
#include "ci.h" | ||
#include "bits.h" | ||
#include "otg.h" | ||
#include "otg_fsm.h" | ||
|
||
int ci_hdrc_otg_fsm_init(struct ci_hdrc *ci) | ||
{ | ||
struct usb_otg *otg; | ||
|
||
otg = devm_kzalloc(ci->dev, | ||
sizeof(struct usb_otg), GFP_KERNEL); | ||
if (!otg) { | ||
dev_err(ci->dev, | ||
"Failed to allocate usb_otg structure for ci hdrc otg!\n"); | ||
return -ENOMEM; | ||
} | ||
|
||
otg->phy = ci->transceiver; | ||
otg->gadget = &ci->gadget; | ||
ci->fsm.otg = otg; | ||
ci->transceiver->otg = ci->fsm.otg; | ||
ci->fsm.power_up = 1; | ||
ci->fsm.id = hw_read_otgsc(ci, OTGSC_ID) ? 1 : 0; | ||
ci->transceiver->state = OTG_STATE_UNDEFINED; | ||
|
||
mutex_init(&ci->fsm.lock); | ||
|
||
/* Enable A vbus valid irq */ | ||
hw_write_otgsc(ci, OTGSC_AVVIE, OTGSC_AVVIE); | ||
|
||
if (ci->fsm.id) { | ||
ci->fsm.b_ssend_srp = | ||
hw_read_otgsc(ci, OTGSC_BSV) ? 0 : 1; | ||
ci->fsm.b_sess_vld = | ||
hw_read_otgsc(ci, OTGSC_BSV) ? 1 : 0; | ||
/* Enable BSV irq */ | ||
hw_write_otgsc(ci, OTGSC_BSVIE, OTGSC_BSVIE); | ||
} | ||
|
||
return 0; | ||
} |
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,29 @@ | ||
/* | ||
* Copyright (C) 2014 Freescale Semiconductor, Inc. | ||
* | ||
* Author: Jun Li | ||
* | ||
* This program 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 __DRIVERS_USB_CHIPIDEA_OTG_FSM_H | ||
#define __DRIVERS_USB_CHIPIDEA_OTG_FSM_H | ||
|
||
#include <linux/usb/otg-fsm.h> | ||
|
||
#ifdef CONFIG_USB_OTG_FSM | ||
|
||
int ci_hdrc_otg_fsm_init(struct ci_hdrc *ci); | ||
|
||
#else | ||
|
||
static inline int ci_hdrc_otg_fsm_init(struct ci_hdrc *ci) | ||
{ | ||
return 0; | ||
} | ||
|
||
#endif | ||
|
||
#endif /* __DRIVERS_USB_CHIPIDEA_OTG_FSM_H */ |