tests: drivers: sdhc: setup SDHC IO before test
Rather than relying to the alphanumeric test ordering implemented in ZTEST to ensure certain tests run first, setup the SDHC IO properties to known good values before starting any of the tests. This allows the SDHC tests to run in any order, rather than needing certain tests to run first. Signed-off-by: Daniel DeGrasse <daniel.degrasse@nxp.com>
This commit is contained in:
parent
a6b3b4bb96
commit
2be937dca4
1 changed files with 30 additions and 7 deletions
|
@ -17,6 +17,27 @@ static struct sdhc_io io;
|
|||
|
||||
K_SEM_DEFINE(card_sem, 0, 1);
|
||||
|
||||
/* Prepare IO settings for card */
|
||||
static void *sdhc_power_on(void)
|
||||
{
|
||||
int ret;
|
||||
|
||||
ret = sdhc_get_host_props(sdhc_dev, &props);
|
||||
zassert_equal(ret, 0, "SDHC host props api call failed");
|
||||
|
||||
io.clock = props.f_min;
|
||||
io.bus_mode = SDHC_BUSMODE_PUSHPULL;
|
||||
io.power_mode = SDHC_POWER_ON;
|
||||
io.bus_width = SDHC_BUS_WIDTH1BIT;
|
||||
io.timing = SDHC_TIMING_LEGACY;
|
||||
io.signal_voltage = SD_VOL_3_3_V;
|
||||
|
||||
ret = sdhc_set_io(sdhc_dev, &io);
|
||||
zassert_equal(ret, 0, "Setting io configuration failed");
|
||||
k_msleep(props.power_delay);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* Resets SD host controller, verifies API */
|
||||
ZTEST(sdhc, test_reset)
|
||||
{
|
||||
|
@ -33,6 +54,8 @@ ZTEST(sdhc, test_host_props)
|
|||
{
|
||||
int ret;
|
||||
|
||||
zassert_true(device_is_ready(sdhc_dev), "SDHC device is not ready");
|
||||
|
||||
/* Set all host properties to 0xFF */
|
||||
props.f_max = 0xFF;
|
||||
props.f_min = 0xFF;
|
||||
|
@ -56,6 +79,8 @@ ZTEST(sdhc, test_set_io)
|
|||
{
|
||||
int ret;
|
||||
|
||||
zassert_true(device_is_ready(sdhc_dev), "SDHC device is not ready");
|
||||
|
||||
io.clock = props.f_min;
|
||||
io.bus_mode = SDHC_BUSMODE_PUSHPULL;
|
||||
io.power_mode = SDHC_POWER_ON;
|
||||
|
@ -88,16 +113,12 @@ void sdhc_interrupt_cb(const struct device *dev, int source, const void *data)
|
|||
|
||||
/*
|
||||
* Verify that the driver can detect a present SD card
|
||||
* This test must run first, to ensure the card is present.
|
||||
*/
|
||||
ZTEST(sdhc, test_0_card_presence)
|
||||
ZTEST(sdhc, test_card_presence)
|
||||
{
|
||||
int ret;
|
||||
|
||||
io.clock = props.f_min;
|
||||
ret = sdhc_set_io(sdhc_dev, &io);
|
||||
zassert_equal(ret, 0, "Setting io configuration failed");
|
||||
k_msleep(props.power_delay);
|
||||
zassert_true(device_is_ready(sdhc_dev), "SDHC device is not ready");
|
||||
|
||||
ret = sdhc_card_present(sdhc_dev);
|
||||
if (ret == 0) {
|
||||
|
@ -126,6 +147,8 @@ ZTEST(sdhc, test_card_if_cond)
|
|||
int ret, resp;
|
||||
int check_pattern = SD_IF_COND_CHECK;
|
||||
|
||||
zassert_true(device_is_ready(sdhc_dev), "SDHC device is not ready");
|
||||
|
||||
/* Toggle power to card, to clear state */
|
||||
io.power_mode = SDHC_POWER_OFF;
|
||||
ret = sdhc_set_io(sdhc_dev, &io);
|
||||
|
@ -172,4 +195,4 @@ ZTEST(sdhc, test_card_if_cond)
|
|||
}
|
||||
}
|
||||
|
||||
ZTEST_SUITE(sdhc, NULL, NULL, NULL, NULL, NULL);
|
||||
ZTEST_SUITE(sdhc, NULL, sdhc_power_on, NULL, NULL, NULL);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue