mmcif-sh7372.c 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  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 <mach/mmcif.h>
  13. #define MMCIF_BASE (void __iomem *)0xe6bd0000
  14. #define PORT84CR (void __iomem *)0xe6050054
  15. #define PORT85CR (void __iomem *)0xe6050055
  16. #define PORT86CR (void __iomem *)0xe6050056
  17. #define PORT87CR (void __iomem *)0xe6050057
  18. #define PORT88CR (void __iomem *)0xe6050058
  19. #define PORT89CR (void __iomem *)0xe6050059
  20. #define PORT90CR (void __iomem *)0xe605005a
  21. #define PORT91CR (void __iomem *)0xe605005b
  22. #define PORT92CR (void __iomem *)0xe605005c
  23. #define PORT99CR (void __iomem *)0xe6050063
  24. #define SMSTPCR3 (void __iomem *)0xe615013c
  25. /* SH7372 specific MMCIF loader
  26. *
  27. * loads the zImage from an MMC card starting from block 1.
  28. *
  29. * The image must be start with a vrl4 header and
  30. * the zImage must start at offset 512 of the image. That is,
  31. * at block 2 (=byte 1024) on the media
  32. *
  33. * Use the following line to write the vrl4 formated zImage
  34. * to an MMC card
  35. * # dd if=vrl4.out of=/dev/sdx bs=512 seek=1
  36. */
  37. asmlinkage void mmcif_loader(unsigned char *buf, unsigned long len)
  38. {
  39. mmcif_init_progress();
  40. mmcif_update_progress(MMCIF_PROGRESS_ENTER);
  41. /* Initialise MMC
  42. * registers: PORT84CR-PORT92CR
  43. * (MMCD0_0-MMCD0_7,MMCCMD0 Control)
  44. * value: 0x04 - select function 4
  45. */
  46. __raw_writeb(0x04, PORT84CR);
  47. __raw_writeb(0x04, PORT85CR);
  48. __raw_writeb(0x04, PORT86CR);
  49. __raw_writeb(0x04, PORT87CR);
  50. __raw_writeb(0x04, PORT88CR);
  51. __raw_writeb(0x04, PORT89CR);
  52. __raw_writeb(0x04, PORT90CR);
  53. __raw_writeb(0x04, PORT91CR);
  54. __raw_writeb(0x04, PORT92CR);
  55. /* Initialise MMC
  56. * registers: PORT99CR (MMCCLK0 Control)
  57. * value: 0x10 | 0x04 - enable output | select function 4
  58. */
  59. __raw_writeb(0x14, PORT99CR);
  60. /* Enable clock to MMC hardware block */
  61. __raw_writel(__raw_readl(SMSTPCR3) & ~(1 << 12), SMSTPCR3);
  62. mmcif_update_progress(MMCIF_PROGRESS_INIT);
  63. /* setup MMCIF hardware */
  64. sh_mmcif_boot_init(MMCIF_BASE);
  65. mmcif_update_progress(MMCIF_PROGRESS_LOAD);
  66. /* load kernel via MMCIF interface */
  67. sh_mmcif_boot_do_read(MMCIF_BASE, 2, /* Kernel is at block 2 */
  68. (len + SH_MMCIF_BBS - 1) / SH_MMCIF_BBS, buf);
  69. /* Disable clock to MMC hardware block */
  70. __raw_writel(__raw_readl(SMSTPCR3) & (1 << 12), SMSTPCR3);
  71. mmcif_update_progress(MMCIF_PROGRESS_DONE);
  72. }