summaryrefslogtreecommitdiffstats
path: root/src/occ/gpe/apss_altitude.pS
diff options
context:
space:
mode:
Diffstat (limited to 'src/occ/gpe/apss_altitude.pS')
-rwxr-xr-xsrc/occ/gpe/apss_altitude.pS163
1 files changed, 163 insertions, 0 deletions
diff --git a/src/occ/gpe/apss_altitude.pS b/src/occ/gpe/apss_altitude.pS
new file mode 100755
index 0000000..6deac1d
--- /dev/null
+++ b/src/occ/gpe/apss_altitude.pS
@@ -0,0 +1,163 @@
+# *****************************************************************************
+# @file apss_altitude.S
+# @brief Read the altitude from the APSS
+#
+
+# *****************************************************************************
+#
+# @page ChangeLogs Change Logs
+# @section apss_altitude.S APSS_ALTITUDE.S
+# @verbatim
+#
+# Flag Def/Fea Userid Date Description
+# ------- ---------- -------- ---------- ----------------------------------
+# @rc003 rickylie 02/03/2012 Verify & Clean Up OCC Headers & Comments
+#
+# @endverbatim
+#
+# *****************************************************************************
+
+
+ //////////////////////////////////////////////////////////////////////
+ // Includes
+ //////////////////////////////////////////////////////////////////////
+ .nolist
+#include "pgp.h"
+#include "pgas.h"
+ .list
+
+ //////////////////////////////////////////////////////////////////////
+ // Define Address Space
+ //////////////////////////////////////////////////////////////////////
+ .oci
+
+ //////////////////////////////////////////////////////////////////////
+ // Define Symbols
+ //////////////////////////////////////////////////////////////////////
+
+#include <pss_constants.h>
+
+#define GPE_PROG_ID 0x0002
+
+ //////////////////////////////////////////////////////////////////////
+ // Define Structures
+ //////////////////////////////////////////////////////////////////////
+
+ // Declare the offsets of the struct that will be passed to the
+ // GPE program via the ETR register
+ //
+ // struct G_gpe_apss_read_altitude_args =
+ // {
+ .struct 0
+ERROR_RC:
+ .struct ERROR_RC + 8
+ERROR_FFDC:
+ .struct ERROR_FFDC + 8
+ALTITUDE:
+ // };
+
+
+ //////////////////////////////////////////////////////////////////////
+ // Begin Program
+ //////////////////////////////////////////////////////////////////////
+
+ .text
+
+#include <gpe_macros.h>
+#include <pss_macros.h>
+
+
+ //--------------------------------------------------------------------
+ // PORE-GPE Routine Specification:
+ //
+ // Name: GPE_apss_read_altitude
+ //
+ // Description: Initialize APSS GPIO pins for Input/Output, Interrupt
+ // Drive H/L
+ //
+ // Inputs: G_gpe_apss_read_altitude_args
+ // struct {
+ // PoreGpeErrorStruct error;
+ // uint16_t altitude; // This is where the altitude will be stored (output)
+ // uint8_t reserved[6]; // Requried since GPE only does 8 byte writes.
+ // } G_gpe_apss_read_altitude_args
+ // struct {
+ // uint64_t rc; // This should be read as 63:32=addr, 31:0=rc
+ // uint64_t ffdc; // Whatever GPE program puts in for FFDC data
+ // } PoreGpeErrorStruct;
+ //
+ // Outputs: Altitude (and FFDC on failure)
+ //
+ // Flow: 7/20/11 FN=GPE_apss_set_composite_mode
+ //
+ // References: APSS FUnctional Specification v0.7.18
+ // GPE_apss_access_scoms.odt (summary of regisers/data)
+ //
+ // End PORE-GPE Routine Specification
+ //--------------------------------------------------------------------
+ .global GPE_apss_read_altitude
+GPE_apss_read_altitude:
+
+ // Copy passed Structure Pointer into A1
+ mr A1, ETR
+
+ // Wait for SPI operations to be complete (10usec timeout)
+ _wait_for_spi_ops_complete 10, error_timeout
+
+ // Setup control regs
+ // frame_size=16, out_count=16, in_delay1=never, in_count2=16
+ _putscom SPIPSS_P2S_CTRL_REG0, 0x410FC00004000000
+ // bridge_enable, clock_divider=7, 2 frames
+ _putscom SPIPSS_P2S_CTRL_REG1, 0x801C400000000000
+ // inter_frame_delay=25 (2.5usec)
+ _putscom SPIPSS_P2S_CTRL_REG2, 0x000C800000000000
+
+ // APSS command to get the altitude (APSS cmd 0x9000)
+ li D0, 0x9000000000000000
+ _putscom_d0 SPIPSS_P2S_WDATA_REG
+
+ // Start SPI transaction
+ _putscom SPIPSS_P2S_COMMAND_REG, 0x8000000000000000
+
+ // wait 10usec for command to complete
+ waits (10 * MICROSECONDS)
+
+ // Wait for SPI operations to be complete (10usec timeout)
+ _wait_for_spi_ops_complete 10, error_altitude_timeout
+
+ // Read altitude and store in structure
+ _getscom SPIPSS_P2S_RDATA_REG
+ // The scom data for that cmd is in 2nd two bytes of the register (shift left 2 bytes)
+ rols D0, D0, 16
+ std D0, ALTITUDE, A1
+
+ halt // End of GPE_apss_initialize_gpio
+
+
+error_statusreg:
+ // An error/reserved bit was set when reading p2s status register...
+ // D0: P2S_STATUS_REG
+ _saveffdc GPE_PROG_ID, 0x0002
+ halt
+
+
+error_timeout:
+ // p2s_ongoing bit was never cleared after several retries...
+ // D0: P2S_STATUS_REG
+ _saveffdc GPE_PROG_ID, 0x0001
+ halt
+
+
+error_altitude_timeout:
+ // After sending the read altitude command, the p2s_ongoing bit was
+ // never cleared after several retries...
+ // D0: P2S_STATUS_REG
+ _saveffdc GPE_PROG_ID, 0x0003
+ halt
+
+
+ //////////////////////////////////////////////////////////////////////
+ // End of Program
+ //////////////////////////////////////////////////////////////////////
+
+
OpenPOWER on IntegriCloud