diff options
author | Iru Cai <mytbk920423@gmail.com> | 2018-12-22 01:19:41 +0800 |
---|---|---|
committer | Iru Cai <mytbk920423@gmail.com> | 2019-11-17 15:10:43 +0800 |
commit | f18e603d3ceab10993d9c3724c5ee2df6c7584f0 (patch) | |
tree | 2d5792256d63a33171f869e10a7837ea41d263dd | |
parent | 7469a7a4d100ec291fe95a1bd42a17b77acfa962 (diff) | |
download | coreboot-f18e603d3ceab10993d9c3724c5ee2df6c7584f0.tar.xz |
load_usb
-rw-r--r-- | src/northbridge/intel/haswell/do_raminit_frag.c | 29 | ||||
-rw-r--r-- | src/northbridge/intel/haswell/mrc.asm | 257 | ||||
-rw-r--r-- | src/northbridge/intel/haswell/pei_usb.h | 33 |
3 files changed, 73 insertions, 246 deletions
diff --git a/src/northbridge/intel/haswell/do_raminit_frag.c b/src/northbridge/intel/haswell/do_raminit_frag.c index 65226e069d..977521394e 100644 --- a/src/northbridge/intel/haswell/do_raminit_frag.c +++ b/src/northbridge/intel/haswell/do_raminit_frag.c @@ -6,6 +6,8 @@ #include "mrc_smbus.h" #include "mrc_pch_init.h" #include <console/console.h> +#include "pei_data.h" +#include "pei_usb.h" static void io_fffa3c2e(void) { @@ -200,3 +202,30 @@ void io_fffa4c0d(void) pci_update_config32(PCI_DEV(0, 1, 0), 0x91c, 0xc7ffffff, 0x28000000); pci_update_config32(PCI_DEV(0, 1, 0), 0x93c, 0xc7ffffff, 0x28000000); } + +void load_usb(PEI_USB *pusb, struct pei_data *pd); +void load_usb(PEI_USB *pusb, struct pei_data *pd) +{ + memset(pusb, 0, sizeof(pusb)); + + pusb->v0 = 1; + + for (int i = 0; i < 14; i++) { + pusb->ehci_settings[i].enable = pd->usb2_ports[i].enable; + pusb->ehci_settings[i].location = pd->usb2_ports[i].location; + pusb->ehci_settings[i].length = pd->usb2_ports[i].length; + } + + for (int i = 0; i < 14; i++) + pusb->ehci_oc[i] = pd->usb2_ports[i].over_current_pin; + + for (int i = 0; i < 6; i++) + pusb->xhci_oc[i] = pd->usb3_ports[i].over_current_pin; + + for (int i = 0; i < 6; i++) + pusb->xhci_en[i] = pd->usb3_ports[i].enable; + + pusb->xhci_resume_info[0] = 1; + pusb->xhci_resume_info[1] = 1; + pusb->xhci_resume_info[2] = 2; +} diff --git a/src/northbridge/intel/haswell/mrc.asm b/src/northbridge/intel/haswell/mrc.asm index d71f37ee5e..46a9ebfd8d 100644 --- a/src/northbridge/intel/haswell/mrc.asm +++ b/src/northbridge/intel/haswell/mrc.asm @@ -148,6 +148,7 @@ extern io_fffa45f1 extern io_fffa476b extern io_fffa49a0 extern io_fffa4c0d +extern load_usb mrc_entry: mov ecx, esp @@ -2385,258 +2386,22 @@ mov dword [ebp - 0x604], eax mov eax, ebx rep stosd ; rep stosd dword es:[edi], eax mov al, dl -lea edi, [ebp - 0x403] -mov cl, 0xc3 -rep stosb ; rep stosb byte es:[edi], al -mov byte [ebp - 0x403], 1 -mov eax, dword [ebp - 0x63c] + +; clear the whole PEI_USB struct +; then fill the PEI_USB struct +push dword [ebp - 0x63c] +lea eax, [ebp - 0x403] +push eax +call load_usb +add esp, 8 +xor edx, edx + lea edi, [ebp - 0x632] -mov cl, byte [eax + 0x74] -mov al, byte [ebp - 0x402] -and ecx, 1 -and eax, 0xfffffffe -or eax, ecx -mov ecx, dword [ebp - 0x63c] -mov byte [ebp - 0x402], al -mov al, byte [ecx + 0x76] -mov byte [ebp - 0x401], al -mov ax, word [ecx + 0x72] -mov word [ebp - 0x400], ax -mov cl, byte [ecx + 0x79] -mov al, byte [ebp - 0x3fc] -and ecx, 1 -and eax, 0xfffffffe -or eax, ecx -mov ecx, dword [ebp - 0x63c] -mov byte [ebp - 0x3fc], al -mov al, byte [ecx + 0x7b] -mov byte [ebp - 0x3fb], al -mov ax, word [ecx + 0x77] -mov word [ebp - 0x3fa], ax -mov cl, byte [ecx + 0x7e] -mov al, byte [ebp - 0x3f6] -and ecx, 1 -and eax, 0xfffffffe -or eax, ecx -mov ecx, dword [ebp - 0x63c] -mov byte [ebp - 0x3f6], al -mov al, byte [ecx + 0x80] -mov byte [ebp - 0x3f5], al -mov ax, word [ecx + 0x7c] -mov word [ebp - 0x3f4], ax -mov cl, byte [ecx + 0x83] -mov al, byte [ebp - 0x3f0] -and ecx, 1 -and eax, 0xfffffffe -or eax, ecx -mov ecx, dword [ebp - 0x63c] -mov byte [ebp - 0x3f0], al -mov al, byte [ecx + 0x85] -mov byte [ebp - 0x3ef], al -mov ax, word [ecx + 0x81] -mov word [ebp - 0x3ee], ax -mov cl, byte [ecx + 0x88] -mov al, byte [ebp - 0x3ea] -and ecx, 1 -and eax, 0xfffffffe -or eax, ecx -mov byte [ebp - 0x3ea], al -mov ecx, dword [ebp - 0x63c] -mov al, byte [ecx + 0x8a] -mov byte [ebp - 0x3e9], al -mov ax, word [ecx + 0x86] -mov word [ebp - 0x3e8], ax -mov cl, byte [ecx + 0x8d] -mov al, byte [ebp - 0x3e4] -and ecx, 1 -and eax, 0xfffffffe -or eax, ecx -mov ecx, dword [ebp - 0x63c] -mov byte [ebp - 0x3e4], al -mov al, byte [ecx + 0x8f] -mov byte [ebp - 0x3e3], al -mov ax, word [ecx + 0x8b] -mov word [ebp - 0x3e2], ax -mov cl, byte [ecx + 0x92] -mov al, byte [ebp - 0x3de] -and ecx, 1 -and eax, 0xfffffffe -or eax, ecx -mov ecx, dword [ebp - 0x63c] -mov byte [ebp - 0x3de], al -mov al, byte [ecx + 0x94] -mov byte [ebp - 0x3dd], al -mov ax, word [ecx + 0x90] -mov word [ebp - 0x3dc], ax -mov cl, byte [ecx + 0x97] -mov al, byte [ebp - 0x3d8] -and ecx, 1 -and eax, 0xfffffffe -or eax, ecx -mov ecx, dword [ebp - 0x63c] -mov byte [ebp - 0x3d8], al -mov al, byte [ecx + 0x99] -mov byte [ebp - 0x3d7], al -mov ax, word [ecx + 0x95] -mov word [ebp - 0x3d6], ax -mov cl, byte [ecx + 0x9c] -mov al, byte [ebp - 0x3d2] -and ecx, 1 -and eax, 0xfffffffe -or eax, ecx -mov ecx, dword [ebp - 0x63c] -mov byte [ebp - 0x3d2], al -mov al, byte [ecx + 0x9e] -mov byte [ebp - 0x3d1], al -mov ax, word [ecx + 0x9a] -mov word [ebp - 0x3d0], ax -mov cl, byte [ecx + 0xa1] -mov al, byte [ebp - 0x3cc] -and ecx, 1 -and eax, 0xfffffffe -or eax, ecx -mov ecx, dword [ebp - 0x63c] -mov byte [ebp - 0x3cc], al -mov al, byte [ecx + 0xa3] -mov byte [ebp - 0x3cb], al -mov ax, word [ecx + 0x9f] -mov word [ebp - 0x3ca], ax -mov cl, byte [ecx + 0xa6] -mov al, byte [ebp - 0x3c6] -and ecx, 1 -and eax, 0xfffffffe -or eax, ecx -mov ecx, dword [ebp - 0x63c] -mov byte [ebp - 0x3c6], al -mov al, byte [ecx + 0xa8] -mov byte [ebp - 0x3c5], al -mov ax, word [ecx + 0xa4] -mov word [ebp - 0x3c4], ax -mov cl, byte [ecx + 0xab] -mov al, byte [ebp - 0x3c0] -and ecx, 1 -and eax, 0xfffffffe -or eax, ecx -mov ecx, dword [ebp - 0x63c] -mov byte [ebp - 0x3c0], al -mov al, byte [ecx + 0xad] -mov byte [ebp - 0x3bf], al -mov ax, word [ecx + 0xa9] -mov word [ebp - 0x3be], ax -mov cl, byte [ecx + 0xb0] -mov al, byte [ebp - 0x3ba] -and ecx, 1 -and eax, 0xfffffffe -or eax, ecx -mov ecx, dword [ebp - 0x63c] -mov byte [ebp - 0x3ba], al -mov al, byte [ecx + 0xb2] -mov byte [ebp - 0x3b9], al -mov ax, word [ecx + 0xae] -mov word [ebp - 0x3b8], ax -mov al, byte [ebp - 0x3b4] -mov cl, byte [ecx + 0xb5] -and eax, 0xfffffffe -and ecx, 1 -or byte [ebp - 0x3ae], 1 -or eax, ecx -mov ecx, dword [ebp - 0x63c] -mov byte [ebp - 0x3b4], al -or byte [ebp - 0x3ad], 1 -mov al, byte [ecx + 0xb7] -mov byte [ebp - 0x3b3], al -mov ax, word [ecx + 0xb3] -mov word [ebp - 0x3b2], ax -mov al, byte [ebp - 0x3ac] -and eax, 0xfffffffc -or eax, 2 -mov byte [ebp - 0x3ac], al -movzx eax, byte [ecx + 0x75] -mov dword [ebp - 0x397], eax -movzx eax, byte [ecx + 0x7a] -mov dword [ebp - 0x393], eax -movzx eax, byte [ecx + 0x7f] -mov dword [ebp - 0x38f], eax -movzx eax, byte [ecx + 0x84] -mov dword [ebp - 0x38b], eax -movzx eax, byte [ecx + 0x89] -mov dword [ebp - 0x387], eax -movzx eax, byte [ecx + 0x8e] -mov dword [ebp - 0x383], eax -movzx eax, byte [ecx + 0x93] -mov dword [ebp - 0x37f], eax -movzx eax, byte [ecx + 0x98] -mov dword [ebp - 0x37b], eax -movzx eax, byte [ecx + 0x9d] -mov dword [ebp - 0x377], eax -movzx eax, byte [ecx + 0xa2] -mov dword [ebp - 0x373], eax -movzx eax, byte [ecx + 0xa7] -mov dword [ebp - 0x36f], eax -movzx eax, byte [ecx + 0xac] -mov dword [ebp - 0x36b], eax -movzx eax, byte [ecx + 0xb1] -mov dword [ebp - 0x367], eax -movzx eax, byte [ecx + 0xb6] -mov dword [ebp - 0x363], eax -movzx eax, byte [ecx + 0xc3] -mov dword [ebp - 0x35f], eax -movzx eax, byte [ecx + 0xc5] -mov dword [ebp - 0x35b], eax -movzx eax, byte [ecx + 0xc7] -mov dword [ebp - 0x357], eax -movzx eax, byte [ecx + 0xc9] -mov dword [ebp - 0x353], eax -movzx eax, byte [ecx + 0xcb] -mov dword [ebp - 0x34f], eax -movzx eax, byte [ecx + 0xcd] -mov cl, byte [ecx + 0xc2] -mov dword [ebp - 0x34b], eax -mov al, byte [ebp - 0x346] -and ecx, 1 -and eax, 0xfffffffe -or eax, ecx -mov byte [ebp - 0x346], al -mov eax, dword [ebp - 0x63c] -mov cl, byte [eax + 0xc4] -mov al, byte [ebp - 0x345] -and ecx, 1 -and eax, 0xfffffffe -or eax, ecx -mov byte [ebp - 0x345], al -mov eax, dword [ebp - 0x63c] -mov cl, byte [eax + 0xc6] -mov al, byte [ebp - 0x344] -and ecx, 1 -and eax, 0xfffffffe -or eax, ecx -mov byte [ebp - 0x344], al -mov eax, dword [ebp - 0x63c] -mov cl, byte [eax + 0xc8] -mov al, byte [ebp - 0x343] -and ecx, 1 -and eax, 0xfffffffe -or eax, ecx -mov byte [ebp - 0x343], al -mov eax, dword [ebp - 0x63c] mov byte [ebp - 0x4c0], 3 mov byte [ebp - 0x4bf], 0 mov dword [ebp - 0x4aa], 0 mov byte [ebp - 0x565], 4 -mov cl, byte [eax + 0xca] -mov al, byte [ebp - 0x342] -and ecx, 1 -and eax, 0xfffffffe -or eax, ecx -mov byte [ebp - 0x342], al -mov eax, dword [ebp - 0x63c] -mov cl, byte [eax + 0xcc] -mov al, byte [ebp - 0x341] -and ecx, 1 -and eax, 0xfffffffe -or eax, ecx mov ecx, 3 -mov byte [ebp - 0x341], al mov eax, dword [ebp - 0x63c] cmp dword [eax + 0x46], 0 mov al, dl diff --git a/src/northbridge/intel/haswell/pei_usb.h b/src/northbridge/intel/haswell/pei_usb.h new file mode 100644 index 0000000000..f46831317a --- /dev/null +++ b/src/northbridge/intel/haswell/pei_usb.h @@ -0,0 +1,33 @@ +struct _PEI_EHCI { + uint8_t enable; + uint8_t location; + uint16_t length; + uint8_t f4; + uint8_t f5; +} __packed; + +typedef struct _PEI_EHCI PEI_EHCI; + +struct _PEI_USB +{ + uint8_t v0; // 0x0 + PEI_EHCI ehci_settings[14]; // 0x1 + uint8_t xhci_resume_info[23]; // 0x55 + uint32_t ehci_oc[14]; // 0x6c + uint32_t xhci_oc[6]; // 0xa4 + uint8_t unk; + uint8_t xhci_en[6]; // 0xbd +} __packed; + +typedef struct _PEI_USB PEI_USB; + +struct _EFI_USB_PPI +{ + uint8_t v0; + PEI_USB *usb_pei_data; + uint8_t v1; + uint32_t ehci_bar0; + uint32_t port; + uint32_t ehci_bar1; +} __packed; +typedef struct _EFI_USB_PPI EFI_USB_PPI; |