Lines Matching full:espi
3 * File: espi.c *
41 #include "espi.h"
88 pr_err("%s: ESPI clock not ready\n", adapter->name); in tricn_init()
117 void t1_espi_intr_enable(struct peespi *espi) in t1_espi_intr_enable() argument
119 u32 enable, pl_intr = readl(espi->adapter->regs + A_PL_ENABLE); in t1_espi_intr_enable()
122 * Cannot enable ESPI interrupts on T1B because HW asserts the in t1_espi_intr_enable()
123 * interrupt incorrectly, namely the driver gets ESPI interrupts in t1_espi_intr_enable()
124 * but no data is actually dropped (can verify this reading the ESPI in t1_espi_intr_enable()
125 * drop registers). Also, once the ESPI interrupt is asserted it in t1_espi_intr_enable()
128 enable = t1_is_T1B(espi->adapter) ? 0 : ESPI_INTR_MASK; in t1_espi_intr_enable()
129 writel(enable, espi->adapter->regs + A_ESPI_INTR_ENABLE); in t1_espi_intr_enable()
130 writel(pl_intr | F_PL_INTR_ESPI, espi->adapter->regs + A_PL_ENABLE); in t1_espi_intr_enable()
133 void t1_espi_intr_clear(struct peespi *espi) in t1_espi_intr_clear() argument
135 readl(espi->adapter->regs + A_ESPI_DIP2_ERR_COUNT); in t1_espi_intr_clear()
136 writel(0xffffffff, espi->adapter->regs + A_ESPI_INTR_STATUS); in t1_espi_intr_clear()
137 writel(F_PL_INTR_ESPI, espi->adapter->regs + A_PL_CAUSE); in t1_espi_intr_clear()
140 void t1_espi_intr_disable(struct peespi *espi) in t1_espi_intr_disable() argument
142 u32 pl_intr = readl(espi->adapter->regs + A_PL_ENABLE); in t1_espi_intr_disable()
144 writel(0, espi->adapter->regs + A_ESPI_INTR_ENABLE); in t1_espi_intr_disable()
145 writel(pl_intr & ~F_PL_INTR_ESPI, espi->adapter->regs + A_PL_ENABLE); in t1_espi_intr_disable()
148 int t1_espi_intr_handler(struct peespi *espi) in t1_espi_intr_handler() argument
150 u32 status = readl(espi->adapter->regs + A_ESPI_INTR_STATUS); in t1_espi_intr_handler()
153 espi->intr_cnt.DIP4_err++; in t1_espi_intr_handler()
155 espi->intr_cnt.rx_drops++; in t1_espi_intr_handler()
157 espi->intr_cnt.tx_drops++; in t1_espi_intr_handler()
159 espi->intr_cnt.rx_ovflw++; in t1_espi_intr_handler()
161 espi->intr_cnt.parity_err++; in t1_espi_intr_handler()
163 espi->intr_cnt.DIP2_parity_err++; in t1_espi_intr_handler()
169 readl(espi->adapter->regs + A_ESPI_DIP2_ERR_COUNT); in t1_espi_intr_handler()
173 * For T1B we need to write 1 to clear ESPI interrupts. For T2+ we in t1_espi_intr_handler()
176 if (status && t1_is_T1B(espi->adapter)) in t1_espi_intr_handler()
178 writel(status, espi->adapter->regs + A_ESPI_INTR_STATUS); in t1_espi_intr_handler()
182 const struct espi_intr_counts *t1_espi_get_intr_counts(struct peespi *espi) in t1_espi_get_intr_counts() argument
184 return &espi->intr_cnt; in t1_espi_get_intr_counts()
237 int t1_espi_init(struct peespi *espi, int mac_type, int nports) in t1_espi_init() argument
240 adapter_t *adapter = espi->adapter; in t1_espi_init()
242 /* Disable ESPI training. MACs that can handle it enable it below. */ in t1_espi_init()
273 espi->misc_ctrl = readl(adapter->regs + A_ESPI_MISC_CONTROL); in t1_espi_init()
274 espi->misc_ctrl &= ~MON_MASK; in t1_espi_init()
275 espi->misc_ctrl |= F_MONITORED_DIRECTION; in t1_espi_init()
277 espi->misc_ctrl |= F_MONITORED_INTERFACE; in t1_espi_init()
278 writel(espi->misc_ctrl, adapter->regs + A_ESPI_MISC_CONTROL); in t1_espi_init()
279 spin_lock_init(&espi->lock); in t1_espi_init()
285 void t1_espi_destroy(struct peespi *espi) in t1_espi_destroy() argument
287 kfree(espi); in t1_espi_destroy()
292 struct peespi *espi = kzalloc(sizeof(*espi), GFP_KERNEL); in t1_espi_create() local
294 if (espi) in t1_espi_create()
295 espi->adapter = adapter; in t1_espi_create()
296 return espi; in t1_espi_create()
302 struct peespi *espi = adapter->espi;
306 spin_lock(&espi->lock);
307 espi->misc_ctrl = (val & ~MON_MASK) |
308 (espi->misc_ctrl & MON_MASK);
309 writel(espi->misc_ctrl, adapter->regs + A_ESPI_MISC_CONTROL);
310 spin_unlock(&espi->lock);
316 struct peespi *espi = adapter->espi; in t1_espi_get_mon() local
324 if (!spin_trylock(&espi->lock)) in t1_espi_get_mon()
327 spin_lock(&espi->lock); in t1_espi_get_mon()
329 if ((sel != (espi->misc_ctrl & MON_MASK))) { in t1_espi_get_mon()
330 writel(((espi->misc_ctrl & ~MON_MASK) | sel), in t1_espi_get_mon()
333 writel(espi->misc_ctrl, adapter->regs + A_ESPI_MISC_CONTROL); in t1_espi_get_mon()
336 spin_unlock(&espi->lock); in t1_espi_get_mon()
347 struct peespi *espi = adapter->espi; in t1_espi_get_mon_t204() local
351 if (!spin_trylock(&espi->lock)) in t1_espi_get_mon_t204()
354 spin_lock(&espi->lock); in t1_espi_get_mon_t204()
356 if ((espi->misc_ctrl & MON_MASK) != F_MONITORED_DIRECTION) { in t1_espi_get_mon_t204()
357 espi->misc_ctrl = (espi->misc_ctrl & ~MON_MASK) | in t1_espi_get_mon_t204()
359 writel(espi->misc_ctrl, adapter->regs + A_ESPI_MISC_CONTROL); in t1_espi_get_mon_t204()
363 writel(espi->misc_ctrl | V_MONITORED_PORT_NUM(i), in t1_espi_get_mon_t204()
369 writel(espi->misc_ctrl, adapter->regs + A_ESPI_MISC_CONTROL); in t1_espi_get_mon_t204()
370 spin_unlock(&espi->lock); in t1_espi_get_mon_t204()