Prafulla Wadaskar | 1d8937a | 2009-06-29 20:56:43 +0530 | [diff] [blame] | 1 | /* |
| 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" |
Lei Wen | a7efd71 | 2011-10-18 20:11:42 +0530 | [diff] [blame] | 29 | #include <asm/arch/cpu.h> |
Albert ARIBAUD | 805ad7e | 2012-01-15 22:08:40 +0000 | [diff] [blame] | 30 | |
| 31 | #if defined(CONFIG_KIRKWOOD) |
Prafulla Wadaskar | 1d8937a | 2009-06-29 20:56:43 +0530 | [diff] [blame] | 32 | #include <asm/arch/kirkwood.h> |
Albert ARIBAUD | 805ad7e | 2012-01-15 22:08:40 +0000 | [diff] [blame] | 33 | #elif defined(CONFIG_ORION5X) |
| 34 | #include <asm/arch/orion5x.h> |
| 35 | #endif |
Prafulla Wadaskar | 1d8937a | 2009-06-29 20:56:43 +0530 | [diff] [blame] | 36 | |
Albert ARIBAUD | 74d3442 | 2012-01-15 22:08:39 +0000 | [diff] [blame] | 37 | DECLARE_GLOBAL_DATA_PTR; |
| 38 | |
| 39 | #define rdl(off) readl(MVUSB0_BASE + (off)) |
| 40 | #define wrl(off, val) writel((val), MVUSB0_BASE + (off)) |
Prafulla Wadaskar | 1d8937a | 2009-06-29 20:56:43 +0530 | [diff] [blame] | 41 | |
| 42 | #define USB_WINDOW_CTRL(i) (0x320 + ((i) << 4)) |
| 43 | #define USB_WINDOW_BASE(i) (0x324 + ((i) << 4)) |
| 44 | #define USB_TARGET_DRAM 0x0 |
| 45 | |
| 46 | /* |
| 47 | * USB 2.0 Bridge Address Decoding registers setup |
| 48 | */ |
| 49 | static void usb_brg_adrdec_setup(void) |
| 50 | { |
| 51 | int i; |
Albert ARIBAUD | 74d3442 | 2012-01-15 22:08:39 +0000 | [diff] [blame] | 52 | u32 size, base, attrib; |
Prafulla Wadaskar | 1d8937a | 2009-06-29 20:56:43 +0530 | [diff] [blame] | 53 | |
| 54 | for (i = 0; i < CONFIG_NR_DRAM_BANKS; i++) { |
| 55 | |
| 56 | /* Enable DRAM bank */ |
| 57 | switch (i) { |
| 58 | case 0: |
Albert ARIBAUD | 74d3442 | 2012-01-15 22:08:39 +0000 | [diff] [blame] | 59 | attrib = MVUSB0_CPU_ATTR_DRAM_CS0; |
Prafulla Wadaskar | 1d8937a | 2009-06-29 20:56:43 +0530 | [diff] [blame] | 60 | break; |
| 61 | case 1: |
Albert ARIBAUD | 74d3442 | 2012-01-15 22:08:39 +0000 | [diff] [blame] | 62 | attrib = MVUSB0_CPU_ATTR_DRAM_CS1; |
Prafulla Wadaskar | 1d8937a | 2009-06-29 20:56:43 +0530 | [diff] [blame] | 63 | break; |
| 64 | case 2: |
Albert ARIBAUD | 74d3442 | 2012-01-15 22:08:39 +0000 | [diff] [blame] | 65 | attrib = MVUSB0_CPU_ATTR_DRAM_CS2; |
Prafulla Wadaskar | 1d8937a | 2009-06-29 20:56:43 +0530 | [diff] [blame] | 66 | break; |
| 67 | case 3: |
Albert ARIBAUD | 74d3442 | 2012-01-15 22:08:39 +0000 | [diff] [blame] | 68 | attrib = MVUSB0_CPU_ATTR_DRAM_CS3; |
Prafulla Wadaskar | 1d8937a | 2009-06-29 20:56:43 +0530 | [diff] [blame] | 69 | break; |
| 70 | default: |
| 71 | /* invalide bank, disable access */ |
| 72 | attrib = 0; |
| 73 | break; |
| 74 | } |
| 75 | |
Albert ARIBAUD | 74d3442 | 2012-01-15 22:08:39 +0000 | [diff] [blame] | 76 | size = gd->bd->bi_dram[i].size; |
| 77 | base = gd->bd->bi_dram[i].start; |
Prafulla Wadaskar | 1d8937a | 2009-06-29 20:56:43 +0530 | [diff] [blame] | 78 | if ((size) && (attrib)) |
| 79 | wrl(USB_WINDOW_CTRL(i), |
Albert ARIBAUD | 74d3442 | 2012-01-15 22:08:39 +0000 | [diff] [blame] | 80 | MVCPU_WIN_CTRL_DATA(size, USB_TARGET_DRAM, |
| 81 | attrib, MVCPU_WIN_ENABLE)); |
Prafulla Wadaskar | 1d8937a | 2009-06-29 20:56:43 +0530 | [diff] [blame] | 82 | else |
Albert ARIBAUD | 74d3442 | 2012-01-15 22:08:39 +0000 | [diff] [blame] | 83 | wrl(USB_WINDOW_CTRL(i), MVCPU_WIN_DISABLE); |
Prafulla Wadaskar | 1d8937a | 2009-06-29 20:56:43 +0530 | [diff] [blame] | 84 | |
Albert ARIBAUD | 74d3442 | 2012-01-15 22:08:39 +0000 | [diff] [blame] | 85 | wrl(USB_WINDOW_BASE(i), base); |
Prafulla Wadaskar | 1d8937a | 2009-06-29 20:56:43 +0530 | [diff] [blame] | 86 | } |
| 87 | } |
| 88 | |
| 89 | /* |
| 90 | * Create the appropriate control structures to manage |
| 91 | * a new EHCI host controller. |
| 92 | */ |
Lucas Stach | 676ae06 | 2012-09-26 00:14:35 +0200 | [diff] [blame] | 93 | int ehci_hcd_init(int index, struct ehci_hccr **hccr, struct ehci_hcor **hcor) |
Prafulla Wadaskar | 1d8937a | 2009-06-29 20:56:43 +0530 | [diff] [blame] | 94 | { |
| 95 | usb_brg_adrdec_setup(); |
| 96 | |
Lucas Stach | 676ae06 | 2012-09-26 00:14:35 +0200 | [diff] [blame] | 97 | *hccr = (struct ehci_hccr *)(MVUSB0_BASE + 0x100); |
| 98 | *hcor = (struct ehci_hcor *)((uint32_t) *hccr |
| 99 | + HC_LENGTH(ehci_readl(&(*hccr)->cr_capbase))); |
Prafulla Wadaskar | 1d8937a | 2009-06-29 20:56:43 +0530 | [diff] [blame] | 100 | |
Albert ARIBAUD | 74d3442 | 2012-01-15 22:08:39 +0000 | [diff] [blame] | 101 | debug("ehci-marvell: init hccr %x and hcor %x hc_length %d\n", |
Lucas Stach | 676ae06 | 2012-09-26 00:14:35 +0200 | [diff] [blame] | 102 | (uint32_t)*hccr, (uint32_t)*hcor, |
| 103 | (uint32_t)HC_LENGTH(ehci_readl(&(*hccr)->cr_capbase))); |
Prafulla Wadaskar | 1d8937a | 2009-06-29 20:56:43 +0530 | [diff] [blame] | 104 | |
| 105 | return 0; |
| 106 | } |
| 107 | |
| 108 | /* |
| 109 | * Destroy the appropriate control structures corresponding |
| 110 | * the the EHCI host controller. |
| 111 | */ |
Lucas Stach | 676ae06 | 2012-09-26 00:14:35 +0200 | [diff] [blame] | 112 | int ehci_hcd_stop(int index) |
Prafulla Wadaskar | 1d8937a | 2009-06-29 20:56:43 +0530 | [diff] [blame] | 113 | { |
| 114 | return 0; |
| 115 | } |