Lines Matching +full:fault +full:- +full:gpios

2  * Copyright (c) 2018-2019 PHYTEC Messtechnik GmbH
5 * SPDX-License-Identifier: Apache-2.0
9 * This file is based on SW_DP.c from CMSIS-DAP Source (Revision: V2.0.0)
10 * https://github.com/ARM-software/CMSIS_5/tree/develop/CMSIS/DAP/Firmware
11 * Copyright (c) 2013-2017, ARM Limited, All Rights Reserved
12 * SPDX-License-Identifier: Apache-2.0
16 /* Serial Wire Debug Port interface bit-bang driver */
69 * - CMSIS-DAP Command Specification, DAP_Transfer
70 * - ARM Debug Interface v5 Architecture Specification
91 const struct sw_config *config = dev->config; in pin_swclk_set()
94 swdp_ll_pin_set(config->clk_reg, config->clk.pin); in pin_swclk_set()
96 gpio_pin_set_dt(&config->clk, 1); in pin_swclk_set()
103 const struct sw_config *config = dev->config; in pin_swclk_clr()
106 swdp_ll_pin_clr(config->clk_reg, config->clk.pin); in pin_swclk_clr()
108 gpio_pin_set_dt(&config->clk, 0); in pin_swclk_clr()
115 const struct sw_config *config = dev->config; in pin_swdio_set()
117 if (config->dout.port) { in pin_swdio_set()
119 swdp_ll_pin_set(config->dout_reg, config->dout.pin); in pin_swdio_set()
121 gpio_pin_set_dt(&config->dout, 1); in pin_swdio_set()
125 swdp_ll_pin_set(config->dio_reg, config->dio.pin); in pin_swdio_set()
127 gpio_pin_set_dt(&config->dio, 1); in pin_swdio_set()
135 const struct sw_config *config = dev->config; in pin_swdio_clr()
137 if (config->dout.port) { in pin_swdio_clr()
139 swdp_ll_pin_clr(config->dout_reg, config->dout.pin); in pin_swdio_clr()
141 gpio_pin_set_dt(&config->dout, 0); in pin_swdio_clr()
145 swdp_ll_pin_clr(config->dio_reg, config->dio.pin); in pin_swdio_clr()
147 gpio_pin_set_dt(&config->dio, 0); in pin_swdio_clr()
166 const struct sw_config *config = dev->config; in pin_swdio_in()
169 return swdp_ll_pin_get(config->dio_reg, config->dio.pin); in pin_swdio_in()
171 return gpio_pin_get_dt(&config->dio); in pin_swdio_in()
181 const struct sw_config *config = dev->config; in pin_swdio_out_enable()
183 if (config->dnoe.port) { in pin_swdio_out_enable()
185 swdp_ll_pin_set(config->dnoe_reg, config->dnoe.pin); in pin_swdio_out_enable()
187 gpio_pin_set_dt(&config->dnoe, 1); in pin_swdio_out_enable()
191 swdp_ll_pin_output(config->dio_reg, config->dio.pin); in pin_swdio_out_enable()
193 gpio_pin_configure_dt(&config->dio, GPIO_OUTPUT_ACTIVE); in pin_swdio_out_enable()
203 const struct sw_config *config = dev->config; in pin_swdio_out_disable()
205 if (config->dnoe.port) { in pin_swdio_out_disable()
207 swdp_ll_pin_clr(config->dnoe_reg, config->dnoe.pin); in pin_swdio_out_disable()
209 gpio_pin_set_dt(&config->dnoe, 0); in pin_swdio_out_disable()
213 swdp_ll_pin_input(config->dio_reg, config->dio.pin); in pin_swdio_out_disable()
215 gpio_pin_configure_dt(&config->dio, GPIO_INPUT); in pin_swdio_out_disable()
249 struct sw_cfg_data *sw_data = dev->data; in sw_output_sequence()
259 while (count--) { in sw_output_sequence()
269 SW_CLOCK_CYCLE(dev, sw_data->clock_delay); in sw_output_sequence()
271 n--; in sw_output_sequence()
282 struct sw_cfg_data *sw_data = dev->data; in sw_input_sequence()
292 while (count--) { in sw_input_sequence()
298 SW_READ_BIT(dev, bit, sw_data->clock_delay); in sw_input_sequence()
301 n--; in sw_input_sequence()
312 struct sw_cfg_data *sw_data = dev->data; in sw_cycle_turnaround()
315 for (n = sw_data->turnaround; n; n--) { in sw_cycle_turnaround()
316 SW_CLOCK_CYCLE(dev, sw_data->clock_delay); in sw_cycle_turnaround()
324 struct sw_cfg_data *sw_data = dev->data; in sw_transfer()
343 for (n = 8U; n; n--) { in sw_transfer()
344 SW_WRITE_BIT(dev, val, sw_data->clock_delay); in sw_transfer()
352 SW_READ_BIT(dev, bit, sw_data->clock_delay); in sw_transfer()
354 SW_READ_BIT(dev, bit, sw_data->clock_delay); in sw_transfer()
356 SW_READ_BIT(dev, bit, sw_data->clock_delay); in sw_transfer()
364 for (n = 32U; n; n--) { in sw_transfer()
366 SW_READ_BIT(dev, bit, sw_data->clock_delay); in sw_transfer()
372 SW_READ_BIT(dev, bit, sw_data->clock_delay); in sw_transfer()
390 for (n = 32U; n; n--) { in sw_transfer()
391 SW_WRITE_BIT(dev, val, sw_data->clock_delay); in sw_transfer()
396 SW_WRITE_BIT(dev, parity, sw_data->clock_delay); in sw_transfer()
402 for (; n; n--) { in sw_transfer()
403 SW_CLOCK_CYCLE(dev, sw_data->clock_delay); in sw_transfer()
421 /* WAIT OR fault response */ in sw_transfer()
422 if (sw_data->data_phase) { in sw_transfer()
423 for (n = 32U + 1U + sw_data->turnaround; n; n--) { in sw_transfer()
425 SW_CLOCK_CYCLE(dev, sw_data->clock_delay); in sw_transfer()
434 LOG_DBG("Transfer wait or fault"); in sw_transfer()
443 for (n = sw_data->turnaround + 32U + 1U; n; n--) { in sw_transfer()
445 SW_CLOCK_CYCLE(dev, sw_data->clock_delay); in sw_transfer()
462 const struct sw_config *config = dev->config; in sw_set_pins()
468 gpio_pin_set_dt(&config->clk, 1); in sw_set_pins()
470 gpio_pin_set_dt(&config->clk, 0); in sw_set_pins()
474 if (config->dout_reg != NULL) { in sw_set_pins()
477 gpio_pin_set_dt(&config->dout, 1); in sw_set_pins()
479 gpio_pin_set_dt(&config->dout, 0); in sw_set_pins()
485 gpio_pin_set_dt(&config->dio, 1); in sw_set_pins()
487 gpio_pin_set_dt(&config->dio, 0); in sw_set_pins()
492 if (config->reset.port) { in sw_set_pins()
495 gpio_pin_set_dt(&config->reset, 1); in sw_set_pins()
497 gpio_pin_set_dt(&config->reset, 0); in sw_set_pins()
507 const struct sw_config *config = dev->config; in sw_get_pins()
510 if (config->reset.port) { in sw_get_pins()
511 val = gpio_pin_get_dt(&config->reset); in sw_get_pins()
515 val = gpio_pin_get_dt(&config->dio); in sw_get_pins()
518 val = gpio_pin_get_dt(&config->clk); in sw_get_pins()
528 const struct sw_config *config = dev->config; in sw_set_clock()
529 struct sw_cfg_data *sw_data = dev->data; in sw_set_clock()
532 if (clock >= MAX_SWJ_CLOCK(DELAY_FAST_CYCLES, config->port_write_cycles)) { in sw_set_clock()
533 sw_data->fast_clock = true; in sw_set_clock()
536 sw_data->fast_clock = false; in sw_set_clock()
538 delay = ((CPU_CLOCK / 2U) + (clock - 1U)) / clock; in sw_set_clock()
539 if (delay > config->port_write_cycles) { in sw_set_clock()
540 delay -= config->port_write_cycles; in sw_set_clock()
541 delay = (delay + (DELAY_SLOW_CYCLES - 1U)) / DELAY_SLOW_CYCLES; in sw_set_clock()
547 sw_data->clock_delay = delay; in sw_set_clock()
549 LOG_WRN("cpu_clock %d, delay %d", CPU_CLOCK, sw_data->clock_delay); in sw_set_clock()
557 struct sw_cfg_data *sw_data = dev->data; in sw_configure()
559 sw_data->turnaround = turnaround; in sw_configure()
560 sw_data->data_phase = data_phase; in sw_configure()
563 sw_data->turnaround, sw_data->data_phase); in sw_configure()
570 const struct sw_config *config = dev->config; in sw_port_on()
573 if (config->dnoe.port) { in sw_port_on()
574 ret = gpio_pin_configure_dt(&config->dnoe, GPIO_OUTPUT_ACTIVE); in sw_port_on()
580 if (config->dout.port) { in sw_port_on()
581 ret = gpio_pin_configure_dt(&config->dout, GPIO_OUTPUT_ACTIVE); in sw_port_on()
587 ret = gpio_pin_configure_dt(&config->dio, GPIO_INPUT); in sw_port_on()
592 if (config->noe.port) { in sw_port_on()
593 ret = gpio_pin_configure_dt(&config->noe, GPIO_OUTPUT_ACTIVE); in sw_port_on()
599 ret = gpio_pin_configure_dt(&config->clk, GPIO_OUTPUT_ACTIVE); in sw_port_on()
604 if (config->reset.port) { in sw_port_on()
605 ret = gpio_pin_configure_dt(&config->reset, GPIO_OUTPUT_ACTIVE); in sw_port_on()
616 const struct sw_config *config = dev->config; in sw_port_off()
620 if (config->dnoe.port) { in sw_port_off()
621 ret = gpio_pin_configure_dt(&config->dnoe, GPIO_OUTPUT_INACTIVE); in sw_port_off()
626 if (config->dout.port) { in sw_port_off()
627 ret = gpio_pin_configure_dt(&config->dout, GPIO_OUTPUT_ACTIVE); in sw_port_off()
633 ret = gpio_pin_configure_dt(&config->dio, GPIO_INPUT); in sw_port_off()
638 if (config->dout.port) { in sw_port_off()
639 ret = gpio_pin_configure_dt(&config->dout, GPIO_DISCONNECTED); in sw_port_off()
645 ret = gpio_pin_configure_dt(&config->dio, GPIO_DISCONNECTED); in sw_port_off()
652 if (config->noe.port) { in sw_port_off()
653 ret = gpio_pin_configure_dt(&config->noe, GPIO_OUTPUT_INACTIVE); in sw_port_off()
658 ret = gpio_pin_configure_dt(&config->clk, GPIO_OUTPUT_ACTIVE); in sw_port_off()
664 ret = gpio_pin_configure_dt(&config->clk, GPIO_DISCONNECTED); in sw_port_off()
670 if (config->reset.port) { in sw_port_off()
671 ret = gpio_pin_configure_dt(&config->reset, GPIO_DISCONNECTED); in sw_port_off()
682 struct sw_cfg_data *sw_data = dev->data; in sw_gpio_init()
691 sw_data->turnaround = 1U; in sw_gpio_init()
692 sw_data->data_phase = false; in sw_gpio_init()
693 sw_data->fast_clock = false; in sw_gpio_init()
711 #define SW_GPIOS_GET_REG(n, gpios) \ argument
712 COND_CODE_1(DT_INST_NODE_HAS_PROP(n, gpios), \
713 (INT_TO_POINTER(DT_REG_ADDR(DT_PHANDLE(DT_DRV_INST(n), gpios)))), \
719 "Either the dout-gpios or dnoe-gpios property is missing."); \