1 // SPDX-License-Identifier: GPL-2.0-or-later
3 * read/write operation to the PCI config space of CS5536
5 * Copyright (C) 2007 Lemote, Inc.
6 * Author : jlliu, liujl@lemote.com
8 * Copyright (C) 2009 Lemote, Inc.
9 * Author: Wu Zhangjin, wuzhangjin@gmail.com
11 * the Virtual Support Module(VSM) for virtulizing the PCI
12 * configure space are defined in cs5536_modulename.c respectively,
14 * after this virtulizing, user can access the PCI configure space
15 * directly as a normal multi-function PCI device which follows
19 #include <linux/types.h>
20 #include <cs5536/cs5536_pci.h>
21 #include <cs5536/cs5536_vsm.h>
24 CS5536_FUNC_START = -1,
34 static const cs5536_pci_vsm_write vsm_conf_write[] = {
35 [CS5536_ISA_FUNC] = pci_isa_write_reg,
36 [reserved_func] = NULL,
37 [CS5536_IDE_FUNC] = pci_ide_write_reg,
38 [CS5536_ACC_FUNC] = pci_acc_write_reg,
39 [CS5536_OHCI_FUNC] = pci_ohci_write_reg,
40 [CS5536_EHCI_FUNC] = pci_ehci_write_reg,
43 static const cs5536_pci_vsm_read vsm_conf_read[] = {
44 [CS5536_ISA_FUNC] = pci_isa_read_reg,
45 [reserved_func] = NULL,
46 [CS5536_IDE_FUNC] = pci_ide_read_reg,
47 [CS5536_ACC_FUNC] = pci_acc_read_reg,
48 [CS5536_OHCI_FUNC] = pci_ohci_read_reg,
49 [CS5536_EHCI_FUNC] = pci_ehci_read_reg,
53 * write to PCI config space and transfer it to MSR write.
55 void cs5536_pci_conf_write4(int function, int reg, u32 value)
57 if ((function <= CS5536_FUNC_START) || (function >= CS5536_FUNC_END))
59 if ((reg < 0) || (reg > 0x100) || ((reg & 0x03) != 0))
62 if (vsm_conf_write[function] != NULL)
63 vsm_conf_write[function](reg, value);
67 * read PCI config space and transfer it to MSR access.
69 u32 cs5536_pci_conf_read4(int function, int reg)
73 if ((function <= CS5536_FUNC_START) || (function >= CS5536_FUNC_END))
75 if ((reg < 0) || ((reg & 0x03) != 0))
80 if (vsm_conf_read[function] != NULL)
81 data = vsm_conf_read[function](reg);