blob: 22f730f4ed70795a82a9184cd2d0957c4850a006 [file] [log] [blame]
Zheng Baoeff2ffd2010-03-16 01:38:54 +00001/*
2 * This file is part of the coreboot project.
3 *
4 * Copyright (C) 2010 Advanced Micro Devices, Inc.
Uwe Hermannae3f2b32010-10-02 20:36:26 +00005 * Copyright (C) 2010 Uwe Hermann <uwe@hermann-uwe.de>
Zheng Baoeff2ffd2010-03-16 01:38:54 +00006 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; version 2 of the License.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
Zheng Baoeff2ffd2010-03-16 01:38:54 +000015 */
16
Kyösti Mälkki1fd75082013-06-11 16:32:01 +030017// Use simple device model for this file even in ramstage
18#define __SIMPLE_DEVICE__
19
Uwe Hermanndc3aa7a2010-09-25 23:47:15 +000020#include <stdint.h>
Patrick Georgi5692c572010-10-05 13:40:31 +000021#include <arch/io.h>
Kyösti Mälkkie2227a22014-02-05 13:02:55 +020022#include <device/pci_ehci.h>
Uwe Hermanndc3aa7a2010-09-25 23:47:15 +000023#include <device/pci_def.h>
Patrick Georgi5692c572010-10-05 13:40:31 +000024#include "sb700.h"
Uwe Hermannb015d022010-09-24 18:18:20 +000025
Kyösti Mälkki021fa782013-08-16 06:34:04 +030026#define DEBUGPORT_MISC_CONTROL 0x80
Uwe Hermannae3f2b32010-10-02 20:36:26 +000027
Kyösti Mälkki8101aa62013-08-15 16:27:06 +030028pci_devfn_t pci_ehci_dbg_dev(unsigned int hcd_idx)
Uwe Hermannb015d022010-09-24 18:18:20 +000029{
Elyes HAOUASc021ffe2016-09-18 19:18:56 +020030 if (hcd_idx == 2)
Kyösti Mälkkia1179ca2013-09-17 00:12:05 +030031 return PCI_DEV(0, 0x13, 2);
32 else
33 return PCI_DEV(0, 0x12, 2);
Kyösti Mälkki8101aa62013-08-15 16:27:06 +030034}
35
36void pci_ehci_dbg_set_port(pci_devfn_t dev, unsigned int port)
37{
Kevin Paul Herbertbde6d302014-12-24 18:43:20 -080038 u8 *base_regs = pci_ehci_base_regs(dev);
Uwe Hermannae3f2b32010-10-02 20:36:26 +000039 u32 reg32;
40
41 /* Write the port number to DEBUGPORT_MISC_CONTROL[31:28]. */
Kyösti Mälkki021fa782013-08-16 06:34:04 +030042 reg32 = read32(base_regs + DEBUGPORT_MISC_CONTROL);
Uwe Hermannae3f2b32010-10-02 20:36:26 +000043 reg32 &= ~(0xf << 28);
44 reg32 |= (port << 28);
45 reg32 |= (1 << 27); /* Enable Debug Port port number remapping. */
Kyösti Mälkki021fa782013-08-16 06:34:04 +030046 write32(base_regs + DEBUGPORT_MISC_CONTROL, reg32);
Uwe Hermannb015d022010-09-24 18:18:20 +000047}
48
Kyösti Mälkki8101aa62013-08-15 16:27:06 +030049void pci_ehci_dbg_enable(pci_devfn_t dev, unsigned long base)
Zheng Baoeff2ffd2010-03-16 01:38:54 +000050{
Uwe Hermanndc3aa7a2010-09-25 23:47:15 +000051 /* Set the EHCI BAR address. */
Kyösti Mälkki8101aa62013-08-15 16:27:06 +030052 pci_write_config32(dev, EHCI_BAR_INDEX, base);
Uwe Hermanndc3aa7a2010-09-25 23:47:15 +000053
54 /* Enable access to the EHCI memory space registers. */
55 pci_write_config8(dev, PCI_COMMAND, PCI_COMMAND_MEMORY);
Uwe Hermannae3f2b32010-10-02 20:36:26 +000056
Zheng Baoeff2ffd2010-03-16 01:38:54 +000057}