Advertisement
Guest User

spi_enab_enable

a guest
Feb 13th, 2016
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 5.12 KB | None | 0 0
  1. diff --git a/arch/arm/cpu/armv7/am33xx/clock_am33xx.c b/arch/arm/cpu/armv7/am33xx/clock_am33xx.c
  2. index 92142c8..8724366 100644
  3. --- a/arch/arm/cpu/armv7/am33xx/clock_am33xx.c
  4. +++ b/arch/arm/cpu/armv7/am33xx/clock_am33xx.c
  5. @@ -147,6 +147,7 @@ void enable_basic_clocks(void)
  6.         &cmper->i2c1clkctrl,
  7.         &cmper->cpgmac0clkctrl,
  8.         &cmper->spi0clkctrl,
  9. +        &cmper->spi1clkctrl,
  10.         &cmrtc->rtcclkctrl,
  11.         &cmper->usb0clkctrl,
  12.         &cmper->emiffwclkctrl,
  13. diff --git a/board/ti/am335x/board.c b/board/ti/am335x/board.c
  14. index 49d95cf..c8d4aed 100644
  15. --- a/board/ti/am335x/board.c
  16. +++ b/board/ti/am335x/board.c
  17. @@ -24,6 +24,7 @@
  18.  #include <asm/emif.h>
  19.  #include <asm/gpio.h>
  20.  #include <i2c.h>
  21. +#include <spi.h>
  22.  #include <miiphy.h>
  23.  #include <cpsw.h>
  24.  #include <power/tps65217.h>
  25. @@ -37,6 +38,7 @@ DECLARE_GLOBAL_DATA_PTR;
  26.  
  27.  /* GPIO that controls power to DDR on EVM-SK */
  28.  #define GPIO_DDR_VTT_EN        7
  29. +#define GPIO_ENABLE_PIN     20
  30.  
  31.  #if defined(CONFIG_SPL_BUILD) || \
  32.     (defined(CONFIG_DRIVER_TI_CPSW) && !defined(CONFIG_DM_ETH))
  33. @@ -229,6 +231,13 @@ void am33xx_spl_board_init(void)
  34.     if (read_eeprom(&header) < 0)
  35.         puts("Could not get board ID.\n");
  36.  
  37. +#ifdef CONFIG_DISABLE_REPLICAPE_STEPPERS
  38. +    enable_spi1_pin_mux();
  39. +#endif
  40. +
  41. +#ifdef CONFIG_REPLICAPE_SET_DISABLE_PIN
  42. +    enable_enable_pin_mux();
  43. +#endif
  44.     /* Get the frequency */
  45.     dpll_mpu_opp100.m = am335x_get_efuse_mpu_max_freq(cdev);
  46.  
  47. @@ -476,6 +485,49 @@ void sdram_init(void)
  48.  }
  49.  #endif
  50.  
  51. +
  52. +/* Disable steppers from u-boot*/
  53. +#ifdef CONFIG_DISABLE_REPLICAPE_STEPPERS
  54. +void spi_disable_steppers(void){
  55. +    struct spi_slave *slave;
  56. +   int ret = 0;
  57. +    int bus = 1;
  58. +    int cs = 1;
  59. +    int mode = 0;
  60. +    int bitlen = 40;
  61. +    
  62. +    uchar dout[5] = {0xFF};
  63. +    uchar din[5] = {0xFF};
  64. +    
  65. +    printf("Replicape steppers disabled\n");
  66. +
  67. +   slave = spi_setup_slave(bus, cs, 1000000, mode);
  68. +   if (!slave) {
  69. +       printf("Invalid device %d:%d\n", bus, cs);
  70. +       return;
  71. +   }
  72. +
  73. +   ret = spi_claim_bus(slave);
  74. +   if (ret)
  75. +       goto done;
  76. +   ret = spi_xfer(slave, bitlen, dout, din,
  77. +              SPI_XFER_BEGIN | SPI_XFER_END);
  78. +   if (ret) {
  79. +       printf("Error %d during SPI transaction\n", ret);
  80. +   }
  81. +done:
  82. +   spi_release_bus(slave);
  83. +}
  84. +#endif
  85. +
  86. +#ifdef CONFIG_REPLICAPE_SET_DISABLE_PIN
  87. +void set_enable_pin(void){
  88. +    printf("Replicape enable pin set high\n");
  89. +   gpio_request(GPIO_ENABLE_PIN, "gpio_enable_pin");
  90. +   gpio_direction_output(GPIO_ENABLE_PIN, 1);
  91. +}
  92. +#endif
  93. +
  94.  /*
  95.   * Basic board specific setup.  Pinmux has been handled already.
  96.   */
  97. @@ -483,6 +535,12 @@ int board_init(void)
  98.  {
  99.     u32 sys_reboot;
  100.  
  101. +#ifdef CONFIG_DISABLE_REPLICAPE_STEPPERS
  102. +    spi_disable_steppers();
  103. +#endif
  104. +#ifdef CONFIG_REPLICAPE_SET_DISABLE_PIN
  105. +    set_enable_pin();
  106. +#endif
  107.     sys_reboot = readl(PRM_RSTST);
  108.     if (sys_reboot & (1 << 9))
  109.         puts("Reset Source: IcePick reset has occurred.\n");
  110. diff --git a/board/ti/am335x/board.h b/board/ti/am335x/board.h
  111. index bc700d5..d83fcb9 100644
  112. --- a/board/ti/am335x/board.h
  113. +++ b/board/ti/am335x/board.h
  114. @@ -73,5 +73,8 @@ void enable_uart3_pin_mux(void);
  115.  void enable_uart4_pin_mux(void);
  116.  void enable_uart5_pin_mux(void);
  117.  void enable_i2c0_pin_mux(void);
  118. +#ifdef CONFIG_DISABLE_REPLICAPE_STEPPERS
  119. +void enable_spi1_pin_mux(void);
  120. +#endif
  121.  void enable_board_pin_mux(struct am335x_baseboard_id *header);
  122.  #endif
  123. diff --git a/board/ti/am335x/mux.c b/board/ti/am335x/mux.c
  124. index 79ed02f..007215e 100644
  125. --- a/board/ti/am335x/mux.c
  126. +++ b/board/ti/am335x/mux.c
  127. @@ -129,6 +129,21 @@ static struct module_pin_mux spi0_pin_mux[] = {
  128.     {-1},
  129.  };
  130.  
  131. +static struct module_pin_mux spi1_pin_mux[] = {
  132. +    {OFFSET(mcasp0_aclkx), (MODE(3) | RXACTIVE | PULLUDEN)},    /* SPI1_SCLK */
  133. +    {OFFSET(mcasp0_fsx), (MODE(3) | RXACTIVE | PULLUDEN | PULLUP_EN)},            /* SPI1_D0 */
  134. +    {OFFSET(mcasp0_axr0), (MODE(3) | RXACTIVE | PULLUDEN)},    /* SPI1_D1 */
  135. +    {OFFSET(ecap0_in_pwm0_out), (MODE(2) | RXACTIVE | PULLUDEN | PULLUP_EN)},            /* SPI1_CS1 */
  136. +    {-1},
  137. +};
  138. +
  139. +static struct module_pin_mux enable_pin_mux[] = {
  140. +    {OFFSET(xdma_event_intr1), (MODE(7) | RXACTIVE | PULLUDEN)},    /* ENABLE */
  141. +    {-1},
  142. +};
  143. +
  144. +
  145. +
  146.  static struct module_pin_mux gpio0_7_pin_mux[] = {
  147.     {OFFSET(ecap0_in_pwm0_out), (MODE(7) | PULLUDEN)},  /* GPIO0_7 */
  148.     {-1},
  149. @@ -278,6 +293,16 @@ void enable_i2c0_pin_mux(void)
  150.     configure_module_pin_mux(i2c0_pin_mux);
  151.  }
  152.  
  153. +void enable_spi1_pin_mux(void)
  154. +{
  155. +    configure_module_pin_mux(spi1_pin_mux);
  156. +}
  157. +
  158. +void enable_enable_pin_mux(void)
  159. +{
  160. +    configure_module_pin_mux(enable_pin_mux);
  161. +}
  162. +
  163.  /*
  164.   * The AM335x GP EVM, if daughter card(s) are connected, can have 8
  165.   * different profiles.  These profiles determine what peripherals are
  166. diff --git a/include/configs/am335x_evm.h b/include/configs/am335x_evm.h
  167. index e3402c4..e9d623f 100644
  168. --- a/include/configs/am335x_evm.h
  169. +++ b/include/configs/am335x_evm.h
  170. @@ -18,6 +18,8 @@
  171.  
  172.  #include <configs/ti_am335x_common.h>
  173.  #define CONFIG_ENV_IS_NOWHERE
  174. +#define CONFIG_DISABLE_REPLICAPE_STEPPERS
  175. +#define CONFIG_REPLICAPE_SET_DISABLE_PIN
  176.  
  177.  /* Don't override the distro default bootdelay */
  178.  #undef CONFIG_BOOTDELAY
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement