9
9
#include <assert.h>
10
10
#include <zephyr/drivers/espi.h>
11
11
#include <zephyr/drivers/gpio.h>
12
+ #include <zephyr/drivers/interrupt_controller/wuc_ite_it51xxx.h>
12
13
#include <zephyr/drivers/interrupt_controller/wuc_ite_it8xxx2.h>
13
14
#include <zephyr/kernel.h>
14
15
#include <zephyr/sys/util.h>
21
22
#include <zephyr/irq.h>
22
23
LOG_MODULE_REGISTER (espi , CONFIG_ESPI_LOG_LEVEL );
23
24
24
- #define ESPI_IT8XXX2_GET_GCTRL_BASE \
25
- ((struct gctrl_it8xxx2_regs *)DT_REG_ADDR(DT_NODELABEL(gctrl)))
25
+ #define ESPI_ITE_GET_GCTRL_BASE ((struct gctrl_ite_ec_regs *)DT_REG_ADDR(DT_NODELABEL(gctrl)))
26
26
27
27
#define IT8XXX2_ESPI_IRQ DT_INST_IRQ_BY_IDX(0, 0, irq)
28
28
#define IT8XXX2_ESPI_VW_IRQ DT_INST_IRQ_BY_IDX(0, 1, irq)
@@ -827,9 +827,10 @@ static const struct ec2i_t smfi_settings[] = {
827
827
static void smfi_it8xxx2_init (const struct device * dev )
828
828
{
829
829
const struct espi_it8xxx2_config * const config = dev -> config ;
830
- struct smfi_it8xxx2_regs * const smfi_reg =
831
- (struct smfi_it8xxx2_regs * )config -> base_smfi ;
832
- struct gctrl_it8xxx2_regs * const gctrl = ESPI_IT8XXX2_GET_GCTRL_BASE ;
830
+ struct smfi_ite_ec_regs * const smfi_reg = (struct smfi_ite_ec_regs * )config -> base_smfi ;
831
+
832
+ #ifdef CONFIG_SOC_SERIES_IT8XXX2
833
+ struct gctrl_ite_ec_regs * const gctrl = ESPI_ITE_GET_GCTRL_BASE ;
833
834
uint8_t h2ram_offset ;
834
835
835
836
/* Set the host to RAM cycle address offset */
@@ -838,6 +839,7 @@ static void smfi_it8xxx2_init(const struct device *dev)
838
839
gctrl -> GCTRL_H2ROFSR =
839
840
(gctrl -> GCTRL_H2ROFSR & ~IT8XXX2_ESPI_H2RAM_OFFSET_MASK ) |
840
841
h2ram_offset ;
842
+ #endif
841
843
842
844
#ifdef CONFIG_ESPI_PERIPHERAL_EC_HOST_CMD
843
845
memset (& h2ram_pool [CONFIG_ESPI_PERIPHERAL_HOST_CMD_PARAM_PORT_NUM ], 0 ,
@@ -929,12 +931,13 @@ static void pnpcfg_it8xxx2_configure(const struct device *dev,
929
931
930
932
#define PNPCFG (_s ) \
931
933
pnpcfg_it8xxx2_configure(dev, _s##_settings, ARRAY_SIZE(_s##_settings))
934
+ extern uint8_t _h2ram_pool_start [];
932
935
933
936
static void pnpcfg_it8xxx2_init (const struct device * dev )
934
937
{
935
938
const struct espi_it8xxx2_config * const config = dev -> config ;
936
939
struct ec2i_regs * const ec2i = (struct ec2i_regs * )config -> base_ec2i ;
937
- struct gctrl_it8xxx2_regs * const gctrl = ESPI_IT8XXX2_GET_GCTRL_BASE ;
940
+ struct gctrl_ite_ec_regs * const gctrl = ESPI_ITE_GET_GCTRL_BASE ;
938
941
939
942
/* The register pair to access PNPCFG is 004Eh and 004Fh */
940
943
gctrl -> GCTRL_BADRSEL = 0x1 ;
@@ -953,6 +956,15 @@ static void pnpcfg_it8xxx2_init(const struct device *dev)
953
956
#if defined(CONFIG_ESPI_PERIPHERAL_EC_HOST_CMD ) || \
954
957
defined(CONFIG_ESPI_PERIPHERAL_ACPI_SHM_REGION )
955
958
PNPCFG (smfi );
959
+
960
+ #ifdef CONFIG_SOC_SERIES_IT51XXX
961
+ uint8_t h2ram_pool_idx ;
962
+
963
+ h2ram_pool_idx = ((uint32_t )_h2ram_pool_start & IT8XXX2_ESPI_H2RAM_BASEADDR_MASK ) /
964
+ IT8XXX2_ESPI_H2RAM_POOL_SIZE_MAX ;
965
+ /* H2RAM 4K page select */
966
+ ec2i_it8xxx2_write (dev , HOST_INDEX_DSLDC13 , h2ram_pool_idx );
967
+ #endif
956
968
#endif
957
969
}
958
970
@@ -1086,7 +1098,7 @@ static void pmc1_it8xxx2_init(const struct device *dev)
1086
1098
static void port80_it8xxx2_isr (const struct device * dev )
1087
1099
{
1088
1100
struct espi_it8xxx2_data * const data = dev -> data ;
1089
- struct gctrl_it8xxx2_regs * const gctrl = ESPI_IT8XXX2_GET_GCTRL_BASE ;
1101
+ struct gctrl_ite_ec_regs * const gctrl = ESPI_ITE_GET_GCTRL_BASE ;
1090
1102
struct espi_event evt = {
1091
1103
ESPI_BUS_PERIPHERAL_NOTIFICATION ,
1092
1104
(ESPI_PERIPHERAL_INDEX_0 << 16 ) | ESPI_PERIPHERAL_DEBUG_PORT80 ,
@@ -1107,7 +1119,7 @@ static void port80_it8xxx2_isr(const struct device *dev)
1107
1119
static void port80_it8xxx2_init (const struct device * dev )
1108
1120
{
1109
1121
ARG_UNUSED (dev );
1110
- struct gctrl_it8xxx2_regs * const gctrl = ESPI_IT8XXX2_GET_GCTRL_BASE ;
1122
+ struct gctrl_ite_ec_regs * const gctrl = ESPI_ITE_GET_GCTRL_BASE ;
1111
1123
1112
1124
/* Accept Port 80h (and 81h) Cycle */
1113
1125
if (IS_ENABLED (CONFIG_ESPI_IT8XXX2_PORT_81_CYCLE )) {
@@ -2395,7 +2407,11 @@ void espi_it8xxx2_enable_trans_irq(const struct device *dev, bool enable)
2395
2407
} else {
2396
2408
irq_disable (IT8XXX2_TRANS_IRQ );
2397
2409
/* Clear pending interrupt */
2410
+ #ifdef CONFIG_SOC_SERIES_IT51XXX
2411
+ it51xxx_wuc_clear_status (config -> wuc .wucs , config -> wuc .mask );
2412
+ #else
2398
2413
it8xxx2_wuc_clear_status (config -> wuc .wucs , config -> wuc .mask );
2414
+ #endif
2399
2415
}
2400
2416
}
2401
2417
@@ -2431,7 +2447,7 @@ void espi_it8xxx2_espi_reset_isr(const struct device *port,
2431
2447
#define ESPI_IT8XXX2_ESPI_RESET_PIN 2
2432
2448
static void espi_it8xxx2_enable_reset (void )
2433
2449
{
2434
- struct gpio_it8xxx2_regs * const gpio_regs = GPIO_IT8XXX2_REG_BASE ;
2450
+ struct gpio_ite_ec_regs * const gpio_regs = GPIO_ITE_EC_REGS_BASE ;
2435
2451
static struct gpio_callback espi_reset_cb ;
2436
2452
2437
2453
/* eSPI reset is enabled on GPD2 */
@@ -2472,7 +2488,7 @@ static int espi_it8xxx2_init(const struct device *dev)
2472
2488
(struct espi_vw_regs * )config -> base_espi_vw ;
2473
2489
struct espi_slave_regs * const slave_reg =
2474
2490
(struct espi_slave_regs * )config -> base_espi_slave ;
2475
- struct gctrl_it8xxx2_regs * const gctrl = ESPI_IT8XXX2_GET_GCTRL_BASE ;
2491
+ struct gctrl_ite_ec_regs * const gctrl = ESPI_ITE_GET_GCTRL_BASE ;
2476
2492
2477
2493
/* configure VCC detector */
2478
2494
gctrl -> GCTRL_RSTS = (gctrl -> GCTRL_RSTS &
@@ -2539,8 +2555,13 @@ static int espi_it8xxx2_init(const struct device *dev)
2539
2555
slave_reg -> ESGCTRL2 |= IT8XXX2_ESPI_TO_WUC_ENABLE ;
2540
2556
2541
2557
/* Enable WU42 of WUI */
2558
+ #ifdef CONFIG_SOC_SERIES_IT51XXX
2559
+ it51xxx_wuc_clear_status (config -> wuc .wucs , config -> wuc .mask );
2560
+ it51xxx_wuc_enable (config -> wuc .wucs , config -> wuc .mask );
2561
+ #else
2542
2562
it8xxx2_wuc_clear_status (config -> wuc .wucs , config -> wuc .mask );
2543
2563
it8xxx2_wuc_enable (config -> wuc .wucs , config -> wuc .mask );
2564
+ #endif
2544
2565
/*
2545
2566
* Only register isr here, the interrupt only need to be enabled
2546
2567
* before CPU and RAM clocks gated in the idle function.
0 commit comments