cpu-8815.c 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149
  1. /*
  2. * Copyright STMicroelectronics, 2007.
  3. *
  4. * This program is free software; you can redistribute it and/or modify
  5. * it under the terms of the GNU General Public License as published by
  6. * the Free Software Foundation; either version 2 of the License, or
  7. * (at your option) any later version.
  8. *
  9. * This program is distributed in the hope that it will be useful,
  10. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. * GNU General Public License for more details.
  13. *
  14. * You should have received a copy of the GNU General Public License
  15. * along with this program; if not, write to the Free Software
  16. * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  17. */
  18. #include <linux/types.h>
  19. #include <linux/init.h>
  20. #include <linux/device.h>
  21. #include <linux/amba/bus.h>
  22. #include <linux/platform_device.h>
  23. #include <linux/io.h>
  24. #include <linux/slab.h>
  25. #include <linux/irq.h>
  26. #include <linux/dma-mapping.h>
  27. #include <linux/platform_data/clk-nomadik.h>
  28. #include <plat/gpio-nomadik.h>
  29. #include <mach/hardware.h>
  30. #include <mach/irqs.h>
  31. #include <asm/mach/map.h>
  32. #include <asm/hardware/vic.h>
  33. #include <asm/cacheflush.h>
  34. #include <asm/hardware/cache-l2x0.h>
  35. #include "cpu-8815.h"
  36. /* The 8815 has 4 GPIO blocks, let's register them immediately */
  37. static resource_size_t __initdata cpu8815_gpio_base[] = {
  38. NOMADIK_GPIO0_BASE,
  39. NOMADIK_GPIO1_BASE,
  40. NOMADIK_GPIO2_BASE,
  41. NOMADIK_GPIO3_BASE,
  42. };
  43. static struct platform_device *
  44. cpu8815_add_gpio(int id, resource_size_t addr, int irq,
  45. struct nmk_gpio_platform_data *pdata)
  46. {
  47. struct resource resources[] = {
  48. {
  49. .start = addr,
  50. .end = addr + 127,
  51. .flags = IORESOURCE_MEM,
  52. },
  53. {
  54. .start = irq,
  55. .end = irq,
  56. .flags = IORESOURCE_IRQ,
  57. }
  58. };
  59. return platform_device_register_resndata(NULL, "gpio", id,
  60. resources, ARRAY_SIZE(resources),
  61. pdata, sizeof(*pdata));
  62. }
  63. void cpu8815_add_gpios(resource_size_t *base, int num, int irq,
  64. struct nmk_gpio_platform_data *pdata)
  65. {
  66. int first = 0;
  67. int i;
  68. for (i = 0; i < num; i++, first += 32, irq++) {
  69. pdata->first_gpio = first;
  70. pdata->first_irq = NOMADIK_GPIO_TO_IRQ(first);
  71. pdata->num_gpio = 32;
  72. cpu8815_add_gpio(i, base[i], irq, pdata);
  73. }
  74. }
  75. static int __init cpu8815_init(void)
  76. {
  77. struct nmk_gpio_platform_data pdata = {
  78. /* No custom data yet */
  79. };
  80. cpu8815_add_gpios(cpu8815_gpio_base, ARRAY_SIZE(cpu8815_gpio_base),
  81. IRQ_GPIO0, &pdata);
  82. amba_apb_device_add(NULL, "rng", NOMADIK_RNG_BASE, SZ_4K, 0, 0, NULL, 0);
  83. amba_apb_device_add(NULL, "rtc-pl031", NOMADIK_RTC_BASE, SZ_4K, IRQ_RTC_RTT, 0, NULL, 0);
  84. return 0;
  85. }
  86. arch_initcall(cpu8815_init);
  87. /* All SoC devices live in the same area (see hardware.h) */
  88. static struct map_desc nomadik_io_desc[] __initdata = {
  89. {
  90. .virtual = NOMADIK_IO_VIRTUAL,
  91. .pfn = __phys_to_pfn(NOMADIK_IO_PHYSICAL),
  92. .length = NOMADIK_IO_SIZE,
  93. .type = MT_DEVICE,
  94. }
  95. /* static ram and secured ram may be added later */
  96. };
  97. void __init cpu8815_map_io(void)
  98. {
  99. iotable_init(nomadik_io_desc, ARRAY_SIZE(nomadik_io_desc));
  100. }
  101. void __init cpu8815_init_irq(void)
  102. {
  103. /* This modified VIC cell has two register blocks, at 0 and 0x20 */
  104. vic_init(io_p2v(NOMADIK_IC_BASE + 0x00), IRQ_VIC_START + 0, ~0, 0);
  105. vic_init(io_p2v(NOMADIK_IC_BASE + 0x20), IRQ_VIC_START + 32, ~0, 0);
  106. /*
  107. * Init clocks here so that they are available for system timer
  108. * initialization.
  109. */
  110. nomadik_clk_init();
  111. }
  112. /*
  113. * This function is called from the board init ("init_machine").
  114. */
  115. void __init cpu8815_platform_init(void)
  116. {
  117. #ifdef CONFIG_CACHE_L2X0
  118. /* At full speed latency must be >=2, so 0x249 in low bits */
  119. l2x0_init(io_p2v(NOMADIK_L2CC_BASE), 0x00730249, 0xfe000fff);
  120. #endif
  121. return;
  122. }
  123. void cpu8815_restart(char mode, const char *cmd)
  124. {
  125. void __iomem *src_rstsr = io_p2v(NOMADIK_SRC_BASE + 0x18);
  126. /* FIXME: use egpio when implemented */
  127. /* Write anything to Reset status register */
  128. writel(1, src_rstsr);
  129. }