From b25cbd812068fb79c56b655a0ea526ab2c0b7382 Mon Sep 17 00:00:00 2001 From: Werner Almesberger Date: Sun, 5 Sep 2010 21:18:56 -0300 Subject: [PATCH] Fix board initialization in uSD driver. atspi-id now works. - tools/lib/atusd.c (atusd_cycle): we never turned power back on ? - tools/atspi-id/atspi-id.c (main): call atspi_close on exit - tools/lib/atusd.c (atusd_cycle, wait_for_power): moved power on delay to separate function - tools/lib/atusd.c (atusd_open): wait for power to stabilize - tools/lib/atusd.c (atusd_open): need to reset the board to bring it up properly --- tools/atspi-id/atspi-id.c | 2 ++ tools/lib/atusd.c | 35 +++++++++++++++++++++-------------- 2 files changed, 23 insertions(+), 14 deletions(-) diff --git a/tools/atspi-id/atspi-id.c b/tools/atspi-id/atspi-id.c index e7e9520..facca2a 100644 --- a/tools/atspi-id/atspi-id.c +++ b/tools/atspi-id/atspi-id.c @@ -144,5 +144,7 @@ int main(int argc, const char **argv) show_info(dsc); + atspi_close(dsc); + return 0; } diff --git a/tools/lib/atusd.c b/tools/lib/atusd.c index 10fb61b..d07963e 100644 --- a/tools/lib/atusd.c +++ b/tools/lib/atusd.c @@ -68,6 +68,16 @@ struct atusd_dsc { /* ----- Reset functions --------------------------------------------------- */ +static void wait_for_power(void) +{ + /* + * Give power time to stabilize and the chip time to reset. + * Experiments show that even usleep(0) is long enough. + */ + usleep(10*1000); +} + + static void atusd_cycle(struct atusd_dsc *dsc) { /* stop the MMC bus clock */ @@ -97,11 +107,7 @@ static void atusd_cycle(struct atusd_dsc *dsc) /* start MMC clock output */ MSC_STRPCL = 2; - /* - * Give power time to stabilize and the chip time to reset. - * Experiments show that even usleep(0) is long enough. - */ - usleep(10*1000); + wait_for_power(); } @@ -205,6 +211,14 @@ static void spi_send(struct atusd_dsc *dsc, uint8_t v) /* ----- Driver operations ------------------------------------------------- */ +static void atusd_reset_rf(void *handle) +{ + struct atusd_dsc *dsc = handle; + + atusd_cycle(dsc); +} + + static void *atusd_open(void) { struct atusd_dsc *dsc; @@ -254,7 +268,8 @@ static void *atusd_open(void) /* start MMC clock output */ MSC_STRPCL = 2; - atusd_cycle(dsc); + wait_for_power(); + atusd_reset_rf(dsc); return dsc; } @@ -275,14 +290,6 @@ static void atusd_close(void *arg) } -static void atusd_reset_rf(void *handle) -{ - struct atusd_dsc *dsc = handle; - - atusd_cycle(dsc); -} - - static void atusd_reg_write(void *handle, uint8_t reg, uint8_t v) { struct atusd_dsc *dsc = handle;