1 /***********************license start*********************************** 2 * Copyright (c) 2003-2017 Cavium Inc. ([email protected]). All rights 3 * reserved. 4 * 5 * 6 * Redistribution and use in source and binary forms, with or without 7 * modification, are permitted provided that the following conditions are 8 * met: 9 * 10 * * Redistributions of source code must retain the above copyright 11 * notice, this list of conditions and the following disclaimer. 12 * 13 * * Redistributions in binary form must reproduce the above 14 * copyright notice, this list of conditions and the following 15 * disclaimer in the documentation and/or other materials provided 16 * with the distribution. 17 * 18 * * Neither the name of Cavium Inc. nor the names of 19 * its contributors may be used to endorse or promote products 20 * derived from this software without specific prior written 21 * permission. 22 * 23 * This Software, including technical data, may be subject to U.S. export 24 * control laws, including the U.S. Export Administration Act and its 25 * associated regulations, and may be subject to export or import 26 * regulations in other countries. 27 * 28 * TO THE MAXIMUM EXTENT PERMITTED BY LAW, THE SOFTWARE IS PROVIDED "AS IS" 29 * AND WITH ALL FAULTS AND CAVIUM INC. MAKES NO PROMISES, REPRESENTATIONS OR 30 * WARRANTIES, EITHER EXPRESS, IMPLIED, STATUTORY, OR OTHERWISE, WITH RESPECT 31 * TO THE SOFTWARE, INCLUDING ITS CONDITION, ITS CONFORMITY TO ANY 32 * REPRESENTATION OR DESCRIPTION, OR THE EXISTENCE OF ANY LATENT OR PATENT 33 * DEFECTS, AND CAVIUM SPECIFICALLY DISCLAIMS ALL IMPLIED (IF ANY) WARRANTIES 34 * OF TITLE, MERCHANTABILITY, NONINFRINGEMENT, FITNESS FOR A PARTICULAR 35 * PURPOSE, LACK OF VIRUSES, ACCURACY OR COMPLETENESS, QUIET ENJOYMENT, 36 * QUIET POSSESSION OR CORRESPONDENCE TO DESCRIPTION. THE ENTIRE RISK 37 * ARISING OUT OF USE OR PERFORMANCE OF THE SOFTWARE LIES WITH YOU. 38 ***********************license end**************************************/ 39 #include "libbdk-arch/bdk-csrs-sgp.h" 40 41 /** 42 * @file 43 * 44 * Serial GPIO interface (SGPIO) 45 * 46 * <hr>$Revision: 49448 $<hr> 47 * 48 * @addtogroup hal 49 * @{ 50 */ 51 #ifndef _BDK_DRIVER_SGPIO_H_ 52 #define _BDK_DRIVER_SGPIO_H_ 53 54 typedef enum 55 { 56 BDK_SGPIO_LED_ACT, 57 BDK_SGPIO_LED_LOC, 58 BDK_SGPIO_LED_ERR, 59 } bdk_sgpio_led_t; 60 61 typedef enum 62 { 63 BDK_SGPIO_STATIC_ON = BDK_SGP_TX_ACT_E_STATIC_ON, 64 BDK_SGPIO_STATIC_OFF = BDK_SGP_TX_ACT_E_STATIC_OFF, 65 BDK_SGPIO_BLINK = BDK_SGP_TX_ACT_E_A_ON_OFF, 66 } bdk_sgpio_led_state_t; 67 68 69 /** 70 * Get the SGPIO controller state 71 * 72 * @param node CPU node number 73 * 74 * @return 1 == Controller is enabled, 0 == Controller is disabled 75 */ 76 int bdk_sgpio_is_enabled(bdk_node_t node); 77 78 /** 79 * Set the mode for a specific LED. 80 * 81 * @param node CPU node number 82 * @param drive Drive number of LED (0-15) 83 * @param led LED type: 84 * BDK_SGPIO_LED_ACT 85 * BDK_SGPIO_LED_ERR 86 * BDK_SGPIO_LED_LOC 87 * 88 * @return 89 */ 90 void bdk_sgpio_set_led_state(bdk_node_t node, int drive, int led, int state); 91 92 /** 93 * Get the mode for a specific LED. 94 * 95 * @param node CPU node number 96 * @param drive Drive number of LED (0-15) 97 * @param led LED type: 98 * BDK_SGPIO_LED_ACT 99 * BDK_SGPIO_LED_ERR 100 * BDK_SGPIO_LED_LOC 101 * 102 * @return LED state: 103 * BDK_SGPIO_STATIC_ON 104 * BDK_SGPIO_STATIC_OFF 105 * BDK_SGPIO_BLINK 106 */ 107 int bdk_sgpio_get_led_state(bdk_node_t node, int drive, int led); 108 109 /** 110 * Set the controller's SCLOCK frequency 111 * 112 * @param node CPU node number 113 * @param freq Frequency to set 114 * 115 * @return Zero on success, negative on failure 116 */ 117 int bdk_sgpio_set_sclock(bdk_node_t node, int freq); 118 119 /** 120 * Enable / disable controller 121 * 122 * @param node CPU node number 123 * @param ena zero = disable, non-zero = enable 124 * 125 * @return 126 */ 127 void bdk_sgpio_enable_controller(bdk_node_t node, int ena); 128 129 /** 130 * Set up SGPIO pin muxing based on environment. 131 * 132 * @param node CPU node number 133 * 134 * @return Zero on success, negative on failure 135 */ 136 int bdk_sgpio_setup_gpio_pins(bdk_node_t node); 137 138 /** 139 * Initialize the SGPIO controller. 140 * - Set up the SGPIO pin muxing as per configuration environment. 141 * - Turn all LEDs off 142 * - Set the blink rate to 1/2 second 143 * - Enable the controller 144 * 145 * @param node CPU node number 146 * 147 * @return Zero on success, negative on failure 148 */ 149 int bdk_sgpio_initialize(bdk_node_t node); 150 151 /** @} */ 152 153 #endif /* _BDK_DRIVER_SGPIO_H_ */ 154