summaryrefslogtreecommitdiff
path: root/arch/arm/mach-bcm283x/msg.c
diff options
context:
space:
mode:
authorTom Rini <trini@konsulko.com>2023-03-27 15:19:57 -0400
committerTom Rini <trini@konsulko.com>2023-03-27 15:19:57 -0400
commit605bc145f91d2a28ba2e517cae4e53e255e34b6f (patch)
treea8df36d6569d441bc013399ff7dafff07cd36657 /arch/arm/mach-bcm283x/msg.c
parentfde439219ff53a46bdd5dff69e049ccd4be57310 (diff)
parent41a88ad529b3943b1e465846eb24fe2c29203e35 (diff)
downloadu-boot-605bc145f91d2a28ba2e517cae4e53e255e34b6f.tar.gz
Merge branch 'master' into next
Diffstat (limited to 'arch/arm/mach-bcm283x/msg.c')
-rw-r--r--arch/arm/mach-bcm283x/msg.c47
1 files changed, 46 insertions, 1 deletions
diff --git a/arch/arm/mach-bcm283x/msg.c b/arch/arm/mach-bcm283x/msg.c
index fe243e2dca..2188b38d84 100644
--- a/arch/arm/mach-bcm283x/msg.c
+++ b/arch/arm/mach-bcm283x/msg.c
@@ -21,6 +21,12 @@ struct msg_get_clock_rate {
u32 end_tag;
};
+struct msg_set_sdhost_clock {
+ struct bcm2835_mbox_hdr hdr;
+ struct bcm2835_mbox_tag_set_sdhost_clock set_sdhost_clock;
+ u32 end_tag;
+};
+
struct msg_query {
struct bcm2835_mbox_hdr hdr;
struct bcm2835_mbox_tag_physical_w_h physical_w_h;
@@ -75,6 +81,7 @@ int bcm2835_get_mmc_clock(u32 clock_id)
{
ALLOC_CACHE_ALIGN_BUFFER(struct msg_get_clock_rate, msg_clk, 1);
int ret;
+ u32 clock_rate = 0;
ret = bcm2835_power_on_module(BCM2835_MBOX_POWER_DEVID_SDHCI);
if (ret)
@@ -90,7 +97,45 @@ int bcm2835_get_mmc_clock(u32 clock_id)
return -EIO;
}
- return msg_clk->get_clock_rate.body.resp.rate_hz;
+ clock_rate = msg_clk->get_clock_rate.body.resp.rate_hz;
+
+ if (clock_rate == 0) {
+ BCM2835_MBOX_INIT_HDR(msg_clk);
+ BCM2835_MBOX_INIT_TAG(&msg_clk->get_clock_rate, GET_MAX_CLOCK_RATE);
+ msg_clk->get_clock_rate.body.req.clock_id = clock_id;
+
+ ret = bcm2835_mbox_call_prop(BCM2835_MBOX_PROP_CHAN, &msg_clk->hdr);
+ if (ret) {
+ printf("bcm2835: Could not query max eMMC clock rate\n");
+ return -EIO;
+ }
+
+ clock_rate = msg_clk->get_clock_rate.body.resp.rate_hz;
+ }
+
+ return clock_rate;
+}
+
+int bcm2835_set_sdhost_clock(u32 rate_hz, u32 *rate_1, u32 *rate_2)
+{
+ ALLOC_CACHE_ALIGN_BUFFER(struct msg_set_sdhost_clock, msg_sdhost_clk, 1);
+ int ret;
+
+ BCM2835_MBOX_INIT_HDR(msg_sdhost_clk);
+ BCM2835_MBOX_INIT_TAG(&msg_sdhost_clk->set_sdhost_clock, SET_SDHOST_CLOCK);
+
+ msg_sdhost_clk->set_sdhost_clock.body.req.rate_hz = rate_hz;
+
+ ret = bcm2835_mbox_call_prop(BCM2835_MBOX_PROP_CHAN, &msg_sdhost_clk->hdr);
+ if (ret) {
+ printf("bcm2835: Could not query sdhost clock rate\n");
+ return -EIO;
+ }
+
+ *rate_1 = msg_sdhost_clk->set_sdhost_clock.body.resp.rate_1;
+ *rate_2 = msg_sdhost_clk->set_sdhost_clock.body.resp.rate_2;
+
+ return 0;
}
int bcm2835_get_video_size(int *widthp, int *heightp)