Lines Matching +full:gpio2 +full:- +full:output +full:- +full:enable
4 * Copyright (c) 2024 Arnaud Minier <arnaud.minier@telecom-paris.fr>
5 * Copyright (c) 2024 Inès Varhol <ines.varhol@telecom-paris.fr>
8 * See the COPYING file in the top-level directory.
12 #include "libqtest-single.h"
84 #define GPIO_ADDR_MASK (~(GPIO_SIZE - 1))
121 return (gpio_addr - GPIO_BASE_ADDR) / GPIO_SIZE; in get_gpio_id()
137 r = qtest_qmp(global_qtest, "{ 'execute': 'qom-set', 'arguments': " in disconnect_all_pins()
138 "{ 'path': %s, 'property': 'disconnected-pins', 'value': %d } }", in disconnect_all_pins()
151 r = qtest_qmp(global_qtest, "{ 'execute': 'qom-get', 'arguments':" in get_disconnected_pins()
152 " { 'path': %s, 'property': 'disconnected-pins'} }", path); in get_disconnected_pins()
183 * (intput/output/analog : register MODER, push-pull/open-drain : in test_idr_reset_value()
184 * register OTYPER, pull-up/pull-down/none : register PUPDR) in test_idr_reset_value()
186 * (in case the pin is in output mode). in test_idr_reset_value()
221 /* 15: pull-up, 14: pull-down, 13: pull-up, 12: neither ... */ in test_idr_reset_value()
236 /* ... 5: neither, 4: pull-up, 3: neither ... */ in test_idr_reset_value()
250 /* no pull-up or pull-down */ in test_idr_reset_value()
264 /* no pull-up or pull-down */ in test_idr_reset_value()
277 * when not in output mode are stored and not discarded. in test_gpio_output_mode()
290 /* Configure the relevant line as output and check the pin is high */ in test_gpio_output_mode()
340 * Test that a floating pin with pull-up sets the pin in test_pull_up_pull_down()
341 * high and vice-versa. in test_pull_up_pull_down()
349 /* Configure a line as input with pull-up, check the line is set high */ in test_pull_up_pull_down()
355 /* Configure the line with pull-down, check the line is low */ in test_pull_up_pull_down()
369 * Test that configuring a line in push-pull output mode in test_push_pull()
375 uint32_t gpio2 = GPIO_BASE_ADDR + (GPIO_H - gpio); in test_push_pull() local
379 /* Setting a line high externally, configuring it in push-pull output */ in test_push_pull()
386 /* Setting a line low externally, configuring it in push-pull output */ in test_push_pull()
388 gpio_set_irq(gpio2, pin, 0); in test_push_pull()
389 gpio_set_bit(gpio2, ODR, pin, 1); in test_push_pull()
390 gpio_set_2bits(gpio2, MODER, pin, MODER_OUTPUT); in test_push_pull()
391 g_assert_cmphex(get_disconnected_pins(gpio2), ==, 0xFFFF); in test_push_pull()
392 g_assert_cmphex(gpio_readl(gpio2, IDR), ==, reset(gpio2, IDR) | (1 << pin)); in test_push_pull()
394 /* Trying to set a push-pull output pin, checking it doesn't work */ in test_push_pull()
399 /* Trying to reset a push-pull output pin, checking it doesn't work */ in test_push_pull()
400 gpio_set_irq(gpio2, pin, 0); in test_push_pull()
401 g_assert_cmphex(get_disconnected_pins(gpio2), ==, 0xFFFF); in test_push_pull()
402 g_assert_cmphex(gpio_readl(gpio2, IDR), ==, reset(gpio2, IDR) | (1 << pin)); in test_push_pull()
406 gpio_writel(gpio2, ODR, reset(gpio2, ODR)); in test_push_pull()
407 gpio_writel(gpio2, MODER, reset(gpio2, MODER)); in test_push_pull()
413 * Test that configuring a line in open-drain output mode in test_open_drain()
415 * can't be set high externally while configured in open-drain. in test_open_drain()
418 * and it can be set low externally when in open-drain mode. in test_open_drain()
422 uint32_t gpio2 = GPIO_BASE_ADDR + (GPIO_H - gpio); in test_open_drain() local
426 /* Setting a line high externally, configuring it in open-drain output */ in test_open_drain()
434 /* Setting a line low externally, configuring it in open-drain output */ in test_open_drain()
436 gpio_set_irq(gpio2, pin, 0); in test_open_drain()
437 gpio_set_bit(gpio2, ODR, pin, 1); in test_open_drain()
438 gpio_set_bit(gpio2, OTYPER, pin, OTYPER_OPEN_DRAIN); in test_open_drain()
439 gpio_set_2bits(gpio2, MODER, pin, MODER_OUTPUT); in test_open_drain()
440 g_assert_cmphex(get_disconnected_pins(gpio2), ==, 0xFFFF & ~(1 << pin)); in test_open_drain()
441 g_assert_cmphex(gpio_readl(gpio2, IDR), ==, in test_open_drain()
442 reset(gpio2, IDR) & ~(1 << pin)); in test_open_drain()
444 /* Trying to set a open-drain output pin, checking it doesn't work */ in test_open_drain()
449 /* Trying to reset a open-drain output pin, checking it works */ in test_open_drain()
452 g_assert_cmphex(get_disconnected_pins(gpio2), ==, 0xFFFF & ~(1 << pin)); in test_open_drain()
453 g_assert_cmphex(gpio_readl(gpio2, IDR), ==, in test_open_drain()
454 reset(gpio2, IDR) & ~(1 << pin)); in test_open_drain()
457 disconnect_all_pins(gpio2); in test_open_drain()
458 gpio_writel(gpio2, OTYPER, reset(gpio2, OTYPER)); in test_open_drain()
459 gpio_writel(gpio2, ODR, reset(gpio2, ODR)); in test_open_drain()
460 gpio_writel(gpio2, MODER, reset(gpio2, MODER)); in test_open_drain()
461 g_assert_cmphex(gpio_readl(gpio2, IDR), ==, reset(gpio2, IDR)); in test_open_drain()
504 * For each GPIO, enable its clock in RCC in test_clock_enable()
509 for (uint32_t gpio = GPIO_A; gpio <= GPIO_H; gpio += GPIO_B - GPIO_A) { in test_clock_enable()
514 /* Enable the gpio clock */ in test_clock_enable()
575 qtest_start("-machine b-l475e-iot01a"); in main()