Skip to content

Commit 695337a

Browse files
committed
Making sure sdhci.c uses sdhci_regs.c instead of bcm_emmc_regs.c.
1 parent 71f0ac0 commit 695337a

9 files changed

+191
-191
lines changed

mmc/CMakeLists.txt

+4-2
Original file line numberDiff line numberDiff line change
@@ -403,7 +403,7 @@ add_library(mmc_rpi3b_lib_sdhci src/mmc_driver/sdhci.c)
403403
target_include_directories(mmc_rpi3b_lib_sdhci PUBLIC include/)
404404
target_link_libraries(
405405
mmc_rpi3b_lib_sdhci
406-
mmc_rpi3b_lib_bcm_emmc_regs
406+
mmc_rpi3b_lib_sdhci_regs
407407
mmc_rpi3b_lib_result
408408
mmc_rpi3b_lib_sleep
409409
mmc_rpi3b_lib_log
@@ -424,7 +424,7 @@ target_include_directories(mmc_rpi3b_lib_bcm_emmc PUBLIC include/)
424424
target_link_libraries(
425425
mmc_rpi3b_lib_bcm_emmc
426426
mmc_rpi3b_lib_result
427-
mmc_rpi3b_lib_bcm_emmc_regs
427+
mmc_rpi3b_lib_sdhci_regs
428428
mmc_rpi3b_lib_sleep
429429
mmc_rpi3b_lib_sdhci
430430
mmc_rpi3b_lib_log
@@ -444,6 +444,7 @@ target_link_libraries(
444444
mmc_rpi3b_lib_log
445445
mmc_rpi3b_lib_bcm_emmc
446446
mmc_rpi3b_lib_sdcard
447+
mmc_rpi3b_lib_sdhci_regs
447448
)
448449

449450
add_library(mmc_rpi3b_lib_mmc_driver src/mmc_driver.c)
@@ -452,6 +453,7 @@ target_link_libraries(
452453
mmc_rpi3b_lib_mmc_driver
453454
mmc_rpi3b_sel4cp_facade
454455
mmc_rpi3b_lib_bcm_emmc
456+
mmc_rpi3b_lib_bcm_emmc_regs
455457
mmc_rpi3b_lib_result
456458
mmc_rpi3b_lib_printf
457459
mmc_rpi3b_lib_log

mmc/include/bcm_emmc.h

+3-8
Original file line numberDiff line numberDiff line change
@@ -2,27 +2,22 @@
22
#pragma once
33

44
#include "result.h"
5-
#include "bcm_emmc_regs.h"
5+
#include "sdhci_regs.h"
66
#include "sleep.h"
77
#include "sdhci.h"
88
#include "log.h"
99
#include "sdhci_result.h"
1010
#include "bcm_gpio_regs.h"
1111
#include "gpio_driver.h"
1212

13-
//typedef struct bcm_emmc bcm_emmc_t;
14-
//struct bcm_emmc {
15-
// bcm_emmc_regs_t *regs;
16-
//};
17-
1813
/**
1914
* Initialises the BCM EMMC device.
20-
* @param bcm_emmc_regs
15+
* @param sdhci_regs
2116
* @param bcm_gpio_regs
2217
* @return
2318
*/
2419
result_t bcm_emmc_init(
25-
bcm_emmc_regs_t *bcm_emmc_regs,
20+
sdhci_regs_t *sdhci_regs,
2621
bcm_gpio_regs_t *bcm_gpio_regs
2722
);
2823

mmc/include/mmc_driver.h

+1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
#include "sel4cp_facade.h"
66
#include "result.h"
77
#include "bcm_emmc.h"
8+
#include "bcm_emmc_regs.h"
89

910
#include "log.h"
1011
#include "printf.h"

mmc/include/mmc_driver_e2e.h

+6-5
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
#include "clock.h"
99
#include "log.h"
1010
#include "sdhci.h"
11-
#include "bcm_emmc_regs.h"
11+
#include "sdhci_regs.h"
1212
#include "sdcard.h"
1313

1414
/**
@@ -19,22 +19,23 @@ result_t mmc_driver_e2e_sleep();
1919

2020
/**
2121
* Simple read/write test on the SD card.
22+
* @param sdhci_regs
23+
* @param sdcard
2224
* @return
2325
*/
2426
result_t mmc_driver_e2e_read_write_simple(
25-
bcm_emmc_regs_t *bcm_emmc_regs,
27+
sdhci_regs_t *sdhci_regs,
2628
sdcard_t *sdcard
2729
);
2830

2931
/**
3032
* Read/write test on the SD card.
31-
* @return
32-
* @param bcm_emmc_regs
33+
* @param sdhci_regs
3334
* @param sdcard
3435
* @return
3536
*/
3637
result_t mmc_driver_e2e_read_write_multiple_blocks(
37-
bcm_emmc_regs_t *bcm_emmc_regs,
38+
sdhci_regs_t *sdhci_regs,
3839
sdcard_t *sdcard
3940
);
4041

mmc/include/sdhci.h

+22-21
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
#pragma once
22

33
#include "result.h"
4-
#include "bcm_emmc_regs.h"
4+
#include "sdhci_regs.h"
5+
//#include "sdhci_regs.h"
56
#include "sleep.h"
67
#include "log.h"
78
#include "arith.h"
@@ -17,34 +18,34 @@
1718

1819
/**
1920
* Initialises an SD card.
20-
* @param bcm_emmc_regs
21+
* @param sdhci_regs
2122
* @param sdcard
2223
* @return
2324
*/
2425
result_t sdhci_card_init_and_id(
25-
bcm_emmc_regs_t *bcm_emmc_regs,
26+
sdhci_regs_t *sdhci_regs,
2627
sdcard_t *sdcard,
2728
sdhci_result_t *sdhci_result
2829
);
2930

3031
/**
3132
* Sets the Bus Width to its maximum value as specified by the SD Card
3233
* Configuration Register (SCR), which is stored in our `sdcard`.
33-
* @param bcm_emmc_regs
34+
* @param sdhci_regs
3435
* @param sdcard
3536
* @param sd_clock_freq_hz
3637
* @param sdhci_result
3738
* @return
3839
*/
3940
result_t sdhci_set_max_bus_width(
40-
bcm_emmc_regs_t *bcm_emmc_regs,
41+
sdhci_regs_t *sdhci_regs,
4142
sdcard_t *sdcard,
4243
sdhci_result_t *sdhci_result
4344
);
4445

4546
/**
4647
* Reads the specified number of blocks from the SD card.
47-
* @param bcm_emmc_regs
48+
* @param sdhci_regs
4849
* @param sdcard
4950
* @param lba
5051
* @param num_blocks
@@ -55,7 +56,7 @@ result_t sdhci_set_max_bus_width(
5556
* @return
5657
*/
5758
result_t sdhci_read_blocks(
58-
bcm_emmc_regs_t *bcm_emmc_regs,
59+
sdhci_regs_t *sdhci_regs,
5960
sdcard_t *sdcard,
6061
size_t lba,
6162
size_t num_blocks,
@@ -67,7 +68,7 @@ result_t sdhci_read_blocks(
6768

6869
/**
6970
* Writes the specified number of blocks to the SD card.
70-
* @param bcm_emmc_regs
71+
* @param sdhci_regs
7172
* @param sdcard
7273
* @param lba
7374
* @param num_blocks
@@ -78,7 +79,7 @@ result_t sdhci_read_blocks(
7879
* @return
7980
*/
8081
result_t sdhci_write_blocks(
81-
bcm_emmc_regs_t *bcm_emmc_regs,
82+
sdhci_regs_t *sdhci_regs,
8283
sdcard_t *sdcard,
8384
size_t lba,
8485
size_t num_blocks,
@@ -90,7 +91,7 @@ result_t sdhci_write_blocks(
9091

9192
/**
9293
* Transfers specified number of blocks to/from the SD card.
93-
* @param bcm_emmc_regs
94+
* @param sdhci_regs
9495
* @param sdcard
9596
* @param lba
9697
* @param num_blocks
@@ -102,7 +103,7 @@ result_t sdhci_write_blocks(
102103
* @return
103104
*/
104105
result_t sdhci_transfer_blocks(
105-
bcm_emmc_regs_t *bcm_emmc_regs,
106+
sdhci_regs_t *sdhci_regs,
106107
sdcard_t *sdcard,
107108
size_t lba,
108109
size_t num_blocks,
@@ -122,7 +123,7 @@ result_t sdhci_transfer_blocks(
122123
* @return
123124
*/
124125
result_t sdhci_get_sd_clock_divisor(
125-
bcm_emmc_regs_t *bcm_emmc_regs,
126+
sdhci_regs_t *sdhci_regs,
126127
uint32_t freq,
127128
uint32_t *ret_val
128129
);
@@ -134,56 +135,56 @@ result_t sdhci_get_sd_clock_divisor(
134135
* @return
135136
*/
136137
result_t sdhci_set_sd_clock(
137-
bcm_emmc_regs_t *bcm_emmc_regs,
138+
sdhci_regs_t *sdhci_regs,
138139
uint32_t freq
139140
);
140141

141142
/**
142143
* Waits for the specified interrupt to be set.
143-
* @param bcm_emmc_regs
144+
* @param sdhci_regs
144145
* @param interrupt_mask
145146
* @param sdhci_result
146147
* @return
147148
*/
148149
result_t sdhci_wait_for_interrupt(
149-
bcm_emmc_regs_t *bcm_emmc_regs,
150+
sdhci_regs_t *sdhci_regs,
150151
uint32_t interrupt_mask,
151152
sdhci_result_t *sdhci_result
152153
);
153154

154155
/**
155156
* Waits for cmd_in_progress to be cleared.
156-
* @param bcm_emmc_regs
157+
* @param sdhci_regs
157158
* @param sdhci_result
158159
* @return
159160
*/
160161
result_t sdhci_wait_for_cmd_in_progress(
161-
bcm_emmc_regs_t *bcm_emmc_regs,
162+
sdhci_regs_t *sdhci_regs,
162163
sdhci_result_t *sdhci_result
163164
);
164165

165166
/**
166167
* Waits for data_in_progress to be cleared.
167-
* @param bcm_emmc_regs
168+
* @param sdhci_regs
168169
* @param sdhci_result
169170
* @return
170171
*/
171172
result_t sdhci_wait_for_data_in_progress(
172-
bcm_emmc_regs_t *bcm_emmc_regs,
173+
sdhci_regs_t *sdhci_regs,
173174
sdhci_result_t *sdhci_result
174175
);
175176

176177
/**
177178
* Sends the specified command to the SD card.
178-
* @param bcm_emmc_regs
179+
* @param sdhci_regs
179180
* @param sdhci_cmd_index
180181
* @param arg
181182
* @param sdcard
182183
* @param sdhci_result
183184
* @return
184185
*/
185186
result_t sdhci_send_cmd(
186-
bcm_emmc_regs_t *bcm_emmc_regs,
187+
sdhci_regs_t *sdhci_regs,
187188
size_t sdhci_cmd_index,
188189
uint32_t arg,
189190
sdcard_t *sdcard,

mmc/src/mmc_driver.c

+14-14
Original file line numberDiff line numberDiff line change
@@ -79,31 +79,31 @@ void init(void) {
7979
* depends upon.*/
8080
mmc_driver_e2e_sleep();
8181

82-
/* Initialise and reset the Pi's SD card Host Controller. */
83-
res = bcm_emmc_init(
84-
(bcm_emmc_regs_t *) emmc_base_vaddr,
85-
(bcm_gpio_regs_t *) gpio_base_vaddr
82+
/* Initialise SDHCI registers. */
83+
res = sdhci_regs_init(
84+
&global_sdhci_regs,
85+
(void *) emmc_base_vaddr
8686
);
8787
if (result_is_err(res)) {
8888
result_printf(res);
8989
return;
9090
}
91-
log_trace("Finished initialising SD Host Controller.");
9291

93-
/* Initialise SDHCI registers. */
94-
res = sdhci_regs_init(
92+
/* Initialise and reset the Pi's SD card Host Controller. */
93+
res = bcm_emmc_init(
9594
&global_sdhci_regs,
96-
(void *) emmc_base_vaddr
95+
(bcm_gpio_regs_t *) gpio_base_vaddr
9796
);
9897
if (result_is_err(res)) {
9998
result_printf(res);
10099
return;
101100
}
101+
log_trace("Finished initialising SD Host Controller.");
102102

103103
/* Initialise and identify the SD card. */
104104
sdhci_result_t sdhci_result;
105105
res = sdhci_card_init_and_id(
106-
(bcm_emmc_regs_t *) emmc_base_vaddr,
106+
&global_sdhci_regs,
107107
&global_sdcard,
108108
&sdhci_result
109109
);
@@ -115,7 +115,7 @@ void init(void) {
115115

116116
/* Setting Bus Width to maximum possible value. */
117117
res = sdhci_set_max_bus_width(
118-
(bcm_emmc_regs_t *) emmc_base_vaddr,
118+
&global_sdhci_regs,
119119
&global_sdcard,
120120
&sdhci_result
121121
);
@@ -127,7 +127,7 @@ void init(void) {
127127

128128
/* Running E2E tests to verify our SD card driver works properly.*/
129129
res = mmc_driver_e2e_read_write_simple(
130-
(bcm_emmc_regs_t *) emmc_base_vaddr,
130+
&global_sdhci_regs,
131131
&global_sdcard
132132
);
133133
if (result_is_err(res)) {
@@ -136,7 +136,7 @@ void init(void) {
136136
}
137137

138138
res = mmc_driver_e2e_read_write_multiple_blocks(
139-
(bcm_emmc_regs_t *) emmc_base_vaddr,
139+
&global_sdhci_regs,
140140
&global_sdcard
141141
);
142142
if (result_is_err(res)) {
@@ -187,7 +187,7 @@ result_t mmc_driver_write_blocks(
187187
}
188188
sdhci_result_t sdhci_result;
189189
return sdhci_write_blocks(
190-
(bcm_emmc_regs_t *) emmc_base_vaddr,
190+
&global_sdhci_regs,
191191
&global_sdcard,
192192
lba,
193193
num_blocks,
@@ -210,7 +210,7 @@ result_t mmc_driver_read_blocks(
210210
}
211211
sdhci_result_t sdhci_result;
212212
return sdhci_read_blocks(
213-
(bcm_emmc_regs_t *) emmc_base_vaddr,
213+
&global_sdhci_regs,
214214
&global_sdcard,
215215
lba,
216216
num_blocks,

0 commit comments

Comments
 (0)