rpi_b.c 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. /*
  2. * (C) Copyright 2012 Stephen Warren
  3. *
  4. * See file CREDITS for list of people who contributed to this
  5. * project.
  6. *
  7. * This program is free software; you can redistribute it and/or
  8. * modify it under the terms of the GNU General Public License
  9. * version 2 as published by the Free Software Foundation.
  10. *
  11. * This program is distributed in the hope that it will be useful, but
  12. * WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. * GNU General Public License for more details.
  15. */
  16. #include <common.h>
  17. #include <asm/arch/mbox.h>
  18. #include <asm/arch/sdhci.h>
  19. #include <asm/global_data.h>
  20. DECLARE_GLOBAL_DATA_PTR;
  21. struct msg_get_arm_mem {
  22. struct bcm2835_mbox_hdr hdr;
  23. struct bcm2835_mbox_tag_get_arm_mem get_arm_mem;
  24. u32 end_tag;
  25. };
  26. struct msg_get_clock_rate {
  27. struct bcm2835_mbox_hdr hdr;
  28. struct bcm2835_mbox_tag_get_clock_rate get_clock_rate;
  29. u32 end_tag;
  30. };
  31. int dram_init(void)
  32. {
  33. ALLOC_ALIGN_BUFFER(struct msg_get_arm_mem, msg, 1, 16);
  34. int ret;
  35. BCM2835_MBOX_INIT_HDR(msg);
  36. BCM2835_MBOX_INIT_TAG(&msg->get_arm_mem, GET_ARM_MEMORY);
  37. ret = bcm2835_mbox_call_prop(BCM2835_MBOX_PROP_CHAN, &msg->hdr);
  38. if (ret) {
  39. printf("bcm2835: Could not query ARM memory size\n");
  40. return -1;
  41. }
  42. gd->ram_size = msg->get_arm_mem.body.resp.mem_size;
  43. return 0;
  44. }
  45. int board_init(void)
  46. {
  47. gd->bd->bi_boot_params = 0x100;
  48. return 0;
  49. }
  50. int board_mmc_init(void)
  51. {
  52. ALLOC_ALIGN_BUFFER(struct msg_get_clock_rate, msg_clk, 1, 16);
  53. int ret;
  54. BCM2835_MBOX_INIT_HDR(msg_clk);
  55. BCM2835_MBOX_INIT_TAG(&msg_clk->get_clock_rate, GET_CLOCK_RATE);
  56. msg_clk->get_clock_rate.body.req.clock_id = BCM2835_MBOX_CLOCK_ID_EMMC;
  57. ret = bcm2835_mbox_call_prop(BCM2835_MBOX_PROP_CHAN, &msg_clk->hdr);
  58. if (ret) {
  59. printf("bcm2835: Could not query eMMC clock rate\n");
  60. return -1;
  61. }
  62. return bcm2835_sdhci_init(BCM2835_SDHCI_BASE,
  63. msg_clk->get_clock_rate.body.resp.rate_hz);
  64. }