mmp2.c 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230
  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/module.h>
  13. #include <linux/kernel.h>
  14. #include <linux/init.h>
  15. #include <linux/io.h>
  16. #include <asm/hardware/cache-tauros2.h>
  17. #include <asm/mach/time.h>
  18. #include <mach/addr-map.h>
  19. #include <mach/regs-apbc.h>
  20. #include <mach/regs-apmu.h>
  21. #include <mach/cputype.h>
  22. #include <mach/irqs.h>
  23. #include <mach/dma.h>
  24. #include <mach/mfp.h>
  25. #include <mach/gpio.h>
  26. #include <mach/devices.h>
  27. #include <mach/mmp2.h>
  28. #include "common.h"
  29. #include "clock.h"
  30. #define MFPR_VIRT_BASE (APB_VIRT_BASE + 0x1e000)
  31. #define APMASK(i) (GPIO_REGS_VIRT + BANK_OFF(i) + 0x9c)
  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. unsigned long mfpr_pmic, data;
  75. mfpr_pmic = APB_VIRT_BASE + 0x1e000 + 0x2c4;
  76. data = __raw_readl(mfpr_pmic);
  77. __raw_writel(data | (1 << 6), mfpr_pmic);
  78. __raw_writel(data, mfpr_pmic);
  79. }
  80. static void __init mmp2_init_gpio(void)
  81. {
  82. int i;
  83. /* enable GPIO clock */
  84. __raw_writel(APBC_APBCLK | APBC_FNCLK, APBC_MMP2_GPIO);
  85. /* unmask GPIO edge detection for all 6 banks -- APMASKx */
  86. for (i = 0; i < 6; i++)
  87. __raw_writel(0xffffffff, APMASK(i));
  88. pxa_init_gpio(IRQ_MMP2_GPIO, 0, 167, NULL);
  89. }
  90. void __init mmp2_init_irq(void)
  91. {
  92. mmp2_init_icu();
  93. mmp2_init_gpio();
  94. }
  95. static void sdhc_clk_enable(struct clk *clk)
  96. {
  97. uint32_t clk_rst;
  98. clk_rst = __raw_readl(clk->clk_rst);
  99. clk_rst |= clk->enable_val;
  100. __raw_writel(clk_rst, clk->clk_rst);
  101. }
  102. static void sdhc_clk_disable(struct clk *clk)
  103. {
  104. uint32_t clk_rst;
  105. clk_rst = __raw_readl(clk->clk_rst);
  106. clk_rst &= ~clk->enable_val;
  107. __raw_writel(clk_rst, clk->clk_rst);
  108. }
  109. struct clkops sdhc_clk_ops = {
  110. .enable = sdhc_clk_enable,
  111. .disable = sdhc_clk_disable,
  112. };
  113. /* APB peripheral clocks */
  114. static APBC_CLK(uart1, MMP2_UART1, 1, 26000000);
  115. static APBC_CLK(uart2, MMP2_UART2, 1, 26000000);
  116. static APBC_CLK(uart3, MMP2_UART3, 1, 26000000);
  117. static APBC_CLK(uart4, MMP2_UART4, 1, 26000000);
  118. static APBC_CLK(twsi1, MMP2_TWSI1, 0, 26000000);
  119. static APBC_CLK(twsi2, MMP2_TWSI2, 0, 26000000);
  120. static APBC_CLK(twsi3, MMP2_TWSI3, 0, 26000000);
  121. static APBC_CLK(twsi4, MMP2_TWSI4, 0, 26000000);
  122. static APBC_CLK(twsi5, MMP2_TWSI5, 0, 26000000);
  123. static APBC_CLK(twsi6, MMP2_TWSI6, 0, 26000000);
  124. static APMU_CLK(nand, NAND, 0xbf, 100000000);
  125. static APMU_CLK_OPS(sdh0, SDH0, 0x1b, 200000000, &sdhc_clk_ops);
  126. static APMU_CLK_OPS(sdh1, SDH1, 0x1b, 200000000, &sdhc_clk_ops);
  127. static APMU_CLK_OPS(sdh2, SDH2, 0x1b, 200000000, &sdhc_clk_ops);
  128. static APMU_CLK_OPS(sdh3, SDH3, 0x1b, 200000000, &sdhc_clk_ops);
  129. static struct clk_lookup mmp2_clkregs[] = {
  130. INIT_CLKREG(&clk_uart1, "pxa2xx-uart.0", NULL),
  131. INIT_CLKREG(&clk_uart2, "pxa2xx-uart.1", NULL),
  132. INIT_CLKREG(&clk_uart3, "pxa2xx-uart.2", NULL),
  133. INIT_CLKREG(&clk_uart4, "pxa2xx-uart.3", NULL),
  134. INIT_CLKREG(&clk_twsi1, "pxa2xx-i2c.0", NULL),
  135. INIT_CLKREG(&clk_twsi2, "pxa2xx-i2c.1", NULL),
  136. INIT_CLKREG(&clk_twsi3, "pxa2xx-i2c.2", NULL),
  137. INIT_CLKREG(&clk_twsi4, "pxa2xx-i2c.3", NULL),
  138. INIT_CLKREG(&clk_twsi5, "pxa2xx-i2c.4", NULL),
  139. INIT_CLKREG(&clk_twsi6, "pxa2xx-i2c.5", NULL),
  140. INIT_CLKREG(&clk_nand, "pxa3xx-nand", NULL),
  141. INIT_CLKREG(&clk_sdh0, "sdhci-pxa.0", "PXA-SDHCLK"),
  142. INIT_CLKREG(&clk_sdh1, "sdhci-pxa.1", "PXA-SDHCLK"),
  143. INIT_CLKREG(&clk_sdh2, "sdhci-pxa.2", "PXA-SDHCLK"),
  144. INIT_CLKREG(&clk_sdh3, "sdhci-pxa.3", "PXA-SDHCLK"),
  145. };
  146. static int __init mmp2_init(void)
  147. {
  148. if (cpu_is_mmp2()) {
  149. #ifdef CONFIG_CACHE_TAUROS2
  150. tauros2_init();
  151. #endif
  152. mfp_init_base(MFPR_VIRT_BASE);
  153. mfp_init_addr(mmp2_addr_map);
  154. pxa_init_dma(IRQ_MMP2_DMA_RIQ, 16);
  155. clkdev_add_table(ARRAY_AND_SIZE(mmp2_clkregs));
  156. }
  157. return 0;
  158. }
  159. postcore_initcall(mmp2_init);
  160. static void __init mmp2_timer_init(void)
  161. {
  162. unsigned long clk_rst;
  163. __raw_writel(APBC_APBCLK | APBC_RST, APBC_MMP2_TIMERS);
  164. /*
  165. * enable bus/functional clock, enable 6.5MHz (divider 4),
  166. * release reset
  167. */
  168. clk_rst = APBC_APBCLK | APBC_FNCLK | APBC_FNCLKSEL(1);
  169. __raw_writel(clk_rst, APBC_MMP2_TIMERS);
  170. timer_init(IRQ_MMP2_TIMER1);
  171. }
  172. struct sys_timer mmp2_timer = {
  173. .init = mmp2_timer_init,
  174. };
  175. /* on-chip devices */
  176. MMP2_DEVICE(uart1, "pxa2xx-uart", 0, UART1, 0xd4030000, 0x30, 4, 5);
  177. MMP2_DEVICE(uart2, "pxa2xx-uart", 1, UART2, 0xd4017000, 0x30, 20, 21);
  178. MMP2_DEVICE(uart3, "pxa2xx-uart", 2, UART3, 0xd4018000, 0x30, 22, 23);
  179. MMP2_DEVICE(uart4, "pxa2xx-uart", 3, UART4, 0xd4016000, 0x30, 18, 19);
  180. MMP2_DEVICE(twsi1, "pxa2xx-i2c", 0, TWSI1, 0xd4011000, 0x70);
  181. MMP2_DEVICE(twsi2, "pxa2xx-i2c", 1, TWSI2, 0xd4031000, 0x70);
  182. MMP2_DEVICE(twsi3, "pxa2xx-i2c", 2, TWSI3, 0xd4032000, 0x70);
  183. MMP2_DEVICE(twsi4, "pxa2xx-i2c", 3, TWSI4, 0xd4033000, 0x70);
  184. MMP2_DEVICE(twsi5, "pxa2xx-i2c", 4, TWSI5, 0xd4033800, 0x70);
  185. MMP2_DEVICE(twsi6, "pxa2xx-i2c", 5, TWSI6, 0xd4034000, 0x70);
  186. MMP2_DEVICE(nand, "pxa3xx-nand", -1, NAND, 0xd4283000, 0x100, 28, 29);
  187. MMP2_DEVICE(sdh0, "sdhci-pxa", 0, MMC, 0xd4280000, 0x120);
  188. MMP2_DEVICE(sdh1, "sdhci-pxa", 1, MMC2, 0xd4280800, 0x120);
  189. MMP2_DEVICE(sdh2, "sdhci-pxa", 2, MMC3, 0xd4281000, 0x120);
  190. MMP2_DEVICE(sdh3, "sdhci-pxa", 3, MMC4, 0xd4281800, 0x120);