2 * host.c - ChipIdea USB host controller driver
4 * Copyright (c) 2012 Intel Corporation
6 * Author: Alexander Shishkin
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.
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.
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.
22 #include <linux/kernel.h>
23 #include <linux/usb.h>
24 #include <linux/usb/hcd.h>
25 #include <linux/usb/chipidea.h>
28 #include "../host/ehci-hcd.c"
34 static int ci_ehci_setup(struct usb_hcd
*hcd
)
36 struct ehci_hcd
*ehci
= hcd_to_ehci(hcd
);
41 ret
= ehci_setup(hcd
);
45 ehci_port_power(ehci
, 0);
50 static const struct hc_driver ci_ehci_hc_driver
= {
51 .description
= "ehci_hcd",
52 .product_desc
= "ChipIdea HDRC EHCI",
53 .hcd_priv_size
= sizeof(struct ehci_hcd
),
56 * generic hardware linkage
59 .flags
= HCD_MEMORY
| HCD_USB2
,
62 * basic lifecycle operations
64 .reset
= ci_ehci_setup
,
67 .shutdown
= ehci_shutdown
,
70 * managing i/o requests and associated device resources
72 .urb_enqueue
= ehci_urb_enqueue
,
73 .urb_dequeue
= ehci_urb_dequeue
,
74 .endpoint_disable
= ehci_endpoint_disable
,
75 .endpoint_reset
= ehci_endpoint_reset
,
80 .get_frame_number
= ehci_get_frame
,
85 .hub_status_data
= ehci_hub_status_data
,
86 .hub_control
= ehci_hub_control
,
87 .bus_suspend
= ehci_bus_suspend
,
88 .bus_resume
= ehci_bus_resume
,
89 .relinquish_port
= ehci_relinquish_port
,
90 .port_handed_over
= ehci_port_handed_over
,
92 .clear_tt_buffer_complete
= ehci_clear_tt_buffer_complete
,
95 static irqreturn_t
host_irq(struct ci13xxx
*ci
)
97 return usb_hcd_irq(ci
->irq
, ci
->hcd
);
100 static int host_start(struct ci13xxx
*ci
)
103 struct ehci_hcd
*ehci
;
109 hcd
= usb_create_hcd(&ci_ehci_hc_driver
, ci
->dev
, dev_name(ci
->dev
));
113 dev_set_drvdata(ci
->dev
, ci
);
114 hcd
->rsrc_start
= ci
->hw_bank
.phys
;
115 hcd
->rsrc_len
= ci
->hw_bank
.size
;
116 hcd
->regs
= ci
->hw_bank
.abs
;
119 hcd
->power_budget
= ci
->platdata
->power_budget
;
120 hcd
->phy
= ci
->transceiver
;
122 ehci
= hcd_to_ehci(hcd
);
123 ehci
->caps
= ci
->hw_bank
.cap
;
124 ehci
->has_hostpc
= ci
->hw_bank
.lpm
;
126 ret
= usb_add_hcd(hcd
, 0, 0);
135 static void host_stop(struct ci13xxx
*ci
)
137 struct usb_hcd
*hcd
= ci
->hcd
;
143 int ci_hdrc_host_init(struct ci13xxx
*ci
)
145 struct ci_role_driver
*rdrv
;
147 if (!hw_read(ci
, CAP_DCCPARAMS
, DCCPARAMS_HC
))
150 rdrv
= devm_kzalloc(ci
->dev
, sizeof(struct ci_role_driver
), GFP_KERNEL
);
154 rdrv
->start
= host_start
;
155 rdrv
->stop
= host_stop
;
156 rdrv
->irq
= host_irq
;
158 ci
->roles
[CI_ROLE_HOST
] = rdrv
;