blob: 9f0ed06a85343e282ed43d44339b1d4078d35477 [file] [log] [blame]
Rajeshwari Shinde5f0ffea2012-05-02 19:18:51 +05301/*
Rajeshwari Shinde7590d3c2012-05-21 16:38:03 +05302 * SAMSUNG EXYNOS USB HOST EHCI Controller
Rajeshwari Shinde5f0ffea2012-05-02 19:18:51 +05303 *
4 * Copyright (C) 2012 Samsung Electronics Co.Ltd
5 * Vivek Gautam <gautam.vivek@samsung.com>
6 *
7 * This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License as
9 * published by the Free Software Foundation; either version 2 of
10 * the License, or (at your option) any later version.
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., 51 Franklin Street, Fifth Floor, Boston,
20 * MA 02110-1301 USA
21 */
22
23#include <common.h>
24#include <usb.h>
25#include <asm/arch/cpu.h>
Rajeshwari Shinde7590d3c2012-05-21 16:38:03 +053026#include <asm/arch/ehci.h>
Rajeshwari Shinde71045da2012-05-14 05:52:02 +000027#include <asm/arch/system.h>
Rajeshwari Shindec48ac112012-05-14 05:52:03 +000028#include <asm/arch/power.h>
Rajeshwari Shinde5f0ffea2012-05-02 19:18:51 +053029#include "ehci.h"
Rajeshwari Shinde5f0ffea2012-05-02 19:18:51 +053030
31/* Setup the EHCI host controller. */
Rajeshwari Shinde7590d3c2012-05-21 16:38:03 +053032static void setup_usb_phy(struct exynos_usb_phy *usb)
Rajeshwari Shinde5f0ffea2012-05-02 19:18:51 +053033{
Rajeshwari Shinde71045da2012-05-14 05:52:02 +000034 set_usbhost_mode(USB20_PHY_CFG_HOST_LINK_EN);
35
Rajeshwari Shindec48ac112012-05-14 05:52:03 +000036 set_usbhost_phy_ctrl(POWER_USB_HOST_PHY_CTRL_EN);
37
Rajeshwari Shinde5f0ffea2012-05-02 19:18:51 +053038 clrbits_le32(&usb->usbphyctrl0,
39 HOST_CTRL0_FSEL_MASK |
40 HOST_CTRL0_COMMONON_N |
41 /* HOST Phy setting */
42 HOST_CTRL0_PHYSWRST |
43 HOST_CTRL0_PHYSWRSTALL |
44 HOST_CTRL0_SIDDQ |
45 HOST_CTRL0_FORCESUSPEND |
46 HOST_CTRL0_FORCESLEEP);
47
48 setbits_le32(&usb->usbphyctrl0,
49 /* Setting up the ref freq */
50 (CLK_24MHZ << 16) |
51 /* HOST Phy setting */
52 HOST_CTRL0_LINKSWRST |
53 HOST_CTRL0_UTMISWRST);
54 udelay(10);
55 clrbits_le32(&usb->usbphyctrl0,
56 HOST_CTRL0_LINKSWRST |
57 HOST_CTRL0_UTMISWRST);
58 udelay(20);
59
60 /* EHCI Ctrl setting */
61 setbits_le32(&usb->ehcictrl,
62 EHCICTRL_ENAINCRXALIGN |
63 EHCICTRL_ENAINCR4 |
64 EHCICTRL_ENAINCR8 |
65 EHCICTRL_ENAINCR16);
66}
67
68/* Reset the EHCI host controller. */
Rajeshwari Shinde7590d3c2012-05-21 16:38:03 +053069static void reset_usb_phy(struct exynos_usb_phy *usb)
Rajeshwari Shinde5f0ffea2012-05-02 19:18:51 +053070{
71 /* HOST_PHY reset */
72 setbits_le32(&usb->usbphyctrl0,
73 HOST_CTRL0_PHYSWRST |
74 HOST_CTRL0_PHYSWRSTALL |
75 HOST_CTRL0_SIDDQ |
76 HOST_CTRL0_FORCESUSPEND |
77 HOST_CTRL0_FORCESLEEP);
Rajeshwari Shindec48ac112012-05-14 05:52:03 +000078
79 set_usbhost_phy_ctrl(POWER_USB_HOST_PHY_CTRL_DISABLE);
Rajeshwari Shinde5f0ffea2012-05-02 19:18:51 +053080}
81
82/*
83 * EHCI-initialization
84 * Create the appropriate control structures to manage
85 * a new EHCI host controller.
86 */
Lucas Stach676ae062012-09-26 00:14:35 +020087int ehci_hcd_init(int index, struct ehci_hccr **hccr, struct ehci_hcor **hcor)
Rajeshwari Shinde5f0ffea2012-05-02 19:18:51 +053088{
Rajeshwari Shinde7590d3c2012-05-21 16:38:03 +053089 struct exynos_usb_phy *usb;
Rajeshwari Shinde5f0ffea2012-05-02 19:18:51 +053090
Rajeshwari Shinde7590d3c2012-05-21 16:38:03 +053091 usb = (struct exynos_usb_phy *)samsung_get_base_usb_phy();
Rajeshwari Shinde5f0ffea2012-05-02 19:18:51 +053092 setup_usb_phy(usb);
93
Lucas Stach676ae062012-09-26 00:14:35 +020094 *hccr = (struct ehci_hccr *)samsung_get_base_usb_ehci();
95 *hcor = (struct ehci_hcor *)((uint32_t) *hccr
96 + HC_LENGTH(ehci_readl(&(*hccr)->cr_capbase)));
Rajeshwari Shinde5f0ffea2012-05-02 19:18:51 +053097
98 debug("Exynos5-ehci: init hccr %x and hcor %x hc_length %d\n",
Lucas Stach676ae062012-09-26 00:14:35 +020099 (uint32_t)*hccr, (uint32_t)*hcor,
100 (uint32_t)HC_LENGTH(ehci_readl(&(*hccr)->cr_capbase)));
Rajeshwari Shinde5f0ffea2012-05-02 19:18:51 +0530101
102 return 0;
103}
104
105/*
106 * Destroy the appropriate control structures corresponding
107 * the EHCI host controller.
108 */
Lucas Stach676ae062012-09-26 00:14:35 +0200109int ehci_hcd_stop(int index)
Rajeshwari Shinde5f0ffea2012-05-02 19:18:51 +0530110{
Rajeshwari Shinde7590d3c2012-05-21 16:38:03 +0530111 struct exynos_usb_phy *usb;
Rajeshwari Shinde5f0ffea2012-05-02 19:18:51 +0530112
Rajeshwari Shinde7590d3c2012-05-21 16:38:03 +0530113 usb = (struct exynos_usb_phy *)samsung_get_base_usb_phy();
Rajeshwari Shinde5f0ffea2012-05-02 19:18:51 +0530114 reset_usb_phy(usb);
115
116 return 0;
117}