board_can.c 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. /*
  2. * Copyright (c) 2012, Freescale Semiconductor, Inc.
  3. * All rights reserved.
  4. *
  5. * Redistribution and use in source and binary forms, with or without modification,
  6. * are permitted provided that the following conditions are met:
  7. *
  8. * o Redistributions of source code must retain the above copyright notice, this list
  9. * of conditions and the following disclaimer.
  10. *
  11. * o Redistributions in binary form must reproduce the above copyright notice, this
  12. * list of conditions and the following disclaimer in the documentation and/or
  13. * other materials provided with the distribution.
  14. *
  15. * o Neither the name of Freescale Semiconductor, Inc. nor the names of its
  16. * contributors may be used to endorse or promote products derived from this
  17. * software without specific prior written permission.
  18. *
  19. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
  20. * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  21. * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  22. * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
  23. * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  24. * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  25. * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
  26. * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  27. * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  28. * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  29. */
  30. #include "iomux_config.h"
  31. #include "ioexpander/max7310.h"
  32. #include "gpio/gpio.h"
  33. #include "registers/regsflexcan.h"
  34. #include "flexcan/flexcan.h"
  35. ////////////////////////////////////////////////////////////////////////////////
  36. // Code
  37. ////////////////////////////////////////////////////////////////////////////////
  38. /*!
  39. * board dependent IOMUX configuration functions
  40. */
  41. void hw_can_iomux_config(uint32_t module_instance)
  42. {
  43. #ifdef BOARD_SABRE_AI
  44. board_ioexpander_iomux_config();
  45. /* CAN_EN active high output */
  46. max7310_set_gpio_output(1, 6, GPIO_HIGH_LEVEL); //expander b, io6
  47. /* CAN_STBY active high output */
  48. max7310_set_gpio_output(1, 5, GPIO_HIGH_LEVEL); //expander b, io5
  49. #endif
  50. flexcan_iomux_config(module_instance);
  51. #ifdef BOARD_SABRE_AI
  52. switch (module_instance)
  53. {
  54. case HW_FLEXCAN1:
  55. board_ioexpander_iomux_config();
  56. /* Select CAN, ENET_CAN1_STEER(PORT_EXP_B3) */
  57. max7310_set_gpio_output(1, 3, GPIO_HIGH_LEVEL); //expander b, io3
  58. /* Select ALT5 mode of GPIO_4 for GPIO1_4 - CAN1_NERR_B */
  59. /* active low input */
  60. gpio_set_gpio(GPIO_PORT1, 4);
  61. gpio_set_direction(GPIO_PORT1, 4, GPIO_GDIR_INPUT);
  62. break;
  63. case HW_FLEXCAN2:
  64. /* Select ALT5 mode of SD4_DAT3 for GPIO2_11 - CAN2_NERR_B */
  65. /* active low input */
  66. gpio_set_gpio(GPIO_PORT2, 11);
  67. gpio_set_direction(GPIO_PORT2, 11, GPIO_GDIR_INPUT);
  68. break;
  69. default:
  70. printf("ERR: invalid FLEXCAN instance for iomux config\n");
  71. break;
  72. }
  73. #endif
  74. }
  75. ////////////////////////////////////////////////////////////////////////////////
  76. // EOF
  77. ////////////////////////////////////////////////////////////////////////////////