sdhi-sh7372.c 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. /*
  2. * SuperH Mobile SDHI
  3. *
  4. * Copyright (C) 2010 Magnus Damm
  5. * Copyright (C) 2010 Kuninori Morimoto
  6. * Copyright (C) 2010 Simon Horman
  7. *
  8. * This file is subject to the terms and conditions of the GNU General Public
  9. * License. See the file "COPYING" in the main directory of this archive
  10. * for more details.
  11. *
  12. * Parts inspired by u-boot
  13. */
  14. #include <linux/io.h>
  15. #include <mach/mmc.h>
  16. #include <linux/mmc/boot.h>
  17. #include <linux/mmc/tmio.h>
  18. #include "sdhi-shmobile.h"
  19. #define PORT179CR 0xe60520b3
  20. #define PORT180CR 0xe60520b4
  21. #define PORT181CR 0xe60520b5
  22. #define PORT182CR 0xe60520b6
  23. #define PORT183CR 0xe60520b7
  24. #define PORT184CR 0xe60520b8
  25. #define SMSTPCR3 0xe615013c
  26. #define CR_INPUT_ENABLE 0x10
  27. #define CR_FUNCTION1 0x01
  28. #define SDHI1_BASE (void __iomem *)0xe6860000
  29. #define SDHI_BASE SDHI1_BASE
  30. /* SuperH Mobile SDHI loader
  31. *
  32. * loads the zImage from an SD card starting from block 0
  33. * on physical partition 1
  34. *
  35. * The image must be start with a vrl4 header and
  36. * the zImage must start at offset 512 of the image. That is,
  37. * at block 1 (=byte 512) of physical partition 1
  38. *
  39. * Use the following line to write the vrl4 formated zImage
  40. * to an SD card
  41. * # dd if=vrl4.out of=/dev/sdx bs=512
  42. */
  43. asmlinkage void mmc_loader(unsigned short *buf, unsigned long len)
  44. {
  45. int high_capacity;
  46. mmc_init_progress();
  47. mmc_update_progress(MMC_PROGRESS_ENTER);
  48. /* Initialise SDHI1 */
  49. /* PORT184CR: GPIO_FN_SDHICMD1 Control */
  50. __raw_writeb(CR_FUNCTION1, PORT184CR);
  51. /* PORT179CR: GPIO_FN_SDHICLK1 Control */
  52. __raw_writeb(CR_INPUT_ENABLE|CR_FUNCTION1, PORT179CR);
  53. /* PORT181CR: GPIO_FN_SDHID1_3 Control */
  54. __raw_writeb(CR_FUNCTION1, PORT183CR);
  55. /* PORT182CR: GPIO_FN_SDHID1_2 Control */
  56. __raw_writeb(CR_FUNCTION1, PORT182CR);
  57. /* PORT183CR: GPIO_FN_SDHID1_1 Control */
  58. __raw_writeb(CR_FUNCTION1, PORT181CR);
  59. /* PORT180CR: GPIO_FN_SDHID1_0 Control */
  60. __raw_writeb(CR_FUNCTION1, PORT180CR);
  61. /* Enable clock to SDHI1 hardware block */
  62. __raw_writel(__raw_readl(SMSTPCR3) & ~(1 << 13), SMSTPCR3);
  63. /* setup SDHI hardware */
  64. mmc_update_progress(MMC_PROGRESS_INIT);
  65. high_capacity = sdhi_boot_init(SDHI_BASE);
  66. if (high_capacity < 0)
  67. goto err;
  68. mmc_update_progress(MMC_PROGRESS_LOAD);
  69. /* load kernel */
  70. if (sdhi_boot_do_read(SDHI_BASE, high_capacity,
  71. 0, /* Kernel is at block 1 */
  72. (len + TMIO_BBS - 1) / TMIO_BBS, buf))
  73. goto err;
  74. /* Disable clock to SDHI1 hardware block */
  75. __raw_writel(__raw_readl(SMSTPCR3) & (1 << 13), SMSTPCR3);
  76. mmc_update_progress(MMC_PROGRESS_DONE);
  77. return;
  78. err:
  79. for(;;);
  80. }