Linux Kernel  3.7.1
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
cs5536_pci.c
Go to the documentation of this file.
1 /*
2  * read/write operation to the PCI config space of CS5536
3  *
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  * This program is free software; you can redistribute it and/or modify it
11  * under the terms of the GNU General Public License as published by the
12  * Free Software Foundation; either version 2 of the License, or (at your
13  * option) any later version.
14  *
15  * the Virtual Support Module(VSM) for virtulizing the PCI
16  * configure space are defined in cs5536_modulename.c respectively,
17  *
18  * after this virtulizing, user can access the PCI configure space
19  * directly as a normal multi-function PCI device which follows
20  * the PCI-2.2 spec.
21  */
22 
23 #include <linux/types.h>
24 #include <cs5536/cs5536_vsm.h>
25 
26 enum {
35 };
36 
37 static const cs5536_pci_vsm_write vsm_conf_write[] = {
44 };
45 
46 static const cs5536_pci_vsm_read vsm_conf_read[] = {
53 };
54 
55 /*
56  * write to PCI config space and transfer it to MSR write.
57  */
58 void cs5536_pci_conf_write4(int function, int reg, u32 value)
59 {
60  if ((function <= CS5536_FUNC_START) || (function >= CS5536_FUNC_END))
61  return;
62  if ((reg < 0) || (reg > 0x100) || ((reg & 0x03) != 0))
63  return;
64 
65  if (vsm_conf_write[function] != NULL)
66  vsm_conf_write[function](reg, value);
67 }
68 
69 /*
70  * read PCI config space and transfer it to MSR access.
71  */
72 u32 cs5536_pci_conf_read4(int function, int reg)
73 {
74  u32 data = 0;
75 
76  if ((function <= CS5536_FUNC_START) || (function >= CS5536_FUNC_END))
77  return 0;
78  if ((reg < 0) || ((reg & 0x03) != 0))
79  return 0;
80  if (reg > 0x100)
81  return 0xffffffff;
82 
83  if (vsm_conf_read[function] != NULL)
84  data = vsm_conf_read[function](reg);
85 
86  return data;
87 }