1 /**
2  *
3  * Copyright (c) 2019 Microchip Technology Inc. and its subsidiaries.
4  *
5  * \asf_license_start
6  *
7  * \page License
8  *
9  * SPDX-License-Identifier: Apache-2.0
10  *
11  * Licensed under the Apache License, Version 2.0 (the "License"); you may
12  * not use this file except in compliance with the License.
13  * You may obtain a copy of the Licence at
14  *
15  * http://www.apache.org/licenses/LICENSE-2.0
16  *
17  * Unless required by applicable law or agreed to in writing, software
18  * distributed under the License is distributed on an AS IS BASIS, WITHOUT
19  * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
20  * See the License for the specific language governing permissions and
21  * limitations under the License.
22  *
23  * \asf_license_stop
24  *
25  */
26 
27 /** @file keyscan.h
28  *MEC1501 Keyboard matrix scan controller registers
29  */
30 /** @defgroup MEC1501 Peripherals KSCAN
31  */
32 
33 #ifndef _KSCAN_H
34 #define _KSCAN_H
35 
36 #include <stdint.h>
37 #include <stddef.h>
38 
39 #include "regaccess.h"
40 
41 /* =========================================================================*/
42 /* ================   KBC				   ================ */
43 /* =========================================================================*/
44 
45 #define MCHP_KSCAN_BASE_ADDR	0x40009c00u
46 
47 /*
48  * KSCAN interrupts
49  */
50 #define MCHP_KSCAN_GIRQ		21u
51 #define MCHP_KSCAN_GIRQ_NVIC	13u
52 /* Direct mode connection to NVIC */
53 #define MCHP_KSAN_NVIC		135u
54 
55 #define MCHP_KSCAN_GIRQ_POS	25u
56 
57 #define MCHP_KSCAN_GIRQ_VAL	(1u << 25)
58 
59 /*
60  * KSO_SEL
61  */
62 #define MCHP_KSCAN_KSO_SEL_REG_MASK	0xffu
63 #define MCHP_KSCAN_KSO_LINES_POS	0u
64 #define MCHP_KSCAN_KSO_LINES_MASK0	0x1fu
65 #define MCHP_KSCAN_KSO_LINES_MASK	0x1fu
66 #define MCHP_KSCAN_KSO_ALL_POS		5u
67 #define MCHP_KSCAN_KSO_ALL		(1u << 5)
68 #define MCHP_KSCAN_KSO_EN_POS		6u
69 #define MCHP_KSCAN_KSO_EN		(1u << 6)
70 #define MCHP_KSCAN_KSO_INV_POS		7u
71 #define MCHP_KSCAN_KSO_INV		(1u << 7)
72 
73 /*
74  * KSI_IN
75  */
76 #define MCHP_KSCAN_KSI_IN_REG_MASK	0xffu
77 
78 /*
79  * KSI_STS
80  */
81 #define MCHP_KSCAN_KSI_STS_REG_MASK	0xffu
82 
83 /*
84  * KSI_IEN
85  */
86 #define MCHP_KSCAN_KSI_IEN_REG_MASK	0xffu
87 
88 /*
89  * EXT_CTRL
90  */
91 #define MCHP_KSCAN_EXT_CTRL_REG_MASK	0x01u
92 #define MCHP_KSCAN_EXT_CTRL_PREDRV_EN	0x01u
93 
94 /**
95   * @brief Keyboard Controller Registers (KSCAN)
96   */
97 typedef struct kscan_regs
98 {
99 	uint8_t RSVD[4];
100 	__IOM uint32_t KSO_SEL;	/*!< (@ 0x0004) KSO Select */
101 	uint32_t KSI_IN;	/*!< (@ 0x0008) KSI Input States */
102 	__IOM uint32_t KSI_STS;	/*!< (@ 0x000c) KSI Status */
103 	__IOM uint32_t KSI_IEN;	/*!< (@ 0x0010) KSI Interrupt Enable */
104 	__IOM uint32_t EXT_CTRL;	/*!< (@ 0x0014) Extended Control */
105 } KSCAN_Type;
106 
107 #endif	/* #ifndef _KSCAN_H */
108 /* end kscan.h */
109 /**   @}
110  */
111