Random fixes for TI pci1x2x / Nokia IP530 / others.
[coreboot.git] / src / drivers / dec / 21143 / 21143.c
1 /*
2  * This file is part of the coreboot project.
3  *
4  * Copyright (C) 2010 Marc Bertens <mbertens@xs4all.nl>
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; either version 2 of the License, or
9  * (at your option) any later version.
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.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program; if not, write to the Free Software
18  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA
19  */
20
21 #include <device/device.h>
22 #include <device/pci_def.h>
23 #include <device/pci.h>
24 #include <device/pci_ids.h>
25 #include <console/console.h>
26
27 /**
28  * The following should be set in the mainboard-specific Kconfig file.
29  */
30 #if (!defined(CONFIG_DEC21143_CACHE_LINE_SIZE) || \
31      !defined(CONFIG_DEC21143_EXPANSION_ROM_BASE_ADDRESS) || \
32      !defined(CONFIG_DEC21143_COMMAND_AND_STATUS_CONFIGURATION))
33 #error "you must supply these values in your mainboard-specific Kconfig file"
34 #endif
35
36 /* CONFIG_DEC21143_CACHE_LINE_SIZE try 0x00000000 if unsure */
37 /* CONFIG_DEC21143_EXPANSION_ROM_BASE_ADDRESS try 0x00000000 if unsure */
38 /* CONFIG_DEC21143_COMMAND_AND_STATUS_CONFIGURATION try 0x02800107 or 0x02800007 if unsure */
39
40 /**
41  * This driver takes the values from Kconfig and loads them in the registers.
42  */
43 static void dec_21143_enable(device_t dev)
44 {
45         printk(BIOS_DEBUG, "Initializing DECchip 21143\n");
46
47         /* Command and status configuration (offset 0x04) */
48         pci_write_config32(dev, 0x04,
49                            CONFIG_DEC21143_COMMAND_AND_STATUS_CONFIGURATION);
50         printk(BIOS_DEBUG, "0x04 = %08x (07 01 80 02)\n",
51                pci_read_config32(dev, 0x04));
52
53         /* Cache line size (offset 0x0C) */
54         pci_write_config8(dev, 0x0C, CONFIG_DEC21143_CACHE_LINE_SIZE);
55         printk(BIOS_DEBUG, "0x0c = %08x (00 80 00 00)\n",
56                pci_read_config32(dev, 0x0C));
57
58         /* Expansion ROM base address (offset 0x30) */
59         pci_write_config32(dev, 0x30,
60                            CONFIG_DEC21143_EXPANSION_ROM_BASE_ADDRESS);
61         printk(BIOS_DEBUG, "0x30 = %08x (0x00000000)\n",
62                pci_read_config32(dev, 0x30));
63 }
64
65 static struct device_operations dec_21143_ops = {
66         .read_resources   = pci_dev_read_resources,
67         .set_resources    = pci_dev_set_resources,
68         .enable_resources = pci_dev_enable_resources,
69         .init             = dec_21143_enable,
70         .scan_bus         = 0,
71 };
72
73 static const struct pci_driver dec_21143_driver __pci_driver = {
74         .ops    = &dec_21143_ops,
75         .vendor = PCI_VENDOR_ID_DEC,
76         .device = PCI_DEVICE_ID_DEC_21142,
77 };