1
0
mirror of git://projects.qi-hardware.com/ben-wpan.git synced 2024-11-26 05:28:25 +02:00

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
This commit is contained in:
Werner Almesberger 2010-09-05 21:18:56 -03:00
parent 406517baa2
commit b25cbd8120
2 changed files with 23 additions and 14 deletions

View File

@ -144,5 +144,7 @@ int main(int argc, const char **argv)
show_info(dsc); show_info(dsc);
atspi_close(dsc);
return 0; return 0;
} }

View File

@ -68,6 +68,16 @@ struct atusd_dsc {
/* ----- Reset functions --------------------------------------------------- */ /* ----- 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) static void atusd_cycle(struct atusd_dsc *dsc)
{ {
/* stop the MMC bus clock */ /* stop the MMC bus clock */
@ -97,11 +107,7 @@ static void atusd_cycle(struct atusd_dsc *dsc)
/* start MMC clock output */ /* start MMC clock output */
MSC_STRPCL = 2; MSC_STRPCL = 2;
/* wait_for_power();
* Give power time to stabilize and the chip time to reset.
* Experiments show that even usleep(0) is long enough.
*/
usleep(10*1000);
} }
@ -205,6 +211,14 @@ static void spi_send(struct atusd_dsc *dsc, uint8_t v)
/* ----- Driver operations ------------------------------------------------- */ /* ----- Driver operations ------------------------------------------------- */
static void atusd_reset_rf(void *handle)
{
struct atusd_dsc *dsc = handle;
atusd_cycle(dsc);
}
static void *atusd_open(void) static void *atusd_open(void)
{ {
struct atusd_dsc *dsc; struct atusd_dsc *dsc;
@ -254,7 +268,8 @@ static void *atusd_open(void)
/* start MMC clock output */ /* start MMC clock output */
MSC_STRPCL = 2; MSC_STRPCL = 2;
atusd_cycle(dsc); wait_for_power();
atusd_reset_rf(dsc);
return 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) static void atusd_reg_write(void *handle, uint8_t reg, uint8_t v)
{ {
struct atusd_dsc *dsc = handle; struct atusd_dsc *dsc = handle;