blob: 89c8af72874cf763ed1a84d7e856944191d7f92d [file] [log] [blame]
Prafulla Wadaskar1d8937a2009-06-29 20:56:43 +05301/*
2 * (C) Copyright 2009
3 * Marvell Semiconductor <www.marvell.com>
4 * Written-by: Prafulla Wadaskar <prafulla@marvell.com>
5 *
6 * See file CREDITS for list of people who contributed to this
7 * project.
8 *
9 * This program is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU General Public License as
11 * published by the Free Software Foundation; either version 2 of
12 * the License, or (at your option) any later version.
13 *
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
18 *
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
22 * MA 02110-1301 USA
23 */
24
25#include <common.h>
26#include <asm/io.h>
27#include <usb.h>
28#include "ehci.h"
29#include "ehci-core.h"
Lei Wena7efd712011-10-18 20:11:42 +053030#include <asm/arch/cpu.h>
Albert ARIBAUD805ad7e2012-01-15 22:08:40 +000031
32#if defined(CONFIG_KIRKWOOD)
Prafulla Wadaskar1d8937a2009-06-29 20:56:43 +053033#include <asm/arch/kirkwood.h>
Albert ARIBAUD805ad7e2012-01-15 22:08:40 +000034#elif defined(CONFIG_ORION5X)
35#include <asm/arch/orion5x.h>
36#endif
Prafulla Wadaskar1d8937a2009-06-29 20:56:43 +053037
Albert ARIBAUD74d34422012-01-15 22:08:39 +000038DECLARE_GLOBAL_DATA_PTR;
39
40#define rdl(off) readl(MVUSB0_BASE + (off))
41#define wrl(off, val) writel((val), MVUSB0_BASE + (off))
Prafulla Wadaskar1d8937a2009-06-29 20:56:43 +053042
43#define USB_WINDOW_CTRL(i) (0x320 + ((i) << 4))
44#define USB_WINDOW_BASE(i) (0x324 + ((i) << 4))
45#define USB_TARGET_DRAM 0x0
46
47/*
48 * USB 2.0 Bridge Address Decoding registers setup
49 */
50static void usb_brg_adrdec_setup(void)
51{
52 int i;
Albert ARIBAUD74d34422012-01-15 22:08:39 +000053 u32 size, base, attrib;
Prafulla Wadaskar1d8937a2009-06-29 20:56:43 +053054
55 for (i = 0; i < CONFIG_NR_DRAM_BANKS; i++) {
56
57 /* Enable DRAM bank */
58 switch (i) {
59 case 0:
Albert ARIBAUD74d34422012-01-15 22:08:39 +000060 attrib = MVUSB0_CPU_ATTR_DRAM_CS0;
Prafulla Wadaskar1d8937a2009-06-29 20:56:43 +053061 break;
62 case 1:
Albert ARIBAUD74d34422012-01-15 22:08:39 +000063 attrib = MVUSB0_CPU_ATTR_DRAM_CS1;
Prafulla Wadaskar1d8937a2009-06-29 20:56:43 +053064 break;
65 case 2:
Albert ARIBAUD74d34422012-01-15 22:08:39 +000066 attrib = MVUSB0_CPU_ATTR_DRAM_CS2;
Prafulla Wadaskar1d8937a2009-06-29 20:56:43 +053067 break;
68 case 3:
Albert ARIBAUD74d34422012-01-15 22:08:39 +000069 attrib = MVUSB0_CPU_ATTR_DRAM_CS3;
Prafulla Wadaskar1d8937a2009-06-29 20:56:43 +053070 break;
71 default:
72 /* invalide bank, disable access */
73 attrib = 0;
74 break;
75 }
76
Albert ARIBAUD74d34422012-01-15 22:08:39 +000077 size = gd->bd->bi_dram[i].size;
78 base = gd->bd->bi_dram[i].start;
Prafulla Wadaskar1d8937a2009-06-29 20:56:43 +053079 if ((size) && (attrib))
80 wrl(USB_WINDOW_CTRL(i),
Albert ARIBAUD74d34422012-01-15 22:08:39 +000081 MVCPU_WIN_CTRL_DATA(size, USB_TARGET_DRAM,
82 attrib, MVCPU_WIN_ENABLE));
Prafulla Wadaskar1d8937a2009-06-29 20:56:43 +053083 else
Albert ARIBAUD74d34422012-01-15 22:08:39 +000084 wrl(USB_WINDOW_CTRL(i), MVCPU_WIN_DISABLE);
Prafulla Wadaskar1d8937a2009-06-29 20:56:43 +053085
Albert ARIBAUD74d34422012-01-15 22:08:39 +000086 wrl(USB_WINDOW_BASE(i), base);
Prafulla Wadaskar1d8937a2009-06-29 20:56:43 +053087 }
88}
89
90/*
91 * Create the appropriate control structures to manage
92 * a new EHCI host controller.
93 */
94int ehci_hcd_init(void)
95{
96 usb_brg_adrdec_setup();
97
Albert ARIBAUD74d34422012-01-15 22:08:39 +000098 hccr = (struct ehci_hccr *)(MVUSB0_BASE + 0x100);
Prafulla Wadaskar1d8937a2009-06-29 20:56:43 +053099 hcor = (struct ehci_hcor *)((uint32_t) hccr
100 + HC_LENGTH(ehci_readl(&hccr->cr_capbase)));
101
Albert ARIBAUD74d34422012-01-15 22:08:39 +0000102 debug("ehci-marvell: init hccr %x and hcor %x hc_length %d\n",
Prafulla Wadaskar1d8937a2009-06-29 20:56:43 +0530103 (uint32_t)hccr, (uint32_t)hcor,
104 (uint32_t)HC_LENGTH(ehci_readl(&hccr->cr_capbase)));
105
106 return 0;
107}
108
109/*
110 * Destroy the appropriate control structures corresponding
111 * the the EHCI host controller.
112 */
113int ehci_hcd_stop(void)
114{
115 return 0;
116}