pxa168.c 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180
  1. /*
  2. * linux/arch/arm/mach-mmp/pxa168.c
  3. *
  4. * Code specific to PXA168
  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 version 2 as
  8. * published by the Free Software Foundation.
  9. */
  10. #include <linux/module.h>
  11. #include <linux/kernel.h>
  12. #include <linux/init.h>
  13. #include <linux/list.h>
  14. #include <linux/io.h>
  15. #include <linux/clk.h>
  16. #include <linux/clk/mmp.h>
  17. #include <linux/platform_device.h>
  18. #include <linux/platform_data/mv_usb.h>
  19. #include <linux/dma-mapping.h>
  20. #include <asm/mach/time.h>
  21. #include <asm/system_misc.h>
  22. #include "addr-map.h"
  23. #include "clock.h"
  24. #include "common.h"
  25. #include "cputype.h"
  26. #include "devices.h"
  27. #include "irqs.h"
  28. #include "mfp.h"
  29. #include "pxa168.h"
  30. #include "regs-apbc.h"
  31. #include "regs-apmu.h"
  32. #include "regs-usb.h"
  33. #define MFPR_VIRT_BASE (APB_VIRT_BASE + 0x1e000)
  34. static struct mfp_addr_map pxa168_mfp_addr_map[] __initdata =
  35. {
  36. MFP_ADDR_X(GPIO0, GPIO36, 0x04c),
  37. MFP_ADDR_X(GPIO37, GPIO55, 0x000),
  38. MFP_ADDR_X(GPIO56, GPIO123, 0x0e0),
  39. MFP_ADDR_X(GPIO124, GPIO127, 0x0f4),
  40. MFP_ADDR_END,
  41. };
  42. void __init pxa168_init_irq(void)
  43. {
  44. icu_init_irq();
  45. }
  46. static int __init pxa168_init(void)
  47. {
  48. if (cpu_is_pxa168()) {
  49. mfp_init_base(MFPR_VIRT_BASE);
  50. mfp_init_addr(pxa168_mfp_addr_map);
  51. pxa168_clk_init(APB_PHYS_BASE + 0x50000,
  52. AXI_PHYS_BASE + 0x82800,
  53. APB_PHYS_BASE + 0x15000);
  54. }
  55. return 0;
  56. }
  57. postcore_initcall(pxa168_init);
  58. /* system timer - clock enabled, 3.25MHz */
  59. #define TIMER_CLK_RST (APBC_APBCLK | APBC_FNCLK | APBC_FNCLKSEL(3))
  60. #define APBC_TIMERS APBC_REG(0x34)
  61. void __init pxa168_timer_init(void)
  62. {
  63. /* this is early, we have to initialize the CCU registers by
  64. * ourselves instead of using clk_* API. Clock rate is defined
  65. * by APBC_TIMERS_CLK_RST (3.25MHz) and enabled free-running
  66. */
  67. __raw_writel(APBC_APBCLK | APBC_RST, APBC_TIMERS);
  68. /* 3.25MHz, bus/functional clock enabled, release reset */
  69. __raw_writel(TIMER_CLK_RST, APBC_TIMERS);
  70. timer_init(IRQ_PXA168_TIMER1);
  71. }
  72. void pxa168_clear_keypad_wakeup(void)
  73. {
  74. uint32_t val;
  75. uint32_t mask = APMU_PXA168_KP_WAKE_CLR;
  76. /* wake event clear is needed in order to clear keypad interrupt */
  77. val = __raw_readl(APMU_WAKE_CLR);
  78. __raw_writel(val | mask, APMU_WAKE_CLR);
  79. }
  80. /* on-chip devices */
  81. PXA168_DEVICE(uart1, "pxa2xx-uart", 0, UART1, 0xd4017000, 0x30, 21, 22);
  82. PXA168_DEVICE(uart2, "pxa2xx-uart", 1, UART2, 0xd4018000, 0x30, 23, 24);
  83. PXA168_DEVICE(uart3, "pxa2xx-uart", 2, UART3, 0xd4026000, 0x30, 23, 24);
  84. PXA168_DEVICE(twsi0, "pxa2xx-i2c", 0, TWSI0, 0xd4011000, 0x28);
  85. PXA168_DEVICE(twsi1, "pxa2xx-i2c", 1, TWSI1, 0xd4025000, 0x28);
  86. PXA168_DEVICE(pwm1, "pxa168-pwm", 0, NONE, 0xd401a000, 0x10);
  87. PXA168_DEVICE(pwm2, "pxa168-pwm", 1, NONE, 0xd401a400, 0x10);
  88. PXA168_DEVICE(pwm3, "pxa168-pwm", 2, NONE, 0xd401a800, 0x10);
  89. PXA168_DEVICE(pwm4, "pxa168-pwm", 3, NONE, 0xd401ac00, 0x10);
  90. PXA168_DEVICE(nand, "pxa3xx-nand", -1, NAND, 0xd4283000, 0x80, 97, 99);
  91. PXA168_DEVICE(ssp1, "pxa168-ssp", 0, SSP1, 0xd401b000, 0x40, 52, 53);
  92. PXA168_DEVICE(ssp2, "pxa168-ssp", 1, SSP2, 0xd401c000, 0x40, 54, 55);
  93. PXA168_DEVICE(ssp3, "pxa168-ssp", 2, SSP3, 0xd401f000, 0x40, 56, 57);
  94. PXA168_DEVICE(ssp4, "pxa168-ssp", 3, SSP4, 0xd4020000, 0x40, 58, 59);
  95. PXA168_DEVICE(ssp5, "pxa168-ssp", 4, SSP5, 0xd4021000, 0x40, 60, 61);
  96. PXA168_DEVICE(fb, "pxa168-fb", -1, LCD, 0xd420b000, 0x1c8);
  97. PXA168_DEVICE(keypad, "pxa27x-keypad", -1, KEYPAD, 0xd4012000, 0x4c);
  98. PXA168_DEVICE(eth, "pxa168-eth", -1, MFU, 0xc0800000, 0x0fff);
  99. struct resource pxa168_resource_gpio[] = {
  100. {
  101. .start = 0xd4019000,
  102. .end = 0xd4019fff,
  103. .flags = IORESOURCE_MEM,
  104. }, {
  105. .start = IRQ_PXA168_GPIOX,
  106. .end = IRQ_PXA168_GPIOX,
  107. .name = "gpio_mux",
  108. .flags = IORESOURCE_IRQ,
  109. },
  110. };
  111. struct platform_device pxa168_device_gpio = {
  112. .name = "mmp-gpio",
  113. .id = -1,
  114. .num_resources = ARRAY_SIZE(pxa168_resource_gpio),
  115. .resource = pxa168_resource_gpio,
  116. };
  117. struct resource pxa168_usb_host_resources[] = {
  118. /* USB Host conroller register base */
  119. [0] = {
  120. .start = PXA168_U2H_REGBASE + U2x_CAPREGS_OFFSET,
  121. .end = PXA168_U2H_REGBASE + USB_REG_RANGE,
  122. .flags = IORESOURCE_MEM,
  123. .name = "capregs",
  124. },
  125. /* USB PHY register base */
  126. [1] = {
  127. .start = PXA168_U2H_PHYBASE,
  128. .end = PXA168_U2H_PHYBASE + USB_PHY_RANGE,
  129. .flags = IORESOURCE_MEM,
  130. .name = "phyregs",
  131. },
  132. [2] = {
  133. .start = IRQ_PXA168_USB2,
  134. .end = IRQ_PXA168_USB2,
  135. .flags = IORESOURCE_IRQ,
  136. },
  137. };
  138. static u64 pxa168_usb_host_dmamask = DMA_BIT_MASK(32);
  139. struct platform_device pxa168_device_usb_host = {
  140. .name = "pxa-sph",
  141. .id = -1,
  142. .dev = {
  143. .dma_mask = &pxa168_usb_host_dmamask,
  144. .coherent_dma_mask = DMA_BIT_MASK(32),
  145. },
  146. .num_resources = ARRAY_SIZE(pxa168_usb_host_resources),
  147. .resource = pxa168_usb_host_resources,
  148. };
  149. int __init pxa168_add_usb_host(struct mv_usb_platform_data *pdata)
  150. {
  151. pxa168_device_usb_host.dev.platform_data = pdata;
  152. return platform_device_register(&pxa168_device_usb_host);
  153. }
  154. void pxa168_restart(enum reboot_mode mode, const char *cmd)
  155. {
  156. soft_restart(0xffff0000);
  157. }