Lines Matching +full:done +full:- +full:gpios

1 // SPDX-License-Identifier: GPL-2.0-only
3 // KUnit test for the Cirrus side-codec library.
42 return !!(gpio_priv->pin_state & BIT(offset)); in cirrus_scodec_test_gpio_get()
48 return -EOPNOTSUPP; in cirrus_scodec_test_gpio_direction_out()
63 return -EOPNOTSUPP; in cirrus_scodec_test_gpio_set_config()
80 .base = -1,
89 gpio_priv = devm_kzalloc(&pdev->dev, sizeof(*gpio_priv), GFP_KERNEL); in cirrus_scodec_test_gpio_probe()
91 return -ENOMEM; in cirrus_scodec_test_gpio_probe()
94 gpio_priv->chip = cirrus_scodec_test_gpio_chip; in cirrus_scodec_test_gpio_probe()
95 ret = devm_gpiochip_add_data(&pdev->dev, &gpio_priv->chip, gpio_priv); in cirrus_scodec_test_gpio_probe()
97 return dev_err_probe(&pdev->dev, ret, "Failed to add gpiochip\n"); in cirrus_scodec_test_gpio_probe()
99 dev_set_drvdata(&pdev->dev, gpio_priv); in cirrus_scodec_test_gpio_probe()
116 struct cirrus_scodec_test_priv *priv = test->priv; in cirrus_scodec_test_create_gpio()
119 priv->gpio_pdev = platform_device_alloc(cirrus_scodec_test_gpio_driver.driver.name, -1); in cirrus_scodec_test_create_gpio()
120 if (!priv->gpio_pdev) in cirrus_scodec_test_create_gpio()
121 return -ENOMEM; in cirrus_scodec_test_create_gpio()
123 ret = device_add_software_node(&priv->gpio_pdev->dev, &cirrus_scodec_test_gpio_swnode); in cirrus_scodec_test_create_gpio()
125 platform_device_put(priv->gpio_pdev); in cirrus_scodec_test_create_gpio()
130 ret = platform_device_add(priv->gpio_pdev); in cirrus_scodec_test_create_gpio()
132 platform_device_put(priv->gpio_pdev); in cirrus_scodec_test_create_gpio()
137 priv->gpio_priv = dev_get_drvdata(&priv->gpio_pdev->dev); in cirrus_scodec_test_create_gpio()
138 if (!priv->gpio_priv) { in cirrus_scodec_test_create_gpio()
139 platform_device_put(priv->gpio_pdev); in cirrus_scodec_test_create_gpio()
141 return -EINVAL; in cirrus_scodec_test_create_gpio()
162 PROPERTY_ENTRY_REF_ARRAY_LEN("spk-id-gpios", args, num_args), in cirrus_scodec_test_set_spkid_swnode()
170 return -ENOMEM; in cirrus_scodec_test_set_spkid_swnode()
174 return -ENOMEM; in cirrus_scodec_test_set_spkid_swnode()
177 node->properties = props; in cirrus_scodec_test_set_spkid_swnode()
190 struct cirrus_scodec_test_priv *priv = test->priv; in cirrus_scodec_test_spkid_parse()
191 const struct cirrus_scodec_test_spkid_param *param = test->param_value; in cirrus_scodec_test_spkid_parse()
192 int num_spk_id_refs = param->num_amps * param->gpios_per_amp; in cirrus_scodec_test_spkid_parse()
194 struct device *dev = &priv->amp_pdev.dev; in cirrus_scodec_test_spkid_parse()
205 * If amps are sharing GPIOs repeat the last set of in cirrus_scodec_test_spkid_parse()
206 * GPIOs until we've done that number of amps. in cirrus_scodec_test_spkid_parse()
207 * We have done all GPIOs for an amp when i is a multiple in cirrus_scodec_test_spkid_parse()
209 * We have done all amps sharing the same GPIOs when i is in cirrus_scodec_test_spkid_parse()
212 if (!(i % param->gpios_per_amp) && in cirrus_scodec_test_spkid_parse()
213 (i % (param->gpios_per_amp * param->num_amps_sharing))) in cirrus_scodec_test_spkid_parse()
214 v -= param->gpios_per_amp; in cirrus_scodec_test_spkid_parse()
220 for (i = 0; i < param->num_amps; ++i) { in cirrus_scodec_test_spkid_parse()
221 for (v = 0; v < (1 << param->gpios_per_amp); ++v) { in cirrus_scodec_test_spkid_parse()
223 priv->gpio_priv->pin_state = in cirrus_scodec_test_spkid_parse()
224 v << (param->gpios_per_amp * (i / param->num_amps_sharing)); in cirrus_scodec_test_spkid_parse()
226 ret = cirrus_scodec_get_speaker_id(dev, i, param->num_amps, -1); in cirrus_scodec_test_spkid_parse()
229 i, priv->gpio_priv->pin_state); in cirrus_scodec_test_spkid_parse()
236 struct cirrus_scodec_test_priv *priv = test->priv; in cirrus_scodec_test_no_spkid()
237 struct device *dev = &priv->amp_pdev.dev; in cirrus_scodec_test_no_spkid()
240 ret = cirrus_scodec_get_speaker_id(dev, 0, 4, -1); in cirrus_scodec_test_no_spkid()
241 KUNIT_EXPECT_EQ(test, ret, -ENOENT); in cirrus_scodec_test_no_spkid()
255 return -ENOMEM; in cirrus_scodec_test_case_init()
257 test->priv = priv; in cirrus_scodec_test_case_init()
265 priv->amp_pdev.name = "cirrus_scodec_test_amp_drv"; in cirrus_scodec_test_case_init()
266 priv->amp_pdev.id = -1; in cirrus_scodec_test_case_init()
267 priv->amp_pdev.dev.release = cirrus_scodec_test_dev_release; in cirrus_scodec_test_case_init()
268 ret = platform_device_register(&priv->amp_pdev); in cirrus_scodec_test_case_init()
276 struct cirrus_scodec_test_priv *priv = test->priv; in cirrus_scodec_test_case_exit()
278 if (priv->amp_pdev.name) in cirrus_scodec_test_case_exit()
279 platform_device_unregister(&priv->amp_pdev); in cirrus_scodec_test_case_exit()
281 if (priv->gpio_pdev) { in cirrus_scodec_test_case_exit()
282 device_remove_software_node(&priv->gpio_pdev->dev); in cirrus_scodec_test_case_exit()
283 platform_device_unregister(priv->gpio_pdev); in cirrus_scodec_test_case_exit()
334 /* Two sets of shared GPIOs */
345 param->num_amps, param->gpios_per_amp, param->num_amps_sharing); in cirrus_scodec_test_spkid_param_desc()
358 .name = "snd-hda-scodec-cs35l56-test",
369 MODULE_DESCRIPTION("KUnit test for the Cirrus side-codec library");