Date:2010-09-05 19:07:01 (8 years 11 months ago)
Author:Werner Almesberger
Commit:a18d5969bd1582a6bc4623cdd0ee3d19b74d8627
Message:Next part of board bringup: reset and power cycling.

- atusd/ERRATA: one more problem: the transistor footprint is wrong
- atusd/tools/lib/atusd.c (atusd_cycle, atusd_reset): added power cycling and
hardware reset
- atusd/tools/lib/atusd.h: be nice and make a header file
- atusd/tools/try.c: be nice and use header files (caught a bug as well)
Files: atusd/ERRATA (1 diff)
atusd/tools/lib/atusd.c (3 diffs)
atusd/tools/lib/atusd.h (1 diff)
atusd/tools/try.c (2 diffs)

Change Details

atusd/ERRATA
33
44- added wire connecting uSD-side ground plane to ground plane at outer edge,
55  to improve CLK signal return. (Probably unnecessary, too.)
6
7- the footprint of the transistor (Q1) is reversed :-( It works after
8  converting the chip from SOT to PLCC.
atusd/tools/lib/atusd.c
11#include <stdint.h>
22#include <stdlib.h>
33#include <stdio.h>
4#include <unistd.h>
45#include <fcntl.h>
56#include <sys/mman.h>
67
...... 
102103
103104void atusd_close(struct atusd_dsc *dsc)
104105{
105    /* stop the MMC clock */
106    /* stop the MMC bus clock */
106107    MSC_STRPCL = 1;
107108
108109    /* cut the power */
...... 
111112    /* make all MMC pins inputs */
112113    PDDIRC = MxSx | CLK | SCLK | SLP_TR | IRQ | nSEL;
113114}
115
116
117void atusd_cycle(struct atusd_dsc *dsc)
118{
119    /* stop the MMC bus clock */
120    MSC_STRPCL = 1;
121
122    /* drive all outputs low (including the MMC bus clock) */
123    PDDATC = MxSx | CLK | SCLK | SLP_TR | nSEL;
124
125    /* make the MMC bus clock a regular output */
126    PDFUNC = CLK;
127
128    /* cut the power */
129    PDDATS = VDD_OFF;
130
131    /* Power drains within about 20 ms. Wait 100 ms to be sure. */
132    usleep(100*1000);
133
134    /* drive nSS high */
135    PDDATS = nSEL;
136
137    /* supply power */
138    PDDATS = VDD_OFF;
139
140    /* return the bus clock output to the MMC controller */
141    PDFUNS = CLK;
142
143    /* start MMC clock output */
144    MSC_STRPCL = 2;
145}
146
147
148void atusd_reset(struct atusd_dsc *dsc)
149{
150    /* activate reset */
151    PDDATS = SLP_TR;
152    PDDATC = nSEL;
153
154    /*
155     * Data sheet says 625 ns, programmer's guide says 6 us. Whom do we
156     * trust ?
157     */
158    usleep(6);
159
160    /* release reset */
161    PDDATS = nSEL;
162    PDDATC = SLP_TR;
163}
atusd/tools/lib/atusd.h
1struct atusd_dsc;
2
3
4struct atusd_dsc *atusd_open(void);
5void atusd_close(struct atusd_dsc *dsc);
6void atusd_cycle(struct atusd_dsc *dsc);
7void atusd_reset(struct atusd_dsc *dsc);
atusd/tools/try.c
1struct atusd_dsc;
1#include <stdio.h>
2#include <unistd.h>
3
4#include "lib/atusd.h"
25
36
47int main(void)
...... 
710    char tmp;
811
912    dsc = atusd_open();
10    read(1, tmp, 1);
13    read(1, &tmp, 1);
14fprintf(stderr, "cycling\n");
15    atusd_cycle(dsc);
16    read(1, &tmp, 1);
1117    atusd_close(dsc);
1218
1319    return 0;

Archive Download the corresponding diff file



interactive