Stefan Reinauer | 4885daa | 2011-04-26 23:47:04 +0000 | [diff] [blame] | 1 | /* |
| 2 | * This file is part of the coreboot project. |
| 3 | * |
| 4 | * Copyright (C) 2011 Google 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. |
Stefan Reinauer | 4885daa | 2011-04-26 23:47:04 +0000 | [diff] [blame] | 14 | */ |
| 15 | |
| 16 | #include <device/device.h> |
| 17 | #include <device/pci_def.h> |
| 18 | #include <device/pci.h> |
| 19 | #include <device/pci_ids.h> |
| 20 | #include <console/console.h> |
Kyösti Mälkki | 2b95da0 | 2014-02-15 10:19:23 +0200 | [diff] [blame] | 21 | #include <console/uart.h> |
Stefan Reinauer | 4885daa | 2011-04-26 23:47:04 +0000 | [diff] [blame] | 22 | #include <arch/io.h> |
Stefan Reinauer | 4885daa | 2011-04-26 23:47:04 +0000 | [diff] [blame] | 23 | |
Elyes HAOUAS | a26c153 | 2018-05-02 22:02:45 +0200 | [diff] [blame] | 24 | static void oxford_oxpcie_enable(struct device *dev) |
Stefan Reinauer | 4885daa | 2011-04-26 23:47:04 +0000 | [diff] [blame] | 25 | { |
| 26 | printk(BIOS_DEBUG, "Initializing Oxford OXPCIe952\n"); |
| 27 | |
| 28 | struct resource *res = find_resource(dev, 0x10); |
| 29 | if (!res) { |
| 30 | printk(BIOS_WARNING, "OXPCIe952: No UART resource found.\n"); |
| 31 | return; |
| 32 | } |
Kyösti Mälkki | 8517f94 | 2015-03-12 11:33:14 +0200 | [diff] [blame] | 33 | void *bar0 = res2mmio(res, 0, 0); |
Stefan Reinauer | 4885daa | 2011-04-26 23:47:04 +0000 | [diff] [blame] | 34 | |
| 35 | printk(BIOS_DEBUG, "OXPCIe952: Class=%x Revision ID=%x\n", |
Kyösti Mälkki | 8517f94 | 2015-03-12 11:33:14 +0200 | [diff] [blame] | 36 | (read32(bar0) >> 8), (read32(bar0) & 0xff)); |
Stefan Reinauer | 4885daa | 2011-04-26 23:47:04 +0000 | [diff] [blame] | 37 | printk(BIOS_DEBUG, "OXPCIe952: %d UARTs detected.\n", |
Kyösti Mälkki | 8517f94 | 2015-03-12 11:33:14 +0200 | [diff] [blame] | 38 | (read32(bar0 + 4) & 3)); |
Marc Jones | 48c6bae | 2012-07-02 22:31:22 -0600 | [diff] [blame] | 39 | printk(BIOS_DEBUG, "OXPCIe952: UART BAR: 0x%x\n", (u32)res->base); |
Stefan Reinauer | 4885daa | 2011-04-26 23:47:04 +0000 | [diff] [blame] | 40 | } |
| 41 | |
Stefan Reinauer | dfab0f6 | 2011-05-10 12:54:56 -0700 | [diff] [blame] | 42 | |
| 43 | static void oxford_oxpcie_set_resources(struct device *dev) |
| 44 | { |
| 45 | pci_dev_set_resources(dev); |
| 46 | |
Stefan Reinauer | dfab0f6 | 2011-05-10 12:54:56 -0700 | [diff] [blame] | 47 | /* Re-initialize OXPCIe base address after set_resources */ |
Kyösti Mälkki | 2b95da0 | 2014-02-15 10:19:23 +0200 | [diff] [blame] | 48 | u32 mmio_base = pci_read_config32(dev, PCI_BASE_ADDRESS_0); |
| 49 | oxford_remap(mmio_base & ~0xf); |
Stefan Reinauer | dfab0f6 | 2011-05-10 12:54:56 -0700 | [diff] [blame] | 50 | } |
| 51 | |
Stefan Reinauer | 4885daa | 2011-04-26 23:47:04 +0000 | [diff] [blame] | 52 | static struct device_operations oxford_oxpcie_ops = { |
| 53 | .read_resources = pci_dev_read_resources, |
Stefan Reinauer | dfab0f6 | 2011-05-10 12:54:56 -0700 | [diff] [blame] | 54 | .set_resources = oxford_oxpcie_set_resources, |
Stefan Reinauer | 4885daa | 2011-04-26 23:47:04 +0000 | [diff] [blame] | 55 | .enable_resources = pci_dev_enable_resources, |
| 56 | .init = oxford_oxpcie_enable, |
| 57 | .scan_bus = 0, |
| 58 | }; |
| 59 | |
| 60 | static const struct pci_driver oxford_oxpcie_driver __pci_driver = { |
| 61 | .ops = &oxford_oxpcie_ops, |
| 62 | .vendor = 0x1415, |
| 63 | .device = 0xc158, |
| 64 | }; |
Stefan Reinauer | a6087d1 | 2011-05-09 15:19:29 -0700 | [diff] [blame] | 65 | |
| 66 | static const struct pci_driver oxford_oxpcie_driver_2 __pci_driver = { |
| 67 | .ops = &oxford_oxpcie_ops, |
| 68 | .vendor = 0x1415, |
| 69 | .device = 0xc11b, |
| 70 | }; |