411-MIPS-BCM63XX-Register-SPI-flash-if-present.patch 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133
  1. From d135d94b3d1fe599d13e7198d5f502912d694c13 Mon Sep 17 00:00:00 2001
  2. From: Jonas Gorski <jonas.gorski@gmail.com>
  3. Date: Sun, 3 Jul 2011 15:00:38 +0200
  4. Subject: [PATCH 29/60] MIPS: BCM63XX: Register SPI flash if present
  5. Signed-off-by: Jonas Gorski <jonas.gorski@gmail.com>
  6. ---
  7. arch/mips/bcm63xx/dev-flash.c | 33 +++++++++++++++++++-
  8. arch/mips/include/asm/mach-bcm63xx/bcm63xx_regs.h | 2 +
  9. 2 files changed, 33 insertions(+), 2 deletions(-)
  10. --- a/arch/mips/bcm63xx/dev-flash.c
  11. +++ b/arch/mips/bcm63xx/dev-flash.c
  12. @@ -17,9 +17,12 @@
  13. #include <linux/mtd/partitions.h>
  14. #include <linux/mtd/physmap.h>
  15. #include <linux/mtd/spi-nor.h>
  16. +#include <linux/spi/spi.h>
  17. +#include <linux/spi/flash.h>
  18. #include <bcm63xx_cpu.h>
  19. #include <bcm63xx_dev_flash.h>
  20. +#include <bcm63xx_dev_hsspi.h>
  21. #include <bcm63xx_regs.h>
  22. #include <bcm63xx_io.h>
  23. @@ -66,6 +69,21 @@ void __init bcm63xx_flash_force_phys_bas
  24. mtd_resources[0].end = end;
  25. }
  26. +static struct flash_platform_data bcm63xx_flash_data = {
  27. + .part_probe_types = bcm63xx_part_types,
  28. +};
  29. +
  30. +static struct spi_board_info bcm63xx_spi_flash_info[] = {
  31. + {
  32. + .bus_num = 0,
  33. + .chip_select = 0,
  34. + .mode = 0,
  35. + .max_speed_hz = 781000,
  36. + .modalias = "m25p80",
  37. + .platform_data = &bcm63xx_flash_data,
  38. + },
  39. +};
  40. +
  41. static int __init bcm63xx_detect_flash_type(void)
  42. {
  43. u32 val;
  44. @@ -73,9 +91,15 @@ static int __init bcm63xx_detect_flash_t
  45. switch (bcm63xx_get_cpu_id()) {
  46. case BCM6318_CPU_ID:
  47. /* only support serial flash */
  48. + bcm63xx_spi_flash_info[0].max_speed_hz = 62500000;
  49. return BCM63XX_FLASH_TYPE_SERIAL;
  50. case BCM6328_CPU_ID:
  51. val = bcm_misc_readl(MISC_STRAPBUS_6328_REG);
  52. + if (val & STRAPBUS_6328_HSSPI_CLK_FAST)
  53. + bcm63xx_spi_flash_info[0].max_speed_hz = 33333334;
  54. + else
  55. + bcm63xx_spi_flash_info[0].max_speed_hz = 16666667;
  56. +
  57. if (val & STRAPBUS_6328_BOOT_SEL_SERIAL)
  58. return BCM63XX_FLASH_TYPE_SERIAL;
  59. else
  60. @@ -94,12 +118,20 @@ static int __init bcm63xx_detect_flash_t
  61. return BCM63XX_FLASH_TYPE_SERIAL;
  62. case BCM6362_CPU_ID:
  63. val = bcm_misc_readl(MISC_STRAPBUS_6362_REG);
  64. + if (val & STRAPBUS_6362_HSSPI_CLK_FAST)
  65. + bcm63xx_spi_flash_info[0].max_speed_hz = 50000000;
  66. + else
  67. + bcm63xx_spi_flash_info[0].max_speed_hz = 20000000;
  68. +
  69. if (val & STRAPBUS_6362_BOOT_SEL_SERIAL)
  70. return BCM63XX_FLASH_TYPE_SERIAL;
  71. else
  72. return BCM63XX_FLASH_TYPE_NAND;
  73. case BCM6368_CPU_ID:
  74. val = bcm_gpio_readl(GPIO_STRAPBUS_REG);
  75. + if (val & STRAPBUS_6368_SPI_CLK_FAST)
  76. + bcm63xx_spi_flash_info[0].max_speed_hz = 20000000;
  77. +
  78. switch (val & STRAPBUS_6368_BOOT_SEL_MASK) {
  79. case STRAPBUS_6368_BOOT_SEL_NAND:
  80. return BCM63XX_FLASH_TYPE_NAND;
  81. @@ -110,6 +142,11 @@ static int __init bcm63xx_detect_flash_t
  82. }
  83. case BCM63268_CPU_ID:
  84. val = bcm_misc_readl(MISC_STRAPBUS_63268_REG);
  85. + if (val & STRAPBUS_63268_HSSPI_CLK_FAST)
  86. + bcm63xx_spi_flash_info[0].max_speed_hz = 50000000;
  87. + else
  88. + bcm63xx_spi_flash_info[0].max_speed_hz = 20000000;
  89. +
  90. if (val & STRAPBUS_63268_BOOT_SEL_SERIAL)
  91. return BCM63XX_FLASH_TYPE_SERIAL;
  92. else
  93. @@ -195,8 +232,15 @@ int __init bcm63xx_flash_register(void)
  94. return platform_device_register(&mtd_dev);
  95. case BCM63XX_FLASH_TYPE_SERIAL:
  96. - pr_warn("unsupported serial flash detected\n");
  97. - return -ENODEV;
  98. + if (BCMCPU_IS_6318() || BCMCPU_IS_6328() || BCMCPU_IS_6362() ||
  99. + BCMCPU_IS_63268())
  100. + bcm63xx_spi_flash_info[0].bus_num = 1;
  101. +
  102. + if (BCMCPU_IS_6358() || BCMCPU_IS_6368())
  103. + bcm63xx_flash_data.max_transfer_len = SPI_6358_MSG_DATA_SIZE;
  104. +
  105. + return spi_register_board_info(bcm63xx_spi_flash_info,
  106. + ARRAY_SIZE(bcm63xx_spi_flash_info));
  107. case BCM63XX_FLASH_TYPE_NAND:
  108. pr_warn("unsupported NAND flash detected\n");
  109. return -ENODEV;
  110. --- a/arch/mips/include/asm/mach-bcm63xx/bcm63xx_regs.h
  111. +++ b/arch/mips/include/asm/mach-bcm63xx/bcm63xx_regs.h
  112. @@ -708,6 +708,7 @@
  113. #define GPIO_STRAPBUS_REG 0x40
  114. #define STRAPBUS_6358_BOOT_SEL_PARALLEL (1 << 1)
  115. #define STRAPBUS_6358_BOOT_SEL_SERIAL (0 << 1)
  116. +#define STRAPBUS_6368_SPI_CLK_FAST (1 << 6)
  117. #define STRAPBUS_6368_BOOT_SEL_MASK 0x3
  118. #define STRAPBUS_6368_BOOT_SEL_NAND 0
  119. #define STRAPBUS_6368_BOOT_SEL_SERIAL 1
  120. @@ -1578,6 +1579,7 @@
  121. #define IDDQ_CTRL_63268_USBH (1 << 4)
  122. #define MISC_STRAPBUS_6328_REG 0x240
  123. +#define STRAPBUS_6328_HSSPI_CLK_FAST (1 << 4)
  124. #define STRAPBUS_6328_FCVO_SHIFT 7
  125. #define STRAPBUS_6328_FCVO_MASK (0x1f << STRAPBUS_6328_FCVO_SHIFT)
  126. #define STRAPBUS_6328_BOOT_SEL_SERIAL (1 << 28)