Set up DMA using SMFI
This commit is contained in:
		
							
								
								
									
										7
									
								
								src/board/system76/lemp9/include/board/smfi.h
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										7
									
								
								src/board/system76/lemp9/include/board/smfi.h
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,7 @@
 | 
				
			|||||||
 | 
					#ifndef _BOARD_SMFI_H
 | 
				
			||||||
 | 
					#define _BOARD_SMFI_H
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					void smfi_init(void);
 | 
				
			||||||
 | 
					void smfi_event(void);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#endif // _BOARD_SMFI_H
 | 
				
			||||||
@@ -18,6 +18,7 @@
 | 
				
			|||||||
#include <board/ps2.h>
 | 
					#include <board/ps2.h>
 | 
				
			||||||
#include <board/pwm.h>
 | 
					#include <board/pwm.h>
 | 
				
			||||||
#include <board/smbus.h>
 | 
					#include <board/smbus.h>
 | 
				
			||||||
 | 
					#include <board/smfi.h>
 | 
				
			||||||
#include <board/tcpm.h>
 | 
					#include <board/tcpm.h>
 | 
				
			||||||
#include <common/debug.h>
 | 
					#include <common/debug.h>
 | 
				
			||||||
#include <common/macro.h>
 | 
					#include <common/macro.h>
 | 
				
			||||||
@@ -48,6 +49,7 @@ void init(void) {
 | 
				
			|||||||
    pmc_init();
 | 
					    pmc_init();
 | 
				
			||||||
    pwm_init();
 | 
					    pwm_init();
 | 
				
			||||||
    smbus_init();
 | 
					    smbus_init();
 | 
				
			||||||
 | 
					    smfi_init();
 | 
				
			||||||
    tcpm_init();
 | 
					    tcpm_init();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    //TODO: INTC
 | 
					    //TODO: INTC
 | 
				
			||||||
@@ -119,7 +121,9 @@ void main(void) {
 | 
				
			|||||||
        }
 | 
					        }
 | 
				
			||||||
        // Handles ACPI communication
 | 
					        // Handles ACPI communication
 | 
				
			||||||
        pmc_event(&PMC_1);
 | 
					        pmc_event(&PMC_1);
 | 
				
			||||||
 | 
					        // AP/EC communication over SMFI
 | 
				
			||||||
 | 
					        smfi_event();
 | 
				
			||||||
        // Idle until next timer interrupt
 | 
					        // Idle until next timer interrupt
 | 
				
			||||||
        PCON |= 1;
 | 
					        //Disabled until interrupts used: PCON |= 1;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -41,6 +41,12 @@ void pnp_enable() {
 | 
				
			|||||||
    pnp_write(0x07, 0x05);
 | 
					    pnp_write(0x07, 0x05);
 | 
				
			||||||
    pnp_write(0x30, 0x01);
 | 
					    pnp_write(0x30, 0x01);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    // Enable SMFI
 | 
				
			||||||
 | 
					    pnp_write(0x07, 0x0F);
 | 
				
			||||||
 | 
					    pnp_write(0xF5, 0x00);
 | 
				
			||||||
 | 
					    pnp_write(0xF6, 0x01);
 | 
				
			||||||
 | 
					    pnp_write(0x30, 0x01);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    // Enable SWUC
 | 
					    // Enable SWUC
 | 
				
			||||||
    pnp_write(0x07, 0x04);
 | 
					    pnp_write(0x07, 0x04);
 | 
				
			||||||
    pnp_write(0x30, 0x01);
 | 
					    pnp_write(0x30, 0x01);
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										35
									
								
								src/board/system76/lemp9/smfi.c
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										35
									
								
								src/board/system76/lemp9/smfi.c
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,35 @@
 | 
				
			|||||||
 | 
					#include <stdint.h>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					volatile uint8_t __xdata __at(0x105A) HRAMWC;
 | 
				
			||||||
 | 
					volatile uint8_t __xdata __at(0x105B) HRAMW0BA;
 | 
				
			||||||
 | 
					volatile uint8_t __xdata __at(0x105C) HRAMW1BA;
 | 
				
			||||||
 | 
					volatile uint8_t __xdata __at(0x105D) HRAMW0AAS;
 | 
				
			||||||
 | 
					volatile uint8_t __xdata __at(0x105E) HRAMW1AAS;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					volatile uint8_t __xdata __at(0xC00) smfi_cmd[256];
 | 
				
			||||||
 | 
					volatile uint8_t __xdata __at(0xD00) smfi_dbg[256];
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					void smfi_init(void) {
 | 
				
			||||||
 | 
					    // Semaphore
 | 
				
			||||||
 | 
					    smfi_cmd[0] = 0x00;
 | 
				
			||||||
 | 
					    // Signature
 | 
				
			||||||
 | 
					    smfi_cmd[1] = 0x76;
 | 
				
			||||||
 | 
					    smfi_cmd[2] = 0xEC;
 | 
				
			||||||
 | 
					    // Version
 | 
				
			||||||
 | 
					    smfi_cmd[3] = 0x01;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    // H2RAM window 0 address 0xC00 - 0xCFF, read/write
 | 
				
			||||||
 | 
					    HRAMW0BA = 0xC0;
 | 
				
			||||||
 | 
					    HRAMW0AAS = 0x04;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    // H2RAM window 1 address 0xD00 - 0xDFF, read/write
 | 
				
			||||||
 | 
					    HRAMW1BA = 0xD0;
 | 
				
			||||||
 | 
					    HRAMW0AAS = 0x04;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    // Enable H2RAM window 0 and 1 using LPC I/O
 | 
				
			||||||
 | 
					    HRAMWC |= 0x13;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					void smfi_event(void) {
 | 
				
			||||||
 | 
					    //TODO: when host semaphore occurs, read command
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
		Reference in New Issue
	
	Block a user