LMS 2012
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
d_uart_mod.c File Reference
#include <asm/types.h>
#include "../../lms2012/source/lms2012.h"
#include "../../lms2012/source/am1808.h"
#include <linux/kernel.h>
#include <linux/fs.h>
#include <linux/sched.h>
#include <linux/mm.h>
#include <linux/hrtimer.h>
#include <linux/interrupt.h>
#include <linux/init.h>
#include <linux/uaccess.h>
#include <linux/debugfs.h>
#include <linux/ioport.h>
#include <asm/gpio.h>
#include <asm/io.h>
#include <linux/module.h>
#include <linux/miscdevice.h>
#include <asm/uaccess.h>
#include <linux/ti_omapl_pru_suart.h>
#include "omapl_suart_board.h"
#include "suart_api.h"
#include "suart_utils.h"
#include "suart_err.h"
#include "pru.h"
#include "lego_ti_omapl_pru_suart.h"

Go to the source code of this file.

Data Structures

struct  UARTPORT
 

Macros

#define BYTE_SYNC   0x00
 
#define BYTE_ACK   0x04
 
#define BYTE_NACK   0x02
 
#define MESSAGE_SYS   0x00
 
#define MESSAGE_CMD   0x40
 
#define MESSAGE_INFO   0x80
 
#define MESSAGE_DATA   0xC0
 
#define GET_MESSAGE_TYPE(B)   (B & 0xC0)
 
#define CMD_TYPE   0x00
 
#define CMD_MODES   0x01
 
#define CMD_SPEED   0x02
 
#define CMD_SELECT   0x03
 
#define CMD_WRITE   0x04
 
#define GET_CMD_COMMAND(B)   (B & 0x07)
 
#define GET_MODE(B)   (B & 0x07)
 
#define CONVERT_LENGTH(C)   (1 << (C & 0x07))
 
#define GET_MESSAGE_LENGTH(B)   (CONVERT_LENGTH(B >> 3))
 
#define MAKE_CMD_COMMAND(C, LC)   (MESSAGE_CMD + (C & 0x07) + ((LC & 0x07) << 3))
 
#define INFO_NAME   0x00
 
#define INFO_RAW   0x01
 
#define INFO_PCT   0x02
 
#define INFO_SI   0x03
 
#define INFO_SYMBOL   0x04
 
#define INFO_FORMAT   0x80
 
#define GET_INFO_COMMAND(B)   (B)
 
#define HW_ID_SUPPORT
 
#define MODULE_NAME   "uart_module"
 
#define DEVICE1_NAME   UART_DEVICE
 
#define DEVICE2_NAME   TEST_UART_DEVICE
 
#define NO_OF_INPUT_PORTS   INPUTS
 
#define Uart1   0
 
#define Uart2   1
 
#define Uart3   2
 
#define Uart4   3
 
#define PUARTFloat(port, pin)
 
#define PUARTRead(port, pin)   ((*InputUartPin[port][pin].pGpio).in_data & InputUartPin[port][pin].Mask)
 
#define PUARTHigh(port, pin)
 
#define PUARTLow(port, pin)
 
#define TESTOn
 
#define TESTOff
 
#define UART_CLOCK1   132000000
 
#define UART_CLOCK2   150000000
 
#define UART_RBR   0
 
#define UART_THR   0
 
#define UART_IER   1
 
#define UART_IIR   2
 
#define UART_FCR   2
 
#define UART_LCR   3
 
#define UART_MCR   4
 
#define UART_LSR   5
 
#define UART_MSR   6
 
#define UART_SCR   7
 
#define UART_DLL   8
 
#define UART_DLH   9
 
#define UART_REVID1   10
 
#define UART_REVID2   11
 
#define UART_PWREMU_MGMT   12
 
#define UART_MDR   13
 
#define UART_RECBUF_SIZE   256
 
#define Uart1_RECEIVE_TIMER_RESOLUTION   500
 
#define INFODATA_INIT   0x00000000L
 
#define INFODATA_CMD_TYPE   0x00000001L
 
#define INFODATA_CMD_MODES   0x00000002L
 
#define INFODATA_CMD_SPEED   0x00000004L
 
#define INFODATA_INFO_NAME   0x00000100L
 
#define INFODATA_INFO_RAW   0x00000200L
 
#define INFODATA_INFO_PCT   0x00000400L
 
#define INFODATA_INFO_SI   0x00000800L
 
#define INFODATA_INFO_SYMBOL   0x00001000L
 
#define INFODATA_INFO_FORMAT   0x00002000L
 
#define INFODATA_CLEAR   (~(INFODATA_INFO_NAME | INFODATA_INFO_RAW | INFODATA_INFO_PCT | INFODATA_INFO_SI | INFODATA_INFO_SYMBOL | INFODATA_INFO_FORMAT))
 
#define INFODATA_NEEDED   (INFODATA_CMD_TYPE | INFODATA_CMD_MODES | INFODATA_INFO_NAME | INFODATA_INFO_FORMAT)
 
#define UART_TIMER_RESOLUTION   10
 
#define UART_BREAK_TIME   1000
 
#define UART_TERMINAL_DELAY   20000
 
#define UART_CHANGE_BITRATE_DELAY   100
 
#define UART_ACK_DELAY   100
 
#define UART_SHOW_TIME   2500
 
#define UART_WATCHDOG_TIME   1000
 
#define UART_ALLOWABLE_DATA_ERRORS   6
 
#define SHM_LENGTH   (sizeof(UartDefault))
 
#define NPAGES   ((SHM_LENGTH + PAGE_SIZE - 1) / PAGE_SIZE)
 
#define BUFFER_LNG   16
 

Enumerations

enum  InputUartPins {
  INPUT_UART_BUFFER, INPUT_UART_TXD, INPUT_UART_RXD, INPUT_UART_PIN5,
  INPUT_UART_PIN6, INPUT_UART_PINS
}
 
enum  TestPins { TESTPIN, TEST_PINS }
 
enum  UART_STATE {
  UART_IDLE, UART_INIT, UART_RESTART, UART_ENABLE,
  UART_FLUSH, UART_SYNC, UART_MESSAGE_START, UART_CMD,
  UART_INFO, UART_DATA, UART_DATA_COPY, UART_ACK_WAIT,
  UART_ACK_INFO, UART_CMD_ERROR, UART_INFO_ERROR, UART_TERMINAL,
  UART_DATA_ERROR, UART_ERROR, UART_EXIT, UART_STATES
}
 

Functions

 MODULE_LICENSE ("GPL")
 
 MODULE_AUTHOR ("The LEGO Group")
 
 MODULE_DESCRIPTION (MODULE_NAME)
 
 MODULE_SUPPORTED_DEVICE (DEVICE1_NAME)
 
 module_init (ModuleInit)
 
 module_exit (ModuleExit)
 
void SetGpio (int Pin)
 
void InitGpio (void)
 
irqreturn_t Uart1Interrupt (int irq, void *dev_id)
 
void Uart1Exit (void)
 
irqreturn_t Uart2Interrupt (int irq, void *dev_id)
 
void Uart2Exit (void)
 
void Uart3Exit (void)
 
void Uart4Exit (void)
 
 module_param (HwId, charp, 0)
 

Variables

TYPES TypeDefaultUart []
 
int Hw = 0
 
INPIN InputUartPin [NO_OF_INPUT_PORTS][INPUT_UART_PINS]
 
INPIN TestPin [TEST_PINS]
 
unsigned long UartBaseAddr []
 
int UartIntr []
 
INPINpInputUartPin []
 
INPINpTestPin []
 
volatile ULONGBase [INPUTS]
 
UBYTE IntSuccess [INPUTS]
 
volatile ULONGUart1Base
 
volatile ULONGUart2Base
 
char UartStateText [UART_STATES][50]
 
UARTPORT UartPortDefault
 
TYPES TypeData [INPUTS][MAX_DEVICE_MODES]
 TypeData. More...
 
DATA8 Changed [INPUTS][MAX_DEVICE_MODES]
 
UBYTE UartConfigured [INPUTS]
 
UARTPORT UartPort [INPUTS]
 
UBYTE WriteRequest [INPUTS]
 

Macro Definition Documentation

#define BUFFER_LNG   16

Definition at line 3998 of file d_uart_mod.c.

#define BYTE_ACK   0x04

Definition at line 451 of file d_uart_mod.c.

#define BYTE_NACK   0x02

Definition at line 452 of file d_uart_mod.c.

#define BYTE_SYNC   0x00

Definition at line 450 of file d_uart_mod.c.

#define CMD_MODES   0x01

Definition at line 461 of file d_uart_mod.c.

#define CMD_SELECT   0x03

Definition at line 463 of file d_uart_mod.c.

#define CMD_SPEED   0x02

Definition at line 462 of file d_uart_mod.c.

#define CMD_TYPE   0x00

Definition at line 460 of file d_uart_mod.c.

#define CMD_WRITE   0x04

Definition at line 464 of file d_uart_mod.c.

#define CONVERT_LENGTH (   C)    (1 << (C & 0x07))

Definition at line 469 of file d_uart_mod.c.

#define DEVICE1_NAME   UART_DEVICE

Definition at line 519 of file d_uart_mod.c.

#define DEVICE2_NAME   TEST_UART_DEVICE

Definition at line 520 of file d_uart_mod.c.

#define GET_CMD_COMMAND (   B)    (B & 0x07)

Definition at line 465 of file d_uart_mod.c.

#define GET_INFO_COMMAND (   B)    (B)

Definition at line 483 of file d_uart_mod.c.

#define GET_MESSAGE_LENGTH (   B)    (CONVERT_LENGTH(B >> 3))

Definition at line 470 of file d_uart_mod.c.

#define GET_MESSAGE_TYPE (   B)    (B & 0xC0)

Definition at line 458 of file d_uart_mod.c.

#define GET_MODE (   B)    (B & 0x07)

Definition at line 467 of file d_uart_mod.c.

#define HW_ID_SUPPORT

Definition at line 490 of file d_uart_mod.c.

#define INFO_FORMAT   0x80

Definition at line 482 of file d_uart_mod.c.

#define INFO_NAME   0x00

Definition at line 477 of file d_uart_mod.c.

#define INFO_PCT   0x02

Definition at line 479 of file d_uart_mod.c.

#define INFO_RAW   0x01

Definition at line 478 of file d_uart_mod.c.

#define INFO_SI   0x03

Definition at line 480 of file d_uart_mod.c.

#define INFO_SYMBOL   0x04

Definition at line 481 of file d_uart_mod.c.

#define INFODATA_CMD_MODES   0x00000002L

Definition at line 1826 of file d_uart_mod.c.

#define INFODATA_CMD_SPEED   0x00000004L

Definition at line 1827 of file d_uart_mod.c.

#define INFODATA_CMD_TYPE   0x00000001L

Definition at line 1825 of file d_uart_mod.c.

#define INFODATA_INFO_FORMAT   0x00002000L

Definition at line 1834 of file d_uart_mod.c.

#define INFODATA_INFO_NAME   0x00000100L

Definition at line 1829 of file d_uart_mod.c.

#define INFODATA_INFO_PCT   0x00000400L

Definition at line 1831 of file d_uart_mod.c.

#define INFODATA_INFO_RAW   0x00000200L

Definition at line 1830 of file d_uart_mod.c.

#define INFODATA_INFO_SI   0x00000800L

Definition at line 1832 of file d_uart_mod.c.

#define INFODATA_INFO_SYMBOL   0x00001000L

Definition at line 1833 of file d_uart_mod.c.

#define INFODATA_INIT   0x00000000L

Definition at line 1824 of file d_uart_mod.c.

Definition at line 1838 of file d_uart_mod.c.

#define MAKE_CMD_COMMAND (   C,
  LC 
)    (MESSAGE_CMD + (C & 0x07) + ((LC & 0x07) << 3))

Definition at line 472 of file d_uart_mod.c.

#define MESSAGE_CMD   0x40

Definition at line 455 of file d_uart_mod.c.

#define MESSAGE_DATA   0xC0

Definition at line 457 of file d_uart_mod.c.

#define MESSAGE_INFO   0x80

Definition at line 456 of file d_uart_mod.c.

#define MESSAGE_SYS   0x00

Definition at line 454 of file d_uart_mod.c.

#define MODULE_NAME   "uart_module"

Definition at line 518 of file d_uart_mod.c.

#define NO_OF_INPUT_PORTS   INPUTS

Definition at line 572 of file d_uart_mod.c.

#define NPAGES   ((SHM_LENGTH + PAGE_SIZE - 1) / PAGE_SIZE)

Definition at line 3803 of file d_uart_mod.c.

#define PUARTFloat (   port,
  pin 
)
Value:
{\
(*InputUartPin[port][pin].pGpio).dir |= InputUartPin[port][pin].Mask;\
}
GPIOC pGpio
Definition: am1808.h:225
INPIN InputUartPin[NO_OF_INPUT_PORTS][INPUT_UART_PINS]
Definition: d_uart_mod.c:591

Definition at line 896 of file d_uart_mod.c.

#define PUARTHigh (   port,
  pin 
)
Value:
{\
(*InputUartPin[port][pin].pGpio).set_data = InputUartPin[port][pin].Mask;\
(*InputUartPin[port][pin].pGpio).dir &= ~InputUartPin[port][pin].Mask;\
}
GPIOC pGpio
Definition: am1808.h:225
INPIN InputUartPin[NO_OF_INPUT_PORTS][INPUT_UART_PINS]
Definition: d_uart_mod.c:591

Definition at line 904 of file d_uart_mod.c.

#define PUARTLow (   port,
  pin 
)
Value:
{\
(*InputUartPin[port][pin].pGpio).clr_data = InputUartPin[port][pin].Mask;\
(*InputUartPin[port][pin].pGpio).dir &= ~InputUartPin[port][pin].Mask;\
}
GPIOC pGpio
Definition: am1808.h:225
INPIN InputUartPin[NO_OF_INPUT_PORTS][INPUT_UART_PINS]
Definition: d_uart_mod.c:591

Definition at line 909 of file d_uart_mod.c.

#define PUARTRead (   port,
  pin 
)    ((*InputUartPin[port][pin].pGpio).in_data & InputUartPin[port][pin].Mask)

Definition at line 901 of file d_uart_mod.c.

#define SHM_LENGTH   (sizeof(UartDefault))

Definition at line 3802 of file d_uart_mod.c.

#define TESTOff
Value:
{\
(*TestPin[TESTPIN].pGpio).clr_data = TestPin[TESTPIN].Mask;\
(*TestPin[TESTPIN].pGpio).dir &= ~TestPin[TESTPIN].Mask;\
}
GPIOC pGpio
Definition: am1808.h:225
INPIN TestPin[TEST_PINS]
Definition: d_uart_mod.c:593

Definition at line 919 of file d_uart_mod.c.

#define TESTOn
Value:
{\
(*TestPin[TESTPIN].pGpio).set_data = TestPin[TESTPIN].Mask;\
(*TestPin[TESTPIN].pGpio).dir &= ~TestPin[TESTPIN].Mask;\
}
GPIOC pGpio
Definition: am1808.h:225
INPIN TestPin[TEST_PINS]
Definition: d_uart_mod.c:593

Definition at line 914 of file d_uart_mod.c.

#define Uart1   0

Definition at line 597 of file d_uart_mod.c.

#define Uart1_RECEIVE_TIMER_RESOLUTION   500

Definition at line 1197 of file d_uart_mod.c.

#define Uart2   1

Definition at line 598 of file d_uart_mod.c.

#define Uart3   2

Definition at line 599 of file d_uart_mod.c.

#define Uart4   3

Definition at line 600 of file d_uart_mod.c.

#define UART_ACK_DELAY   100

Definition at line 1961 of file d_uart_mod.c.

#define UART_ALLOWABLE_DATA_ERRORS   6

Definition at line 1966 of file d_uart_mod.c.

#define UART_BREAK_TIME   1000

Definition at line 1958 of file d_uart_mod.c.

#define UART_CHANGE_BITRATE_DELAY   100

Definition at line 1960 of file d_uart_mod.c.

#define UART_CLOCK1   132000000

Definition at line 927 of file d_uart_mod.c.

#define UART_CLOCK2   150000000

Definition at line 928 of file d_uart_mod.c.

#define UART_DLH   9

Definition at line 942 of file d_uart_mod.c.

#define UART_DLL   8

Definition at line 941 of file d_uart_mod.c.

#define UART_FCR   2

Definition at line 935 of file d_uart_mod.c.

#define UART_IER   1

Definition at line 933 of file d_uart_mod.c.

#define UART_IIR   2

Definition at line 934 of file d_uart_mod.c.

#define UART_LCR   3

Definition at line 936 of file d_uart_mod.c.

#define UART_LSR   5

Definition at line 938 of file d_uart_mod.c.

#define UART_MCR   4

Definition at line 937 of file d_uart_mod.c.

#define UART_MDR   13

Definition at line 946 of file d_uart_mod.c.

#define UART_MSR   6

Definition at line 939 of file d_uart_mod.c.

#define UART_PWREMU_MGMT   12

Definition at line 945 of file d_uart_mod.c.

#define UART_RBR   0

Definition at line 931 of file d_uart_mod.c.

#define UART_RECBUF_SIZE   256

Definition at line 948 of file d_uart_mod.c.

#define UART_REVID1   10

Definition at line 943 of file d_uart_mod.c.

#define UART_REVID2   11

Definition at line 944 of file d_uart_mod.c.

#define UART_SCR   7

Definition at line 940 of file d_uart_mod.c.

#define UART_SHOW_TIME   2500

Definition at line 1962 of file d_uart_mod.c.

#define UART_TERMINAL_DELAY   20000

Definition at line 1959 of file d_uart_mod.c.

#define UART_THR   0

Definition at line 932 of file d_uart_mod.c.

#define UART_TIMER_RESOLUTION   10

Definition at line 1956 of file d_uart_mod.c.

#define UART_WATCHDOG_TIME   1000

Definition at line 1964 of file d_uart_mod.c.

Enumeration Type Documentation

Enumerator
INPUT_UART_BUFFER 
INPUT_UART_TXD 
INPUT_UART_RXD 
INPUT_UART_PIN5 
INPUT_UART_PIN6 
INPUT_UART_PINS 

Definition at line 574 of file d_uart_mod.c.

enum TestPins
Enumerator
TESTPIN 
TEST_PINS 

Definition at line 584 of file d_uart_mod.c.

enum UART_STATE
Enumerator
UART_IDLE 
UART_INIT 
UART_RESTART 
UART_ENABLE 
UART_FLUSH 
UART_SYNC 
UART_MESSAGE_START 
UART_CMD 
UART_INFO 
UART_DATA 
UART_DATA_COPY 
UART_ACK_WAIT 
UART_ACK_INFO 
UART_CMD_ERROR 
UART_INFO_ERROR 
UART_TERMINAL 
UART_DATA_ERROR 
UART_ERROR 
UART_EXIT 
UART_STATES 

Definition at line 1841 of file d_uart_mod.c.

Function Documentation

void InitGpio ( void  )

Definition at line 839 of file d_uart_mod.c.

MODULE_AUTHOR ( "The LEGO Group"  )
MODULE_DESCRIPTION ( MODULE_NAME  )
module_exit ( ModuleExit  )
module_init ( ModuleInit  )
MODULE_LICENSE ( "GPL"  )
module_param ( HwId  ,
charp  ,
 
)
MODULE_SUPPORTED_DEVICE ( DEVICE1_NAME  )
void SetGpio ( int  Pin)

Definition at line 792 of file d_uart_mod.c.

void Uart1Exit ( void  )

Definition at line 1278 of file d_uart_mod.c.

irqreturn_t Uart1Interrupt ( int  irq,
void *  dev_id 
)

Definition at line 1032 of file d_uart_mod.c.

void Uart2Exit ( void  )

Definition at line 1519 of file d_uart_mod.c.

irqreturn_t Uart2Interrupt ( int  irq,
void *  dev_id 
)

Definition at line 1313 of file d_uart_mod.c.

void Uart3Exit ( void  )

Definition at line 1670 of file d_uart_mod.c.

void Uart4Exit ( void  )

Definition at line 1813 of file d_uart_mod.c.

Variable Documentation

volatile ULONG* Base[INPUTS]

Definition at line 925 of file d_uart_mod.c.

DATA8 Changed[INPUTS][MAX_DEVICE_MODES]

Definition at line 1953 of file d_uart_mod.c.

int Hw = 0

Definition at line 570 of file d_uart_mod.c.

Definition at line 591 of file d_uart_mod.c.

UBYTE IntSuccess[INPUTS]

Definition at line 926 of file d_uart_mod.c.

INPIN* pInputUartPin[]
Initial value:
=
{
[FINAL] = (INPIN*)&FINAL_InputUartPin[0],
[FINALB] = (INPIN*)&FINALB_InputUartPin[0],
[EP2] = (INPIN*)&EP2_InputUartPin[0],
}
Definition: am1808.h:222
#define EP2
Schematics revision D.
Definition: lms2012.h:99
#define FINAL
Final prototype.
Definition: lms2012.h:101
#define FINALB
Schematics revision B and C.
Definition: lms2012.h:100

Definition at line 771 of file d_uart_mod.c.

INPIN* pTestPin[]
Initial value:
=
{
[FINAL] = FINAL_TestPin,
[FINALB] = FINALB_TestPin,
[EP2] = EP2_TestPin,
}
#define EP2
Schematics revision D.
Definition: lms2012.h:99
#define FINAL
Final prototype.
Definition: lms2012.h:101
#define FINALB
Schematics revision B and C.
Definition: lms2012.h:100

Definition at line 779 of file d_uart_mod.c.

INPIN TestPin[TEST_PINS]

Definition at line 593 of file d_uart_mod.c.

TYPES TypeData[INPUTS][MAX_DEVICE_MODES]

TypeData.

Definition at line 1952 of file d_uart_mod.c.

TYPES TypeDefaultUart[]
Initial value:
=
{
{ "" , TYPE_UNKNOWN , CONN_UNKNOWN , 0 , 1 , 1 , 4 , 0 , 0 , 0.0, 1023.0, 0.0, 100.0, 0.0, 1023.0, 10, 0, '-', "" },
{ "TERMINAL" , TYPE_TERMINAL , CONN_INPUT_UART , 0 , 0 , 0 , 4 , 0 , 0 , 0.0, 4095.0, 0.0, 100.0, 0.0, 1000.0, 0, 0, '-', "" },
{ "\0" }
}
Port not empty but type has not been determined.
Definition: lms2012.h:584
Port is connected to a terminal.
Definition: lms2012.h:583

Definition at line 496 of file d_uart_mod.c.

volatile ULONG* Uart1Base

Definition at line 1019 of file d_uart_mod.c.

volatile ULONG* Uart2Base

Definition at line 1298 of file d_uart_mod.c.

unsigned long UartBaseAddr[]
Initial value:
=
{
0x01D0C000,
0x01C42000,
0,
0
}

Definition at line 602 of file d_uart_mod.c.

UBYTE UartConfigured[INPUTS]

Definition at line 1968 of file d_uart_mod.c.

int UartIntr[]
Initial value:
=
{
IRQ_DA8XX_UARTINT1,
IRQ_DA8XX_UARTINT0,
0,
0
}

Definition at line 611 of file d_uart_mod.c.

UARTPORT UartPort[INPUTS]

Definition at line 1969 of file d_uart_mod.c.

UARTPORT UartPortDefault
Initial value:
=
{
(ULONG)LOWEST_BITRATE,
(ULONG)LOWEST_BITRATE,
0,
0,
0,
0,
0,
-1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
"",
0,
0,
0,
0,
}
Port not empty but type has not been determined.
Definition: lms2012.h:584
unsigned int ULONG
Basic Type used to symbolise 32 bit unsigned values.
Definition: lmstypes.h:31
#define INFODATA_INIT
Definition: d_uart_mod.c:1824

Definition at line 1923 of file d_uart_mod.c.

char UartStateText[UART_STATES][50]
Initial value:
=
{
"IDLE\n",
"INIT",
"UART_RESTART",
"ENABLE",
"FLUSH",
"SYNC",
"MESSAGE_START",
"CMD",
"INFO",
"DATA",
"DATA_COPY",
"ACK_WAIT",
"ACK_INFO",
"CMD_ERROR",
"INFO_ERROR",
"TERMINAL",
"DATA_ERROR",
"ERROR",
"EXIT"
}

Definition at line 1866 of file d_uart_mod.c.

UBYTE WriteRequest[INPUTS]

Definition at line 2243 of file d_uart_mod.c.