www.pudn.com > sdio-2.6.18-full.rar > gps.h


/*+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
@file: gps.h

@abstract: OS independent include for GPS SDIO function driver

#notes:

@notice: Copyright (c), 2004-2005 Atheros Communications, Inc.
 *
 *  This program is free software; you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License version 2 as
 *  published by the Free Software Foundation;
 *
 *  Software distributed under the License is distributed on an "AS
 *  IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
 *  implied. See the License for the specific language governing
 *  rights and limitations under the License.
 *
 *  Portions o this code were developed with information supplied from the
 *  SD Card Association Simplified Specifications. The following conditions and disclaimers may apply:
 *
 *   The following conditions apply to the release of the SD simplified specification (“Simplified
 *   Specification”) by the SD Card Association. The Simplified Specification is a subset of the complete
 *   SD Specification which is owned by the SD Card Association. This Simplified Specification is provided
 *   on a non-confidential basis subject to the disclaimers below. Any implementation of the Simplified
 *   Specification may require a license from the SD Card Association or other third parties.
 *   Disclaimers:
 *   The information contained in the Simplified Specification is presented only as a standard
 *   specification for SD Cards and SD Host/Ancillary products and is provided "AS-IS" without any
 *   representations or warranties of any kind. No responsibility is assumed by the SD Card Association for
 *   any damages, any infringements of patents or other right of the SD Card Association or any third
 *   parties, which may result from its use. No license is granted by implication, estoppel or otherwise
 *   under any patent or other rights of the SD Card Association or any third party. Nothing herein shall
 *   be construed as an obligation by the SD Card Association to disclose or distribute any technical
 *   information, know-how or other confidential information to any third party.
 *
 *
 *  The initial developers of the original code are Seung Yi and Paul Lever
 *
 *  sdio@atheros.com
 *
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/
#ifndef __GPS_H___
#define __GPS_H___

#include "gps_linux.h"

typedef struct _SDGPS_DRIVER_CONTEXT {
    SDFUNCTION   Function;  /* function description for bus driver */
    PSDDEVICE    pSDDevice; /* bus driver's device we are supporting (only 1) */
    SDGPS_DEVICE GpsDevice; /* per device info, we only support one device right now */
}SDGPS_DRIVER_CONTEXT, *PSDGPS_DRIVER_CONTEXT;

#define SDIO_GPS_TRACE_INT  (SDDBG_TRACE+1)

#define GPS_CMD_52                   52
#define GPS_MAX_BAUD_RATE            115200
#define GPS_FIFO_SIZE                16
#define GPS_TYPE                     "SDIO GPS 16650"
#define GPS_TUPLE                    0x91

struct SDIO_GPS_SUBTPL_SIOREG {
    UINT8   RegisterID;
    UINT8   RegisterExpID;
    UINT8   RegisterOffset[3];
    UINT8   MaxBaudRateCode;
    UINT8   DRL_4800;
    UINT8   DRM_4800;
}__attribute__ ((packed));

struct SDIO_GPS_SUBTPL_RCVCAPS {
    UINT8   Junk;  /* defined in some other doc */
}__attribute__ ((packed));

union GPS_TPL_DATA {
    struct SDIO_GPS_SUBTPL_SIOREG  AsSIOReg;
    struct SDIO_GPS_SUBTPL_RCVCAPS AsRcvCaps;
};

    /* GPS tuple */
struct SDIO_GPS_TPL {
    UINT8   InterfaceCode;
    UINT8   StdTupleNumber;
#define STD_GPS_TUPLE_SIOREG 0x00
#define STD_GPS_TUPLE_RCVCAP 0x01
    union GPS_TPL_DATA  Tpd;
}__attribute__ ((packed));

    /* 166550 UART register offsets */
#define UART_RECEIVE_REG             0x00
#define UART_SEND_REG                0x00
#define UART_BAUD_LOW_REG            0x00
#define UART_BAUD_HIGH_REG           0x01
#define UART_INT_ENABLE_REG          0x01
#define UART_INT_IDENT_REG           0x02
#define UART_FIFO_CNTRL_REG          0x02
#define UART_LINE_CNTRL_REG          0x03
#define UART_MODEM_CONTROL_REG       0x04
#define UART_LINE_STATUS_REG         0x05
#define UART_MODEM_STATUS_REG        0x06
#define UART_SCRATCH_REG             0x07

    //INTERRUPT_STATUS_REG
#define UART_UARTINT                 0x80
#define UART_RXWKINT                 0x02

    //INT_ENABLE_REG
#define UART_EDSSI                   0x08    /* enable modem status interrupt */
#define UART_ELSI                    0x04    /* enable receiver line status interrupt */
#define UART_ETBEI                   0x02    /* enable transmitter holding register empty int. */
#define UART_ERBFI                   0x01    /* enable received data available interrupt */

    //INT_IDENT_REG
#define UART_FIFO_ENABLED            0xC0
#define UART_IID_RLS                 0x06
#define UART_IID_RDA                 0x04
#define UART_IID_CTI                 0x0C
#define UART_IID_THRE                0x02
#define UART_IID_MS                  0x00
#define UART_INTPEND                 0x01
#define UART_IID_MASK                0x0F

    //FIFO_CNTRL_REG
#define UART_FIFO_ENABLE             0x01
#define UART_FIFO_TRIGGER_1          0x00
#define UART_FIFO_TRIGGER_4          0x40
#define UART_FIFO_TRIGGER_8          0x80
#define UART_FIFO_TRIGGER_14         0xC0
#define UART_FIFO_XMIT_RESET         0x04
#define UART_FIFO_RCV_RESET          0x02

    //LINE_CNTRL_REG
#define UART_CLOCK_ENABLE            0x80
#define UART_SET_BREAK               0x40
#define UART_EVEN_PARITY_SELECT      0x10
#define UART_PARITY_ENABLE           0x08
#define UART_NO_PARITY               0x00
#define UART_NUM_STOP_BITS           0x04
#define UART_ONE_STOP                0x00
#define UART_DATA_8_BITS             0x03


    //MODEM_CONTROL_REG
#define UART_RTS_AUTO_FLOW           0x40
#define UART_CTS_AUTO_FLOW           0x20
#define UART_LOOP                    0x10
#define UART_TOUT2                   0x08
#define UART_TOUT1                   0x04
#define UART_RTS_ON                  0x02
#define UART_DTR_ON                  0x01

    //LINE_STATUS_REG
#define UART_LSR_EIRF                0x80    /* error receive fifo */
#define UART_LSR_TEMT                0x40
#define UART_LSR_THRE                0x20    /* transmitter holding register empty */
#define UART_LSR_BI                  0x10
#define UART_LSR_FE                  0x08
#define UART_LSR_PE                  0x04
#define UART_LSR_OE                  0x02
#define UART_LSR_DR                  0x01

    //MODEM_STATUS_REG
#define UART_MSR_DCD                 0x80
#define UART_MSR_RI                  0x40
#define UART_MSR_DSR                 0x20
#define UART_MSR_CTS                 0x10
#define UART_MSR_DCTS                0x01

    //UART_INIT_REG
#define UART_UART_INIT               0xC7

#define GPS_FIFO_SIZE                  16

/* prototypes */
SDIO_STATUS IssueCMD52(PSDDEVICE     pDevice,
                       UINT8         FuncNo,
                       UINT32        Address,
                       PUCHAR        pData,
                       INT           ByteCount,
                       BOOL          Write);
#define ReadRegister(pDev,reg,pData) \
        SDLIB_IssueCMD52((pDev)->pSDDevice,SDDEVICE_GET_SDIO_FUNCNO((pDev)->pSDDevice),\
                          ((pDev)->UartRegOffset + (reg)),(pData),1,FALSE)
SDIO_STATUS WriteRegister(PSDGPS_DEVICE pDevice, UINT reg, UINT8 Data);
SDIO_STATUS WriteRegisterAsynch(PSDGPS_DEVICE pDevice, UINT reg, UINT8 Data, PSDREQUEST pReq);
SDIO_STATUS GpsInitialize(PSDGPS_DEVICE pDevice);
void GpsDeinitialize(PSDGPS_DEVICE pDevice);
SDIO_STATUS GpsReceive(PSDGPS_DEVICE pDevice);
SDIO_STATUS GpsTransmit(PSDGPS_DEVICE pDevice);
SDIO_STATUS SetBaudRate(PSDGPS_DEVICE pDevice, UINT32 BaudRate);


#endif /* __GPS_H___*/