3 * some basic access of msr read/write and gpio read/write.
4 * this access function only suitable before the virtual support module(VSM)
5 * working for some simple debugs.
7 * Author : jlliu <liujl@lemote.com>
11 #include <sys/linux/types.h>
12 #include <sys/param.h>
13 #include <sys/device.h>
14 #include <sys/systm.h>
15 #include <sys/malloc.h>
17 #include <dev/pci/pcivar.h>
18 #include <dev/pci/pcireg.h>
19 #include <dev/pci/nppbreg.h>
21 #include <machine/bus.h>
23 #include <include/bonito.h>
24 #include <include/cs5536_pci.h>
28 /******************************************************************************/
31 * rdmsr : read 64bits data from the cs5536 MSR register
33 void _rdmsr(u32 msr
, u32
*hi
, u32
*lo
)
38 addr
= (PCI_BUS_CS5536
<< 16) | (1 << (PCI_IDSEL_CS5536
+ 11) ) | (0 << 8) | 0xf4;
39 BONITO_PCICMD
|= PCI_STATUS_MASTER_ABORT
| PCI_STATUS_MASTER_TARGET_ABORT
;
40 BONITO_PCIMAP_CFG
= (addr
>> 16) | type
;
41 *(volatile pcireg_t
*)PHYS_TO_UNCACHED(BONITO_PCICFG_BASE
| (addr
& 0xfffc)) = msr
;
42 if (BONITO_PCICMD
& PCI_STATUS_MASTER_ABORT
) {
43 BONITO_PCICMD
|= PCI_STATUS_MASTER_ABORT
;
45 if (BONITO_PCICMD
& PCI_STATUS_MASTER_TARGET_ABORT
) {
46 BONITO_PCICMD
|= PCI_STATUS_MASTER_TARGET_ABORT
;
49 addr
= (PCI_BUS_CS5536
<< 16) | (1 << (PCI_IDSEL_CS5536
+ 11) ) | (0 << 8) | 0xf8;
50 BONITO_PCICMD
|= PCI_STATUS_MASTER_ABORT
| PCI_STATUS_MASTER_TARGET_ABORT
;
51 BONITO_PCIMAP_CFG
= (addr
>> 16) | type
;
52 *lo
= *(volatile pcireg_t
*)PHYS_TO_UNCACHED(BONITO_PCICFG_BASE
| (addr
& 0xfffc));
53 if (BONITO_PCICMD
& PCI_STATUS_MASTER_ABORT
) {
54 BONITO_PCICMD
|= PCI_STATUS_MASTER_ABORT
;
56 if (BONITO_PCICMD
& PCI_STATUS_MASTER_TARGET_ABORT
) {
57 BONITO_PCICMD
|= PCI_STATUS_MASTER_TARGET_ABORT
;
60 addr
= (PCI_BUS_CS5536
<< 16) | (1 << (PCI_IDSEL_CS5536
+ 11) ) | (0 << 8) | 0xfc;
61 BONITO_PCICMD
|= PCI_STATUS_MASTER_ABORT
| PCI_STATUS_MASTER_TARGET_ABORT
;
62 BONITO_PCIMAP_CFG
= (addr
>> 16) | type
;
63 *hi
= *(volatile pcireg_t
*)PHYS_TO_UNCACHED(BONITO_PCICFG_BASE
| (addr
& 0xfffc));
64 if (BONITO_PCICMD
& PCI_STATUS_MASTER_ABORT
) {
65 BONITO_PCICMD
|= PCI_STATUS_MASTER_ABORT
;
67 if (BONITO_PCICMD
& PCI_STATUS_MASTER_TARGET_ABORT
) {
68 BONITO_PCICMD
|= PCI_STATUS_MASTER_TARGET_ABORT
;
75 * wrmsr : write 64bits data to the cs5536 MSR register
77 void _wrmsr(u32 msr
, u32 hi
, u32 lo
)
82 addr
= (PCI_BUS_CS5536
<< 16) | (1 << (PCI_IDSEL_CS5536
+ 11) ) | (0 << 8) | 0xf4;
83 BONITO_PCICMD
|= PCI_STATUS_MASTER_ABORT
| PCI_STATUS_MASTER_TARGET_ABORT
;
84 BONITO_PCIMAP_CFG
= (addr
>> 16) | type
;
85 *(volatile pcireg_t
*)PHYS_TO_UNCACHED(BONITO_PCICFG_BASE
| (addr
& 0xfffc)) = msr
;
86 if (BONITO_PCICMD
& PCI_STATUS_MASTER_ABORT
) {
87 BONITO_PCICMD
|= PCI_STATUS_MASTER_ABORT
;
89 if (BONITO_PCICMD
& PCI_STATUS_MASTER_TARGET_ABORT
) {
90 BONITO_PCICMD
|= PCI_STATUS_MASTER_TARGET_ABORT
;
93 addr
= (PCI_BUS_CS5536
<< 16) | (1 << (PCI_IDSEL_CS5536
+ 11) ) | (0 << 8) | 0xf8;
94 BONITO_PCICMD
|= PCI_STATUS_MASTER_ABORT
| PCI_STATUS_MASTER_TARGET_ABORT
;
95 BONITO_PCIMAP_CFG
= (addr
>> 16) | type
;
96 *(volatile pcireg_t
*)PHYS_TO_UNCACHED(BONITO_PCICFG_BASE
| (addr
& 0xfffc)) = lo
;
97 if (BONITO_PCICMD
& PCI_STATUS_MASTER_ABORT
) {
98 BONITO_PCICMD
|= PCI_STATUS_MASTER_ABORT
;
100 if (BONITO_PCICMD
& PCI_STATUS_MASTER_TARGET_ABORT
) {
101 BONITO_PCICMD
|= PCI_STATUS_MASTER_TARGET_ABORT
;
105 addr
= (PCI_BUS_CS5536
<< 16) | (1 << (PCI_IDSEL_CS5536
+ 11) ) | (0 << 8) | 0xfc;
106 BONITO_PCICMD
|= PCI_STATUS_MASTER_ABORT
| PCI_STATUS_MASTER_TARGET_ABORT
;
107 BONITO_PCIMAP_CFG
= (addr
>> 16) | type
;
108 *(volatile pcireg_t
*)PHYS_TO_UNCACHED(BONITO_PCICFG_BASE
| (addr
& 0xfffc)) = hi
;
109 if (BONITO_PCICMD
& PCI_STATUS_MASTER_ABORT
) {
110 BONITO_PCICMD
|= PCI_STATUS_MASTER_ABORT
;
112 if (BONITO_PCICMD
& PCI_STATUS_MASTER_TARGET_ABORT
) {
113 BONITO_PCICMD
|= PCI_STATUS_MASTER_TARGET_ABORT
;