blob: 794994e12d1676cc5815e025683281fedf074752 [file] [log] [blame]
Patrice Chotardf41a8242018-10-24 14:10:23 +02001# SPDX-License-Identifier: GPL-2.0
2
3import pytest
4import u_boot_utils
5
6@pytest.mark.buildconfigspec('cmd_pinmux')
7def test_pinmux_usage_1(u_boot_console):
8 """Test that 'pinmux' command without parameters displays
9 pinmux usage."""
10 output = u_boot_console.run_command('pinmux')
11 assert 'Usage:' in output
12
13@pytest.mark.buildconfigspec('cmd_pinmux')
14def test_pinmux_usage_2(u_boot_console):
15 """Test that 'pinmux status' executed without previous "pinmux dev"
Patrick Delaunay4c60fd92021-05-21 09:47:31 +020016 command displays error message."""
Patrice Chotardf41a8242018-10-24 14:10:23 +020017 output = u_boot_console.run_command('pinmux status')
Patrick Delaunay4c60fd92021-05-21 09:47:31 +020018 assert 'pin-controller device not selected' in output
Patrice Chotardf41a8242018-10-24 14:10:23 +020019
20@pytest.mark.buildconfigspec('cmd_pinmux')
21@pytest.mark.boardspec('sandbox')
22def test_pinmux_status_all(u_boot_console):
23 """Test that 'pinmux status -a' displays pin's muxing."""
24 output = u_boot_console.run_command('pinmux status -a')
Patrick Delaunaye5301ba2020-01-13 11:35:15 +010025
26 assert ('pinctrl-gpio:' in output)
27 assert ('a5 : gpio output .' in output)
28 assert ('a6 : gpio output .' in output)
29
30 assert ('pinctrl:' in output)
Sean Anderson7f0f1802020-09-14 11:01:57 -040031 assert ('P0 : UART TX.' in output)
32 assert ('P1 : UART RX.' in output)
33 assert ('P2 : I2S SCK.' in output)
34 assert ('P3 : I2S SD.' in output)
35 assert ('P4 : I2S WS.' in output)
36 assert ('P5 : GPIO0 bias-pull-up input-disable.' in output)
37 assert ('P6 : GPIO1 drive-open-drain.' in output)
38 assert ('P7 : GPIO2 bias-pull-down input-enable.' in output)
39 assert ('P8 : GPIO3 bias-disable.' in output)
Patrice Chotardf41a8242018-10-24 14:10:23 +020040
41@pytest.mark.buildconfigspec('cmd_pinmux')
42@pytest.mark.boardspec('sandbox')
43def test_pinmux_list(u_boot_console):
44 """Test that 'pinmux list' returns the pin-controller list."""
45 output = u_boot_console.run_command('pinmux list')
46 assert 'sandbox_pinctrl' in output
47
48@pytest.mark.buildconfigspec('cmd_pinmux')
49def test_pinmux_dev_bad(u_boot_console):
50 """Test that 'pinmux dev' returns an error when trying to select a
51 wrong pin controller."""
52 pincontroller = 'bad_pin_controller_name'
53 output = u_boot_console.run_command('pinmux dev ' + pincontroller)
54 expected_output = 'Can\'t get the pin-controller: ' + pincontroller + '!'
55 assert (expected_output in output)
56
57@pytest.mark.buildconfigspec('cmd_pinmux')
58@pytest.mark.boardspec('sandbox')
59def test_pinmux_dev(u_boot_console):
60 """Test that 'pinmux dev' select the wanted pin controller."""
61 pincontroller = 'pinctrl'
62 output = u_boot_console.run_command('pinmux dev ' + pincontroller)
63 expected_output = 'dev: ' + pincontroller
64 assert (expected_output in output)
65
66@pytest.mark.buildconfigspec('cmd_pinmux')
67@pytest.mark.boardspec('sandbox')
68def test_pinmux_status(u_boot_console):
69 """Test that 'pinmux status' displays selected pincontroller's pin
70 muxing descriptions."""
Simon Glass2aa11882022-08-06 17:51:45 -060071 u_boot_console.run_command('pinmux dev pinctrl')
Patrice Chotardf41a8242018-10-24 14:10:23 +020072 output = u_boot_console.run_command('pinmux status')
Patrick Delaunaye5301ba2020-01-13 11:35:15 +010073
74 assert (not 'pinctrl-gpio:' in output)
75 assert (not 'pinctrl:' in output)
76
Sean Anderson7f0f1802020-09-14 11:01:57 -040077 assert ('P0 : UART TX.' in output)
78 assert ('P1 : UART RX.' in output)
79 assert ('P2 : I2S SCK.' in output)
80 assert ('P3 : I2S SD.' in output)
81 assert ('P4 : I2S WS.' in output)
82 assert ('P5 : GPIO0 bias-pull-up input-disable.' in output)
83 assert ('P6 : GPIO1 drive-open-drain.' in output)
84 assert ('P7 : GPIO2 bias-pull-down input-enable.' in output)
85 assert ('P8 : GPIO3 bias-disable.' in output)