Organize into arch, board, and ec modules
This commit is contained in:
@ -1,7 +1,7 @@
|
|||||||
#include <8051.h>
|
#include <8051.h>
|
||||||
|
|
||||||
#include "include/delay.h"
|
#include <arch/delay.h>
|
||||||
#include "include/timer.h"
|
#include <arch/timer.h>
|
||||||
|
|
||||||
// One millisecond in ticks is determined as follows:
|
// One millisecond in ticks is determined as follows:
|
||||||
// 9.2 MHz is the clock rate
|
// 9.2 MHz is the clock rate
|
6
src/arch/8051/include/arch/delay.h
Normal file
6
src/arch/8051/include/arch/delay.h
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
#ifndef _ARCH_DELAY_H
|
||||||
|
#define _ARCH_DELAY_H
|
||||||
|
|
||||||
|
void delay_ms(int ms);
|
||||||
|
|
||||||
|
#endif // _ARCH_DELAY_H
|
6
src/arch/8051/include/arch/reset.h
Normal file
6
src/arch/8051/include/arch/reset.h
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
#ifndef _ARCH_RESET_H
|
||||||
|
#define _ARCH_RESET_H
|
||||||
|
|
||||||
|
void reset(void);
|
||||||
|
|
||||||
|
#endif // _ARCH_RESET_H
|
@ -1,8 +1,8 @@
|
|||||||
#ifndef _TIMER_H_
|
#ifndef _ARCH_TIMER_H
|
||||||
#define _TIMER_H_
|
#define _ARCH_TIMER_H
|
||||||
|
|
||||||
void timer_mode_1(int value);
|
void timer_mode_1(int value);
|
||||||
void timer_wait(void);
|
void timer_wait(void);
|
||||||
void timer_stop(void);
|
void timer_stop(void);
|
||||||
|
|
||||||
#endif // _TIMER_H_
|
#endif // _ARCH_TIMER_H
|
@ -1,4 +1,4 @@
|
|||||||
#include "include/reset.h"
|
#include <arch/reset.h>
|
||||||
|
|
||||||
void reset(void) {
|
void reset(void) {
|
||||||
__asm__("ljmp 0");
|
__asm__("ljmp 0");
|
@ -1,6 +1,6 @@
|
|||||||
#include <8051.h>
|
#include <8051.h>
|
||||||
|
|
||||||
#include "include/timer.h"
|
#include <arch/timer.h>
|
||||||
|
|
||||||
void timer_mode_1(int value) {
|
void timer_mode_1(int value) {
|
||||||
timer_stop();
|
timer_stop();
|
@ -1,5 +1,5 @@
|
|||||||
#ifndef UART_H
|
#ifndef _ARCH_UART_H
|
||||||
#define UART_H
|
#define _ARCH_UART_H
|
||||||
|
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
|
||||||
@ -28,4 +28,7 @@ unsigned char uart_can_write(struct Uart * uart);
|
|||||||
unsigned char uart_read(struct Uart * uart);
|
unsigned char uart_read(struct Uart * uart);
|
||||||
void uart_write(struct Uart * uart, unsigned char data);
|
void uart_write(struct Uart * uart, unsigned char data);
|
||||||
|
|
||||||
#endif // UART_H
|
extern struct Uart * uart_stdio;
|
||||||
|
void uart_stdio_init(int num, unsigned long baud);
|
||||||
|
|
||||||
|
#endif // _ARCH_UART_H
|
@ -1,8 +1,8 @@
|
|||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <avr/io.h>
|
#include <avr/io.h>
|
||||||
|
|
||||||
#include "include/cpu.h"
|
#include <arch/uart.h>
|
||||||
#include "include/uart.h"
|
#include <board/cpu.h>
|
||||||
|
|
||||||
#define UART(N) \
|
#define UART(N) \
|
||||||
{ \
|
{ \
|
||||||
@ -72,3 +72,28 @@ void uart_write(struct Uart * uart, unsigned char data) {
|
|||||||
while (!uart_can_write(uart)) ;
|
while (!uart_can_write(uart)) ;
|
||||||
*(uart->data) = data;
|
*(uart->data) = data;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
struct Uart * uart_stdio = NULL;
|
||||||
|
|
||||||
|
int uart_stdio_get(FILE * stream) {
|
||||||
|
return (int)uart_read(uart_stdio);
|
||||||
|
}
|
||||||
|
|
||||||
|
int uart_stdio_put(char data, FILE * stream) {
|
||||||
|
if (data == '\n') {
|
||||||
|
uart_write(uart_stdio, '\r');
|
||||||
|
}
|
||||||
|
uart_write(uart_stdio, (unsigned char)data);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
FILE uart_stdio_file = FDEV_SETUP_STREAM(uart_stdio_put, uart_stdio_get, _FDEV_SETUP_RW);
|
||||||
|
|
||||||
|
void uart_stdio_init(int num, unsigned long baud) {
|
||||||
|
struct Uart * uart = uart_new(num);
|
||||||
|
if(uart != NULL) {
|
||||||
|
uart_init(uart, baud);
|
||||||
|
uart_stdio = uart;
|
||||||
|
stdin = stdout = stderr = &uart_stdio_file;
|
||||||
|
}
|
||||||
|
}
|
6
src/board/arduino/mega2560/include/board/cpu.h
Normal file
6
src/board/arduino/mega2560/include/board/cpu.h
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
#ifndef _BOARD_CPU_H
|
||||||
|
#define _BOARD_CPU_H
|
||||||
|
|
||||||
|
#define F_CPU 16000000ULL
|
||||||
|
|
||||||
|
#endif // _BOARD_CPU_H
|
@ -1,6 +0,0 @@
|
|||||||
#ifndef CPU_H
|
|
||||||
#define CPU_H
|
|
||||||
|
|
||||||
#define F_CPU 16000000ULL
|
|
||||||
|
|
||||||
#endif // CPU_H
|
|
@ -1,7 +0,0 @@
|
|||||||
#ifndef STDIO_H
|
|
||||||
#define STDIO_H
|
|
||||||
|
|
||||||
extern struct Uart * stdio_uart;
|
|
||||||
void stdio_init(int num, unsigned long baud);
|
|
||||||
|
|
||||||
#endif // STDIO_H
|
|
@ -1,9 +1,9 @@
|
|||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
||||||
#include "include/stdio.h"
|
#include <arch/uart.h>
|
||||||
|
|
||||||
void init(void) {
|
void init(void) {
|
||||||
stdio_init(0, 9600);
|
uart_stdio_init(0, 9600);
|
||||||
}
|
}
|
||||||
|
|
||||||
void main(void) {
|
void main(void) {
|
||||||
|
@ -1,29 +0,0 @@
|
|||||||
#include <stdio.h>
|
|
||||||
|
|
||||||
#include "include/stdio.h"
|
|
||||||
#include "include/uart.h"
|
|
||||||
|
|
||||||
struct Uart * stdio_uart = NULL;
|
|
||||||
|
|
||||||
int stdio_get(FILE * stream) {
|
|
||||||
return (int)uart_read(stdio_uart);
|
|
||||||
}
|
|
||||||
|
|
||||||
int stdio_put(char data, FILE * stream) {
|
|
||||||
if (data == '\n') {
|
|
||||||
uart_write(stdio_uart, '\r');
|
|
||||||
}
|
|
||||||
uart_write(stdio_uart, (unsigned char)data);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
FILE stdio_file = FDEV_SETUP_STREAM(stdio_put, stdio_get, _FDEV_SETUP_RW);
|
|
||||||
|
|
||||||
void stdio_init(int num, unsigned long baud) {
|
|
||||||
struct Uart * uart = uart_new(num);
|
|
||||||
if(uart != NULL) {
|
|
||||||
uart_init(uart, baud);
|
|
||||||
stdio_uart = uart;
|
|
||||||
stdin = stdout = stderr = &stdio_file;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,6 +1,6 @@
|
|||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
||||||
#include "include/acpi.h"
|
#include <board/acpi.h>
|
||||||
|
|
||||||
uint8_t acpi_read(uint8_t addr) {
|
uint8_t acpi_read(uint8_t addr) {
|
||||||
uint8_t data = 0;
|
uint8_t data = 0;
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
#include "include/gctrl.h"
|
#include <board/gctrl.h>
|
||||||
|
|
||||||
void gctrl_init(void) {
|
void gctrl_init(void) {
|
||||||
SPCTRL1 = 0x03;
|
SPCTRL1 = 0x03;
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
||||||
#include "include/gpio.h"
|
#include <board/gpio.h>
|
||||||
|
|
||||||
void gpio_init() {
|
void gpio_init() {
|
||||||
// Enable LPC reset on GPD2
|
// Enable LPC reset on GPD2
|
||||||
|
@ -1,9 +1,9 @@
|
|||||||
#ifndef _ACPI_H_
|
#ifndef _BOARD_ACPI_H
|
||||||
#define _ACPI_H_
|
#define _BOARD_ACPI_H
|
||||||
|
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
|
||||||
uint8_t acpi_read(uint8_t addr);
|
uint8_t acpi_read(uint8_t addr);
|
||||||
void acpi_write(uint8_t addr, uint8_t data);
|
void acpi_write(uint8_t addr, uint8_t data);
|
||||||
|
|
||||||
#endif // _ACPI_H_
|
#endif // _BOARD_ACPI_H
|
8
src/board/system76/galp3-c/include/board/gctrl.h
Normal file
8
src/board/system76/galp3-c/include/board/gctrl.h
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
#ifndef _BOARD_GCTRL_H
|
||||||
|
#define _BOARD_GCTRL_H
|
||||||
|
|
||||||
|
#include <ec/gctrl.h>
|
||||||
|
|
||||||
|
void gctrl_init(void);
|
||||||
|
|
||||||
|
#endif // _BOARD_GCTRL_H
|
9
src/board/system76/galp3-c/include/board/gpio.h
Normal file
9
src/board/system76/galp3-c/include/board/gpio.h
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
#ifndef _BOARD_GPIO_H
|
||||||
|
#define _BOARD_GPIO_H
|
||||||
|
|
||||||
|
#include <ec/gpio.h>
|
||||||
|
|
||||||
|
void gpio_init(void);
|
||||||
|
void gpio_debug(void);
|
||||||
|
|
||||||
|
#endif // _BOARD_GPIO_H
|
8
src/board/system76/galp3-c/include/board/kbc.h
Normal file
8
src/board/system76/galp3-c/include/board/kbc.h
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
#ifndef _BOARD_KBC_H
|
||||||
|
#define _BOARD_KBC_H
|
||||||
|
|
||||||
|
#include <ec/kbc.h>
|
||||||
|
|
||||||
|
void kbc_init(void);
|
||||||
|
|
||||||
|
#endif // _BOARD_KBC_H
|
8
src/board/system76/galp3-c/include/board/kbscan.h
Normal file
8
src/board/system76/galp3-c/include/board/kbscan.h
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
#ifndef _BOARD_KBSCAN_H
|
||||||
|
#define _BOARD_KBSCAN_H
|
||||||
|
|
||||||
|
#include <ec/kbscan.h>
|
||||||
|
|
||||||
|
void kbscan_init(void);
|
||||||
|
|
||||||
|
#endif // _BOARD_KBSCAN_H
|
8
src/board/system76/galp3-c/include/board/pmc.h
Normal file
8
src/board/system76/galp3-c/include/board/pmc.h
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
#ifndef _BOARD_PMC_H
|
||||||
|
#define _BOARD_PMC_H
|
||||||
|
|
||||||
|
#include <ec/pmc.h>
|
||||||
|
|
||||||
|
void pmc_init(void);
|
||||||
|
|
||||||
|
#endif // _BOARD_PMC_H
|
8
src/board/system76/galp3-c/include/board/ps2.h
Normal file
8
src/board/system76/galp3-c/include/board/ps2.h
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
#ifndef _BOARD_PS2_H
|
||||||
|
#define _BOARD_PS2_H
|
||||||
|
|
||||||
|
#include <ec/ps2.h>
|
||||||
|
|
||||||
|
void ps2_init(void);
|
||||||
|
|
||||||
|
#endif // _BOARD_PS2_H
|
@ -1,6 +0,0 @@
|
|||||||
#ifndef _DELAY_H_
|
|
||||||
#define _DELAY_H_
|
|
||||||
|
|
||||||
void delay_ms(int ms);
|
|
||||||
|
|
||||||
#endif // _DELAY_H_
|
|
@ -1,10 +0,0 @@
|
|||||||
#ifndef _GCTRL_H_
|
|
||||||
#define _GCTRL_H_
|
|
||||||
|
|
||||||
void gctrl_init(void);
|
|
||||||
|
|
||||||
__xdata volatile unsigned char __at(0x2006) RSTS;
|
|
||||||
__xdata volatile unsigned char __at(0x200A) BADRSEL;
|
|
||||||
__xdata volatile unsigned char __at(0x200D) SPCTRL1;
|
|
||||||
|
|
||||||
#endif // _GCTRL_H_
|
|
@ -1,143 +0,0 @@
|
|||||||
#ifndef _GPIO_H_
|
|
||||||
#define _GPIO_H_
|
|
||||||
|
|
||||||
void gpio_init(void);
|
|
||||||
void gpio_debug(void);
|
|
||||||
|
|
||||||
__xdata volatile unsigned char __at(0x1600) GCR;
|
|
||||||
|
|
||||||
__xdata volatile unsigned char __at(0x1601) GPDRA;
|
|
||||||
__xdata volatile unsigned char __at(0x1602) GPDRB;
|
|
||||||
__xdata volatile unsigned char __at(0x1603) GPDRC;
|
|
||||||
__xdata volatile unsigned char __at(0x1604) GPDRD;
|
|
||||||
__xdata volatile unsigned char __at(0x1605) GPDRE;
|
|
||||||
__xdata volatile unsigned char __at(0x1606) GPDRF;
|
|
||||||
__xdata volatile unsigned char __at(0x1607) GPDRG;
|
|
||||||
__xdata volatile unsigned char __at(0x1608) GPDRH;
|
|
||||||
__xdata volatile unsigned char __at(0x1609) GPDRI;
|
|
||||||
__xdata volatile unsigned char __at(0x160A) GPDRJ;
|
|
||||||
__xdata volatile unsigned char __at(0x160D) GPDRM;
|
|
||||||
|
|
||||||
__xdata volatile unsigned char __at(0x1661) GPDMRA;
|
|
||||||
__xdata volatile unsigned char __at(0x1662) GPDMRB;
|
|
||||||
__xdata volatile unsigned char __at(0x1663) GPDMRC;
|
|
||||||
__xdata volatile unsigned char __at(0x1664) GPDMRD;
|
|
||||||
__xdata volatile unsigned char __at(0x1665) GPDMRE;
|
|
||||||
__xdata volatile unsigned char __at(0x1666) GPDMRF;
|
|
||||||
__xdata volatile unsigned char __at(0x1667) GPDMRG;
|
|
||||||
__xdata volatile unsigned char __at(0x1668) GPDMRH;
|
|
||||||
__xdata volatile unsigned char __at(0x1669) GPDMRI;
|
|
||||||
__xdata volatile unsigned char __at(0x166A) GPDMRJ;
|
|
||||||
__xdata volatile unsigned char __at(0x166D) GPDMRM;
|
|
||||||
|
|
||||||
__xdata volatile unsigned char __at(0x1671) GPOTA;
|
|
||||||
__xdata volatile unsigned char __at(0x1672) GPOTB;
|
|
||||||
__xdata volatile unsigned char __at(0x1673) GPOTC;
|
|
||||||
__xdata volatile unsigned char __at(0x1674) GPOTD;
|
|
||||||
__xdata volatile unsigned char __at(0x1675) GPOTE;
|
|
||||||
__xdata volatile unsigned char __at(0x1676) GPOTF;
|
|
||||||
__xdata volatile unsigned char __at(0x1677) GPOTG;
|
|
||||||
__xdata volatile unsigned char __at(0x1678) GPOTH;
|
|
||||||
__xdata volatile unsigned char __at(0x1679) GPOTI;
|
|
||||||
__xdata volatile unsigned char __at(0x167A) GPOTJ;
|
|
||||||
// GPOTM does not exist
|
|
||||||
|
|
||||||
__xdata volatile unsigned char __at(0x1610) GPCRA0;
|
|
||||||
__xdata volatile unsigned char __at(0x1611) GPCRA1;
|
|
||||||
__xdata volatile unsigned char __at(0x1612) GPCRA2;
|
|
||||||
__xdata volatile unsigned char __at(0x1613) GPCRA3;
|
|
||||||
__xdata volatile unsigned char __at(0x1614) GPCRA4;
|
|
||||||
__xdata volatile unsigned char __at(0x1615) GPCRA5;
|
|
||||||
__xdata volatile unsigned char __at(0x1616) GPCRA6;
|
|
||||||
__xdata volatile unsigned char __at(0x1617) GPCRA7;
|
|
||||||
|
|
||||||
__xdata volatile unsigned char __at(0x1618) GPCRB0;
|
|
||||||
__xdata volatile unsigned char __at(0x1619) GPCRB1;
|
|
||||||
__xdata volatile unsigned char __at(0x161A) GPCRB2;
|
|
||||||
__xdata volatile unsigned char __at(0x161B) GPCRB3;
|
|
||||||
__xdata volatile unsigned char __at(0x161C) GPCRB4;
|
|
||||||
__xdata volatile unsigned char __at(0x161D) GPCRB5;
|
|
||||||
__xdata volatile unsigned char __at(0x161E) GPCRB6;
|
|
||||||
__xdata volatile unsigned char __at(0x161F) GPCRB7;
|
|
||||||
|
|
||||||
__xdata volatile unsigned char __at(0x1620) GPCRC0;
|
|
||||||
__xdata volatile unsigned char __at(0x1621) GPCRC1;
|
|
||||||
__xdata volatile unsigned char __at(0x1622) GPCRC2;
|
|
||||||
__xdata volatile unsigned char __at(0x1623) GPCRC3;
|
|
||||||
__xdata volatile unsigned char __at(0x1624) GPCRC4;
|
|
||||||
__xdata volatile unsigned char __at(0x1625) GPCRC5;
|
|
||||||
__xdata volatile unsigned char __at(0x1626) GPCRC6;
|
|
||||||
__xdata volatile unsigned char __at(0x1627) GPCRC7;
|
|
||||||
|
|
||||||
__xdata volatile unsigned char __at(0x1628) GPCRD0;
|
|
||||||
__xdata volatile unsigned char __at(0x1629) GPCRD1;
|
|
||||||
__xdata volatile unsigned char __at(0x162A) GPCRD2;
|
|
||||||
__xdata volatile unsigned char __at(0x162B) GPCRD3;
|
|
||||||
__xdata volatile unsigned char __at(0x162C) GPCRD4;
|
|
||||||
__xdata volatile unsigned char __at(0x162D) GPCRD5;
|
|
||||||
__xdata volatile unsigned char __at(0x162E) GPCRD6;
|
|
||||||
__xdata volatile unsigned char __at(0x162F) GPCRD7;
|
|
||||||
|
|
||||||
__xdata volatile unsigned char __at(0x1630) GPCRE0;
|
|
||||||
__xdata volatile unsigned char __at(0x1631) GPCRE1;
|
|
||||||
__xdata volatile unsigned char __at(0x1632) GPCRE2;
|
|
||||||
__xdata volatile unsigned char __at(0x1633) GPCRE3;
|
|
||||||
__xdata volatile unsigned char __at(0x1634) GPCRE4;
|
|
||||||
__xdata volatile unsigned char __at(0x1635) GPCRE5;
|
|
||||||
__xdata volatile unsigned char __at(0x1636) GPCRE6;
|
|
||||||
__xdata volatile unsigned char __at(0x1637) GPCRE7;
|
|
||||||
|
|
||||||
__xdata volatile unsigned char __at(0x1638) GPCRF0;
|
|
||||||
__xdata volatile unsigned char __at(0x1639) GPCRF1;
|
|
||||||
__xdata volatile unsigned char __at(0x163A) GPCRF2;
|
|
||||||
__xdata volatile unsigned char __at(0x163B) GPCRF3;
|
|
||||||
__xdata volatile unsigned char __at(0x163C) GPCRF4;
|
|
||||||
__xdata volatile unsigned char __at(0x163D) GPCRF5;
|
|
||||||
__xdata volatile unsigned char __at(0x163E) GPCRF6;
|
|
||||||
__xdata volatile unsigned char __at(0x163F) GPCRF7;
|
|
||||||
|
|
||||||
__xdata volatile unsigned char __at(0x1640) GPCRG0;
|
|
||||||
__xdata volatile unsigned char __at(0x1641) GPCRG1;
|
|
||||||
__xdata volatile unsigned char __at(0x1642) GPCRG2;
|
|
||||||
__xdata volatile unsigned char __at(0x1643) GPCRG3;
|
|
||||||
__xdata volatile unsigned char __at(0x1644) GPCRG4;
|
|
||||||
__xdata volatile unsigned char __at(0x1645) GPCRG5;
|
|
||||||
__xdata volatile unsigned char __at(0x1646) GPCRG6;
|
|
||||||
__xdata volatile unsigned char __at(0x1647) GPCRG7;
|
|
||||||
|
|
||||||
__xdata volatile unsigned char __at(0x1648) GPCRH0;
|
|
||||||
__xdata volatile unsigned char __at(0x1649) GPCRH1;
|
|
||||||
__xdata volatile unsigned char __at(0x164A) GPCRH2;
|
|
||||||
__xdata volatile unsigned char __at(0x164B) GPCRH3;
|
|
||||||
__xdata volatile unsigned char __at(0x164C) GPCRH4;
|
|
||||||
__xdata volatile unsigned char __at(0x164D) GPCRH5;
|
|
||||||
__xdata volatile unsigned char __at(0x164E) GPCRH6;
|
|
||||||
__xdata volatile unsigned char __at(0x164F) GPCRH7;
|
|
||||||
|
|
||||||
__xdata volatile unsigned char __at(0x1650) GPCRI0;
|
|
||||||
__xdata volatile unsigned char __at(0x1651) GPCRI1;
|
|
||||||
__xdata volatile unsigned char __at(0x1652) GPCRI2;
|
|
||||||
__xdata volatile unsigned char __at(0x1653) GPCRI3;
|
|
||||||
__xdata volatile unsigned char __at(0x1654) GPCRI4;
|
|
||||||
__xdata volatile unsigned char __at(0x1655) GPCRI5;
|
|
||||||
__xdata volatile unsigned char __at(0x1656) GPCRI6;
|
|
||||||
__xdata volatile unsigned char __at(0x1657) GPCRI7;
|
|
||||||
|
|
||||||
__xdata volatile unsigned char __at(0x1658) GPCRJ0;
|
|
||||||
__xdata volatile unsigned char __at(0x1659) GPCRJ1;
|
|
||||||
__xdata volatile unsigned char __at(0x165A) GPCRJ2;
|
|
||||||
__xdata volatile unsigned char __at(0x165B) GPCRJ3;
|
|
||||||
__xdata volatile unsigned char __at(0x165C) GPCRJ4;
|
|
||||||
__xdata volatile unsigned char __at(0x165D) GPCRJ5;
|
|
||||||
__xdata volatile unsigned char __at(0x165E) GPCRJ6;
|
|
||||||
__xdata volatile unsigned char __at(0x165F) GPCRJ7;
|
|
||||||
|
|
||||||
__xdata volatile unsigned char __at(0x16A0) GPCRM0;
|
|
||||||
__xdata volatile unsigned char __at(0x16A1) GPCRM1;
|
|
||||||
__xdata volatile unsigned char __at(0x16A2) GPCRM2;
|
|
||||||
__xdata volatile unsigned char __at(0x16A3) GPCRM3;
|
|
||||||
__xdata volatile unsigned char __at(0x16A4) GPCRM4;
|
|
||||||
__xdata volatile unsigned char __at(0x16A5) GPCRM5;
|
|
||||||
__xdata volatile unsigned char __at(0x16A6) GPCRM6;
|
|
||||||
|
|
||||||
#endif // _GPIO_H_
|
|
@ -1,47 +0,0 @@
|
|||||||
#ifndef _KBSCAN_H_
|
|
||||||
#define _KBSCAN_H_
|
|
||||||
|
|
||||||
void kbscan_init(void);
|
|
||||||
|
|
||||||
__xdata volatile unsigned char __at(0x1D00) KSOL;
|
|
||||||
__xdata volatile unsigned char __at(0x1D01) KSOH1;
|
|
||||||
__xdata volatile unsigned char __at(0x1D02) KSOCTRL;
|
|
||||||
__xdata volatile unsigned char __at(0x1D03) KSOH2;
|
|
||||||
__xdata volatile unsigned char __at(0x1D04) KSI;
|
|
||||||
__xdata volatile unsigned char __at(0x1D05) KSICTRLR;
|
|
||||||
__xdata volatile unsigned char __at(0x1D06) KSIGCTRL;
|
|
||||||
__xdata volatile unsigned char __at(0x1D07) KSIGOEN;
|
|
||||||
__xdata volatile unsigned char __at(0x1D08) KSIGDAT;
|
|
||||||
__xdata volatile unsigned char __at(0x1D09) KSIGDMRR;
|
|
||||||
__xdata volatile unsigned char __at(0x1D0A) KSOHGCTRL;
|
|
||||||
__xdata volatile unsigned char __at(0x1D0B) KSOHGOEN;
|
|
||||||
__xdata volatile unsigned char __at(0x1D0C) KSOHGDMRR;
|
|
||||||
__xdata volatile unsigned char __at(0x1D0D) KSOLGCTRL;
|
|
||||||
__xdata volatile unsigned char __at(0x1D0E) KSOLGOEN;
|
|
||||||
__xdata volatile unsigned char __at(0x1D0F) KSOLGDMRR;
|
|
||||||
|
|
||||||
__xdata volatile unsigned char __at(0x1D10) KSO0LSDR;
|
|
||||||
__xdata volatile unsigned char __at(0x1D11) KSO1LSDR;
|
|
||||||
__xdata volatile unsigned char __at(0x1D12) KSO2LSDR;
|
|
||||||
__xdata volatile unsigned char __at(0x1D13) KSO3LSDR;
|
|
||||||
__xdata volatile unsigned char __at(0x1D14) KSO4LSDR;
|
|
||||||
__xdata volatile unsigned char __at(0x1D15) KSO5LSDR;
|
|
||||||
__xdata volatile unsigned char __at(0x1D16) KSO6LSDR;
|
|
||||||
__xdata volatile unsigned char __at(0x1D17) KSO7LSDR;
|
|
||||||
__xdata volatile unsigned char __at(0x1D18) KSO8LSDR;
|
|
||||||
__xdata volatile unsigned char __at(0x1D19) KSO9LSDR;
|
|
||||||
__xdata volatile unsigned char __at(0x1D1A) KSO10LSDR;
|
|
||||||
__xdata volatile unsigned char __at(0x1D1B) KSO11LSDR;
|
|
||||||
__xdata volatile unsigned char __at(0x1D1C) KSO12LSDR;
|
|
||||||
__xdata volatile unsigned char __at(0x1D1D) KSO13LSDR;
|
|
||||||
__xdata volatile unsigned char __at(0x1D1E) KSO14LSDR;
|
|
||||||
__xdata volatile unsigned char __at(0x1D1F) KSO15LSDR;
|
|
||||||
__xdata volatile unsigned char __at(0x1D20) KSO16LSDR;
|
|
||||||
__xdata volatile unsigned char __at(0x1D21) KSO17LSDR;
|
|
||||||
|
|
||||||
__xdata volatile unsigned char __at(0x1D22) SDC1R;
|
|
||||||
__xdata volatile unsigned char __at(0x1D23) SDC2R;
|
|
||||||
__xdata volatile unsigned char __at(0x1D24) SDC3R;
|
|
||||||
__xdata volatile unsigned char __at(0x1D25) SDSR;
|
|
||||||
|
|
||||||
#endif // _KBSCAN_H_
|
|
@ -1,25 +0,0 @@
|
|||||||
#ifndef _PIN_H_
|
|
||||||
#define _PIN_H_
|
|
||||||
|
|
||||||
#include <stdbool.h>
|
|
||||||
|
|
||||||
#include "gpio.h"
|
|
||||||
|
|
||||||
struct Pin {
|
|
||||||
__xdata volatile unsigned char * data;
|
|
||||||
__xdata volatile unsigned char * mirror;
|
|
||||||
__xdata volatile unsigned char * control;
|
|
||||||
unsigned char value;
|
|
||||||
};
|
|
||||||
|
|
||||||
#define PIN(BLOCK, NUMBER) { \
|
|
||||||
.data = &GPDR ## BLOCK, \
|
|
||||||
.mirror = &GPDMR ## BLOCK, \
|
|
||||||
.control = &GPCR ## BLOCK ## NUMBER, \
|
|
||||||
.value = (1 << NUMBER), \
|
|
||||||
}
|
|
||||||
|
|
||||||
bool pin_get(struct Pin * pin);
|
|
||||||
void pin_set(struct Pin * pin, bool value);
|
|
||||||
|
|
||||||
#endif // _PIN_H_
|
|
@ -1,22 +0,0 @@
|
|||||||
#ifndef _PS2_H_
|
|
||||||
#define _PS2_H_
|
|
||||||
|
|
||||||
void ps2_init(void);
|
|
||||||
|
|
||||||
__xdata volatile unsigned char __at(0x1700) PSCTL1;
|
|
||||||
__xdata volatile unsigned char __at(0x1701) PSCTL2;
|
|
||||||
__xdata volatile unsigned char __at(0x1702) PSCTL3;
|
|
||||||
|
|
||||||
__xdata volatile unsigned char __at(0x1704) PSINT1;
|
|
||||||
__xdata volatile unsigned char __at(0x1705) PSINT2;
|
|
||||||
__xdata volatile unsigned char __at(0x1706) PSINT3;
|
|
||||||
|
|
||||||
__xdata volatile unsigned char __at(0x1708) PSSTS1;
|
|
||||||
__xdata volatile unsigned char __at(0x1709) PSSTS2;
|
|
||||||
__xdata volatile unsigned char __at(0x170A) PSSTS3;
|
|
||||||
|
|
||||||
__xdata volatile unsigned char __at(0x170C) PSDAT1;
|
|
||||||
__xdata volatile unsigned char __at(0x170D) PSDAT2;
|
|
||||||
__xdata volatile unsigned char __at(0x170E) PSDAT3;
|
|
||||||
|
|
||||||
#endif // _PS2_H_
|
|
@ -1,6 +0,0 @@
|
|||||||
#ifndef _RESET_H_
|
|
||||||
#define _RESET_H_
|
|
||||||
|
|
||||||
void reset(void);
|
|
||||||
|
|
||||||
#endif // _RESET_H_
|
|
@ -1,45 +1,6 @@
|
|||||||
#include <stdio.h>
|
#include <board/kbc.h>
|
||||||
|
|
||||||
#include "include/kbc.h"
|
|
||||||
|
|
||||||
__code struct Kbc KBC = {
|
|
||||||
.control = &KBHICR,
|
|
||||||
.irq = &KBIRQR,
|
|
||||||
.status = &KBHISR,
|
|
||||||
.keyboard_out = &KBHIKDOR,
|
|
||||||
.mouse_out = &KBHIMDOR,
|
|
||||||
.data_in = &KBHIDIR,
|
|
||||||
};
|
|
||||||
|
|
||||||
void kbc_init(void) {
|
void kbc_init(void) {
|
||||||
*(KBC.irq) = 0;
|
*(KBC.irq) = 0;
|
||||||
*(KBC.control) = 0x48;
|
*(KBC.control) = 0x48;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint8_t kbc_status(struct Kbc * kbc) {
|
|
||||||
return *(kbc->status);
|
|
||||||
}
|
|
||||||
|
|
||||||
uint8_t kbc_read(struct Kbc * kbc) {
|
|
||||||
return *(kbc->data_in);
|
|
||||||
}
|
|
||||||
|
|
||||||
void kbc_keyboard(struct Kbc * kbc, uint8_t data) {
|
|
||||||
*(kbc->keyboard_out) = data;
|
|
||||||
}
|
|
||||||
|
|
||||||
void kbc_mouse(struct Kbc * kbc, uint8_t data) {
|
|
||||||
*(kbc->mouse_out) = data;
|
|
||||||
}
|
|
||||||
|
|
||||||
void kbc_event(struct Kbc * kbc) {
|
|
||||||
uint8_t sts = kbc_status(kbc);
|
|
||||||
if (sts & KBC_STS_IBF) {
|
|
||||||
uint8_t data = kbc_read(kbc);
|
|
||||||
if (sts & KBC_STS_CMD) {
|
|
||||||
printf("kbc cmd: %02X\n", data);
|
|
||||||
} else {
|
|
||||||
printf("kbc data: %02X\n", data);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
#include "include/kbscan.h"
|
#include <board/kbscan.h>
|
||||||
|
|
||||||
void kbscan_init(void) {
|
void kbscan_init(void) {
|
||||||
KSOCTRL = 0x05;
|
KSOCTRL = 0x05;
|
||||||
|
@ -2,14 +2,13 @@
|
|||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
||||||
#include "include/delay.h"
|
#include <arch/delay.h>
|
||||||
#include "include/gpio.h"
|
#include <board/gpio.h>
|
||||||
#include "include/gctrl.h"
|
#include <board/gctrl.h>
|
||||||
#include "include/kbc.h"
|
#include <board/kbc.h>
|
||||||
#include "include/pin.h"
|
#include <board/kbscan.h>
|
||||||
#include "include/pmc.h"
|
#include <board/pmc.h>
|
||||||
#include "include/ps2.h"
|
#include <board/ps2.h>
|
||||||
#include "include/kbscan.h"
|
|
||||||
|
|
||||||
void external_0(void) __interrupt(0) {
|
void external_0(void) __interrupt(0) {
|
||||||
printf("external_0\n");
|
printf("external_0\n");
|
||||||
@ -47,24 +46,24 @@ void init(void) {
|
|||||||
// PECI information can be found here: https://www.intel.com/content/dam/www/public/us/en/documents/design-guides/core-i7-lga-2011-guide.pdf
|
// PECI information can be found here: https://www.intel.com/content/dam/www/public/us/en/documents/design-guides/core-i7-lga-2011-guide.pdf
|
||||||
}
|
}
|
||||||
|
|
||||||
void power_button(struct Pin * button) {
|
void power_button(struct Gpio * button) {
|
||||||
static bool last = false;
|
static bool last = false;
|
||||||
|
|
||||||
// Check if the power switch goes low
|
// Check if the power switch goes low
|
||||||
bool new = pin_get(button);
|
bool new = gpio_get(button);
|
||||||
if (!new && last) {
|
if (!new && last) {
|
||||||
printf("Power Switch\n");
|
printf("Power Switch\n");
|
||||||
}
|
}
|
||||||
last = new;
|
last = new;
|
||||||
}
|
}
|
||||||
|
|
||||||
struct Pin PWR_SW = PIN(D, 0);
|
struct Gpio PWR_SW = GPIO(D, 0);
|
||||||
|
|
||||||
struct Pin LED_BAT_CHG = PIN(A, 5);
|
struct Gpio LED_BAT_CHG = GPIO(A, 5);
|
||||||
struct Pin LED_BAT_FULL = PIN(A, 6);
|
struct Gpio LED_BAT_FULL = GPIO(A, 6);
|
||||||
struct Pin LED_PWR = PIN(A, 7);
|
struct Gpio LED_PWR = GPIO(A, 7);
|
||||||
struct Pin LED_ACIN = PIN(C, 7);
|
struct Gpio LED_ACIN = GPIO(C, 7);
|
||||||
struct Pin LED_AIRPLANE_N = PIN(G, 6);
|
struct Gpio LED_AIRPLANE_N = GPIO(G, 6);
|
||||||
|
|
||||||
__code const char * MODEL = "galp3-c";
|
__code const char * MODEL = "galp3-c";
|
||||||
|
|
||||||
@ -72,7 +71,7 @@ void main(void) {
|
|||||||
init();
|
init();
|
||||||
|
|
||||||
// Set the battery full LED (to know our firmware is loaded)
|
// Set the battery full LED (to know our firmware is loaded)
|
||||||
pin_set(&LED_BAT_FULL, true);
|
gpio_set(&LED_BAT_FULL, true);
|
||||||
printf("Hello from System76 EC for %s!\n", MODEL);
|
printf("Hello from System76 EC for %s!\n", MODEL);
|
||||||
|
|
||||||
gpio_debug();
|
gpio_debug();
|
||||||
|
@ -1,17 +0,0 @@
|
|||||||
#include "include/pin.h"
|
|
||||||
|
|
||||||
bool pin_get(struct Pin * pin) {
|
|
||||||
if (*(pin->data) & pin->value) {
|
|
||||||
return true;
|
|
||||||
} else {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void pin_set(struct Pin * pin, bool value) {
|
|
||||||
if (value) {
|
|
||||||
*(pin->data) |= pin->value;
|
|
||||||
} else {
|
|
||||||
*(pin->data) &= ~(pin->value);
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,84 +1,6 @@
|
|||||||
#include <stdio.h>
|
#include <board/pmc.h>
|
||||||
|
|
||||||
#include "include/acpi.h"
|
|
||||||
#include "include/pmc.h"
|
|
||||||
|
|
||||||
#define PMC(NUM) { \
|
|
||||||
.status = &PM ## NUM ## STS, \
|
|
||||||
.data_out = &PM ## NUM ## DO, \
|
|
||||||
.data_in = &PM ## NUM ## DI, \
|
|
||||||
.control = &PM ## NUM ## CTL, \
|
|
||||||
}
|
|
||||||
|
|
||||||
__code struct Pmc PMC_1 = PMC(1);
|
|
||||||
__code struct Pmc PMC_2 = PMC(2);
|
|
||||||
|
|
||||||
void pmc_init(void) {
|
void pmc_init(void) {
|
||||||
*(PMC_1.control) = 0x41;
|
*(PMC_1.control) = 0x41;
|
||||||
*(PMC_2.control) = 0x41;
|
*(PMC_2.control) = 0x41;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint8_t pmc_status(struct Pmc * pmc) {
|
|
||||||
return *(pmc->status);
|
|
||||||
}
|
|
||||||
|
|
||||||
uint8_t pmc_read(struct Pmc * pmc) {
|
|
||||||
return *(pmc->data_in);
|
|
||||||
}
|
|
||||||
|
|
||||||
void pmc_write(struct Pmc * pmc, uint8_t data) {
|
|
||||||
*(pmc->data_out) = data;
|
|
||||||
}
|
|
||||||
|
|
||||||
enum PmcState {
|
|
||||||
PMC_STATE_DEFAULT,
|
|
||||||
PMC_STATE_ACPI_READ,
|
|
||||||
PMC_STATE_ACPI_WRITE,
|
|
||||||
PMC_STATE_ACPI_WRITE_ADDR,
|
|
||||||
};
|
|
||||||
|
|
||||||
void pmc_event(struct Pmc * pmc) {
|
|
||||||
static enum PmcState state = PMC_STATE_DEFAULT;
|
|
||||||
static uint8_t state_data[2] = {0, 0};
|
|
||||||
|
|
||||||
uint8_t sts = pmc_status(pmc);
|
|
||||||
if (sts & PMC_STS_IBF) {
|
|
||||||
uint8_t data = pmc_read(pmc);
|
|
||||||
if (sts & PMC_STS_CMD) {
|
|
||||||
printf("pmc cmd: %02X\n", data);
|
|
||||||
|
|
||||||
switch (data) {
|
|
||||||
case 0x80:
|
|
||||||
state = PMC_STATE_ACPI_READ;
|
|
||||||
break;
|
|
||||||
case 0x81:
|
|
||||||
state = PMC_STATE_ACPI_WRITE;
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
state = PMC_STATE_DEFAULT;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
printf("pmc data: %02X\n", data);
|
|
||||||
|
|
||||||
switch (state) {
|
|
||||||
case PMC_STATE_ACPI_READ:
|
|
||||||
state = PMC_STATE_DEFAULT;
|
|
||||||
uint8_t value = acpi_read(data);
|
|
||||||
pmc_write(pmc, value);
|
|
||||||
break;
|
|
||||||
case PMC_STATE_ACPI_WRITE:
|
|
||||||
state = PMC_STATE_ACPI_WRITE_ADDR;
|
|
||||||
state_data[0] = data;
|
|
||||||
break;
|
|
||||||
case PMC_STATE_ACPI_WRITE_ADDR:
|
|
||||||
state = PMC_STATE_DEFAULT;
|
|
||||||
acpi_write(state_data[0], data);
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
state = PMC_STATE_DEFAULT;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
#include "include/ps2.h"
|
#include <board/ps2.h>
|
||||||
|
|
||||||
void ps2_init(void) {
|
void ps2_init(void) {
|
||||||
PSCTL1 = 0x11;
|
PSCTL1 = 0x11;
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
||||||
#include "include/kbscan.h"
|
#include <arch/timer.h>
|
||||||
#include "include/timer.h"
|
#include <board/kbscan.h>
|
||||||
|
|
||||||
// Wait 25 us
|
// Wait 25 us
|
||||||
// 65536 - (25 / 1.304) = 65517
|
// 65536 - (25 / 1.304) = 65517
|
||||||
|
17
src/ec/it8587e/gpio.c
Normal file
17
src/ec/it8587e/gpio.c
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
#include <ec/gpio.h>
|
||||||
|
|
||||||
|
bool gpio_get(struct Gpio * gpio) {
|
||||||
|
if (*(gpio->data) & gpio->value) {
|
||||||
|
return true;
|
||||||
|
} else {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void gpio_set(struct Gpio * gpio, bool value) {
|
||||||
|
if (value) {
|
||||||
|
*(gpio->data) |= gpio->value;
|
||||||
|
} else {
|
||||||
|
*(gpio->data) &= ~(gpio->value);
|
||||||
|
}
|
||||||
|
}
|
10
src/ec/it8587e/include/ec/gctrl.h
Normal file
10
src/ec/it8587e/include/ec/gctrl.h
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
#ifndef _EC_GCTRL_H
|
||||||
|
#define _EC_GCTRL_H
|
||||||
|
|
||||||
|
#include <stdint.h>
|
||||||
|
|
||||||
|
__xdata volatile uint8_t __at(0x2006) RSTS;
|
||||||
|
__xdata volatile uint8_t __at(0x200A) BADRSEL;
|
||||||
|
__xdata volatile uint8_t __at(0x200D) SPCTRL1;
|
||||||
|
|
||||||
|
#endif // _EC_GCTRL_H
|
160
src/ec/it8587e/include/ec/gpio.h
Normal file
160
src/ec/it8587e/include/ec/gpio.h
Normal file
@ -0,0 +1,160 @@
|
|||||||
|
#ifndef _EC_GPIO_H
|
||||||
|
#define _EC_GPIO_H
|
||||||
|
|
||||||
|
#include <stdbool.h>
|
||||||
|
#include <stdint.h>
|
||||||
|
|
||||||
|
struct Gpio {
|
||||||
|
__xdata volatile uint8_t * data;
|
||||||
|
__xdata volatile uint8_t * mirror;
|
||||||
|
__xdata volatile uint8_t * control;
|
||||||
|
uint8_t value;
|
||||||
|
};
|
||||||
|
|
||||||
|
#define GPIO(BLOCK, NUMBER) { \
|
||||||
|
.data = &GPDR ## BLOCK, \
|
||||||
|
.mirror = &GPDMR ## BLOCK, \
|
||||||
|
.control = &GPCR ## BLOCK ## NUMBER, \
|
||||||
|
.value = (1 << NUMBER), \
|
||||||
|
}
|
||||||
|
|
||||||
|
bool gpio_get(struct Gpio * gpio);
|
||||||
|
void gpio_set(struct Gpio * gpio, bool value);
|
||||||
|
|
||||||
|
__xdata volatile uint8_t __at(0x1600) GCR;
|
||||||
|
|
||||||
|
__xdata volatile uint8_t __at(0x1601) GPDRA;
|
||||||
|
__xdata volatile uint8_t __at(0x1602) GPDRB;
|
||||||
|
__xdata volatile uint8_t __at(0x1603) GPDRC;
|
||||||
|
__xdata volatile uint8_t __at(0x1604) GPDRD;
|
||||||
|
__xdata volatile uint8_t __at(0x1605) GPDRE;
|
||||||
|
__xdata volatile uint8_t __at(0x1606) GPDRF;
|
||||||
|
__xdata volatile uint8_t __at(0x1607) GPDRG;
|
||||||
|
__xdata volatile uint8_t __at(0x1608) GPDRH;
|
||||||
|
__xdata volatile uint8_t __at(0x1609) GPDRI;
|
||||||
|
__xdata volatile uint8_t __at(0x160A) GPDRJ;
|
||||||
|
__xdata volatile uint8_t __at(0x160D) GPDRM;
|
||||||
|
|
||||||
|
__xdata volatile uint8_t __at(0x1661) GPDMRA;
|
||||||
|
__xdata volatile uint8_t __at(0x1662) GPDMRB;
|
||||||
|
__xdata volatile uint8_t __at(0x1663) GPDMRC;
|
||||||
|
__xdata volatile uint8_t __at(0x1664) GPDMRD;
|
||||||
|
__xdata volatile uint8_t __at(0x1665) GPDMRE;
|
||||||
|
__xdata volatile uint8_t __at(0x1666) GPDMRF;
|
||||||
|
__xdata volatile uint8_t __at(0x1667) GPDMRG;
|
||||||
|
__xdata volatile uint8_t __at(0x1668) GPDMRH;
|
||||||
|
__xdata volatile uint8_t __at(0x1669) GPDMRI;
|
||||||
|
__xdata volatile uint8_t __at(0x166A) GPDMRJ;
|
||||||
|
__xdata volatile uint8_t __at(0x166D) GPDMRM;
|
||||||
|
|
||||||
|
__xdata volatile uint8_t __at(0x1671) GPOTA;
|
||||||
|
__xdata volatile uint8_t __at(0x1672) GPOTB;
|
||||||
|
__xdata volatile uint8_t __at(0x1673) GPOTC;
|
||||||
|
__xdata volatile uint8_t __at(0x1674) GPOTD;
|
||||||
|
__xdata volatile uint8_t __at(0x1675) GPOTE;
|
||||||
|
__xdata volatile uint8_t __at(0x1676) GPOTF;
|
||||||
|
__xdata volatile uint8_t __at(0x1677) GPOTG;
|
||||||
|
__xdata volatile uint8_t __at(0x1678) GPOTH;
|
||||||
|
__xdata volatile uint8_t __at(0x1679) GPOTI;
|
||||||
|
__xdata volatile uint8_t __at(0x167A) GPOTJ;
|
||||||
|
// GPOTM does not exist
|
||||||
|
|
||||||
|
__xdata volatile uint8_t __at(0x1610) GPCRA0;
|
||||||
|
__xdata volatile uint8_t __at(0x1611) GPCRA1;
|
||||||
|
__xdata volatile uint8_t __at(0x1612) GPCRA2;
|
||||||
|
__xdata volatile uint8_t __at(0x1613) GPCRA3;
|
||||||
|
__xdata volatile uint8_t __at(0x1614) GPCRA4;
|
||||||
|
__xdata volatile uint8_t __at(0x1615) GPCRA5;
|
||||||
|
__xdata volatile uint8_t __at(0x1616) GPCRA6;
|
||||||
|
__xdata volatile uint8_t __at(0x1617) GPCRA7;
|
||||||
|
|
||||||
|
__xdata volatile uint8_t __at(0x1618) GPCRB0;
|
||||||
|
__xdata volatile uint8_t __at(0x1619) GPCRB1;
|
||||||
|
__xdata volatile uint8_t __at(0x161A) GPCRB2;
|
||||||
|
__xdata volatile uint8_t __at(0x161B) GPCRB3;
|
||||||
|
__xdata volatile uint8_t __at(0x161C) GPCRB4;
|
||||||
|
__xdata volatile uint8_t __at(0x161D) GPCRB5;
|
||||||
|
__xdata volatile uint8_t __at(0x161E) GPCRB6;
|
||||||
|
__xdata volatile uint8_t __at(0x161F) GPCRB7;
|
||||||
|
|
||||||
|
__xdata volatile uint8_t __at(0x1620) GPCRC0;
|
||||||
|
__xdata volatile uint8_t __at(0x1621) GPCRC1;
|
||||||
|
__xdata volatile uint8_t __at(0x1622) GPCRC2;
|
||||||
|
__xdata volatile uint8_t __at(0x1623) GPCRC3;
|
||||||
|
__xdata volatile uint8_t __at(0x1624) GPCRC4;
|
||||||
|
__xdata volatile uint8_t __at(0x1625) GPCRC5;
|
||||||
|
__xdata volatile uint8_t __at(0x1626) GPCRC6;
|
||||||
|
__xdata volatile uint8_t __at(0x1627) GPCRC7;
|
||||||
|
|
||||||
|
__xdata volatile uint8_t __at(0x1628) GPCRD0;
|
||||||
|
__xdata volatile uint8_t __at(0x1629) GPCRD1;
|
||||||
|
__xdata volatile uint8_t __at(0x162A) GPCRD2;
|
||||||
|
__xdata volatile uint8_t __at(0x162B) GPCRD3;
|
||||||
|
__xdata volatile uint8_t __at(0x162C) GPCRD4;
|
||||||
|
__xdata volatile uint8_t __at(0x162D) GPCRD5;
|
||||||
|
__xdata volatile uint8_t __at(0x162E) GPCRD6;
|
||||||
|
__xdata volatile uint8_t __at(0x162F) GPCRD7;
|
||||||
|
|
||||||
|
__xdata volatile uint8_t __at(0x1630) GPCRE0;
|
||||||
|
__xdata volatile uint8_t __at(0x1631) GPCRE1;
|
||||||
|
__xdata volatile uint8_t __at(0x1632) GPCRE2;
|
||||||
|
__xdata volatile uint8_t __at(0x1633) GPCRE3;
|
||||||
|
__xdata volatile uint8_t __at(0x1634) GPCRE4;
|
||||||
|
__xdata volatile uint8_t __at(0x1635) GPCRE5;
|
||||||
|
__xdata volatile uint8_t __at(0x1636) GPCRE6;
|
||||||
|
__xdata volatile uint8_t __at(0x1637) GPCRE7;
|
||||||
|
|
||||||
|
__xdata volatile uint8_t __at(0x1638) GPCRF0;
|
||||||
|
__xdata volatile uint8_t __at(0x1639) GPCRF1;
|
||||||
|
__xdata volatile uint8_t __at(0x163A) GPCRF2;
|
||||||
|
__xdata volatile uint8_t __at(0x163B) GPCRF3;
|
||||||
|
__xdata volatile uint8_t __at(0x163C) GPCRF4;
|
||||||
|
__xdata volatile uint8_t __at(0x163D) GPCRF5;
|
||||||
|
__xdata volatile uint8_t __at(0x163E) GPCRF6;
|
||||||
|
__xdata volatile uint8_t __at(0x163F) GPCRF7;
|
||||||
|
|
||||||
|
__xdata volatile uint8_t __at(0x1640) GPCRG0;
|
||||||
|
__xdata volatile uint8_t __at(0x1641) GPCRG1;
|
||||||
|
__xdata volatile uint8_t __at(0x1642) GPCRG2;
|
||||||
|
__xdata volatile uint8_t __at(0x1643) GPCRG3;
|
||||||
|
__xdata volatile uint8_t __at(0x1644) GPCRG4;
|
||||||
|
__xdata volatile uint8_t __at(0x1645) GPCRG5;
|
||||||
|
__xdata volatile uint8_t __at(0x1646) GPCRG6;
|
||||||
|
__xdata volatile uint8_t __at(0x1647) GPCRG7;
|
||||||
|
|
||||||
|
__xdata volatile uint8_t __at(0x1648) GPCRH0;
|
||||||
|
__xdata volatile uint8_t __at(0x1649) GPCRH1;
|
||||||
|
__xdata volatile uint8_t __at(0x164A) GPCRH2;
|
||||||
|
__xdata volatile uint8_t __at(0x164B) GPCRH3;
|
||||||
|
__xdata volatile uint8_t __at(0x164C) GPCRH4;
|
||||||
|
__xdata volatile uint8_t __at(0x164D) GPCRH5;
|
||||||
|
__xdata volatile uint8_t __at(0x164E) GPCRH6;
|
||||||
|
__xdata volatile uint8_t __at(0x164F) GPCRH7;
|
||||||
|
|
||||||
|
__xdata volatile uint8_t __at(0x1650) GPCRI0;
|
||||||
|
__xdata volatile uint8_t __at(0x1651) GPCRI1;
|
||||||
|
__xdata volatile uint8_t __at(0x1652) GPCRI2;
|
||||||
|
__xdata volatile uint8_t __at(0x1653) GPCRI3;
|
||||||
|
__xdata volatile uint8_t __at(0x1654) GPCRI4;
|
||||||
|
__xdata volatile uint8_t __at(0x1655) GPCRI5;
|
||||||
|
__xdata volatile uint8_t __at(0x1656) GPCRI6;
|
||||||
|
__xdata volatile uint8_t __at(0x1657) GPCRI7;
|
||||||
|
|
||||||
|
__xdata volatile uint8_t __at(0x1658) GPCRJ0;
|
||||||
|
__xdata volatile uint8_t __at(0x1659) GPCRJ1;
|
||||||
|
__xdata volatile uint8_t __at(0x165A) GPCRJ2;
|
||||||
|
__xdata volatile uint8_t __at(0x165B) GPCRJ3;
|
||||||
|
__xdata volatile uint8_t __at(0x165C) GPCRJ4;
|
||||||
|
__xdata volatile uint8_t __at(0x165D) GPCRJ5;
|
||||||
|
__xdata volatile uint8_t __at(0x165E) GPCRJ6;
|
||||||
|
__xdata volatile uint8_t __at(0x165F) GPCRJ7;
|
||||||
|
|
||||||
|
__xdata volatile uint8_t __at(0x16A0) GPCRM0;
|
||||||
|
__xdata volatile uint8_t __at(0x16A1) GPCRM1;
|
||||||
|
__xdata volatile uint8_t __at(0x16A2) GPCRM2;
|
||||||
|
__xdata volatile uint8_t __at(0x16A3) GPCRM3;
|
||||||
|
__xdata volatile uint8_t __at(0x16A4) GPCRM4;
|
||||||
|
__xdata volatile uint8_t __at(0x16A5) GPCRM5;
|
||||||
|
__xdata volatile uint8_t __at(0x16A6) GPCRM6;
|
||||||
|
|
||||||
|
#endif // _EC_GPIO_H
|
@ -1,5 +1,5 @@
|
|||||||
#ifndef _KBC_H_
|
#ifndef _EC_KBC_H
|
||||||
#define _KBC_H_
|
#define _EC_KBC_H
|
||||||
|
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
|
||||||
@ -40,4 +40,4 @@ __xdata volatile uint8_t __at(0x1306) KBHIKDOR;
|
|||||||
__xdata volatile uint8_t __at(0x1308) KBHIMDOR;
|
__xdata volatile uint8_t __at(0x1308) KBHIMDOR;
|
||||||
__xdata volatile uint8_t __at(0x130A) KBHIDIR;
|
__xdata volatile uint8_t __at(0x130A) KBHIDIR;
|
||||||
|
|
||||||
#endif // _KBC_H_
|
#endif // _EC_KBC_H
|
47
src/ec/it8587e/include/ec/kbscan.h
Normal file
47
src/ec/it8587e/include/ec/kbscan.h
Normal file
@ -0,0 +1,47 @@
|
|||||||
|
#ifndef _EC_KBSCAN_H
|
||||||
|
#define _EC_KBSCAN_H
|
||||||
|
|
||||||
|
#include <stdint.h>
|
||||||
|
|
||||||
|
__xdata volatile uint8_t __at(0x1D00) KSOL;
|
||||||
|
__xdata volatile uint8_t __at(0x1D01) KSOH1;
|
||||||
|
__xdata volatile uint8_t __at(0x1D02) KSOCTRL;
|
||||||
|
__xdata volatile uint8_t __at(0x1D03) KSOH2;
|
||||||
|
__xdata volatile uint8_t __at(0x1D04) KSI;
|
||||||
|
__xdata volatile uint8_t __at(0x1D05) KSICTRLR;
|
||||||
|
__xdata volatile uint8_t __at(0x1D06) KSIGCTRL;
|
||||||
|
__xdata volatile uint8_t __at(0x1D07) KSIGOEN;
|
||||||
|
__xdata volatile uint8_t __at(0x1D08) KSIGDAT;
|
||||||
|
__xdata volatile uint8_t __at(0x1D09) KSIGDMRR;
|
||||||
|
__xdata volatile uint8_t __at(0x1D0A) KSOHGCTRL;
|
||||||
|
__xdata volatile uint8_t __at(0x1D0B) KSOHGOEN;
|
||||||
|
__xdata volatile uint8_t __at(0x1D0C) KSOHGDMRR;
|
||||||
|
__xdata volatile uint8_t __at(0x1D0D) KSOLGCTRL;
|
||||||
|
__xdata volatile uint8_t __at(0x1D0E) KSOLGOEN;
|
||||||
|
__xdata volatile uint8_t __at(0x1D0F) KSOLGDMRR;
|
||||||
|
|
||||||
|
__xdata volatile uint8_t __at(0x1D10) KSO0LSDR;
|
||||||
|
__xdata volatile uint8_t __at(0x1D11) KSO1LSDR;
|
||||||
|
__xdata volatile uint8_t __at(0x1D12) KSO2LSDR;
|
||||||
|
__xdata volatile uint8_t __at(0x1D13) KSO3LSDR;
|
||||||
|
__xdata volatile uint8_t __at(0x1D14) KSO4LSDR;
|
||||||
|
__xdata volatile uint8_t __at(0x1D15) KSO5LSDR;
|
||||||
|
__xdata volatile uint8_t __at(0x1D16) KSO6LSDR;
|
||||||
|
__xdata volatile uint8_t __at(0x1D17) KSO7LSDR;
|
||||||
|
__xdata volatile uint8_t __at(0x1D18) KSO8LSDR;
|
||||||
|
__xdata volatile uint8_t __at(0x1D19) KSO9LSDR;
|
||||||
|
__xdata volatile uint8_t __at(0x1D1A) KSO10LSDR;
|
||||||
|
__xdata volatile uint8_t __at(0x1D1B) KSO11LSDR;
|
||||||
|
__xdata volatile uint8_t __at(0x1D1C) KSO12LSDR;
|
||||||
|
__xdata volatile uint8_t __at(0x1D1D) KSO13LSDR;
|
||||||
|
__xdata volatile uint8_t __at(0x1D1E) KSO14LSDR;
|
||||||
|
__xdata volatile uint8_t __at(0x1D1F) KSO15LSDR;
|
||||||
|
__xdata volatile uint8_t __at(0x1D20) KSO16LSDR;
|
||||||
|
__xdata volatile uint8_t __at(0x1D21) KSO17LSDR;
|
||||||
|
|
||||||
|
__xdata volatile uint8_t __at(0x1D22) SDC1R;
|
||||||
|
__xdata volatile uint8_t __at(0x1D23) SDC2R;
|
||||||
|
__xdata volatile uint8_t __at(0x1D24) SDC3R;
|
||||||
|
__xdata volatile uint8_t __at(0x1D25) SDSR;
|
||||||
|
|
||||||
|
#endif // _EC_KBSCAN_H
|
@ -1,10 +1,8 @@
|
|||||||
#ifndef _PMC_H_
|
#ifndef _EC_PMC_H
|
||||||
#define _PMC_H_
|
#define _EC_PMC_H
|
||||||
|
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
|
||||||
void pmc_init(void);
|
|
||||||
|
|
||||||
struct Pmc {
|
struct Pmc {
|
||||||
// Status register
|
// Status register
|
||||||
volatile uint8_t * status;
|
volatile uint8_t * status;
|
||||||
@ -39,4 +37,4 @@ __xdata volatile uint8_t __at(0x1511) PM2DO;
|
|||||||
__xdata volatile uint8_t __at(0x1514) PM2DI;
|
__xdata volatile uint8_t __at(0x1514) PM2DI;
|
||||||
__xdata volatile uint8_t __at(0x1516) PM2CTL;
|
__xdata volatile uint8_t __at(0x1516) PM2CTL;
|
||||||
|
|
||||||
#endif // _PMC_H_
|
#endif // _EC_PMC_H
|
22
src/ec/it8587e/include/ec/ps2.h
Normal file
22
src/ec/it8587e/include/ec/ps2.h
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
#ifndef _EC_PS2_H
|
||||||
|
#define _EC_PS2_H
|
||||||
|
|
||||||
|
#include <stdint.h>
|
||||||
|
|
||||||
|
__xdata volatile uint8_t __at(0x1700) PSCTL1;
|
||||||
|
__xdata volatile uint8_t __at(0x1701) PSCTL2;
|
||||||
|
__xdata volatile uint8_t __at(0x1702) PSCTL3;
|
||||||
|
|
||||||
|
__xdata volatile uint8_t __at(0x1704) PSINT1;
|
||||||
|
__xdata volatile uint8_t __at(0x1705) PSINT2;
|
||||||
|
__xdata volatile uint8_t __at(0x1706) PSINT3;
|
||||||
|
|
||||||
|
__xdata volatile uint8_t __at(0x1708) PSSTS1;
|
||||||
|
__xdata volatile uint8_t __at(0x1709) PSSTS2;
|
||||||
|
__xdata volatile uint8_t __at(0x170A) PSSTS3;
|
||||||
|
|
||||||
|
__xdata volatile uint8_t __at(0x170C) PSDAT1;
|
||||||
|
__xdata volatile uint8_t __at(0x170D) PSDAT2;
|
||||||
|
__xdata volatile uint8_t __at(0x170E) PSDAT3;
|
||||||
|
|
||||||
|
#endif // _EC_PS2_H
|
40
src/ec/it8587e/kbc.c
Normal file
40
src/ec/it8587e/kbc.c
Normal file
@ -0,0 +1,40 @@
|
|||||||
|
#include <stdio.h>
|
||||||
|
|
||||||
|
#include <ec/kbc.h>
|
||||||
|
|
||||||
|
__code struct Kbc KBC = {
|
||||||
|
.control = &KBHICR,
|
||||||
|
.irq = &KBIRQR,
|
||||||
|
.status = &KBHISR,
|
||||||
|
.keyboard_out = &KBHIKDOR,
|
||||||
|
.mouse_out = &KBHIMDOR,
|
||||||
|
.data_in = &KBHIDIR,
|
||||||
|
};
|
||||||
|
|
||||||
|
uint8_t kbc_status(struct Kbc * kbc) {
|
||||||
|
return *(kbc->status);
|
||||||
|
}
|
||||||
|
|
||||||
|
uint8_t kbc_read(struct Kbc * kbc) {
|
||||||
|
return *(kbc->data_in);
|
||||||
|
}
|
||||||
|
|
||||||
|
void kbc_keyboard(struct Kbc * kbc, uint8_t data) {
|
||||||
|
*(kbc->keyboard_out) = data;
|
||||||
|
}
|
||||||
|
|
||||||
|
void kbc_mouse(struct Kbc * kbc, uint8_t data) {
|
||||||
|
*(kbc->mouse_out) = data;
|
||||||
|
}
|
||||||
|
|
||||||
|
void kbc_event(struct Kbc * kbc) {
|
||||||
|
uint8_t sts = kbc_status(kbc);
|
||||||
|
if (sts & KBC_STS_IBF) {
|
||||||
|
uint8_t data = kbc_read(kbc);
|
||||||
|
if (sts & KBC_STS_CMD) {
|
||||||
|
printf("kbc cmd: %02X\n", data);
|
||||||
|
} else {
|
||||||
|
printf("kbc data: %02X\n", data);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
79
src/ec/it8587e/pmc.c
Normal file
79
src/ec/it8587e/pmc.c
Normal file
@ -0,0 +1,79 @@
|
|||||||
|
#include <stdio.h>
|
||||||
|
|
||||||
|
#include <board/acpi.h>
|
||||||
|
#include <ec/pmc.h>
|
||||||
|
|
||||||
|
#define PMC(NUM) { \
|
||||||
|
.status = &PM ## NUM ## STS, \
|
||||||
|
.data_out = &PM ## NUM ## DO, \
|
||||||
|
.data_in = &PM ## NUM ## DI, \
|
||||||
|
.control = &PM ## NUM ## CTL, \
|
||||||
|
}
|
||||||
|
|
||||||
|
__code struct Pmc PMC_1 = PMC(1);
|
||||||
|
__code struct Pmc PMC_2 = PMC(2);
|
||||||
|
|
||||||
|
uint8_t pmc_status(struct Pmc * pmc) {
|
||||||
|
return *(pmc->status);
|
||||||
|
}
|
||||||
|
|
||||||
|
uint8_t pmc_read(struct Pmc * pmc) {
|
||||||
|
return *(pmc->data_in);
|
||||||
|
}
|
||||||
|
|
||||||
|
void pmc_write(struct Pmc * pmc, uint8_t data) {
|
||||||
|
*(pmc->data_out) = data;
|
||||||
|
}
|
||||||
|
|
||||||
|
enum PmcState {
|
||||||
|
PMC_STATE_DEFAULT,
|
||||||
|
PMC_STATE_ACPI_READ,
|
||||||
|
PMC_STATE_ACPI_WRITE,
|
||||||
|
PMC_STATE_ACPI_WRITE_ADDR,
|
||||||
|
};
|
||||||
|
|
||||||
|
void pmc_event(struct Pmc * pmc) {
|
||||||
|
static enum PmcState state = PMC_STATE_DEFAULT;
|
||||||
|
static uint8_t state_data[2] = {0, 0};
|
||||||
|
|
||||||
|
uint8_t sts = pmc_status(pmc);
|
||||||
|
if (sts & PMC_STS_IBF) {
|
||||||
|
uint8_t data = pmc_read(pmc);
|
||||||
|
if (sts & PMC_STS_CMD) {
|
||||||
|
printf("pmc cmd: %02X\n", data);
|
||||||
|
|
||||||
|
switch (data) {
|
||||||
|
case 0x80:
|
||||||
|
state = PMC_STATE_ACPI_READ;
|
||||||
|
break;
|
||||||
|
case 0x81:
|
||||||
|
state = PMC_STATE_ACPI_WRITE;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
state = PMC_STATE_DEFAULT;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
printf("pmc data: %02X\n", data);
|
||||||
|
|
||||||
|
switch (state) {
|
||||||
|
case PMC_STATE_ACPI_READ:
|
||||||
|
state = PMC_STATE_DEFAULT;
|
||||||
|
uint8_t value = acpi_read(data);
|
||||||
|
pmc_write(pmc, value);
|
||||||
|
break;
|
||||||
|
case PMC_STATE_ACPI_WRITE:
|
||||||
|
state = PMC_STATE_ACPI_WRITE_ADDR;
|
||||||
|
state_data[0] = data;
|
||||||
|
break;
|
||||||
|
case PMC_STATE_ACPI_WRITE_ADDR:
|
||||||
|
state = PMC_STATE_DEFAULT;
|
||||||
|
acpi_write(state_data[0], data);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
state = PMC_STATE_DEFAULT;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
Reference in New Issue
Block a user