~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

TOMOYO Linux Cross Reference
Linux/arch/mips/loongson2ef/common/cs5536/cs5536_ehci.c

Version: ~ [ linux-6.11.5 ] ~ [ linux-6.10.14 ] ~ [ linux-6.9.12 ] ~ [ linux-6.8.12 ] ~ [ linux-6.7.12 ] ~ [ linux-6.6.58 ] ~ [ linux-6.5.13 ] ~ [ linux-6.4.16 ] ~ [ linux-6.3.13 ] ~ [ linux-6.2.16 ] ~ [ linux-6.1.114 ] ~ [ linux-6.0.19 ] ~ [ linux-5.19.17 ] ~ [ linux-5.18.19 ] ~ [ linux-5.17.15 ] ~ [ linux-5.16.20 ] ~ [ linux-5.15.169 ] ~ [ linux-5.14.21 ] ~ [ linux-5.13.19 ] ~ [ linux-5.12.19 ] ~ [ linux-5.11.22 ] ~ [ linux-5.10.228 ] ~ [ linux-5.9.16 ] ~ [ linux-5.8.18 ] ~ [ linux-5.7.19 ] ~ [ linux-5.6.19 ] ~ [ linux-5.5.19 ] ~ [ linux-5.4.284 ] ~ [ linux-5.3.18 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.322 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.336 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.337 ] ~ [ linux-4.4.302 ] ~ [ linux-3.10.108 ] ~ [ linux-2.6.32.71 ] ~ [ linux-2.6.0 ] ~ [ linux-2.4.37.11 ] ~ [ unix-v6-master ] ~ [ ccs-tools-1.8.9 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

  1 // SPDX-License-Identifier: GPL-2.0-or-later
  2 /*
  3  * the EHCI Virtual Support Module of AMD CS5536
  4  *
  5  * Copyright (C) 2007 Lemote, Inc.
  6  * Author : jlliu, liujl@lemote.com
  7  *
  8  * Copyright (C) 2009 Lemote, Inc.
  9  * Author: Wu Zhangjin, wuzhangjin@gmail.com
 10  */
 11 
 12 #include <cs5536/cs5536.h>
 13 #include <cs5536/cs5536_pci.h>
 14 
 15 void pci_ehci_write_reg(int reg, u32 value)
 16 {
 17         u32 hi = 0, lo = value;
 18 
 19         switch (reg) {
 20         case PCI_COMMAND:
 21                 _rdmsr(USB_MSR_REG(USB_EHCI), &hi, &lo);
 22                 if (value & PCI_COMMAND_MASTER)
 23                         hi |= PCI_COMMAND_MASTER;
 24                 else
 25                         hi &= ~PCI_COMMAND_MASTER;
 26 
 27                 if (value & PCI_COMMAND_MEMORY)
 28                         hi |= PCI_COMMAND_MEMORY;
 29                 else
 30                         hi &= ~PCI_COMMAND_MEMORY;
 31                 _wrmsr(USB_MSR_REG(USB_EHCI), hi, lo);
 32                 break;
 33         case PCI_STATUS:
 34                 if (value & PCI_STATUS_PARITY) {
 35                         _rdmsr(SB_MSR_REG(SB_ERROR), &hi, &lo);
 36                         if (lo & SB_PARE_ERR_FLAG) {
 37                                 lo = (lo & 0x0000ffff) | SB_PARE_ERR_FLAG;
 38                                 _wrmsr(SB_MSR_REG(SB_ERROR), hi, lo);
 39                         }
 40                 }
 41                 break;
 42         case PCI_BAR0_REG:
 43                 if (value == PCI_BAR_RANGE_MASK) {
 44                         _rdmsr(GLCP_MSR_REG(GLCP_SOFT_COM), &hi, &lo);
 45                         lo |= SOFT_BAR_EHCI_FLAG;
 46                         _wrmsr(GLCP_MSR_REG(GLCP_SOFT_COM), hi, lo);
 47                 } else if ((value & 0x01) == 0x00) {
 48                         _rdmsr(USB_MSR_REG(USB_EHCI), &hi, &lo);
 49                         lo = value;
 50                         _wrmsr(USB_MSR_REG(USB_EHCI), hi, lo);
 51 
 52                         value &= 0xfffffff0;
 53                         hi = 0x40000000 | ((value & 0xff000000) >> 24);
 54                         lo = 0x000fffff | ((value & 0x00fff000) << 8);
 55                         _wrmsr(GLIU_MSR_REG(GLIU_P2D_BM4), hi, lo);
 56                 }
 57                 break;
 58         case PCI_EHCI_LEGSMIEN_REG:
 59                 _rdmsr(USB_MSR_REG(USB_EHCI), &hi, &lo);
 60                 hi &= 0x003f0000;
 61                 hi |= (value & 0x3f) << 16;
 62                 _wrmsr(USB_MSR_REG(USB_EHCI), hi, lo);
 63                 break;
 64         case PCI_EHCI_FLADJ_REG:
 65                 _rdmsr(USB_MSR_REG(USB_EHCI), &hi, &lo);
 66                 hi &= ~0x00003f00;
 67                 hi |= value & 0x00003f00;
 68                 _wrmsr(USB_MSR_REG(USB_EHCI), hi, lo);
 69                 break;
 70         default:
 71                 break;
 72         }
 73 }
 74 
 75 u32 pci_ehci_read_reg(int reg)
 76 {
 77         u32 conf_data = 0;
 78         u32 hi, lo;
 79 
 80         switch (reg) {
 81         case PCI_VENDOR_ID:
 82                 conf_data =
 83                     CFG_PCI_VENDOR_ID(CS5536_EHCI_DEVICE_ID, CS5536_VENDOR_ID);
 84                 break;
 85         case PCI_COMMAND:
 86                 _rdmsr(USB_MSR_REG(USB_EHCI), &hi, &lo);
 87                 if (hi & PCI_COMMAND_MASTER)
 88                         conf_data |= PCI_COMMAND_MASTER;
 89                 if (hi & PCI_COMMAND_MEMORY)
 90                         conf_data |= PCI_COMMAND_MEMORY;
 91                 break;
 92         case PCI_STATUS:
 93                 conf_data |= PCI_STATUS_66MHZ;
 94                 conf_data |= PCI_STATUS_FAST_BACK;
 95                 _rdmsr(SB_MSR_REG(SB_ERROR), &hi, &lo);
 96                 if (lo & SB_PARE_ERR_FLAG)
 97                         conf_data |= PCI_STATUS_PARITY;
 98                 conf_data |= PCI_STATUS_DEVSEL_MEDIUM;
 99                 break;
100         case PCI_CLASS_REVISION:
101                 _rdmsr(USB_MSR_REG(USB_CAP), &hi, &lo);
102                 conf_data = lo & 0x000000ff;
103                 conf_data |= (CS5536_EHCI_CLASS_CODE << 8);
104                 break;
105         case PCI_CACHE_LINE_SIZE:
106                 conf_data =
107                     CFG_PCI_CACHE_LINE_SIZE(PCI_NORMAL_HEADER_TYPE,
108                                             PCI_NORMAL_LATENCY_TIMER);
109                 break;
110         case PCI_BAR0_REG:
111                 _rdmsr(GLCP_MSR_REG(GLCP_SOFT_COM), &hi, &lo);
112                 if (lo & SOFT_BAR_EHCI_FLAG) {
113                         conf_data = CS5536_EHCI_RANGE |
114                             PCI_BASE_ADDRESS_SPACE_MEMORY;
115                         lo &= ~SOFT_BAR_EHCI_FLAG;
116                         _wrmsr(GLCP_MSR_REG(GLCP_SOFT_COM), hi, lo);
117                 } else {
118                         _rdmsr(USB_MSR_REG(USB_EHCI), &hi, &lo);
119                         conf_data = lo & 0xfffff000;
120                 }
121                 break;
122         case PCI_CARDBUS_CIS:
123                 conf_data = PCI_CARDBUS_CIS_POINTER;
124                 break;
125         case PCI_SUBSYSTEM_VENDOR_ID:
126                 conf_data =
127                     CFG_PCI_VENDOR_ID(CS5536_EHCI_SUB_ID, CS5536_SUB_VENDOR_ID);
128                 break;
129         case PCI_ROM_ADDRESS:
130                 conf_data = PCI_EXPANSION_ROM_BAR;
131                 break;
132         case PCI_CAPABILITY_LIST:
133                 conf_data = PCI_CAPLIST_USB_POINTER;
134                 break;
135         case PCI_INTERRUPT_LINE:
136                 conf_data =
137                     CFG_PCI_INTERRUPT_LINE(PCI_DEFAULT_PIN, CS5536_USB_INTR);
138                 break;
139         case PCI_EHCI_LEGSMIEN_REG:
140                 _rdmsr(USB_MSR_REG(USB_EHCI), &hi, &lo);
141                 conf_data = (hi & 0x003f0000) >> 16;
142                 break;
143         case PCI_EHCI_LEGSMISTS_REG:
144                 _rdmsr(USB_MSR_REG(USB_EHCI), &hi, &lo);
145                 conf_data = (hi & 0x3f000000) >> 24;
146                 break;
147         case PCI_EHCI_FLADJ_REG:
148                 _rdmsr(USB_MSR_REG(USB_EHCI), &hi, &lo);
149                 conf_data = hi & 0x00003f00;
150                 break;
151         default:
152                 break;
153         }
154 
155         return conf_data;
156 }
157 

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

kernel.org | git.kernel.org | LWN.net | Project Home | SVN repository | Mail admin

Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.

sflogo.php