12ec06378SPeter Delevoryas /* 22ec06378SPeter Delevoryas * QTest testcase for the Aspeed GPIO Controller. 32ec06378SPeter Delevoryas * 42ec06378SPeter Delevoryas * Copyright (c) Meta Platforms, Inc. and affiliates. (http://www.meta.com) 52ec06378SPeter Delevoryas * 62ec06378SPeter Delevoryas * Permission is hereby granted, free of charge, to any person obtaining a copy 72ec06378SPeter Delevoryas * of this software and associated documentation files (the "Software"), to deal 82ec06378SPeter Delevoryas * in the Software without restriction, including without limitation the rights 92ec06378SPeter Delevoryas * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 102ec06378SPeter Delevoryas * copies of the Software, and to permit persons to whom the Software is 112ec06378SPeter Delevoryas * furnished to do so, subject to the following conditions: 122ec06378SPeter Delevoryas * 132ec06378SPeter Delevoryas * The above copyright notice and this permission notice shall be included in 142ec06378SPeter Delevoryas * all copies or substantial portions of the Software. 152ec06378SPeter Delevoryas * 162ec06378SPeter Delevoryas * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 172ec06378SPeter Delevoryas * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 182ec06378SPeter Delevoryas * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 192ec06378SPeter Delevoryas * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 202ec06378SPeter Delevoryas * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 212ec06378SPeter Delevoryas * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 222ec06378SPeter Delevoryas * THE SOFTWARE. 232ec06378SPeter Delevoryas */ 242ec06378SPeter Delevoryas 252ec06378SPeter Delevoryas #include "qemu/osdep.h" 262ec06378SPeter Delevoryas #include "qemu/bitops.h" 272ec06378SPeter Delevoryas #include "qemu/timer.h" 282ec06378SPeter Delevoryas #include "qapi/qmp/qdict.h" 292ec06378SPeter Delevoryas #include "libqtest-single.h" 302ec06378SPeter Delevoryas 312ec06378SPeter Delevoryas static void test_set_colocated_pins(const void *data) 322ec06378SPeter Delevoryas { 332ec06378SPeter Delevoryas QTestState *s = (QTestState *)data; 342ec06378SPeter Delevoryas 352ec06378SPeter Delevoryas /* 362ec06378SPeter Delevoryas * gpioV4-7 occupy bits within a single 32-bit value, so we want to make 372ec06378SPeter Delevoryas * sure that modifying one doesn't affect the other. 382ec06378SPeter Delevoryas */ 39*188052a1SIris Chen qtest_qom_set_bool(s, "/machine/soc/gpio", "gpioV4", true); 40*188052a1SIris Chen qtest_qom_set_bool(s, "/machine/soc/gpio", "gpioV5", false); 41*188052a1SIris Chen qtest_qom_set_bool(s, "/machine/soc/gpio", "gpioV6", true); 42*188052a1SIris Chen qtest_qom_set_bool(s, "/machine/soc/gpio", "gpioV7", false); 43*188052a1SIris Chen g_assert(qtest_qom_get_bool(s, "/machine/soc/gpio", "gpioV4")); 44*188052a1SIris Chen g_assert(!qtest_qom_get_bool(s, "/machine/soc/gpio", "gpioV5")); 45*188052a1SIris Chen g_assert(qtest_qom_get_bool(s, "/machine/soc/gpio", "gpioV6")); 46*188052a1SIris Chen g_assert(!qtest_qom_get_bool(s, "/machine/soc/gpio", "gpioV7")); 472ec06378SPeter Delevoryas } 482ec06378SPeter Delevoryas 492ec06378SPeter Delevoryas int main(int argc, char **argv) 502ec06378SPeter Delevoryas { 512ec06378SPeter Delevoryas QTestState *s; 522ec06378SPeter Delevoryas int r; 532ec06378SPeter Delevoryas 542ec06378SPeter Delevoryas g_test_init(&argc, &argv, NULL); 552ec06378SPeter Delevoryas 562ec06378SPeter Delevoryas s = qtest_init("-machine ast2600-evb"); 572ec06378SPeter Delevoryas qtest_add_data_func("/ast2600/gpio/set_colocated_pins", s, 582ec06378SPeter Delevoryas test_set_colocated_pins); 592ec06378SPeter Delevoryas r = g_test_run(); 602ec06378SPeter Delevoryas qtest_quit(s); 612ec06378SPeter Delevoryas 622ec06378SPeter Delevoryas return r; 632ec06378SPeter Delevoryas } 64