blob: 7a52e1aa50aa73d6270cde3eb03855327ba2e538 [file] [log] [blame]
Zheng Baod0985752011-01-20 04:45:48 +00001/*
2 * This file is part of the coreboot project.
3 *
4 * Copyright (C) 2010 Advanced Micro Devices, Inc.
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; version 2 of the License.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
Zheng Baod0985752011-01-20 04:45:48 +000014 */
Kyösti Mälkki1fd75082013-06-11 16:32:01 +030015
16// Use simple device model for this file even in ramstage
17#define __SIMPLE_DEVICE__
18
Zheng Baod0985752011-01-20 04:45:48 +000019#include <stdint.h>
20#include <arch/io.h>
Kyösti Mälkkie2227a22014-02-05 13:02:55 +020021#include <device/pci_ehci.h>
Zheng Baod0985752011-01-20 04:45:48 +000022#include <device/pci_def.h>
23#include "sb800.h"
24
Kyösti Mälkki021fa782013-08-16 06:34:04 +030025#define DEBUGPORT_MISC_CONTROL 0x80
Zheng Baod0985752011-01-20 04:45:48 +000026
Kyösti Mälkki8101aa62013-08-15 16:27:06 +030027pci_devfn_t pci_ehci_dbg_dev(unsigned int hcd_idx)
Zheng Baod0985752011-01-20 04:45:48 +000028{
Kyösti Mälkkia1179ca2013-09-17 00:12:05 +030029 if (hcd_idx==3)
30 return PCI_DEV(0, 0x16, 2);
31 else if (hcd_idx==2)
32 return PCI_DEV(0, 0x13, 2);
33 else
34 return PCI_DEV(0, 0x12, 2);
Kyösti Mälkki8101aa62013-08-15 16:27:06 +030035}
36
37void pci_ehci_dbg_set_port(pci_devfn_t dev, unsigned int port)
38{
Kevin Paul Herbertbde6d302014-12-24 18:43:20 -080039 u8 *base_regs = pci_ehci_base_regs(dev);
Zheng Baod0985752011-01-20 04:45:48 +000040 u32 reg32;
41
42 /* Write the port number to DEBUGPORT_MISC_CONTROL[31:28]. */
Kyösti Mälkki021fa782013-08-16 06:34:04 +030043 reg32 = read32(base_regs + DEBUGPORT_MISC_CONTROL);
Zheng Baod0985752011-01-20 04:45:48 +000044 reg32 &= ~(0xf << 28);
45 reg32 |= (port << 28);
46 reg32 |= (1 << 27); /* Enable Debug Port port number remapping. */
Kyösti Mälkki021fa782013-08-16 06:34:04 +030047 write32(base_regs + DEBUGPORT_MISC_CONTROL, reg32);
Zheng Baod0985752011-01-20 04:45:48 +000048}
49
50
Kyösti Mälkki8101aa62013-08-15 16:27:06 +030051void pci_ehci_dbg_enable(pci_devfn_t dev, unsigned long base)
Zheng Baod0985752011-01-20 04:45:48 +000052{
Zheng Baob01097e2012-12-14 15:58:15 +080053 /* Enable all of the USB controllers */
54 outb(0xEF, PM_INDEX);
55 outb(0x7F, PM_DATA);
56
Kyösti Mälkki8101aa62013-08-15 16:27:06 +030057 pci_write_config32(dev, EHCI_BAR_INDEX, base);
58 pci_write_config8(dev, PCI_COMMAND, PCI_COMMAND_MEMORY | PCI_COMMAND_MASTER);
Zheng Baod0985752011-01-20 04:45:48 +000059}