Skip to content

Commit 9e1d2a4

Browse files
scottwcpgandrewboie
authored andcommitted
ext : hal : Microchip MEC1501 PS/2 and global configuration updates.
Added header files for PS/2 and global configuration hardware blocks to MEC1501 HAL. Signed-off-by: Scott Worley <scott.worley@microchip.com>
1 parent 409325a commit 9e1d2a4

File tree

3 files changed

+333
-0
lines changed

3 files changed

+333
-0
lines changed

mec/mec1501/MEC1501hsz.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -439,6 +439,7 @@ typedef enum IRQn {
439439
#include "component/espi_io.h"
440440
#include "component/espi_mem.h"
441441
#include "component/espi_vw.h"
442+
#include "component/global_cfg.h"
442443
#include "component/i2c.h"
443444
#include "component/kbc.h"
444445
#include "component/keyscan.h"
@@ -447,6 +448,7 @@ typedef enum IRQn {
447448
#include "component/pcr.h"
448449
#include "component/port80cap.h"
449450
#include "component/port92.h"
451+
#include "component/ps2_ctrl.h"
450452
#include "component/smb.h"
451453
#include "component/tfdp.h"
452454
#include "component/timer.h"
@@ -494,6 +496,9 @@ typedef enum IRQn {
494496

495497
#define TFDP_REGS ((TFDP_Type *) TFDP_BASE)
496498

499+
#define PS2_0_REGS ((PS2_Type *) PS2_0_BASE)
500+
#define PS2_1_REGS ((PS2_Type *) PS2_1_BASE)
501+
497502
#define HTMR0_REGS ((HTMR_Type *) HTMR0_BASE)
498503
#define HTMR1_REGS ((HTMR_Type *) HTMR1_BASE)
499504

@@ -584,6 +589,8 @@ typedef enum IRQn {
584589
#define PORT80_CAP0_REGS ((PORT80_CAP_Type *)(P80CAP0_BASE))
585590
#define PORT80_CAP1_REGS ((PORT80_CAP_Type *)(P80CAP1_BASE))
586591

592+
#define GLOBAL_CFG_REGS ((GLOBAL_CFG_Type *) GCFG_BASE)
593+
587594
/** @} *//* End of group MEC1501 */
588595

589596
/** @} *//* End of group MCHP */

mec/mec1501/component/global_cfg.h

Lines changed: 158 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,158 @@
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 global_cfg.h
28+
*MEC1501 Global Configuration Registers
29+
*/
30+
/** @defgroup MEC1501 Peripherals GlobalConfig
31+
*/
32+
33+
#ifndef _GLOBAL_CFG_H
34+
#define _GLOBAL_CFG_H
35+
36+
#include <stdint.h>
37+
#include <stddef.h>
38+
39+
#include "regaccess.h"
40+
41+
/* ===================================================================*/
42+
/* ================ Global Config ============= */
43+
/* ===================================================================*/
44+
45+
#define MCHP_GCFG_BASE_ADDR 0x400FFF00ul
46+
47+
/*
48+
* Device and Revision ID 32-bit register
49+
* b[7:0] = Revision
50+
* b[15:8] = Device Sub-ID
51+
* b[31:16] = Device ID
52+
* This register can be accesses as bytes or a single 32-bit read from
53+
* the EC. Host access byte access via the Host visible configuration
54+
* register space at 0x2E/0x2F(default).
55+
*/
56+
#define MCHP_GCFG_DEV_ID_REG32_OFS 0x1C
57+
#define MCHP_GCFG_DEV_ID_REG_MASK 0xFFFFFFFFul
58+
#define MCHP_GCFG_REV_ID_POS 0
59+
#define MCHP_GCFG_DID_REV_MASK0 0xFFul
60+
#define MCHP_GCFG_DID_REV_MASK 0xFFul
61+
#define MCHP_GCFG_DID_SUB_ID_POS 8
62+
#define MCHP_GCFG_DID_SUB_ID_MASK0 0xFFul
63+
#define MCHP_GCFG_DID_SUB_ID_MASK (0xFFul << 8)
64+
#define MCHP_GCFG_DID_DEV_ID_POS 16
65+
#define MCHP_GCFG_DID_DEV_ID_MASK0 0xFFFFul
66+
#define MCHP_GCFG_DID_DEV_ID_MASK (0xFFFFul << 16)
67+
68+
/* Byte[0] at offset 0x1C is the 8-bit revision ID */
69+
#define MCHP_GCFG_REV_ID_REG_OFS 0x1C
70+
#define MCHP_GCFG_REV_A1 0x02
71+
#define MCHP_GCFG_REV_B0 0x03
72+
73+
/*
74+
* Byte[1] at offset 0x1D is the 8-bit Sub-ID
75+
* bits[3:0] = package type
76+
* bits[7:4] = chip family
77+
*/
78+
#define MCHP_GCFG_SUB_ID_OFS 0x1D
79+
#define MCHP_GCFG_SUB_ID_PKG_POS 0
80+
#define MCHP_GCFG_SUB_ID_PKG_MASK0 0x0F
81+
#define MCHP_GCFG_SUB_ID_PKG_MASK 0x0F
82+
#define MCHP_GCFG_SUB_ID_PKG_UNDEF 0x00
83+
#define MCHP_GCFG_SUB_ID_PKG_64_PIN 0x01
84+
#define MCHP_GCFG_SUB_ID_PKG_84_PIN 0x02
85+
#define MCHP_GCFG_SUB_ID_PKG_128_PIN 0x03
86+
#define MCHP_GCFG_SUB_ID_PKG_144_PIN 0x04
87+
/* chip family field */
88+
#define MCHP_GCFG_SUB_ID_FAM_POS 4
89+
#define MCHP_GCFG_SUB_ID_FAM_MASK0 0x0F
90+
#define MCHP_GCFG_SUB_ID_FAM_MASK 0xF0
91+
#define MCHP_GCFG_SUB_ID_FAM_UNDEF 0x00
92+
#define MCHP_GCFG_SUB_ID_FAM_MEC 0x01
93+
#define MCHP_GCFG_SUB_ID_FAM_2 0x02
94+
#define MCHP_GCFG_SUB_ID_FAM_3 0x03
95+
#define MCHP_GCFG_SUB_ID_FAM_4 0x04
96+
#define MCHP_GCFG_SUB_ID_FAM_5 0x05
97+
98+
#define MCHP_GCFG_DEV_ID_LSB_OFS 0x1E
99+
#define MCHP_GCFG_DEV_ID_MSB_OFS 0x1F
100+
#define MCHP_GCFG_DEV_ID_15XX 0x0020
101+
#define MCHP_GCFG_DEV_ID_15XX_LSB 0x20
102+
#define MCHP_GCFG_DEV_ID_15XX_MSB 0x00
103+
104+
/* Legacy Device ID value */
105+
#define MCHP_CCFG_LEGACY_DID_REG_OFS 0x20
106+
#define MCHP_GCFG_LEGACY_DEV_ID 0xFE
107+
108+
/*
109+
* Host access via configuration port (default I/O locations 0x2E/0x2F)
110+
*/
111+
#define MCHP_HOST_CFG_INDEX_IO_DFLT 0x2E
112+
#define MCHP_HOST_CFG_DATA_IO_DFLT 0x2F
113+
#define MCHP_HOST_CFG_UNLOCK 0x55
114+
#define MCHP_HOST_CFG_LOCK 0xAA
115+
/*
116+
* Logical Device Configuration Indices.
117+
*/
118+
#define MCHP_HOST_CFG_LDN_IDX 0x07
119+
#define MCHP_HOST_CFG_LD_ACTIVATE_IDX 0x30
120+
#define MCHP_HOST_CFG_LD_BASE_ADDR_IDX 0x34
121+
#define MCHP_HOST_CFG_LD_CFG_SEL_IDX 0xF0
122+
123+
124+
/* Read 32-bit Device, Sub, and Revision ID */
125+
#define MCHP_DEVICE_REV_ID() \
126+
REG32(MCHP_GCFG_BASE_ADDR + MCHP_GCFG_DEV_ID_REG32_OFS)
127+
128+
/* Read 16-bit Device ID */
129+
#define MCHP_DEVICE_ID() \
130+
REG16(MCHP_GCFG_BASE_ADDR + MCHP_GCFG_DEV_ID_LSB_OFS)
131+
132+
/* Read 8-bit Sub ID */
133+
#define MCHP_DEV_SUB_ID() \
134+
REG8(MCHP_GCFG_BASE_ADDR + MCHP_GCFG_SUB_ID_OFS)
135+
136+
/* Read 8-bit Revision ID */
137+
#define MCHP_REVISION_ID() \
138+
REG8(MCHP_GCFG_BASE_ADDR + MCHP_GCFG_REV_ID_REG_OFS)
139+
140+
/**
141+
* @brief Glocal Configuration Registers (GLOBAL_CFG)
142+
*/
143+
typedef struct global_cfg_regs
144+
{
145+
__IOM uint8_t RSVD0[2];
146+
__IOM uint8_t TEST02; /*!< (@ 0x0002) MCHP Test */
147+
__IOM uint8_t RSVD1[4];
148+
__IOM uint8_t LOG_DEV_NUM; /*!< (@ 0x0007) Global Config Logical Device Number */
149+
__IOM uint8_t RSVD2[20];
150+
__IOM uint32_t DEV_REV_ID; /*!< (@ 0x001C) Device and revision ID */
151+
__IOM uint8_t LEGACY_DEV_ID; /*!< (@ 0x0020) Legacy Device ID */
152+
__IOM uint8_t RSVD3[14];
153+
} GLOBAL_CFG_Type;
154+
155+
#endif /* #ifndef _GLOBAL_CFG_H */
156+
/* end global_cfg.h */
157+
/** @}
158+
*/

mec/mec1501/component/ps2_ctrl.h

Lines changed: 168 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,168 @@
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 ps2_ctrl.h
28+
*MEC1501 PS/2 Controller Registers
29+
*/
30+
/** @defgroup MEC1501 Peripherals PS/2
31+
*/
32+
33+
#ifndef _PS2_CTRL_H
34+
#define _PS2_CTRL_H
35+
36+
#include <stdint.h>
37+
#include <stddef.h>
38+
39+
#include "regaccess.h"
40+
41+
/* ===================================================================*/
42+
/* ================ PS2 ============= */
43+
/* ===================================================================*/
44+
45+
#define MCHP_PS2_MAX_INSTANCES 2u
46+
#define MCHP_PS2_SPACING 0x40ul
47+
#define MCHP_PS2_SPACING_PWROF2 6u
48+
49+
#define MCHP_PS2_0_BASE_ADDR 0x40009000ul
50+
#define MCHP_PS2_1_BASE_ADDR 0x40009040ul
51+
52+
/*
53+
* PS2 interrupts
54+
*/
55+
#define MCHP_PS2_0_GIRQ 18u
56+
#define MCHP_PS2_1_GIRQ 18u
57+
#define MCHP_PS2_0_GIRQ_NVIC 10u
58+
#define MCHP_PS2_1_GIRQ_NVIC 10u
59+
#define MCHP_PS2_0_NVIC_DIRECT 100u
60+
#define MCHP_PS2_1_NVIC_DIRECT 101u
61+
62+
#define MCHP_PS2_0_GIRQ_POS 10u
63+
#define MCHP_PS2_1_GIRQ_POS 11u
64+
65+
#define MCHP_PS2_0_GIRQ_VAL (1ul << 10)
66+
#define MCHP_PS2_1_GIRQ_VAL (1ul << 11)
67+
68+
/*
69+
* PS2 TRX Buffer register
70+
* Writes -> Transmit buffer
71+
* Read <- Receive buffer
72+
*/
73+
#define MCHP_PS2_TRX_BUFF_REG_MASK 0xFFUL
74+
75+
/*
76+
* PS2 Control register
77+
*/
78+
#define MCHP_PS2_CTRL_REG_MASK 0x3FUL
79+
80+
/* Select Transmit or Receive */
81+
#define MCHP_PS2_CTRL_TR_POS 0
82+
#define MCHP_PS2_CTRL_TR_RX (0U << (MCHP_PS2_CTRL_TR_POS))
83+
#define MCHP_PS2_CTRL_TR_TX (1U << (MCHP_PS2_CTRL_TR_POS))
84+
85+
/* Enable PS2 state machine */
86+
#define MCHP_PS2_CTRL_EN_POS 1
87+
#define MCHP_PS2_CTRL_EN (1U << (MCHP_PS2_CTRL_EN_POS))
88+
89+
/* Protocol parity selection */
90+
#define MCHP_PS2_CTRL_PAR_POS 2
91+
#define MCHP_PS2_CTRL_PAR_MASK0 0x03U
92+
#define MCHP_PS2_CTRL_PAR_MASK ((MCHP_PS2_CTRL_PAR_MASK0) \
93+
<< (MCHP_PS2_CTRL_PAR_POS))
94+
#define MCHP_PS2_CTRL_PAR_ODD (0U << (MCHP_PS2_CTRL_PAR_POS))
95+
#define MCHP_PS2_CTRL_PAR_EVEN (1U << (MCHP_PS2_CTRL_PAR_POS))
96+
#define MCHP_PS2_CTRL_PAR_IGNORE (2U << (MCHP_PS2_CTRL_PAR_POS))
97+
#define MCHP_PS2_CTRL_PAR_RSVD (3U << (MCHP_PS2_CTRL_PAR_POS))
98+
99+
/* Protocol stop bit selection */
100+
#define MCHP_PS2_CTRL_STOP_POS 4
101+
#define MCHP_PS2_CTRL_STOP_MASK0 0x03U
102+
#define MCHP_PS2_CTRL_STOP_MASK ((MCHP_PS2_CTRL_STOP_MASK0) \
103+
<< (MCHP_PS2_CTRL_STOP_POS))
104+
#define MCHP_PS2_CTRL_STOP_ACT_HI (0U << (MCHP_PS2_CTRL_STOP_POS))
105+
#define MCHP_PS2_CTRL_STOP_ACT_LO (1U << (MCHP_PS2_CTRL_STOP_POS))
106+
#define MCHP_PS2_CTRL_STOP_IGNORE (2U << (MCHP_PS2_CTRL_STOP_POS))
107+
#define MCHP_PS2_CTRL_STOP_RSVD (3U << (MCHP_PS2_CTRL_STOP_POS))
108+
109+
/*
110+
* PS2 Status register
111+
*/
112+
#define MCHP_PS2_STATUS_REG_MASK 0xFFUL
113+
#define MCHP_PS2_STATUS_RW1C_MASK 0xAEUL
114+
#define MCHP_PS2_STATUS_RO_MASK 0x51UL
115+
/* RX Data Ready(Read-Only) */
116+
#define MCHP_PS2_STATUS_RXD_RDY_POS 0
117+
#define MCHP_PS2_STATUS_RXD_RDY (1U << (MCHP_PS2_STATUS_RXD_RDY_POS))
118+
/* RX Timeout(R/W1C) */
119+
#define MCHP_PS2_STATUS_RX_TMOUT_POS 1
120+
#define MCHP_PS2_STATUS_RX_TMOUT (1U << (MCHP_PS2_STATUS_RX_TMOUT_POS))
121+
/* Parity Error(R/W1C) */
122+
#define MCHP_PS2_STATUS_PE_POS 2
123+
#define MCHP_PS2_STATUS_PE (1U << (MCHP_PS2_STATUS_PE_POS))
124+
/* Framing Error(R/W1C) */
125+
#define MCHP_PS2_STATUS_FE_POS 3
126+
#define MCHP_PS2_STATUS_FE (1U << (MCHP_PS2_STATUS_FE_POS))
127+
/* Transmitter is Idle(Read-Only) */
128+
#define MCHP_PS2_STATUS_TX_IDLE_POS 4
129+
#define MCHP_PS2_STATUS_TX_IDLE (1U << (MCHP_PS2_STATUS_TX_IDLE_POS))
130+
/* Transmitter timeout(R/W1C) */
131+
#define MCHP_PS2_STATUS_TX_TMOUT_POS 5
132+
#define MCHP_PS2_STATUS_TX_TMOUT (1U << (MCHP_PS2_STATUS_TX_TMOUT_POS))
133+
/* RX is Busy(Read-Only) */
134+
#define MCHP_PS2_STATUS_RX_BUSY_POS 6
135+
#define MCHP_PS2_STATUS_RX_BUSY (1U << (MCHP_PS2_STATUS_RX_BUSY_POS))
136+
/* Transmitter start timeout(R/W1C) */
137+
#define MCHP_PS2_STATUS_TX_ST_TMOUT_POS 7
138+
#define MCHP_PS2_STATUS_TX_ST_TMOUT (1U << (MCHP_PS2_STATUS_TX_ST_TMOUT_POS))
139+
140+
/*
141+
* PS2 Protocol bit positions
142+
*/
143+
#define MCHP_PS2_PROT_START_BIT_POS 1
144+
#define MCHP_PS2_PROT_DATA_BIT0_POS 2
145+
#define MCHP_PS2_PROT_DATA_BIT1_POS 3
146+
#define MCHP_PS2_PROT_DATA_BIT2_POS 4
147+
#define MCHP_PS2_PROT_DATA_BIT3_POS 5
148+
#define MCHP_PS2_PROT_DATA_BIT4_POS 6
149+
#define MCHP_PS2_PROT_DATA_BIT5_POS 7
150+
#define MCHP_PS2_PROT_DATA_BIT6_POS 8
151+
#define MCHP_PS2_PROT_DATA_BIT7_POS 9
152+
#define MCHP_PS2_PROT_PARITY_POS 10
153+
#define MCHP_PS2_PROT_STOP_BIT_POS 11
154+
155+
/**
156+
* @brief PS/2 Controller Registers (PS2)
157+
*/
158+
typedef struct ps2_regs
159+
{
160+
__IOM uint32_t TRX_BUFF; /*!< (@ 0x0000) PS/2 Transmit buffer(WO), Receive buffer(RO) */
161+
__IOM uint32_t CTRL; /*!< (@ 0x0004) PS/2 Control */
162+
__IOM uint32_t STATUS; /*!< (@ 0x0008) PS/2 Status */
163+
} PS2_Type;
164+
165+
#endif /* #ifndef _PS2_CTRL_H */
166+
/* end ps2_ctrl.h */
167+
/** @}
168+
*/

0 commit comments

Comments
 (0)