USB: EHCI: fix build error in ChipIdea host driver
[pandora-kernel.git] / drivers / usb / chipidea / host.c
1 /*
2  * host.c - ChipIdea USB host controller driver
3  *
4  * Copyright (c) 2012 Intel Corporation
5  *
6  * Author: Alexander Shishkin
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  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with this program; if not, write to the Free Software
19  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20  */
21
22 #include <linux/kernel.h>
23 #include <linux/io.h>
24 #include <linux/usb.h>
25 #include <linux/usb/hcd.h>
26 #include <linux/usb/chipidea.h>
27
28 #define CHIPIDEA_EHCI
29 #include "../host/ehci.h"
30
31 #include "ci.h"
32 #include "bits.h"
33 #include "host.h"
34
35 static const struct ehci_driver_overrides ci_overrides = {
36         .product_desc =         "ChipIdea HDRC EHCI host controller",
37 };
38
39 static struct hc_driver __read_mostly ci_ehci_hc_driver;
40
41 static irqreturn_t host_irq(struct ci13xxx *ci)
42 {
43         return usb_hcd_irq(ci->irq, ci->hcd);
44 }
45
46 static int host_start(struct ci13xxx *ci)
47 {
48         struct usb_hcd *hcd;
49         struct ehci_hcd *ehci;
50         int ret;
51
52         if (usb_disabled())
53                 return -ENODEV;
54
55         hcd = usb_create_hcd(&ci_ehci_hc_driver, ci->dev, dev_name(ci->dev));
56         if (!hcd)
57                 return -ENOMEM;
58
59         dev_set_drvdata(ci->dev, ci);
60         hcd->rsrc_start = ci->hw_bank.phys;
61         hcd->rsrc_len = ci->hw_bank.size;
62         hcd->regs = ci->hw_bank.abs;
63         hcd->has_tt = 1;
64
65         hcd->power_budget = ci->platdata->power_budget;
66         hcd->phy = ci->transceiver;
67
68         ehci = hcd_to_ehci(hcd);
69         ehci->caps = ci->hw_bank.cap;
70         ehci->has_hostpc = ci->hw_bank.lpm;
71
72         ret = usb_add_hcd(hcd, 0, 0);
73         if (ret)
74                 usb_put_hcd(hcd);
75         else
76                 ci->hcd = hcd;
77
78         return ret;
79 }
80
81 static void host_stop(struct ci13xxx *ci)
82 {
83         struct usb_hcd *hcd = ci->hcd;
84
85         usb_remove_hcd(hcd);
86         usb_put_hcd(hcd);
87 }
88
89 int ci_hdrc_host_init(struct ci13xxx *ci)
90 {
91         struct ci_role_driver *rdrv;
92
93         if (!hw_read(ci, CAP_DCCPARAMS, DCCPARAMS_HC))
94                 return -ENXIO;
95
96         rdrv = devm_kzalloc(ci->dev, sizeof(struct ci_role_driver), GFP_KERNEL);
97         if (!rdrv)
98                 return -ENOMEM;
99
100         rdrv->start     = host_start;
101         rdrv->stop      = host_stop;
102         rdrv->irq       = host_irq;
103         rdrv->name      = "host";
104         ci->roles[CI_ROLE_HOST] = rdrv;
105
106         ehci_init_driver(&ci_ehci_hc_driver, &ci_overrides);
107
108         return 0;
109 }