integrator_cp.c 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153
  1. /*
  2. * linux/arch/arm/mach-integrator/integrator_cp.c
  3. *
  4. * Copyright (C) 2003 Deep Blue Solutions Ltd
  5. *
  6. * This program is free software; you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License as published by
  8. * the Free Software Foundation; either version 2 of the License.
  9. */
  10. #include <linux/kernel.h>
  11. #include <linux/amba/mmci.h>
  12. #include <linux/io.h>
  13. #include <linux/irqchip.h>
  14. #include <linux/of_irq.h>
  15. #include <linux/of_address.h>
  16. #include <linux/of_platform.h>
  17. #include <linux/sched_clock.h>
  18. #include <linux/regmap.h>
  19. #include <linux/mfd/syscon.h>
  20. #include <asm/mach/arch.h>
  21. #include <asm/mach/map.h>
  22. #include "hardware.h"
  23. #include "cm.h"
  24. #include "common.h"
  25. /* Base address to the core module header */
  26. static struct regmap *cm_map;
  27. /* Base address to the CP controller */
  28. static void __iomem *intcp_con_base;
  29. #define CM_COUNTER_OFFSET 0x28
  30. /*
  31. * Logical Physical
  32. * f1400000 14000000 Interrupt controller
  33. * f1600000 16000000 UART 0
  34. * fca00000 ca000000 SIC
  35. */
  36. static struct map_desc intcp_io_desc[] __initdata __maybe_unused = {
  37. {
  38. .virtual = IO_ADDRESS(INTEGRATOR_IC_BASE),
  39. .pfn = __phys_to_pfn(INTEGRATOR_IC_BASE),
  40. .length = SZ_4K,
  41. .type = MT_DEVICE
  42. }, {
  43. .virtual = IO_ADDRESS(INTEGRATOR_UART0_BASE),
  44. .pfn = __phys_to_pfn(INTEGRATOR_UART0_BASE),
  45. .length = SZ_4K,
  46. .type = MT_DEVICE
  47. }, {
  48. .virtual = IO_ADDRESS(INTEGRATOR_CP_SIC_BASE),
  49. .pfn = __phys_to_pfn(INTEGRATOR_CP_SIC_BASE),
  50. .length = SZ_4K,
  51. .type = MT_DEVICE
  52. }
  53. };
  54. static void __init intcp_map_io(void)
  55. {
  56. iotable_init(intcp_io_desc, ARRAY_SIZE(intcp_io_desc));
  57. }
  58. /*
  59. * It seems that the card insertion interrupt remains active after
  60. * we've acknowledged it. We therefore ignore the interrupt, and
  61. * rely on reading it from the SIC. This also means that we must
  62. * clear the latched interrupt.
  63. */
  64. static unsigned int mmc_status(struct device *dev)
  65. {
  66. unsigned int status = readl(__io_address(0xca000000 + 4));
  67. writel(8, intcp_con_base + 8);
  68. return status & 8;
  69. }
  70. static struct mmci_platform_data mmc_data = {
  71. .ocr_mask = MMC_VDD_32_33|MMC_VDD_33_34,
  72. .status = mmc_status,
  73. .gpio_wp = -1,
  74. .gpio_cd = -1,
  75. };
  76. static u64 notrace intcp_read_sched_clock(void)
  77. {
  78. unsigned int val;
  79. /* MMIO so discard return code */
  80. regmap_read(cm_map, CM_COUNTER_OFFSET, &val);
  81. return val;
  82. }
  83. static void __init intcp_init_early(void)
  84. {
  85. cm_map = syscon_regmap_lookup_by_compatible("arm,core-module-integrator");
  86. if (IS_ERR(cm_map))
  87. return;
  88. sched_clock_register(intcp_read_sched_clock, 32, 24000000);
  89. }
  90. static void __init intcp_init_irq_of(void)
  91. {
  92. cm_init();
  93. irqchip_init();
  94. }
  95. /*
  96. * For the Device Tree, add in the UART, MMC and CLCD specifics as AUXDATA
  97. * and enforce the bus names since these are used for clock lookups.
  98. */
  99. static struct of_dev_auxdata intcp_auxdata_lookup[] __initdata = {
  100. OF_DEV_AUXDATA("arm,primecell", INTEGRATOR_CP_MMC_BASE,
  101. "mmci", &mmc_data),
  102. { /* sentinel */ },
  103. };
  104. static const struct of_device_id intcp_syscon_match[] = {
  105. { .compatible = "arm,integrator-cp-syscon"},
  106. { },
  107. };
  108. static void __init intcp_init_of(void)
  109. {
  110. struct device_node *cpcon;
  111. cpcon = of_find_matching_node(NULL, intcp_syscon_match);
  112. if (!cpcon)
  113. return;
  114. intcp_con_base = of_iomap(cpcon, 0);
  115. if (!intcp_con_base)
  116. return;
  117. of_platform_default_populate(NULL, intcp_auxdata_lookup, NULL);
  118. }
  119. static const char * intcp_dt_board_compat[] = {
  120. "arm,integrator-cp",
  121. NULL,
  122. };
  123. DT_MACHINE_START(INTEGRATOR_CP_DT, "ARM Integrator/CP (Device Tree)")
  124. .reserve = integrator_reserve,
  125. .map_io = intcp_map_io,
  126. .init_early = intcp_init_early,
  127. .init_irq = intcp_init_irq_of,
  128. .init_machine = intcp_init_of,
  129. .dt_compat = intcp_dt_board_compat,
  130. MACHINE_END