Path: blob/master/arch/mips/loongson2ef/common/cs5536/cs5536_pci.c
26495 views
// SPDX-License-Identifier: GPL-2.0-or-later1/*2* read/write operation to the PCI config space of CS55363*4* Copyright (C) 2007 Lemote, Inc.5* Author : jlliu, [email protected]6*7* Copyright (C) 2009 Lemote, Inc.8* Author: Wu Zhangjin, [email protected]9*10* the Virtual Support Module(VSM) for virtulizing the PCI11* configure space are defined in cs5536_modulename.c respectively,12*13* after this virtulizing, user can access the PCI configure space14* directly as a normal multi-function PCI device which follows15* the PCI-2.2 spec.16*/1718#include <linux/types.h>19#include <cs5536/cs5536_pci.h>20#include <cs5536/cs5536_vsm.h>2122enum {23CS5536_FUNC_START = -1,24CS5536_ISA_FUNC,25reserved_func,26CS5536_IDE_FUNC,27CS5536_ACC_FUNC,28CS5536_OHCI_FUNC,29CS5536_EHCI_FUNC,30CS5536_FUNC_END,31};3233static const cs5536_pci_vsm_write vsm_conf_write[] = {34[CS5536_ISA_FUNC] = pci_isa_write_reg,35[reserved_func] = NULL,36[CS5536_IDE_FUNC] = pci_ide_write_reg,37[CS5536_ACC_FUNC] = pci_acc_write_reg,38[CS5536_OHCI_FUNC] = pci_ohci_write_reg,39[CS5536_EHCI_FUNC] = pci_ehci_write_reg,40};4142static const cs5536_pci_vsm_read vsm_conf_read[] = {43[CS5536_ISA_FUNC] = pci_isa_read_reg,44[reserved_func] = NULL,45[CS5536_IDE_FUNC] = pci_ide_read_reg,46[CS5536_ACC_FUNC] = pci_acc_read_reg,47[CS5536_OHCI_FUNC] = pci_ohci_read_reg,48[CS5536_EHCI_FUNC] = pci_ehci_read_reg,49};5051/*52* write to PCI config space and transfer it to MSR write.53*/54void cs5536_pci_conf_write4(int function, int reg, u32 value)55{56if ((function <= CS5536_FUNC_START) || (function >= CS5536_FUNC_END))57return;58if ((reg < 0) || (reg > 0x100) || ((reg & 0x03) != 0))59return;6061if (vsm_conf_write[function] != NULL)62vsm_conf_write[function](reg, value);63}6465/*66* read PCI config space and transfer it to MSR access.67*/68u32 cs5536_pci_conf_read4(int function, int reg)69{70u32 data = 0;7172if ((function <= CS5536_FUNC_START) || (function >= CS5536_FUNC_END))73return 0;74if ((reg < 0) || ((reg & 0x03) != 0))75return 0;76if (reg > 0x100)77return 0xffffffff;7879if (vsm_conf_read[function] != NULL)80data = vsm_conf_read[function](reg);8182return data;83}848586