aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/usb/chipidea/otg_fsm.c
diff options
context:
space:
mode:
authorLi Jun <B47624@freescale.com>2013-12-31 08:36:51 -0500
committerNitin Garg <nitin.garg@freescale.com>2014-04-16 12:02:32 -0400
commit3767c8168a3dee9032b9e77c6a12e919e0a7a514 (patch)
tree1b9b47e42549c1cd08922c2f80661bc21770ef84 /drivers/usb/chipidea/otg_fsm.c
parentfc47c6565c363633165e9099f5a985c74e0dc3b0 (diff)
ENGR00307558-1 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: Li Jun <b47624@freescale.com>
Diffstat (limited to 'drivers/usb/chipidea/otg_fsm.c')
-rw-r--r--drivers/usb/chipidea/otg_fsm.c65
1 files changed, 65 insertions, 0 deletions
diff --git a/drivers/usb/chipidea/otg_fsm.c b/drivers/usb/chipidea/otg_fsm.c
new file mode 100644
index 000000000000..f4bb7c83b708
--- /dev/null
+++ b/drivers/usb/chipidea/otg_fsm.c
@@ -0,0 +1,65 @@
1/*
2 * otg_fsm.c - ChipIdea USB IP core OTG FSM driver
3 *
4 * Copyright (C) 2014 Freescale Semiconductor, Inc.
5 *
6 * Author: Jun Li
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License version 2 as
10 * published by the Free Software Foundation.
11 */
12
13/*
14 * This file mainly handles OTG fsm, it includes OTG fsm operations
15 * for HNP and SRP.
16 */
17
18#include <linux/usb/otg.h>
19#include <linux/usb/gadget.h>
20#include <linux/usb/hcd.h>
21#include <linux/usb/chipidea.h>
22
23#include "ci.h"
24#include "bits.h"
25#include "otg.h"
26#include "otg_fsm.h"
27
28int ci_hdrc_otg_fsm_init(struct ci_hdrc *ci)
29{
30 struct usb_otg *otg;
31
32 otg = devm_kzalloc(ci->dev,
33 sizeof(struct usb_otg), GFP_KERNEL);
34 if (!otg) {
35 dev_err(ci->dev,
36 "Failed to allocate usb_otg structure for ci hdrc otg!\n");
37 return -ENOMEM;
38 }
39
40 otg->phy = ci->transceiver;
41 otg->gadget = &ci->gadget;
42 if (ci->hcd)
43 otg->host = &ci->hcd->self;
44 ci->fsm.otg = otg;
45 ci->transceiver->otg = ci->fsm.otg;
46 ci->fsm.power_up = 1;
47 ci->fsm.id = hw_read_otgsc(ci, OTGSC_ID) ? 1 : 0;
48 ci->transceiver->state = OTG_STATE_UNDEFINED;
49
50 mutex_init(&ci->fsm.lock);
51
52 /* Enable A vbus valid irq */
53 hw_write_otgsc(ci, OTGSC_AVVIE, OTGSC_AVVIE);
54
55 if (ci->fsm.id) {
56 ci->fsm.b_ssend_srp =
57 hw_read_otgsc(ci, OTGSC_BSV) ? 0 : 1;
58 ci->fsm.b_sess_vld =
59 hw_read_otgsc(ci, OTGSC_BSV) ? 1 : 0;
60 /* Enable BSV irq */
61 hw_write_otgsc(ci, OTGSC_BSVIE, OTGSC_BSVIE);
62 }
63
64 return 0;
65}