@@ -18,13 +18,19 @@ LOG_MODULE_REGISTER(espi, CONFIG_ESPI_LOG_LEVEL);
18
18
19
19
#include "espi_utils.h"
20
20
#include "reg/reg_espi.h"
21
+ #include "reg/reg_port80.h"
21
22
22
23
BUILD_ASSERT (DT_NUM_INST_STATUS_OKAY (DT_DRV_COMPAT ) == 1 , "support only one espi compatible node" );
23
24
24
25
struct espi_rts5912_config {
25
26
volatile struct espi_reg * const espi_reg ;
26
27
uint32_t espislv_clk_grp ;
27
28
uint32_t espislv_clk_idx ;
29
+ #ifdef CONFIG_ESPI_PERIPHERAL_DEBUG_PORT_80
30
+ volatile struct port80_reg * const port80_reg ;
31
+ uint32_t port80_clk_grp ;
32
+ uint32_t port80_clk_idx ;
33
+ #endif
28
34
const struct device * clk_dev ;
29
35
const struct pinctrl_dev_config * pcfg ;
30
36
};
@@ -45,6 +51,62 @@ struct espi_rts5912_data {
45
51
#endif
46
52
};
47
53
54
+ /*
55
+ * =========================================================================
56
+ * ESPI Peripheral Debug Port 80
57
+ * =========================================================================
58
+ */
59
+
60
+ #ifdef CONFIG_ESPI_PERIPHERAL_DEBUG_PORT_80
61
+
62
+ static void espi_port80_isr (const struct device * dev )
63
+ {
64
+ const struct espi_rts5912_config * const espi_config = dev -> config ;
65
+ struct espi_rts5912_data * espi_data = dev -> data ;
66
+ struct espi_event evt = {ESPI_BUS_PERIPHERAL_NOTIFICATION ,
67
+ ESPI_PERIPHERAL_INDEX_0 << 16 | ESPI_PERIPHERAL_DEBUG_PORT80 ,
68
+ ESPI_PERIPHERAL_NODATA };
69
+ volatile struct port80_reg * const port80_reg = espi_config -> port80_reg ;
70
+
71
+ evt .evt_data = port80_reg -> DATA ;
72
+ espi_send_callbacks (& espi_data -> callbacks , dev , evt );
73
+ }
74
+
75
+ static int espi_peri_ch_port80_setup (const struct device * dev )
76
+ {
77
+ const struct espi_rts5912_config * const espi_config = dev -> config ;
78
+ struct rts5912_sccon_subsys sccon ;
79
+ volatile struct port80_reg * const port80_reg = espi_config -> port80_reg ;
80
+ int rc ;
81
+
82
+ if (!device_is_ready (espi_config -> clk_dev )) {
83
+ return - ENODEV ;
84
+ }
85
+
86
+ sccon .clk_grp = espi_config -> port80_clk_grp ;
87
+ sccon .clk_idx = espi_config -> port80_clk_idx ;
88
+
89
+ rc = clock_control_on (espi_config -> clk_dev , (clock_control_subsys_t )& sccon );
90
+ if (rc != 0 ) {
91
+ return rc ;
92
+ }
93
+
94
+ port80_reg -> ADDR = 0x80UL ;
95
+ port80_reg -> CFG = PORT80_CFG_CLRFLG | PORT80_CFG_THREEN ;
96
+ port80_reg -> INTEN = PORT80_INTEN_THREINTEN ;
97
+
98
+ NVIC_ClearPendingIRQ (DT_IRQ_BY_NAME (DT_DRV_INST (0 ), port80 , irq ));
99
+
100
+ IRQ_CONNECT (DT_IRQ_BY_NAME (DT_DRV_INST (0 ), port80 , irq ),
101
+ DT_IRQ_BY_NAME (DT_DRV_INST (0 ), port80 , priority ), espi_port80_isr ,
102
+ DEVICE_DT_GET (DT_DRV_INST (0 )), 0 );
103
+ irq_enable (DT_IRQ_BY_NAME (DT_DRV_INST (0 ), port80 , irq ));
104
+
105
+ return 0 ;
106
+ }
107
+
108
+ #endif /* CONFIG_ESPI_PERIPHERAL_DEBUG_PORT_80 */
109
+
48
110
/*
49
111
* =========================================================================
50
112
* ESPI VWIRE channel
@@ -1573,6 +1635,15 @@ static int espi_rts5912_init(const struct device *dev)
1573
1635
/* Setup eSPI bus reset */
1574
1636
espi_bus_reset_setup (dev );
1575
1637
1638
+ #ifdef CONFIG_ESPI_PERIPHERAL_DEBUG_PORT_80
1639
+ /* Setup Port80 */
1640
+ rc = espi_peri_ch_port80_setup (dev );
1641
+ if (rc != 0 ) {
1642
+ LOG_ERR ("eSPI Port80 setup failed" );
1643
+ goto exit ;
1644
+ }
1645
+ #endif
1646
+
1576
1647
#ifdef CONFIG_ESPI_VWIRE_CHANNEL
1577
1648
/* Setup eSPI virtual-wire channel */
1578
1649
espi_vw_ch_setup (dev );
@@ -1608,6 +1679,11 @@ static const struct espi_rts5912_config espi_rts5912_config = {
1608
1679
.espi_reg = (volatile struct espi_reg * const )DT_INST_REG_ADDR_BY_NAME (0 , espi_target ),
1609
1680
.espislv_clk_grp = DT_CLOCKS_CELL_BY_NAME (DT_DRV_INST (0 ), espi_target , clk_grp ),
1610
1681
.espislv_clk_idx = DT_CLOCKS_CELL_BY_NAME (DT_DRV_INST (0 ), espi_target , clk_idx ),
1682
+ #ifdef CONFIG_ESPI_PERIPHERAL_DEBUG_PORT_80
1683
+ .port80_reg = (volatile struct port80_reg * const )DT_INST_REG_ADDR_BY_NAME (0 , port80 ),
1684
+ .port80_clk_grp = DT_CLOCKS_CELL_BY_NAME (DT_DRV_INST (0 ), port80 , clk_grp ),
1685
+ .port80_clk_idx = DT_CLOCKS_CELL_BY_NAME (DT_DRV_INST (0 ), port80 , clk_idx ),
1686
+ #endif
1611
1687
.clk_dev = DEVICE_DT_GET (DT_INST_CLOCKS_CTLR (0 )),
1612
1688
.pcfg = PINCTRL_DT_INST_DEV_CONFIG_GET (0 ),
1613
1689
};
0 commit comments