Lines Matching full:pin
86 static inline void *test_data(uint32_t gpio_addr, uint8_t pin) in test_data() argument
88 return (void *)(uintptr_t)((gpio_addr & GPIO_ADDR_MASK) | (pin & PIN_MASK)); in test_data()
105 unsigned int pin, uint32_t value) in gpio_set_bit() argument
107 uint32_t mask = 0xFFFFFFFF & ~(0x1 << pin); in gpio_set_bit()
108 gpio_writel(gpio, reg, (gpio_readl(gpio, reg) & mask) | value << pin); in gpio_set_bit()
112 unsigned int pin, uint32_t value) in gpio_set_2bits() argument
114 uint32_t offset = 2 * pin; in gpio_set_2bits()
186 * (in case the pin is in output mode). in test_idr_reset_value()
279 unsigned int pin = test_pin(data); in test_gpio_output_mode() local
286 gpio_set_bit(gpio, ODR, pin, 1); in test_gpio_output_mode()
288 g_assert_false(get_irq(gpio_id * NUM_GPIO_PINS + pin)); in test_gpio_output_mode()
290 /* Configure the relevant line as output and check the pin is high */ in test_gpio_output_mode()
291 gpio_set_2bits(gpio, MODER, pin, MODER_OUTPUT); in test_gpio_output_mode()
292 g_assert_cmphex(gpio_readl(gpio, IDR), ==, reset(gpio, IDR) | (1 << pin)); in test_gpio_output_mode()
293 g_assert_true(get_irq(gpio_id * NUM_GPIO_PINS + pin)); in test_gpio_output_mode()
295 /* Reset the bit in ODR and check the pin is low */ in test_gpio_output_mode()
296 gpio_set_bit(gpio, ODR, pin, 0); in test_gpio_output_mode()
297 g_assert_cmphex(gpio_readl(gpio, IDR), ==, reset(gpio, IDR) & ~(1 << pin)); in test_gpio_output_mode()
298 g_assert_false(get_irq(gpio_id * NUM_GPIO_PINS + pin)); in test_gpio_output_mode()
304 g_assert_false(get_irq(gpio_id * NUM_GPIO_PINS + pin)); in test_gpio_output_mode()
314 unsigned int pin = test_pin(data); in test_gpio_input_mode() local
320 /* Configure a line as input, raise it, and check that the pin is high */ in test_gpio_input_mode()
321 gpio_set_2bits(gpio, MODER, pin, MODER_INPUT); in test_gpio_input_mode()
322 gpio_set_irq(gpio, pin, 1); in test_gpio_input_mode()
323 g_assert_cmphex(gpio_readl(gpio, IDR), ==, reset(gpio, IDR) | (1 << pin)); in test_gpio_input_mode()
324 g_assert_true(get_irq(gpio_id * NUM_GPIO_PINS + pin)); in test_gpio_input_mode()
326 /* Lower the line and check that the pin is low */ in test_gpio_input_mode()
327 gpio_set_irq(gpio, pin, 0); in test_gpio_input_mode()
328 g_assert_cmphex(gpio_readl(gpio, IDR), ==, reset(gpio, IDR) & ~(1 << pin)); in test_gpio_input_mode()
329 g_assert_false(get_irq(gpio_id * NUM_GPIO_PINS + pin)); in test_gpio_input_mode()
340 * Test that a floating pin with pull-up sets the pin in test_pull_up_pull_down()
343 unsigned int pin = test_pin(data); in test_pull_up_pull_down() local
350 gpio_set_2bits(gpio, MODER, pin, MODER_INPUT); in test_pull_up_pull_down()
351 gpio_set_2bits(gpio, PUPDR, pin, PUPDR_PULLUP); in test_pull_up_pull_down()
352 g_assert_cmphex(gpio_readl(gpio, IDR), ==, reset(gpio, IDR) | (1 << pin)); in test_pull_up_pull_down()
353 g_assert_true(get_irq(gpio_id * NUM_GPIO_PINS + pin)); in test_pull_up_pull_down()
356 gpio_set_2bits(gpio, PUPDR, pin, PUPDR_PULLDOWN); in test_pull_up_pull_down()
357 g_assert_cmphex(gpio_readl(gpio, IDR), ==, reset(gpio, IDR) & ~(1 << pin)); in test_pull_up_pull_down()
358 g_assert_false(get_irq(gpio_id * NUM_GPIO_PINS + pin)); in test_pull_up_pull_down()
370 * disconnects the pin, that the pin can't be set or reset in test_push_pull()
373 unsigned int pin = test_pin(data); in test_push_pull() local
380 /* And checking the pin was disconnected */ in test_push_pull()
381 gpio_set_irq(gpio, pin, 1); in test_push_pull()
382 gpio_set_2bits(gpio, MODER, pin, MODER_OUTPUT); in test_push_pull()
384 g_assert_cmphex(gpio_readl(gpio, IDR), ==, reset(gpio, IDR) & ~(1 << pin)); in test_push_pull()
387 /* And checking the pin was disconnected */ 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()
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()
395 gpio_set_irq(gpio, pin, 1); in test_push_pull()
397 g_assert_cmphex(gpio_readl(gpio, IDR), ==, reset(gpio, IDR) & ~(1 << pin)); 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()
402 g_assert_cmphex(gpio_readl(gpio2, IDR), ==, reset(gpio2, IDR) | (1 << pin)); in test_push_pull()
414 * disconnects a pin set high externally and that the pin in test_open_drain()
417 * However a pin set low externally shouldn't be disconnected, in test_open_drain()
420 unsigned int pin = test_pin(data); in test_open_drain() local
427 /* And checking the pin was disconnected */ in test_open_drain()
428 gpio_set_irq(gpio, pin, 1); in test_open_drain()
429 gpio_set_bit(gpio, OTYPER, pin, OTYPER_OPEN_DRAIN); in test_open_drain()
430 gpio_set_2bits(gpio, MODER, pin, MODER_OUTPUT); in test_open_drain()
432 g_assert_cmphex(gpio_readl(gpio, IDR), ==, reset(gpio, IDR) & ~(1 << pin)); in test_open_drain()
435 /* And checking the pin wasn't disconnected */ 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()
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()
445 gpio_set_irq(gpio, pin, 1); in test_open_drain()
447 g_assert_cmphex(gpio_readl(gpio, IDR), ==, reset(gpio, IDR) & ~(1 << pin)); in test_open_drain()
449 /* Trying to reset a open-drain output pin, checking it works */ in test_open_drain()
450 gpio_set_bit(gpio, ODR, pin, 1); in test_open_drain()
451 gpio_set_irq(gpio, pin, 0); in test_open_drain()
452 g_assert_cmphex(get_disconnected_pins(gpio2), ==, 0xFFFF & ~(1 << pin)); in test_open_drain()
454 reset(gpio2, IDR) & ~(1 << pin)); in test_open_drain()
476 unsigned int pin = test_pin(data); in test_bsrr_brr() local
479 gpio_writel(gpio, BSRR, (1 << pin)); in test_bsrr_brr()
480 g_assert_cmphex(gpio_readl(gpio, ODR), ==, reset(gpio, ODR) | (1 << pin)); in test_bsrr_brr()
482 gpio_writel(gpio, BSRR, (1 << (pin + NUM_GPIO_PINS))); in test_bsrr_brr()
485 gpio_writel(gpio, BSRR, (1 << pin)); in test_bsrr_brr()
486 g_assert_cmphex(gpio_readl(gpio, ODR), ==, reset(gpio, ODR) | (1 << pin)); in test_bsrr_brr()
488 gpio_writel(gpio, BRR, (1 << pin)); in test_bsrr_brr()
492 gpio_writel(gpio, BSRR, (1 << pin) | (1 << (pin + NUM_GPIO_PINS))); in test_bsrr_brr()
493 g_assert_cmphex(gpio_readl(gpio, ODR), ==, reset(gpio, ODR) | (1 << pin)); in test_bsrr_brr()
495 gpio_writel(gpio, BRR, (1 << pin)); in test_bsrr_brr()
530 * The inputs for the tests (gpio and pin) can be changed, in main()
533 * Specifically, rising the pin then checking `get_irq()` in main()
534 * is problematic since the pin was already high. in main()