Path: blob/master/arch/mips/loongson/common/cs5536/cs5536_pci.c
10820 views
/*1* read/write operation to the PCI config space of CS55362*3* Copyright (C) 2007 Lemote, Inc.4* Author : jlliu, [email protected]5*6* Copyright (C) 2009 Lemote, Inc.7* Author: Wu Zhangjin, [email protected]8*9* This program is free software; you can redistribute it and/or modify it10* under the terms of the GNU General Public License as published by the11* Free Software Foundation; either version 2 of the License, or (at your12* option) any later version.13*14* the Virtual Support Module(VSM) for virtulizing the PCI15* configure space are defined in cs5536_modulename.c respectively,16*17* after this virtulizing, user can access the PCI configure space18* directly as a normal multi-function PCI device which follows19* the PCI-2.2 spec.20*/2122#include <linux/types.h>23#include <cs5536/cs5536_vsm.h>2425enum {26CS5536_FUNC_START = -1,27CS5536_ISA_FUNC,28reserved_func,29CS5536_IDE_FUNC,30CS5536_ACC_FUNC,31CS5536_OHCI_FUNC,32CS5536_EHCI_FUNC,33CS5536_FUNC_END,34};3536static const cs5536_pci_vsm_write vsm_conf_write[] = {37[CS5536_ISA_FUNC] pci_isa_write_reg,38[reserved_func] NULL,39[CS5536_IDE_FUNC] pci_ide_write_reg,40[CS5536_ACC_FUNC] pci_acc_write_reg,41[CS5536_OHCI_FUNC] pci_ohci_write_reg,42[CS5536_EHCI_FUNC] pci_ehci_write_reg,43};4445static const cs5536_pci_vsm_read vsm_conf_read[] = {46[CS5536_ISA_FUNC] pci_isa_read_reg,47[reserved_func] NULL,48[CS5536_IDE_FUNC] pci_ide_read_reg,49[CS5536_ACC_FUNC] pci_acc_read_reg,50[CS5536_OHCI_FUNC] pci_ohci_read_reg,51[CS5536_EHCI_FUNC] pci_ehci_read_reg,52};5354/*55* write to PCI config space and transfer it to MSR write.56*/57void cs5536_pci_conf_write4(int function, int reg, u32 value)58{59if ((function <= CS5536_FUNC_START) || (function >= CS5536_FUNC_END))60return;61if ((reg < 0) || (reg > 0x100) || ((reg & 0x03) != 0))62return;6364if (vsm_conf_write[function] != NULL)65vsm_conf_write[function](reg, value);66}6768/*69* read PCI config space and transfer it to MSR access.70*/71u32 cs5536_pci_conf_read4(int function, int reg)72{73u32 data = 0;7475if ((function <= CS5536_FUNC_START) || (function >= CS5536_FUNC_END))76return 0;77if ((reg < 0) || ((reg & 0x03) != 0))78return 0;79if (reg > 0x100)80return 0xffffffff;8182if (vsm_conf_read[function] != NULL)83data = vsm_conf_read[function](reg);8485return data;86}878889