m5249.c 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  1. /***************************************************************************/
  2. /*
  3. * linux/arch/m68knommu/platform/5249/config.c
  4. *
  5. * Copyright (C) 2002, Greg Ungerer (gerg@snapgear.com)
  6. */
  7. /***************************************************************************/
  8. #include <linux/kernel.h>
  9. #include <linux/param.h>
  10. #include <linux/init.h>
  11. #include <linux/io.h>
  12. #include <linux/platform_device.h>
  13. #include <asm/machdep.h>
  14. #include <asm/coldfire.h>
  15. #include <asm/mcfsim.h>
  16. #include <asm/mcfgpio.h>
  17. /***************************************************************************/
  18. struct mcf_gpio_chip mcf_gpio_chips[] = {
  19. MCFGPS(GPIO0, 0, 32, MCFSIM2_GPIOENABLE, MCFSIM2_GPIOWRITE, MCFSIM2_GPIOREAD),
  20. MCFGPS(GPIO1, 32, 32, MCFSIM2_GPIO1ENABLE, MCFSIM2_GPIO1WRITE, MCFSIM2_GPIO1READ),
  21. };
  22. unsigned int mcf_gpio_chips_size = ARRAY_SIZE(mcf_gpio_chips);
  23. /***************************************************************************/
  24. #ifdef CONFIG_M5249C3
  25. static struct resource m5249_smc91x_resources[] = {
  26. {
  27. .start = 0xe0000300,
  28. .end = 0xe0000300 + 0x100,
  29. .flags = IORESOURCE_MEM,
  30. },
  31. {
  32. .start = MCFINTC2_GPIOIRQ6,
  33. .end = MCFINTC2_GPIOIRQ6,
  34. .flags = IORESOURCE_IRQ,
  35. },
  36. };
  37. static struct platform_device m5249_smc91x = {
  38. .name = "smc91x",
  39. .id = 0,
  40. .num_resources = ARRAY_SIZE(m5249_smc91x_resources),
  41. .resource = m5249_smc91x_resources,
  42. };
  43. #endif /* CONFIG_M5249C3 */
  44. static struct platform_device *m5249_devices[] __initdata = {
  45. #ifdef CONFIG_M5249C3
  46. &m5249_smc91x,
  47. #endif
  48. };
  49. /***************************************************************************/
  50. #if IS_ENABLED(CONFIG_SPI_COLDFIRE_QSPI)
  51. static void __init m5249_qspi_init(void)
  52. {
  53. /* QSPI irq setup */
  54. writeb(MCFSIM_ICR_AUTOVEC | MCFSIM_ICR_LEVEL4 | MCFSIM_ICR_PRI0,
  55. MCF_MBAR + MCFSIM_QSPIICR);
  56. mcf_mapirq2imr(MCF_IRQ_QSPI, MCFINTC_QSPI);
  57. }
  58. #endif /* IS_ENABLED(CONFIG_SPI_COLDFIRE_QSPI) */
  59. /***************************************************************************/
  60. #ifdef CONFIG_M5249C3
  61. static void __init m5249_smc91x_init(void)
  62. {
  63. u32 gpio;
  64. /* Set the GPIO line as interrupt source for smc91x device */
  65. gpio = readl(MCF_MBAR2 + MCFSIM2_GPIOINTENABLE);
  66. writel(gpio | 0x40, MCF_MBAR2 + MCFSIM2_GPIOINTENABLE);
  67. gpio = readl(MCF_MBAR2 + MCFSIM2_INTLEVEL5);
  68. writel(gpio | 0x04000000, MCF_MBAR2 + MCFSIM2_INTLEVEL5);
  69. }
  70. #endif /* CONFIG_M5249C3 */
  71. /***************************************************************************/
  72. void __init config_BSP(char *commandp, int size)
  73. {
  74. mach_sched_init = hw_timer_init;
  75. #ifdef CONFIG_M5249C3
  76. m5249_smc91x_init();
  77. #endif
  78. #if IS_ENABLED(CONFIG_SPI_COLDFIRE_QSPI)
  79. m5249_qspi_init();
  80. #endif
  81. }
  82. /***************************************************************************/
  83. static int __init init_BSP(void)
  84. {
  85. platform_add_devices(m5249_devices, ARRAY_SIZE(m5249_devices));
  86. return 0;
  87. }
  88. arch_initcall(init_BSP);
  89. /***************************************************************************/