2 * SAMSUNG S5P USB HOST EHCI Controller
4 * Copyright (C) 2011 Samsung Electronics Co.Ltd
5 * Author: Jingoo Han <jg1.han@samsung.com>
6 * Author: Joonyoung Shim <jy0922.shim@samsung.com>
8 * This program is free software; you can redistribute it and/or modify it
9 * under the terms of the GNU General Public License as published by the
10 * Free Software Foundation; either version 2 of the License, or (at your
11 * option) any later version.
15 #include <linux/clk.h>
16 #include <linux/platform_device.h>
17 #include <mach/regs-pmu.h>
19 #include <plat/ehci.h>
20 #include <plat/usb-phy.h>
28 static const struct hc_driver s5p_ehci_hc_driver
= {
29 .description
= hcd_name
,
30 .product_desc
= "S5P EHCI Host Controller",
31 .hcd_priv_size
= sizeof(struct ehci_hcd
),
34 .flags
= HCD_MEMORY
| HCD_USB2
,
39 .shutdown
= ehci_shutdown
,
41 .get_frame_number
= ehci_get_frame
,
43 .urb_enqueue
= ehci_urb_enqueue
,
44 .urb_dequeue
= ehci_urb_dequeue
,
45 .endpoint_disable
= ehci_endpoint_disable
,
46 .endpoint_reset
= ehci_endpoint_reset
,
48 .hub_status_data
= ehci_hub_status_data
,
49 .hub_control
= ehci_hub_control
,
50 .bus_suspend
= ehci_bus_suspend
,
51 .bus_resume
= ehci_bus_resume
,
53 .relinquish_port
= ehci_relinquish_port
,
54 .port_handed_over
= ehci_port_handed_over
,
56 .clear_tt_buffer_complete
= ehci_clear_tt_buffer_complete
,
59 static int __devinit
s5p_ehci_probe(struct platform_device
*pdev
)
61 struct s5p_ehci_platdata
*pdata
;
62 struct s5p_ehci_hcd
*s5p_ehci
;
64 struct ehci_hcd
*ehci
;
69 pdata
= pdev
->dev
.platform_data
;
71 dev_err(&pdev
->dev
, "No platform data defined\n");
75 s5p_ehci
= kzalloc(sizeof(struct s5p_ehci_hcd
), GFP_KERNEL
);
79 s5p_ehci
->dev
= &pdev
->dev
;
81 hcd
= usb_create_hcd(&s5p_ehci_hc_driver
, &pdev
->dev
,
82 dev_name(&pdev
->dev
));
84 dev_err(&pdev
->dev
, "Unable to create HCD\n");
89 s5p_ehci
->clk
= clk_get(&pdev
->dev
, "usbhost");
91 if (IS_ERR(s5p_ehci
->clk
)) {
92 dev_err(&pdev
->dev
, "Failed to get usbhost clock\n");
93 err
= PTR_ERR(s5p_ehci
->clk
);
97 err
= clk_enable(s5p_ehci
->clk
);
101 res
= platform_get_resource(pdev
, IORESOURCE_MEM
, 0);
103 dev_err(&pdev
->dev
, "Failed to get I/O memory\n");
108 hcd
->rsrc_start
= res
->start
;
109 hcd
->rsrc_len
= resource_size(res
);
110 hcd
->regs
= ioremap(res
->start
, resource_size(res
));
112 dev_err(&pdev
->dev
, "Failed to remap I/O memory\n");
117 irq
= platform_get_irq(pdev
, 0);
119 dev_err(&pdev
->dev
, "Failed to get IRQ\n");
125 pdata
->phy_init(pdev
, S5P_USB_PHY_HOST
);
127 ehci
= hcd_to_ehci(hcd
);
128 ehci
->caps
= hcd
->regs
;
129 ehci
->regs
= hcd
->regs
+
130 HC_LENGTH(ehci
, readl(&ehci
->caps
->hc_capbase
));
132 dbg_hcs_params(ehci
, "reset");
133 dbg_hcc_params(ehci
, "reset");
135 /* cache this readonly data; minimize chip reads */
136 ehci
->hcs_params
= readl(&ehci
->caps
->hcs_params
);
138 err
= usb_add_hcd(hcd
, irq
, IRQF_DISABLED
| IRQF_SHARED
);
140 dev_err(&pdev
->dev
, "Failed to add USB HCD\n");
144 platform_set_drvdata(pdev
, s5p_ehci
);
151 clk_disable(s5p_ehci
->clk
);
153 clk_put(s5p_ehci
->clk
);
161 static int __devexit
s5p_ehci_remove(struct platform_device
*pdev
)
163 struct s5p_ehci_platdata
*pdata
= pdev
->dev
.platform_data
;
164 struct s5p_ehci_hcd
*s5p_ehci
= platform_get_drvdata(pdev
);
165 struct usb_hcd
*hcd
= s5p_ehci
->hcd
;
169 if (pdata
&& pdata
->phy_exit
)
170 pdata
->phy_exit(pdev
, S5P_USB_PHY_HOST
);
174 clk_disable(s5p_ehci
->clk
);
175 clk_put(s5p_ehci
->clk
);
183 static void s5p_ehci_shutdown(struct platform_device
*pdev
)
185 struct s5p_ehci_hcd
*s5p_ehci
= platform_get_drvdata(pdev
);
186 struct usb_hcd
*hcd
= s5p_ehci
->hcd
;
188 if (hcd
->driver
->shutdown
)
189 hcd
->driver
->shutdown(hcd
);
192 static struct platform_driver s5p_ehci_driver
= {
193 .probe
= s5p_ehci_probe
,
194 .remove
= __devexit_p(s5p_ehci_remove
),
195 .shutdown
= s5p_ehci_shutdown
,
198 .owner
= THIS_MODULE
,
202 MODULE_ALIAS("platform:s5p-ehci");