mmp2.c 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179
  1. /*
  2. * linux/arch/arm/mach-mmp/mmp2.c
  3. *
  4. * code name MMP2
  5. *
  6. * Copyright (C) 2009 Marvell International Ltd.
  7. *
  8. * This program is free software; you can redistribute it and/or modify
  9. * it under the terms of the GNU General Public License version 2 as
  10. * published by the Free Software Foundation.
  11. */
  12. #include <linux/clk/mmp.h>
  13. #include <linux/module.h>
  14. #include <linux/kernel.h>
  15. #include <linux/init.h>
  16. #include <linux/io.h>
  17. #include <linux/irq.h>
  18. #include <linux/irqchip/mmp.h>
  19. #include <linux/platform_device.h>
  20. #include <asm/hardware/cache-tauros2.h>
  21. #include <asm/mach/time.h>
  22. #include "addr-map.h"
  23. #include "regs-apbc.h"
  24. #include "cputype.h"
  25. #include "irqs.h"
  26. #include "mfp.h"
  27. #include "devices.h"
  28. #include "mmp2.h"
  29. #include "pm-mmp2.h"
  30. #include "common.h"
  31. #define MFPR_VIRT_BASE (APB_VIRT_BASE + 0x1e000)
  32. static struct mfp_addr_map mmp2_addr_map[] __initdata = {
  33. MFP_ADDR_X(GPIO0, GPIO58, 0x54),
  34. MFP_ADDR_X(GPIO59, GPIO73, 0x280),
  35. MFP_ADDR_X(GPIO74, GPIO101, 0x170),
  36. MFP_ADDR(GPIO102, 0x0),
  37. MFP_ADDR(GPIO103, 0x4),
  38. MFP_ADDR(GPIO104, 0x1fc),
  39. MFP_ADDR(GPIO105, 0x1f8),
  40. MFP_ADDR(GPIO106, 0x1f4),
  41. MFP_ADDR(GPIO107, 0x1f0),
  42. MFP_ADDR(GPIO108, 0x21c),
  43. MFP_ADDR(GPIO109, 0x218),
  44. MFP_ADDR(GPIO110, 0x214),
  45. MFP_ADDR(GPIO111, 0x200),
  46. MFP_ADDR(GPIO112, 0x244),
  47. MFP_ADDR(GPIO113, 0x25c),
  48. MFP_ADDR(GPIO114, 0x164),
  49. MFP_ADDR_X(GPIO115, GPIO122, 0x260),
  50. MFP_ADDR(GPIO123, 0x148),
  51. MFP_ADDR_X(GPIO124, GPIO141, 0xc),
  52. MFP_ADDR(GPIO142, 0x8),
  53. MFP_ADDR_X(GPIO143, GPIO151, 0x220),
  54. MFP_ADDR_X(GPIO152, GPIO153, 0x248),
  55. MFP_ADDR_X(GPIO154, GPIO155, 0x254),
  56. MFP_ADDR_X(GPIO156, GPIO159, 0x14c),
  57. MFP_ADDR(GPIO160, 0x250),
  58. MFP_ADDR(GPIO161, 0x210),
  59. MFP_ADDR(GPIO162, 0x20c),
  60. MFP_ADDR(GPIO163, 0x208),
  61. MFP_ADDR(GPIO164, 0x204),
  62. MFP_ADDR(GPIO165, 0x1ec),
  63. MFP_ADDR(GPIO166, 0x1e8),
  64. MFP_ADDR(GPIO167, 0x1e4),
  65. MFP_ADDR(GPIO168, 0x1e0),
  66. MFP_ADDR_X(TWSI1_SCL, TWSI1_SDA, 0x140),
  67. MFP_ADDR_X(TWSI4_SCL, TWSI4_SDA, 0x2bc),
  68. MFP_ADDR(PMIC_INT, 0x2c4),
  69. MFP_ADDR(CLK_REQ, 0x160),
  70. MFP_ADDR_END,
  71. };
  72. void mmp2_clear_pmic_int(void)
  73. {
  74. void __iomem *mfpr_pmic;
  75. unsigned long data;
  76. mfpr_pmic = APB_VIRT_BASE + 0x1e000 + 0x2c4;
  77. data = __raw_readl(mfpr_pmic);
  78. __raw_writel(data | (1 << 6), mfpr_pmic);
  79. __raw_writel(data, mfpr_pmic);
  80. }
  81. void __init mmp2_init_irq(void)
  82. {
  83. mmp2_init_icu();
  84. #ifdef CONFIG_PM
  85. icu_irq_chip.irq_set_wake = mmp2_set_wake;
  86. #endif
  87. }
  88. static int __init mmp2_init(void)
  89. {
  90. if (cpu_is_mmp2()) {
  91. #ifdef CONFIG_CACHE_TAUROS2
  92. tauros2_init(0);
  93. #endif
  94. mfp_init_base(MFPR_VIRT_BASE);
  95. mfp_init_addr(mmp2_addr_map);
  96. mmp2_clk_init(APB_PHYS_BASE + 0x50000,
  97. AXI_PHYS_BASE + 0x82800,
  98. APB_PHYS_BASE + 0x15000);
  99. }
  100. return 0;
  101. }
  102. postcore_initcall(mmp2_init);
  103. #define APBC_TIMERS APBC_REG(0x024)
  104. void __init mmp2_timer_init(void)
  105. {
  106. unsigned long clk_rst;
  107. __raw_writel(APBC_APBCLK | APBC_RST, APBC_TIMERS);
  108. /*
  109. * enable bus/functional clock, enable 6.5MHz (divider 4),
  110. * release reset
  111. */
  112. clk_rst = APBC_APBCLK | APBC_FNCLK | APBC_FNCLKSEL(1);
  113. __raw_writel(clk_rst, APBC_TIMERS);
  114. timer_init(IRQ_MMP2_TIMER1);
  115. }
  116. /* on-chip devices */
  117. MMP2_DEVICE(uart1, "pxa2xx-uart", 0, UART1, 0xd4030000, 0x30, 4, 5);
  118. MMP2_DEVICE(uart2, "pxa2xx-uart", 1, UART2, 0xd4017000, 0x30, 20, 21);
  119. MMP2_DEVICE(uart3, "pxa2xx-uart", 2, UART3, 0xd4018000, 0x30, 22, 23);
  120. MMP2_DEVICE(uart4, "pxa2xx-uart", 3, UART4, 0xd4016000, 0x30, 18, 19);
  121. MMP2_DEVICE(twsi1, "pxa2xx-i2c", 0, TWSI1, 0xd4011000, 0x70);
  122. MMP2_DEVICE(twsi2, "pxa2xx-i2c", 1, TWSI2, 0xd4031000, 0x70);
  123. MMP2_DEVICE(twsi3, "pxa2xx-i2c", 2, TWSI3, 0xd4032000, 0x70);
  124. MMP2_DEVICE(twsi4, "pxa2xx-i2c", 3, TWSI4, 0xd4033000, 0x70);
  125. MMP2_DEVICE(twsi5, "pxa2xx-i2c", 4, TWSI5, 0xd4033800, 0x70);
  126. MMP2_DEVICE(twsi6, "pxa2xx-i2c", 5, TWSI6, 0xd4034000, 0x70);
  127. MMP2_DEVICE(nand, "pxa3xx-nand", -1, NAND, 0xd4283000, 0x100, 28, 29);
  128. MMP2_DEVICE(sdh0, "sdhci-pxav3", 0, MMC, 0xd4280000, 0x120);
  129. MMP2_DEVICE(sdh1, "sdhci-pxav3", 1, MMC2, 0xd4280800, 0x120);
  130. MMP2_DEVICE(sdh2, "sdhci-pxav3", 2, MMC3, 0xd4281000, 0x120);
  131. MMP2_DEVICE(sdh3, "sdhci-pxav3", 3, MMC4, 0xd4281800, 0x120);
  132. MMP2_DEVICE(asram, "asram", -1, NONE, 0xe0000000, 0x4000);
  133. /* 0xd1000000 ~ 0xd101ffff is reserved for secure processor */
  134. MMP2_DEVICE(isram, "isram", -1, NONE, 0xd1020000, 0x18000);
  135. struct resource mmp2_resource_gpio[] = {
  136. {
  137. .start = 0xd4019000,
  138. .end = 0xd4019fff,
  139. .flags = IORESOURCE_MEM,
  140. }, {
  141. .start = IRQ_MMP2_GPIO,
  142. .end = IRQ_MMP2_GPIO,
  143. .name = "gpio_mux",
  144. .flags = IORESOURCE_IRQ,
  145. },
  146. };
  147. struct platform_device mmp2_device_gpio = {
  148. .name = "mmp2-gpio",
  149. .id = -1,
  150. .num_resources = ARRAY_SIZE(mmp2_resource_gpio),
  151. .resource = mmp2_resource_gpio,
  152. };