/* Copyright (c) 2014 The Chromium OS Authors. All rights reserved. * Use of this source code is governed by a BSD-style license that can be * found in the LICENSE file. * * Register map for NPCX processor */ #ifndef __CROS_EC_REGISTERS_H #define __CROS_EC_REGISTERS_H #include "common.h" /******************************************************************************/ /* * Macro Functions */ #define SET_BIT(reg, bit) ((reg) |= (0x1 << (bit))) #define CLEAR_BIT(reg, bit) ((reg) &= (~(0x1 << (bit)))) #define IS_BIT_SET(reg, bit) ((reg >> bit) & (0x1)) #define UPDATE_BIT(reg, bit, cond) { if (cond) \ SET_BIT(reg, bit); \ else \ CLEAR_BIT(reg, bit); } /******************************************************************************/ /* * NPCX (Nuvoton M4 EC) Register Definitions */ /* Global Definition */ #define CHIP_VERSION 3 /* A3 version */ #define I2C_7BITS_ADDR 0 #define I2C_LEVEL_SUPPORT 1 /* Switcher of features */ #define SUPPORT_LCT 1 #define SUPPORT_WDG 1 #define SUPPORT_HIB 1 #define SUPPORT_P80_SEG 0 /* Note: it uses KSO10 & KSO11 */ /* Switcher of debugging */ #define DEBUG_I2C 0 #define DEBUG_TMR 0 #define DEBUG_WDG 0 #define DEBUG_GPIO 1 #define DEBUG_FAN 0 #define DEBUG_PWM 0 #define DEBUG_SPI 0 #define DEBUG_FLH 0 #define DEBUG_PECI 0 #define DEBUG_SHI 1 #define DEBUG_CLK 0 #define DEBUG_LPC 0 /* Modules Map */ #define NPCX_MDC_BASE_ADDR 0x4000C000 #define NPCX_SIB_BASE_ADDR 0x4000E000 #define NPCX_PMC_BASE_ADDR 0x4000D000 #define NPCX_SHM_BASE_ADDR 0x40010000 #define NPCX_FIU_BASE_ADDR 0x40020000 #define NPCX_KBSCAN_REGS_BASE 0x400A3000 #define NPCX_GLUE_REGS_BASE 0x400A5000 #define NPCX_BBRAM_BASE_ADDR 0x400AF000 #define NPCX_HFCG_BASE_ADDR 0x400B5000 #define NPCX_SHI_BASE_ADDR 0x4000F000 #define NPCX_MTC_BASE_ADDR 0x400B7000 #define NPCX_MSWC_BASE_ADDR 0x400C1000 #define NPCX_SCFG_BASE_ADDR 0x400C3000 #define NPCX_CR_UART_BASE_ADDR 0x400C4000 #define NPCX_KBC_BASE_ADDR 0x400C7000 #define NPCX_ADC_BASE_ADDR 0x400D1000 #define NPCX_SPI_BASE_ADDR 0x400D2000 #define NPCX_PECI_BASE_ADDR 0x400D4000 #define NPCX_TWD_BASE_ADDR 0x400D8000 /* Multi-Modules Map */ #define NPCX_PWM_BASE_ADDR(mdl) (0x40080000 + ((mdl) * 0x2000L)) #define NPCX_GPIO_BASE_ADDR(mdl) (0x40081000 + ((mdl) * 0x2000L)) #define NPCX_ITIM16_BASE_ADDR(mdl) (0x400B0000 + ((mdl) * 0x2000L)) #define NPCX_ITIM32_BASE_ADDR 0x400BC000 #define NPCX_MIWU_BASE_ADDR(mdl) (0x400BB000 + ((mdl) * 0x2000L)) #define NPCX_MFT_BASE_ADDR(mdl) (0x400E1000 + ((mdl) * 0x2000L)) #define NPCX_PM_CH_BASE_ADDR(mdl) (0x400C9000 + ((mdl) * 0x2000L)) #define NPCX_SMB_BASE_ADDR(mdl) ((mdl < 2) ? (0x40009000 + \ ((mdl) * 0x2000L)) : \ (0x400C0000 + ((mdl - 2) * 0x2000L))) /* * NPCX-IRQ numbers */ #define NPCX_IRQ_0 0 #define NPCX_IRQ_1 1 #define NPCX_IRQ_2 2 #define NPCX_IRQ_3 3 #define NPCX_IRQ_4 4 #define NPCX_IRQ_5 5 #define NPCX_IRQ_6 6 #define NPCX_IRQ_7 7 #define NPCX_IRQ_8 8 #define NPCX_IRQ_9 9 #define NPCX_IRQ_10 10 #define NPCX_IRQ_11 11 #define NPCX_IRQ_12 12 #define NPCX_IRQ_13 13 #define NPCX_IRQ_14 14 #define NPCX_IRQ_15 15 #define NPCX_IRQ_16 16 #define NPCX_IRQ_17 17 #define NPCX_IRQ_18 18 #define NPCX_IRQ_19 19 #define NPCX_IRQ_20 20 #define NPCX_IRQ_21 21 #define NPCX_IRQ_22 22 #define NPCX_IRQ_23 23 #define NPCX_IRQ_24 24 #define NPCX_IRQ_25 25 #define NPCX_IRQ_26 26 #define NPCX_IRQ_27 27 #define NPCX_IRQ_28 28 #define NPCX_IRQ_29 29 #define NPCX_IRQ_30 30 #define NPCX_IRQ_31 31 #define NPCX_IRQ_32 32 #define NPCX_IRQ_33 33 #define NPCX_IRQ_34 34 #define NPCX_IRQ_35 35 #define NPCX_IRQ_36 36 #define NPCX_IRQ_37 37 #define NPCX_IRQ_38 38 #define NPCX_IRQ_39 39 #define NPCX_IRQ_40 40 #define NPCX_IRQ_41 41 #define NPCX_IRQ_42 42 #define NPCX_IRQ_43 43 #define NPCX_IRQ_44 44 #define NPCX_IRQ_45 45 #define NPCX_IRQ_46 46 #define NPCX_IRQ_47 47 #define NPCX_IRQ_48 48 #define NPCX_IRQ_49 49 #define NPCX_IRQ_50 50 #define NPCX_IRQ_51 51 #define NPCX_IRQ_52 52 #define NPCX_IRQ_53 53 #define NPCX_IRQ_54 54 #define NPCX_IRQ_55 55 #define NPCX_IRQ_56 56 #define NPCX_IRQ_57 57 #define NPCX_IRQ_58 58 #define NPCX_IRQ_59 59 #define NPCX_IRQ_60 60 #define NPCX_IRQ_61 61 #define NPCX_IRQ_62 62 #define NPCX_IRQ_63 63 #define NPCX_IRQ0_NOUSED NPCX_IRQ_0 #define NPCX_IRQ1_NOUSED NPCX_IRQ_1 #define NPCX_IRQ_KBSCAN NPCX_IRQ_2 #define NPCX_IRQ_PM_CHAN_OBE NPCX_IRQ_3 #define NPCX_IRQ_PECI NPCX_IRQ_4 #define NPCX_IRQ5_NOUSED NPCX_IRQ_5 #define NPCX_IRQ_PORT80 NPCX_IRQ_6 #define NPCX_IRQ_MTC_WKINTAD_0 NPCX_IRQ_7 #define NPCX_IRQ8_NOUSED NPCX_IRQ_8 #define NPCX_IRQ_MFT_1 NPCX_IRQ_9 #define NPCX_IRQ_ADC NPCX_IRQ_10 #define NPCX_IRQ_WKINTEFGH_0 NPCX_IRQ_11 #define NPCX_IRQ_CDMA NPCX_IRQ_12 #define NPCX_IRQ_SMB1 NPCX_IRQ_13 #define NPCX_IRQ_SMB2 NPCX_IRQ_14 #define NPCX_IRQ_WKINTC_0 NPCX_IRQ_15 #define NPCX_IRQ16_NOUSED NPCX_IRQ_16 #define NPCX_IRQ_ITIM16_3 NPCX_IRQ_17 #define NPCX_IRQ_SHI NPCX_IRQ_18 #define NPCX_IRQ19_NOUSED NPCX_IRQ_19 #define NPCX_IRQ20_NOUSED NPCX_IRQ_20 #define NPCX_IRQ_PS2 NPCX_IRQ_21 #define NPCX_IRQ22_NOUSED NPCX_IRQ_22 #define NPCX_IRQ_MFT_2 NPCX_IRQ_23 #define NPCX_IRQ_SHM NPCX_IRQ_24 #define NPCX_IRQ_KBC_IBF NPCX_IRQ_25 #define NPCX_IRQ_PM_CHAN_IBF NPCX_IRQ_26 #define NPCX_IRQ_ITIM16_2 NPCX_IRQ_27 #define NPCX_IRQ_ITIM16_1 NPCX_IRQ_28 #define NPCX_IRQ29_NOUSED NPCX_IRQ_29 #define NPCX_IRQ30_NOUSED NPCX_IRQ_30 #define NPCX_IRQ_TWD_WKINTB_0 NPCX_IRQ_31 #define NPCX_IRQ32_NOUSED NPCX_IRQ_32 #define NPCX_IRQ_UART NPCX_IRQ_33 #define NPCX_IRQ34_NOUSED NPCX_IRQ_34 #define NPCX_IRQ35_NOUSED NPCX_IRQ_35 #define NPCX_IRQ_SMB3 NPCX_IRQ_36 #define NPCX_IRQ_SMB4 NPCX_IRQ_37 #define NPCX_IRQ38_NOUSED NPCX_IRQ_38 #define NPCX_IRQ39_NOUSED NPCX_IRQ_39 #define NPCX_IRQ40_NOUSED NPCX_IRQ_40 #define NPCX_IRQ_MFT_3 NPCX_IRQ_41 #define NPCX_IRQ42_NOUSED NPCX_IRQ_42 #define NPCX_IRQ_ITIM16_4 NPCX_IRQ_43 #define NPCX_IRQ_ITIM16_5 NPCX_IRQ_44 #define NPCX_IRQ_ITIM16_6 NPCX_IRQ_45 #define NPCX_IRQ_ITIM32 NPCX_IRQ_46 #define NPCX_IRQ_WKINTA_1 NPCX_IRQ_47 #define NPCX_IRQ_WKINTB_1 NPCX_IRQ_48 #define NPCX_IRQ_KSI_WKINTC_1 NPCX_IRQ_49 #define NPCX_IRQ_WKINTD_1 NPCX_IRQ_50 #define NPCX_IRQ_WKINTE_1 NPCX_IRQ_51 #define NPCX_IRQ_WKINTF_1 NPCX_IRQ_52 #define NPCX_IRQ_WKINTG_1 NPCX_IRQ_53 #define NPCX_IRQ_WKINTH_1 NPCX_IRQ_54 #define NPCX_IRQ55_NOUSED NPCX_IRQ_55 #define NPCX_IRQ_KBC_OBE NPCX_IRQ_56 #define NPCX_IRQ_SPI NPCX_IRQ_57 #define NPCX_IRQ58_NOUSED NPCX_IRQ_58 #define NPCX_IRQ59_NOUSED NPCX_IRQ_59 #define NPCX_IRQ_WKINTA_2 NPCX_IRQ_60 #define NPCX_IRQ_WKINTB_2 NPCX_IRQ_61 #define NPCX_IRQ_WKINTC_2 NPCX_IRQ_62 #define NPCX_IRQ_WKINTD_2 NPCX_IRQ_63 #define NPCX_IRQ_COUNT 64 /******************************************************************************/ /* Miscellaneous Device Control (MDC) registers */ #define NPCX_FWCTRL REG8(NPCX_MDC_BASE_ADDR + 0x007) /* MDC register fields */ #define NPCX_FWCTRL_RO_REGION 0 /******************************************************************************/ /* High Frequency Clock Generator (HFCG) registers */ #define NPCX_HFCGCTRL REG8(NPCX_HFCG_BASE_ADDR + 0x000) #define NPCX_HFCGML REG8(NPCX_HFCG_BASE_ADDR + 0x002) #define NPCX_HFCGMH REG8(NPCX_HFCG_BASE_ADDR + 0x004) #define NPCX_HFCGN REG8(NPCX_HFCG_BASE_ADDR + 0x006) #define NPCX_HFCGP REG8(NPCX_HFCG_BASE_ADDR + 0x008) #define NPCX_HFCBCD REG8(NPCX_HFCG_BASE_ADDR + 0x010) /* HFCG register fields */ #define NPCX_HFCGCTRL_LOAD 0 #define NPCX_HFCGCTRL_LOCK 2 #define NPCX_HFCGCTRL_CLK_CHNG 7 /******************************************************************************/ /*CR UART Register */ #define NPCX_UTBUF REG8(NPCX_CR_UART_BASE_ADDR + 0x000) #define NPCX_URBUF REG8(NPCX_CR_UART_BASE_ADDR + 0x002) #define NPCX_UICTRL REG8(NPCX_CR_UART_BASE_ADDR + 0x004) #define NPCX_USTAT REG8(NPCX_CR_UART_BASE_ADDR + 0x006) #define NPCX_UFRS REG8(NPCX_CR_UART_BASE_ADDR + 0x008) #define NPCX_UMDSL REG8(NPCX_CR_UART_BASE_ADDR + 0x00A) #define NPCX_UBAUD REG8(NPCX_CR_UART_BASE_ADDR + 0x00C) #define NPCX_UPSR REG8(NPCX_CR_UART_BASE_ADDR + 0x00E) /******************************************************************************/ /* KBSCAN registers */ #define NPCX_KBSIN REG8(NPCX_KBSCAN_REGS_BASE + 0x04) #define NPCX_KBSINPU REG8(NPCX_KBSCAN_REGS_BASE + 0x05) #define NPCX_KBSOUT0 REG16(NPCX_KBSCAN_REGS_BASE + 0x06) #define NPCX_KBSOUT1 REG16(NPCX_KBSCAN_REGS_BASE + 0x08) #define NPCX_KBS_BUF_INDX REG8(NPCX_KBSCAN_REGS_BASE + 0x0A) #define NPCX_KBS_BUF_DATA REG8(NPCX_KBSCAN_REGS_BASE + 0x0B) #define NPCX_KBSEVT REG8(NPCX_KBSCAN_REGS_BASE + 0x0C) #define NPCX_KBSCTL REG8(NPCX_KBSCAN_REGS_BASE + 0x0D) #define NPCX_KBS_CFG_INDX REG8(NPCX_KBSCAN_REGS_BASE + 0x0E) #define NPCX_KBS_CFG_DATA REG8(NPCX_KBSCAN_REGS_BASE + 0x0F) /* KBSCAN register fields */ #define NPCX_KBSBUFINDX 0 #define NPCX_KBSDONE 0 #define NPCX_KBSERR 1 #define NPCX_KBSSTART 0 #define NPCX_KBSMODE 1 #define NPCX_KBSIEN 2 #define NPCX_KBSINC 3 #define NPCX_KBSCFGINDX 0 /* KBSCAN definitions */ #define KB_ROW_NUM 8 /* Rows numbers of keyboard matrix */ #define KB_COL_NUM 18 /* Columns numbers of keyboard matrix */ #define KB_ROW_MASK ((1<