2018-10-24 12:10:23 +00:00
|
|
|
# SPDX-License-Identifier: GPL-2.0
|
|
|
|
|
|
|
|
import pytest
|
|
|
|
import u_boot_utils
|
|
|
|
|
|
|
|
@pytest.mark.buildconfigspec('cmd_pinmux')
|
|
|
|
def test_pinmux_usage_1(u_boot_console):
|
|
|
|
"""Test that 'pinmux' command without parameters displays
|
|
|
|
pinmux usage."""
|
|
|
|
output = u_boot_console.run_command('pinmux')
|
|
|
|
assert 'Usage:' in output
|
|
|
|
|
|
|
|
@pytest.mark.buildconfigspec('cmd_pinmux')
|
|
|
|
def test_pinmux_usage_2(u_boot_console):
|
|
|
|
"""Test that 'pinmux status' executed without previous "pinmux dev"
|
2021-05-21 07:47:31 +00:00
|
|
|
command displays error message."""
|
2018-10-24 12:10:23 +00:00
|
|
|
output = u_boot_console.run_command('pinmux status')
|
2021-05-21 07:47:31 +00:00
|
|
|
assert 'pin-controller device not selected' in output
|
2018-10-24 12:10:23 +00:00
|
|
|
|
|
|
|
@pytest.mark.buildconfigspec('cmd_pinmux')
|
|
|
|
@pytest.mark.boardspec('sandbox')
|
|
|
|
def test_pinmux_status_all(u_boot_console):
|
|
|
|
"""Test that 'pinmux status -a' displays pin's muxing."""
|
|
|
|
output = u_boot_console.run_command('pinmux status -a')
|
2020-01-13 10:35:15 +00:00
|
|
|
|
|
|
|
assert ('pinctrl-gpio:' in output)
|
|
|
|
assert ('a5 : gpio output .' in output)
|
|
|
|
assert ('a6 : gpio output .' in output)
|
|
|
|
|
|
|
|
assert ('pinctrl:' in output)
|
2020-09-14 15:01:57 +00:00
|
|
|
assert ('P0 : UART TX.' in output)
|
|
|
|
assert ('P1 : UART RX.' in output)
|
|
|
|
assert ('P2 : I2S SCK.' in output)
|
|
|
|
assert ('P3 : I2S SD.' in output)
|
|
|
|
assert ('P4 : I2S WS.' in output)
|
|
|
|
assert ('P5 : GPIO0 bias-pull-up input-disable.' in output)
|
|
|
|
assert ('P6 : GPIO1 drive-open-drain.' in output)
|
|
|
|
assert ('P7 : GPIO2 bias-pull-down input-enable.' in output)
|
|
|
|
assert ('P8 : GPIO3 bias-disable.' in output)
|
2018-10-24 12:10:23 +00:00
|
|
|
|
|
|
|
@pytest.mark.buildconfigspec('cmd_pinmux')
|
|
|
|
@pytest.mark.boardspec('sandbox')
|
|
|
|
def test_pinmux_list(u_boot_console):
|
|
|
|
"""Test that 'pinmux list' returns the pin-controller list."""
|
|
|
|
output = u_boot_console.run_command('pinmux list')
|
|
|
|
assert 'sandbox_pinctrl' in output
|
|
|
|
|
|
|
|
@pytest.mark.buildconfigspec('cmd_pinmux')
|
|
|
|
def test_pinmux_dev_bad(u_boot_console):
|
|
|
|
"""Test that 'pinmux dev' returns an error when trying to select a
|
|
|
|
wrong pin controller."""
|
|
|
|
pincontroller = 'bad_pin_controller_name'
|
|
|
|
output = u_boot_console.run_command('pinmux dev ' + pincontroller)
|
|
|
|
expected_output = 'Can\'t get the pin-controller: ' + pincontroller + '!'
|
|
|
|
assert (expected_output in output)
|
|
|
|
|
|
|
|
@pytest.mark.buildconfigspec('cmd_pinmux')
|
|
|
|
@pytest.mark.boardspec('sandbox')
|
|
|
|
def test_pinmux_dev(u_boot_console):
|
|
|
|
"""Test that 'pinmux dev' select the wanted pin controller."""
|
|
|
|
pincontroller = 'pinctrl'
|
|
|
|
output = u_boot_console.run_command('pinmux dev ' + pincontroller)
|
|
|
|
expected_output = 'dev: ' + pincontroller
|
|
|
|
assert (expected_output in output)
|
|
|
|
|
|
|
|
@pytest.mark.buildconfigspec('cmd_pinmux')
|
|
|
|
@pytest.mark.boardspec('sandbox')
|
|
|
|
def test_pinmux_status(u_boot_console):
|
|
|
|
"""Test that 'pinmux status' displays selected pincontroller's pin
|
|
|
|
muxing descriptions."""
|
2022-08-06 23:51:45 +00:00
|
|
|
u_boot_console.run_command('pinmux dev pinctrl')
|
2018-10-24 12:10:23 +00:00
|
|
|
output = u_boot_console.run_command('pinmux status')
|
2020-01-13 10:35:15 +00:00
|
|
|
|
|
|
|
assert (not 'pinctrl-gpio:' in output)
|
|
|
|
assert (not 'pinctrl:' in output)
|
|
|
|
|
2020-09-14 15:01:57 +00:00
|
|
|
assert ('P0 : UART TX.' in output)
|
|
|
|
assert ('P1 : UART RX.' in output)
|
|
|
|
assert ('P2 : I2S SCK.' in output)
|
|
|
|
assert ('P3 : I2S SD.' in output)
|
|
|
|
assert ('P4 : I2S WS.' in output)
|
|
|
|
assert ('P5 : GPIO0 bias-pull-up input-disable.' in output)
|
|
|
|
assert ('P6 : GPIO1 drive-open-drain.' in output)
|
|
|
|
assert ('P7 : GPIO2 bias-pull-down input-enable.' in output)
|
|
|
|
assert ('P8 : GPIO3 bias-disable.' in output)
|