LMS 2012
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
d_sound.c File Reference
#include "../../lms2012/source/lms2012.h"
#include "../../lms2012/source/am1808.h"
#include <linux/kernel.h>
#include <linux/fs.h>
#include <linux/sched.h>
#include <linux/hrtimer.h>
#include <linux/mm.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>

Go to the source code of this file.

Macros

#define HW_ID_SUPPORT
 
#define MODULE_NAME   "sound_module"
 
#define DEVICE1_NAME   SOUND_DEVICE
 
#define __USE_POSIX
 
#define CFGCHIP0   0x60
 
#define PLL_MASTER_LOCK   0x00001000
 
#define DEFAULT_FREQUENCY   16499
 
#define DEFAULT_LEVEL   1000
 
#define TB_COUNT_UP   0x0
 
#define TB_DISABLE   0x0
 
#define TB_ENABLE   0x4
 
#define TB_SHADOW   0x0
 
#define TB_IMMEDIATE   0x8
 
#define TB_SYNC_DISABLE   0x30
 
#define TB_HDIV1   0x0
 
#define TB_DIV1   0x0
 
#define TB_UP   0x2000
 
#define CC_CTR_A_ZERO   0x0
 
#define CC_CTR_B_ZERO   0x0
 
#define CC_A_SHADOW   0x00
 
#define CC_B_SHADOW   0x00
 
#define CC_B_NO_SHADOW   0x40
 
#define TBCTL   0x0
 
#define TBPHS   0x3
 
#define TBCNT   0x4
 
#define TBPRD   0x5
 
#define CMPCTL   0x7
 
#define CMPA   0x9
 
#define CMPB   0xA
 
#define AQCTLA   0xB
 
#define AQCTLB   0xC
 
#define SOUND_RESERVED   0x0000
 
#define SOUND_CBD   0x0400
 
#define SOUND_CBU   0x0100
 
#define SOUND_CAD   0x0000
 
#define SOUND_CAU   0x0000
 
#define SOUND_PRD   0x0008
 
#define SOUND_ZRO   0x0002
 
#define SOUND_SYMM_TONE
 
#define EHRPWMClkDisable
 
#define EHRPWMClkEnable
 
#define EHRPWMClkEnableTone
 
#define SETPwmPeriod(Prd)
 
#define SETSoundLevel(Level)
 
#define STOPPwm
 
#define SOUNDPwmModuleSetupPcm
 
#define SOUNDPwmModuleSetupTone
 
#define SOUNDEnable
 
#define SOUNDDisable
 
#define SOUNDPwmPoweron
 
#define SHM_LENGTH   (sizeof(SoundDefault))
 
#define NPAGES   ((SHM_LENGTH + PAGE_SIZE - 1) / PAGE_SIZE)
 
#define DEBUG
 
#define DEBUG
 

Enumerations

enum  {
  TIMING_SAMPLES, ONE_SHOT, MANUAL, READY_FOR_SAMPLES,
  IDLE
}
 
enum  SoundPins { SOUNDEN, SOUND_ARMA, SOUND_PINS }
 

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)
 
void GetPeriphealBasePtr (ULONG Address, ULONG Size, ULONG **Ptr)
 GetPeriphealBasePtr. More...
 
 module_param (HwId, charp, 0)
 

Variables

enum { ... }  TIMER_MODES
 

Macro Definition Documentation

#define __USE_POSIX

Definition at line 43 of file d_sound.c.

#define AQCTLA   0xB

Definition at line 149 of file d_sound.c.

#define AQCTLB   0xC

Definition at line 150 of file d_sound.c.

#define CC_A_SHADOW   0x00

Definition at line 138 of file d_sound.c.

#define CC_B_NO_SHADOW   0x40

Definition at line 140 of file d_sound.c.

#define CC_B_SHADOW   0x00

Definition at line 139 of file d_sound.c.

#define CC_CTR_A_ZERO   0x0

Definition at line 136 of file d_sound.c.

#define CC_CTR_B_ZERO   0x0

Definition at line 137 of file d_sound.c.

#define CFGCHIP0   0x60

Definition at line 111 of file d_sound.c.

#define CMPA   0x9

Definition at line 147 of file d_sound.c.

#define CMPB   0xA

Definition at line 148 of file d_sound.c.

#define CMPCTL   0x7

Definition at line 146 of file d_sound.c.

#define DEBUG
#define DEBUG
#define DEFAULT_FREQUENCY   16499

Definition at line 113 of file d_sound.c.

#define DEFAULT_LEVEL   1000

Definition at line 114 of file d_sound.c.

#define DEVICE1_NAME   SOUND_DEVICE

Definition at line 38 of file d_sound.c.

#define EHRPWMClkDisable
Value:
{\
eHRPWM0[TBCTL] = 0xC033;\
/* REGUnlock;\
iowrite32((ioread32(&SYSCFG0[CFGCHIP0]) & ~PLL_MASTER_LOCK),&SYSCFG0[0x60]);\
REGLock;*/\
}
#define TBCTL
Definition: d_sound.c:142

Definition at line 206 of file d_sound.c.

#define EHRPWMClkEnable
Value:
{\
eHRPWM0[TBCTL] = 0xC030; \
iowrite32((ioread32(&SYSCFG0[CFGCHIP0]) | PLL_MASTER_LOCK),&SYSCFG0[0x60]);\
}
#define REGLock
Definition: am1808.h:235
#define REGUnlock
Definition: am1808.h:230
#define CFGCHIP0
Definition: d_sound.c:111
#define PLL_MASTER_LOCK
Definition: d_sound.c:112
#define TBCTL
Definition: d_sound.c:142

Definition at line 217 of file d_sound.c.

#define EHRPWMClkEnableTone
Value:
{\
eHRPWM0[TBCTL] = 0xDC30;\
iowrite32((ioread32(&SYSCFG0[CFGCHIP0]) | PLL_MASTER_LOCK),&SYSCFG0[0x60]);\
}
#define REGLock
Definition: am1808.h:235
#define REGUnlock
Definition: am1808.h:230
#define CFGCHIP0
Definition: d_sound.c:111
#define PLL_MASTER_LOCK
Definition: d_sound.c:112
#define TBCTL
Definition: d_sound.c:142

Definition at line 224 of file d_sound.c.

#define HW_ID_SUPPORT

Definition at line 28 of file d_sound.c.

#define MODULE_NAME   "sound_module"

Definition at line 37 of file d_sound.c.

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

Definition at line 719 of file d_sound.c.

#define PLL_MASTER_LOCK   0x00001000

Definition at line 112 of file d_sound.c.

#define SETPwmPeriod (   Prd)
Value:
{\
eHRPWM0[TBPRD] = Prd; /* A factor of sample-rate */\
/* For lowering the quanti- */\
/* zation noise (simpler */\
/* filtering) */\
}
#define TBPRD
Definition: d_sound.c:145

Definition at line 231 of file d_sound.c.

#define SETSoundLevel (   Level)
Value:
{\
eHRPWM0[CMPB] = Level; /* The amplitude for this */\
/* very and/or following */\
/* samples/periods */\
}
#define CMPB
Definition: d_sound.c:148

Definition at line 238 of file d_sound.c.

#define SHM_LENGTH   (sizeof(SoundDefault))

Definition at line 718 of file d_sound.c.

#define SOUND_CAD   0x0000

Definition at line 173 of file d_sound.c.

#define SOUND_CAU   0x0000

Definition at line 177 of file d_sound.c.

#define SOUND_CBD   0x0400

Definition at line 165 of file d_sound.c.

#define SOUND_CBU   0x0100

Definition at line 169 of file d_sound.c.

#define SOUND_PRD   0x0008

Definition at line 181 of file d_sound.c.

#define SOUND_RESERVED   0x0000

Definition at line 161 of file d_sound.c.

#define SOUND_SYMM_TONE
Value:
#define SOUND_PRD
Definition: d_sound.c:181
#define SOUND_CBD
Definition: d_sound.c:165
#define SOUND_CAD
Definition: d_sound.c:173
#define SOUND_ZRO
Definition: d_sound.c:185
#define SOUND_CBU
Definition: d_sound.c:169
#define SOUND_RESERVED
Definition: d_sound.c:161
#define SOUND_CAU
Definition: d_sound.c:177

Definition at line 190 of file d_sound.c.

#define SOUND_ZRO   0x0002

Definition at line 185 of file d_sound.c.

#define SOUNDDisable
Value:
{\
(*SoundPin[SOUNDEN].pGpio).clr_data = SoundPin[SOUNDEN].Mask;\
(*SoundPin[SOUNDEN].pGpio).dir &= ~SoundPin[SOUNDEN].Mask;\
}

Definition at line 282 of file d_sound.c.

#define SOUNDEnable
Value:
{\
(*SoundPin[SOUNDEN].pGpio).set_data = SoundPin[SOUNDEN].Mask;\
(*SoundPin[SOUNDEN].pGpio).dir &= ~SoundPin[SOUNDEN].Mask;\
}

Definition at line 277 of file d_sound.c.

#define SOUNDPwmModuleSetupPcm
Value:
{ \
\
/* eHRPWM Module */\
/* In eHRPWM1[TBCTL] TB_DISABLE, TB_SHADOW, TB_HDIV1, TB_DIV1, TB_COUNT_UP all cleared */\
eHRPWM0[TBPHS] = 0; /* Phase register cleared */\
eHRPWM0[TBCNT] = 0; /* Clear TB counter */\
/* eHRPWM0[TBCTL] = 0xC030;*/\
eHRPWM0[CMPCTL] = (CC_B_SHADOW | CC_CTR_B_ZERO);\
eHRPWM0[AQCTLB] = 0x0102;\
}
#define AQCTLB
Definition: d_sound.c:150
#define EHRPWMClkEnable
Definition: d_sound.c:217
#define TBCNT
Definition: d_sound.c:144
#define TBPHS
Definition: d_sound.c:143
#define CC_CTR_B_ZERO
Definition: d_sound.c:137
#define CC_B_SHADOW
Definition: d_sound.c:139
#define EHRPWMClkDisable
Definition: d_sound.c:206
#define CMPCTL
Definition: d_sound.c:146

Definition at line 250 of file d_sound.c.

#define SOUNDPwmModuleSetupTone
Value:
{ \
\
/* eHRPWM Module */\
/* In eHRPWM1[TBCTL] TB_DISABLE, TB_SHADOW, TB_HDIV1, TB_DIV1, TB_COUNT_UP all cleared */\
eHRPWM0[TBPHS] = 0; /* Phase register cleared */\
eHRPWM0[TBCNT] = 0; /* Clear TB counter */\
/* eHRPWM0[TBCTL] = 0xDC30;*/\
eHRPWM0[CMPCTL] = (CC_B_SHADOW | CC_CTR_B_ZERO);\
eHRPWM0[AQCTLB] = 0x0102;\
/* EHRPWMClkEnable;*/\
}
#define AQCTLB
Definition: d_sound.c:150
#define EHRPWMClkEnableTone
Definition: d_sound.c:224
#define TBCNT
Definition: d_sound.c:144
#define TBPHS
Definition: d_sound.c:143
#define CC_CTR_B_ZERO
Definition: d_sound.c:137
#define CC_B_SHADOW
Definition: d_sound.c:139
#define EHRPWMClkDisable
Definition: d_sound.c:206
#define CMPCTL
Definition: d_sound.c:146

Definition at line 263 of file d_sound.c.

#define SOUNDPwmPoweron
Value:
{\
iowrite32(0x00000003, &PSC1[0x291]); /* Set ePWM module power on */\
iowrite32(0x00000003, &PSC1[0x48]); /* Evaluate all the NEXT fields */\
}

Definition at line 287 of file d_sound.c.

#define STOPPwm
Value:
{\
iowrite16(0x00, &eHRPWM0[TBCTL]);\
iowrite16(0x00, &eHRPWM0[CMPCTL]);\
}
#define TBCTL
Definition: d_sound.c:142
#define EHRPWMClkDisable
Definition: d_sound.c:206
#define CMPCTL
Definition: d_sound.c:146

Definition at line 244 of file d_sound.c.

#define TB_COUNT_UP   0x0

Definition at line 124 of file d_sound.c.

#define TB_DISABLE   0x0

Definition at line 125 of file d_sound.c.

#define TB_DIV1   0x0

Definition at line 131 of file d_sound.c.

#define TB_ENABLE   0x4

Definition at line 126 of file d_sound.c.

#define TB_HDIV1   0x0

Definition at line 130 of file d_sound.c.

#define TB_IMMEDIATE   0x8

Definition at line 128 of file d_sound.c.

#define TB_SHADOW   0x0

Definition at line 127 of file d_sound.c.

#define TB_SYNC_DISABLE   0x30

Definition at line 129 of file d_sound.c.

#define TB_UP   0x2000

Definition at line 132 of file d_sound.c.

#define TBCNT   0x4

Definition at line 144 of file d_sound.c.

#define TBCTL   0x0

Definition at line 142 of file d_sound.c.

#define TBPHS   0x3

Definition at line 143 of file d_sound.c.

#define TBPRD   0x5

Definition at line 145 of file d_sound.c.

Enumeration Type Documentation

anonymous enum
Enumerator
TIMING_SAMPLES 
ONE_SHOT 
MANUAL 
READY_FOR_SAMPLES 
IDLE 

Definition at line 81 of file d_sound.c.

enum SoundPins
Enumerator
SOUNDEN 
SOUND_ARMA 
SOUND_PINS 

Definition at line 292 of file d_sound.c.

Function Documentation

void GetPeriphealBasePtr ( ULONG  Address,
ULONG  Size,
ULONG **  Ptr 
)

GetPeriphealBasePtr.

Helper function for getting the peripheal HW base address

Definition at line 454 of file d_sound.c.

void InitGpio ( void  )

Definition at line 417 of file d_sound.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 372 of file d_sound.c.

Variable Documentation

enum { ... } TIMER_MODES