mpc832x_rdb.c 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183
  1. /*
  2. * arch/powerpc/platforms/83xx/mpc832x_rdb.c
  3. *
  4. * Copyright (C) Freescale Semiconductor, Inc. 2007. All rights reserved.
  5. *
  6. * Description:
  7. * MPC832x RDB board specific routines.
  8. * This file is based on mpc832x_mds.c and mpc8313_rdb.c
  9. * Author: Michael Barkowski <michael.barkowski@freescale.com>
  10. *
  11. * This program is free software; you can redistribute it and/or modify it
  12. * under the terms of the GNU General Public License as published by the
  13. * Free Software Foundation; either version 2 of the License, or (at your
  14. * option) any later version.
  15. */
  16. #include <linux/pci.h>
  17. #include <linux/interrupt.h>
  18. #include <linux/spi/spi.h>
  19. #include <linux/spi/mmc_spi.h>
  20. #include <linux/mmc/host.h>
  21. #include <asm/of_platform.h>
  22. #include <asm/time.h>
  23. #include <asm/ipic.h>
  24. #include <asm/udbg.h>
  25. #include <asm/qe.h>
  26. #include <asm/qe_ic.h>
  27. #include <sysdev/fsl_soc.h>
  28. #include "mpc83xx.h"
  29. #undef DEBUG
  30. #ifdef DEBUG
  31. #define DBG(fmt...) udbg_printf(fmt)
  32. #else
  33. #define DBG(fmt...)
  34. #endif
  35. static void mpc83xx_spi_activate_cs(u8 cs, u8 polarity)
  36. {
  37. pr_debug("%s %d %d\n", __func__, cs, polarity);
  38. par_io_data_set(3, 13, polarity);
  39. }
  40. static void mpc83xx_spi_deactivate_cs(u8 cs, u8 polarity)
  41. {
  42. pr_debug("%s %d %d\n", __func__, cs, polarity);
  43. par_io_data_set(3, 13, !polarity);
  44. }
  45. static struct mmc_spi_platform_data mpc832x_mmc_pdata = {
  46. .ocr_mask = MMC_VDD_33_34,
  47. };
  48. static struct spi_board_info mpc832x_spi_boardinfo = {
  49. .bus_num = 0x4c0,
  50. .chip_select = 0,
  51. .max_speed_hz = 50000000,
  52. .modalias = "mmc_spi",
  53. .platform_data = &mpc832x_mmc_pdata,
  54. };
  55. static int __init mpc832x_spi_init(void)
  56. {
  57. if (!machine_is(mpc832x_rdb))
  58. return 0;
  59. par_io_config_pin(3, 0, 3, 0, 1, 0); /* SPI1 MOSI, I/O */
  60. par_io_config_pin(3, 1, 3, 0, 1, 0); /* SPI1 MISO, I/O */
  61. par_io_config_pin(3, 2, 3, 0, 1, 0); /* SPI1 CLK, I/O */
  62. par_io_config_pin(3, 3, 2, 0, 1, 0); /* SPI1 SEL, I */
  63. par_io_config_pin(3, 13, 1, 0, 0, 0); /* !SD_CS, O */
  64. par_io_config_pin(3, 14, 2, 0, 0, 0); /* SD_INSERT, I */
  65. par_io_config_pin(3, 15, 2, 0, 0, 0); /* SD_PROTECT,I */
  66. return fsl_spi_init(&mpc832x_spi_boardinfo, 1,
  67. mpc83xx_spi_activate_cs,
  68. mpc83xx_spi_deactivate_cs);
  69. }
  70. device_initcall(mpc832x_spi_init);
  71. /* ************************************************************************
  72. *
  73. * Setup the architecture
  74. *
  75. */
  76. static void __init mpc832x_rdb_setup_arch(void)
  77. {
  78. #if defined(CONFIG_PCI) || defined(CONFIG_QUICC_ENGINE)
  79. struct device_node *np;
  80. #endif
  81. if (ppc_md.progress)
  82. ppc_md.progress("mpc832x_rdb_setup_arch()", 0);
  83. #ifdef CONFIG_PCI
  84. for_each_compatible_node(np, "pci", "fsl,mpc8349-pci")
  85. mpc83xx_add_bridge(np);
  86. #endif
  87. #ifdef CONFIG_QUICC_ENGINE
  88. qe_reset();
  89. if ((np = of_find_node_by_name(np, "par_io")) != NULL) {
  90. par_io_init(np);
  91. of_node_put(np);
  92. for (np = NULL; (np = of_find_node_by_name(np, "ucc")) != NULL;)
  93. par_io_of_config(np);
  94. }
  95. #endif /* CONFIG_QUICC_ENGINE */
  96. }
  97. static struct of_device_id mpc832x_ids[] = {
  98. { .type = "soc", },
  99. { .compatible = "soc", },
  100. { .type = "qe", },
  101. {},
  102. };
  103. static int __init mpc832x_declare_of_platform_devices(void)
  104. {
  105. if (!machine_is(mpc832x_rdb))
  106. return 0;
  107. /* Publish the QE devices */
  108. of_platform_bus_probe(NULL, mpc832x_ids, NULL);
  109. return 0;
  110. }
  111. device_initcall(mpc832x_declare_of_platform_devices);
  112. void __init mpc832x_rdb_init_IRQ(void)
  113. {
  114. struct device_node *np;
  115. np = of_find_node_by_type(NULL, "ipic");
  116. if (!np)
  117. return;
  118. ipic_init(np, 0);
  119. /* Initialize the default interrupt mapping priorities,
  120. * in case the boot rom changed something on us.
  121. */
  122. ipic_set_default_priority();
  123. of_node_put(np);
  124. #ifdef CONFIG_QUICC_ENGINE
  125. np = of_find_node_by_type(NULL, "qeic");
  126. if (!np)
  127. return;
  128. qe_ic_init(np, 0, qe_ic_cascade_low_ipic, qe_ic_cascade_high_ipic);
  129. of_node_put(np);
  130. #endif /* CONFIG_QUICC_ENGINE */
  131. }
  132. /*
  133. * Called very early, MMU is off, device-tree isn't unflattened
  134. */
  135. static int __init mpc832x_rdb_probe(void)
  136. {
  137. unsigned long root = of_get_flat_dt_root();
  138. return of_flat_dt_is_compatible(root, "MPC832xRDB");
  139. }
  140. define_machine(mpc832x_rdb) {
  141. .name = "MPC832x RDB",
  142. .probe = mpc832x_rdb_probe,
  143. .setup_arch = mpc832x_rdb_setup_arch,
  144. .init_IRQ = mpc832x_rdb_init_IRQ,
  145. .get_irq = ipic_get_irq,
  146. .restart = mpc83xx_restart,
  147. .time_init = mpc83xx_time_init,
  148. .calibrate_decr = generic_calibrate_decr,
  149. .progress = udbg_progress,
  150. };