redwood6.c 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156
  1. /*
  2. * Author: Armin Kuster <akuster@mvista.com>
  3. *
  4. * 2002 (c) MontaVista, Software, Inc. This file is licensed under
  5. * the terms of the GNU General Public License version 2. This program
  6. * is licensed "as is" without any warranty of any kind, whether express
  7. * or implied.
  8. */
  9. #include <linux/init.h>
  10. #include <linux/pagemap.h>
  11. #include <linux/platform_device.h>
  12. #include <linux/ioport.h>
  13. #include <asm/io.h>
  14. #include <asm/ppc4xx_pic.h>
  15. #include <linux/delay.h>
  16. #include <asm/machdep.h>
  17. /*
  18. * Define external IRQ senses and polarities.
  19. */
  20. unsigned char ppc4xx_uic_ext_irq_cfg[] __initdata = {
  21. (IRQ_SENSE_LEVEL | IRQ_POLARITY_NEGATIVE), /* Ext Int 7 */
  22. (IRQ_SENSE_LEVEL | IRQ_POLARITY_NEGATIVE), /* Ext Int 8 */
  23. (IRQ_SENSE_LEVEL | IRQ_POLARITY_NEGATIVE), /* Ext Int 9 */
  24. (IRQ_SENSE_LEVEL | IRQ_POLARITY_NEGATIVE), /* Ext Int 0 */
  25. (IRQ_SENSE_LEVEL | IRQ_POLARITY_NEGATIVE), /* Ext Int 1 */
  26. (IRQ_SENSE_LEVEL | IRQ_POLARITY_NEGATIVE), /* Ext Int 2 */
  27. (IRQ_SENSE_LEVEL | IRQ_POLARITY_NEGATIVE), /* Ext Int 3 */
  28. (IRQ_SENSE_LEVEL | IRQ_POLARITY_NEGATIVE), /* Ext Int 4 */
  29. (IRQ_SENSE_LEVEL | IRQ_POLARITY_NEGATIVE), /* Ext Int 5 */
  30. (IRQ_SENSE_LEVEL | IRQ_POLARITY_NEGATIVE), /* Ext Int 6 */
  31. };
  32. static struct resource smc91x_resources[] = {
  33. [0] = {
  34. .start = SMC91111_BASE_ADDR,
  35. .end = SMC91111_BASE_ADDR + SMC91111_REG_SIZE - 1,
  36. .flags = IORESOURCE_MEM,
  37. },
  38. [1] = {
  39. .start = SMC91111_IRQ,
  40. .end = SMC91111_IRQ,
  41. .flags = IORESOURCE_IRQ,
  42. },
  43. };
  44. static struct platform_device smc91x_device = {
  45. .name = "smc91x",
  46. .id = 0,
  47. .num_resources = ARRAY_SIZE(smc91x_resources),
  48. .resource = smc91x_resources,
  49. };
  50. static struct platform_device *redwood6_devs[] __initdata = {
  51. &smc91x_device,
  52. };
  53. static int __init
  54. redwood6_platform_add_devices(void)
  55. {
  56. return platform_add_devices(redwood6_devs, ARRAY_SIZE(redwood6_devs));
  57. }
  58. void __init
  59. redwood6_setup_arch(void)
  60. {
  61. #ifdef CONFIG_IDE
  62. void *xilinx, *xilinx_1, *xilinx_2;
  63. unsigned short us_reg5;
  64. #endif
  65. ppc4xx_setup_arch();
  66. #ifdef CONFIG_IDE
  67. xilinx = (unsigned long) ioremap(IDE_XLINUX_MUX_BASE, 0x10);
  68. /* init xilinx control registers - enable ide mux, clear reset bit */
  69. if (!xilinx) {
  70. printk(KERN_CRIT
  71. "redwood6_setup_arch() xilinxi ioremap failed\n");
  72. return;
  73. }
  74. xilinx_1 = xilinx + 0xa;
  75. xilinx_2 = xilinx + 0xe;
  76. us_reg5 = readb(xilinx_1);
  77. writeb(0x01d1, xilinx_1);
  78. writeb(0x0008, xilinx_2);
  79. udelay(10 * 1000);
  80. writeb(0x01d1, xilinx_1);
  81. writeb(0x0008, xilinx_2);
  82. #endif
  83. #ifdef DEBUG_BRINGUP
  84. bd_t *bip = (bd_t *) __res;
  85. printk("\n");
  86. printk("machine\t: %s\n", PPC4xx_MACHINE_NAME);
  87. printk("\n");
  88. printk("bi_s_version\t %s\n", bip->bi_s_version);
  89. printk("bi_r_version\t %s\n", bip->bi_r_version);
  90. printk("bi_memsize\t 0x%8.8x\t %dMBytes\n", bip->bi_memsize,
  91. bip->bi_memsize / (1024 * 1000));
  92. printk("bi_enetaddr %d\t %2.2x%2.2x%2.2x-%2.2x%2.2x%2.2x\n", 0,
  93. bip->bi_enetaddr[0], bip->bi_enetaddr[1], bip->bi_enetaddr[2],
  94. bip->bi_enetaddr[3], bip->bi_enetaddr[4], bip->bi_enetaddr[5]);
  95. printk("bi_intfreq\t 0x%8.8x\t clock:\t %dMhz\n",
  96. bip->bi_intfreq, bip->bi_intfreq / 1000000);
  97. printk("bi_busfreq\t 0x%8.8x\t plb bus clock:\t %dMHz\n",
  98. bip->bi_busfreq, bip->bi_busfreq / 1000000);
  99. printk("bi_tbfreq\t 0x%8.8x\t TB freq:\t %dMHz\n",
  100. bip->bi_tbfreq, bip->bi_tbfreq / 1000000);
  101. printk("\n");
  102. #endif
  103. /* Identify the system */
  104. printk(KERN_INFO "IBM Redwood6 (STBx25XX) Platform\n");
  105. printk(KERN_INFO
  106. "Port by MontaVista Software, Inc. (source@mvista.com)\n");
  107. device_initcall(redwood6_platform_add_devices);
  108. }
  109. void __init
  110. redwood6_map_io(void)
  111. {
  112. int i;
  113. ppc4xx_map_io();
  114. for (i = 0; i < 16; i++) {
  115. unsigned long v, p;
  116. /* 0x400x0000 -> 0xe00x0000 */
  117. p = 0x40000000 | (i << 16);
  118. v = STBx25xx_IO_BASE | (i << 16);
  119. io_block_mapping(v, p, PAGE_SIZE,
  120. _PAGE_NO_CACHE | pgprot_val(PAGE_KERNEL) |
  121. _PAGE_GUARDED);
  122. }
  123. }
  124. void __init
  125. platform_init(unsigned long r3, unsigned long r4, unsigned long r5,
  126. unsigned long r6, unsigned long r7)
  127. {
  128. ppc4xx_init(r3, r4, r5, r6, r7);
  129. ppc_md.setup_arch = redwood6_setup_arch;
  130. ppc_md.setup_io_mappings = redwood6_map_io;
  131. }