mmcif-sh7372.c 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. /*
  2. * sh7372 MMCIF loader
  3. *
  4. * Copyright (C) 2010 Magnus Damm
  5. * Copyright (C) 2010 Simon Horman
  6. *
  7. * This file is subject to the terms and conditions of the GNU General Public
  8. * License. See the file "COPYING" in the main directory of this archive
  9. * for more details.
  10. */
  11. #include <linux/mmc/sh_mmcif.h>
  12. #include <linux/mmc/boot.h>
  13. #include <mach/mmc.h>
  14. #define MMCIF_BASE (void __iomem *)0xe6bd0000
  15. #define PORT84CR (void __iomem *)0xe6050054
  16. #define PORT85CR (void __iomem *)0xe6050055
  17. #define PORT86CR (void __iomem *)0xe6050056
  18. #define PORT87CR (void __iomem *)0xe6050057
  19. #define PORT88CR (void __iomem *)0xe6050058
  20. #define PORT89CR (void __iomem *)0xe6050059
  21. #define PORT90CR (void __iomem *)0xe605005a
  22. #define PORT91CR (void __iomem *)0xe605005b
  23. #define PORT92CR (void __iomem *)0xe605005c
  24. #define PORT99CR (void __iomem *)0xe6050063
  25. #define SMSTPCR3 (void __iomem *)0xe615013c
  26. /* SH7372 specific MMCIF loader
  27. *
  28. * loads the zImage from an MMC card starting from block 1.
  29. *
  30. * The image must be start with a vrl4 header and
  31. * the zImage must start at offset 512 of the image. That is,
  32. * at block 2 (=byte 1024) on the media
  33. *
  34. * Use the following line to write the vrl4 formated zImage
  35. * to an MMC card
  36. * # dd if=vrl4.out of=/dev/sdx bs=512 seek=1
  37. */
  38. asmlinkage void mmcif_loader(unsigned char *buf, unsigned long len)
  39. {
  40. mmc_init_progress();
  41. mmc_update_progress(MMC_PROGRESS_ENTER);
  42. /* Initialise MMC
  43. * registers: PORT84CR-PORT92CR
  44. * (MMCD0_0-MMCD0_7,MMCCMD0 Control)
  45. * value: 0x04 - select function 4
  46. */
  47. __raw_writeb(0x04, PORT84CR);
  48. __raw_writeb(0x04, PORT85CR);
  49. __raw_writeb(0x04, PORT86CR);
  50. __raw_writeb(0x04, PORT87CR);
  51. __raw_writeb(0x04, PORT88CR);
  52. __raw_writeb(0x04, PORT89CR);
  53. __raw_writeb(0x04, PORT90CR);
  54. __raw_writeb(0x04, PORT91CR);
  55. __raw_writeb(0x04, PORT92CR);
  56. /* Initialise MMC
  57. * registers: PORT99CR (MMCCLK0 Control)
  58. * value: 0x10 | 0x04 - enable output | select function 4
  59. */
  60. __raw_writeb(0x14, PORT99CR);
  61. /* Enable clock to MMC hardware block */
  62. __raw_writel(__raw_readl(SMSTPCR3) & ~(1 << 12), SMSTPCR3);
  63. mmc_update_progress(MMC_PROGRESS_INIT);
  64. /* setup MMCIF hardware */
  65. sh_mmcif_boot_init(MMCIF_BASE);
  66. mmc_update_progress(MMC_PROGRESS_LOAD);
  67. /* load kernel via MMCIF interface */
  68. sh_mmcif_boot_do_read(MMCIF_BASE, 2, /* Kernel is at block 2 */
  69. (len + SH_MMCIF_BBS - 1) / SH_MMCIF_BBS, buf);
  70. /* Disable clock to MMC hardware block */
  71. __raw_writel(__raw_readl(SMSTPCR3) & (1 << 12), SMSTPCR3);
  72. mmc_update_progress(MMC_PROGRESS_DONE);
  73. }