Skip to content

Commit efe3719

Browse files
committed
changed values in conditions to make it work
1 parent 8144e90 commit efe3719

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

random/imx6ull-rngb.c

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ static int systemInit(void)
106106
int err;
107107
oid_t dev;
108108

109-
common_rngb.base = mmap(NULL, MMAP_SIZE, PROT_READ | PROT_WRITE, MAP_DEVICE | MAP_UNCACHED, OID_PHYSMEM, RNGB_START_ADDRESS);
109+
common_rngb.base = mmap(NULL, MMAP_SIZE, PROT_READ | PROT_WRITE, MAP_DEVICE, OID_PHYSMEM, RNGB_START_ADDRESS);
110110
if (common_rngb.base == MAP_FAILED) {
111111
printf("rngb: could not map addr\n");
112112
return -1;
@@ -154,13 +154,13 @@ static int hardwareInit(void)
154154
/* Reset and wait until rngb is sleeping */
155155
*(common_rngb.base + rng_cmd) = 0x40;
156156
do {
157-
err = *(common_rngb.base + rng_sr) & 0x4;
157+
err = *(common_rngb.base + rng_sr) & 0x04;
158158
} while (err == 0);
159159

160160
interrupt(RNGB_IRQ, rngb_intr, NULL, common_rngb.cond, NULL);
161161

162162
/* Run self test */
163-
*(common_rngb.base + rng_cmd) = 0x1;
163+
*(common_rngb.base + rng_cmd) = 0x01;
164164
mutexLock(common_rngb.lock);
165165
while (common_rngb.intr_st == 0) {
166166
condWait(common_rngb.cond, common_rngb.lock, 3000);
@@ -177,7 +177,7 @@ static int hardwareInit(void)
177177
common_rngb.intr_st = 0;
178178

179179
/* Run seeding */
180-
*(common_rngb.base + rng_cmd) = 0x2;
180+
*(common_rngb.base + rng_cmd) = 0x02;
181181
mutexLock(common_rngb.lock);
182182
while (common_rngb.intr_st == 0) {
183183
condWait(common_rngb.cond, common_rngb.lock, 3000);
@@ -195,6 +195,9 @@ static int hardwareInit(void)
195195

196196
/* Enable automatic seeding */
197197
*(common_rngb.base + rng_cr) = 0x10;
198+
199+
printf("imx6ull-rngb: initialized\n");
200+
198201
return 0;
199202
}
200203

@@ -217,7 +220,7 @@ static int readRandoms(char *buff, size_t size, unsigned mode)
217220
while (i < size) {
218221
if ((i % sizeof(uint32_t)) == 0) {
219222
status = *(common_rngb.base + rng_sr);
220-
if ((status & (1 << 16)) == 0) {
223+
if ((status & (1 << 16)) == 1) {
221224
mutexUnlock(common_rngb.lock);
222225
return -EIO;
223226
}

0 commit comments

Comments
 (0)