4 * ADM5120 specific PCI operations
6 * Copyright (C) ADMtek Incorporated.
7 * Copyright (C) 2005 Jeroen Vreeken (pe1rxq@amsat.org)
8 * Copyright (C) 2007 Gabor Juhos <juhosg@freemail.hu>
9 * Copyright (C) 2007 OpenWrt.org
11 * This program is free software; you can redistribute it and/or
12 * modify it under the terms of the GNU General Public License
13 * as published by the Free Software Foundation; either version 2
14 * of the License, or (at your option) any later version.
16 * This program is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details.
21 * You should have received a copy of the GNU General Public License
22 * along with this program; if not, write to the
23 * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
24 * Boston, MA 02110-1301, USA.
28 #include <linux/types.h>
29 #include <linux/pci.h>
30 #include <linux/kernel.h>
31 #include <linux/init.h>
33 #include <asm/mach-adm5120/adm5120_defs.h>
35 volatile u32* pci_config_address_reg = (volatile u32*)KSEG1ADDR(ADM5120_PCICFG_ADDR);
36 volatile u32* pci_config_data_reg = (volatile u32*)KSEG1ADDR(ADM5120_PCICFG_DATA);
38 #define PCI_ENABLE 0x80000000
40 static int pci_config_read(struct pci_bus *bus, unsigned int devfn, int where,
41 int size, uint32_t *val)
43 *pci_config_address_reg = ((bus->number & 0xff) << 0x10) |
44 ((devfn & 0xff) << 0x08) | (where & 0xfc) | PCI_ENABLE;
47 *val = ((*pci_config_data_reg)>>((where&3)<<3))&0xff;
50 *val = ((*pci_config_data_reg)>>((where&3)<<3))&0xffff;
53 *val = (*pci_config_data_reg);
56 return PCIBIOS_SUCCESSFUL;
59 static int pci_config_write(struct pci_bus *bus, unsigned int devfn, int where,
60 int size, uint32_t val)
62 *pci_config_address_reg = ((bus->number & 0xff) << 0x10) |
63 ((devfn & 0xff) << 0x08) | (where & 0xfc) | PCI_ENABLE;
66 *(volatile u8 *)(((int)pci_config_data_reg) +
70 *(volatile u16 *)(((int)pci_config_data_reg) +
74 *pci_config_data_reg = (val);
77 return PCIBIOS_SUCCESSFUL;
80 struct pci_ops adm5120_pci_ops = {
81 .read = pci_config_read,
82 .write = pci_config_write,