xref: /rk3399_rockchip-uboot/drivers/usb/host/ehci-tegra.c (revision a896211ff11d6eba553df710168fcab2a1b2d9ec)
187f938c9SSimon Glass /*
28b3f7bf7SJim Lin  * Copyright (c) 2009-2012 NVIDIA Corporation
387f938c9SSimon Glass  *
487f938c9SSimon Glass  * See file CREDITS for list of people who contributed to this
587f938c9SSimon Glass  * project.
687f938c9SSimon Glass  *
787f938c9SSimon Glass  * This program is free software; you can redistribute it and/or
887f938c9SSimon Glass  * modify it under the terms of the GNU General Public License as
987f938c9SSimon Glass  * published by the Free Software Foundation; either version 2 of
1087f938c9SSimon Glass  * the License, or (at your option) any later version.
1187f938c9SSimon Glass  *
1287f938c9SSimon Glass  * This program is distributed in the hope that it will be useful,
1387f938c9SSimon Glass  * but WITHOUT ANY WARRANTY; without even the implied warranty of
1487f938c9SSimon Glass  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
1587f938c9SSimon Glass  * GNU General Public License for more details.
1687f938c9SSimon Glass  *
1787f938c9SSimon Glass  * You should have received a copy of the GNU General Public License
1887f938c9SSimon Glass  * along with this program; if not, write to the Free Software
1987f938c9SSimon Glass  * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
2087f938c9SSimon Glass  * MA 02111-1307 USA
2187f938c9SSimon Glass  */
2287f938c9SSimon Glass 
2387f938c9SSimon Glass #include <common.h>
2487f938c9SSimon Glass #include <usb.h>
2587f938c9SSimon Glass 
2687f938c9SSimon Glass #include "ehci.h"
2787f938c9SSimon Glass 
2887f938c9SSimon Glass #include <asm/errno.h>
2987f938c9SSimon Glass #include <asm/arch/usb.h>
3087f938c9SSimon Glass 
318b3f7bf7SJim Lin /*
328b3f7bf7SJim Lin  * A known hardware issue where Connect Status Change bit of PORTSC register
338b3f7bf7SJim Lin  * of USB1 controller will be set after Port Reset.
348b3f7bf7SJim Lin  * We have to clear it in order for later device enumeration to proceed.
358b3f7bf7SJim Lin  * This ehci_powerup_fixup overrides the weak function ehci_powerup_fixup
368b3f7bf7SJim Lin  * in "ehci-hcd.c".
378b3f7bf7SJim Lin  */
388b3f7bf7SJim Lin void ehci_powerup_fixup(uint32_t *status_reg, uint32_t *reg)
398b3f7bf7SJim Lin {
408b3f7bf7SJim Lin 	mdelay(50);
418b3f7bf7SJim Lin 	if (((u32) status_reg & TEGRA_USB_ADDR_MASK) != TEGRA_USB1_BASE)
428b3f7bf7SJim Lin 		return;
438b3f7bf7SJim Lin 	/* For EHCI_PS_CSC to be cleared in ehci_hcd.c */
448b3f7bf7SJim Lin 	if (ehci_readl(status_reg) & EHCI_PS_CSC)
458b3f7bf7SJim Lin 		*reg |= EHCI_PS_CSC;
468b3f7bf7SJim Lin }
4787f938c9SSimon Glass 
4887f938c9SSimon Glass /*
4987f938c9SSimon Glass  * Create the appropriate control structures to manage
5087f938c9SSimon Glass  * a new EHCI host controller.
5187f938c9SSimon Glass  */
52676ae068SLucas Stach int ehci_hcd_init(int index, struct ehci_hccr **hccr, struct ehci_hcor **hcor)
5387f938c9SSimon Glass {
5487f938c9SSimon Glass 	u32 our_hccr, our_hcor;
5587f938c9SSimon Glass 
5687f938c9SSimon Glass 	/*
5787f938c9SSimon Glass 	 * Select the first port, as we don't have a way of selecting others
5887f938c9SSimon Glass 	 * yet
5987f938c9SSimon Glass 	 */
60*a896211fSLucas Stach 	if (tegrausb_start_port(index, &our_hccr, &our_hcor))
6187f938c9SSimon Glass 		return -1;
6287f938c9SSimon Glass 
63676ae068SLucas Stach 	*hccr = (struct ehci_hccr *)our_hccr;
64676ae068SLucas Stach 	*hcor = (struct ehci_hcor *)our_hcor;
6587f938c9SSimon Glass 
6687f938c9SSimon Glass 	return 0;
6787f938c9SSimon Glass }
6887f938c9SSimon Glass 
6987f938c9SSimon Glass /*
7087f938c9SSimon Glass  * Destroy the appropriate control structures corresponding
7187f938c9SSimon Glass  * the the EHCI host controller.
7287f938c9SSimon Glass  */
73676ae068SLucas Stach int ehci_hcd_stop(int index)
7487f938c9SSimon Glass {
75*a896211fSLucas Stach 	return tegrausb_stop_port(index);
7687f938c9SSimon Glass }
77