summaryrefslogtreecommitdiffstats
path: root/target/linux/realtek/files/drivers/net/rtl819x/rtl_glue.c
blob: 00c631a2bd442d52c2e854a6bdd91eb8a9fcbef5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
/*
* Copyright c                  Realtek Semiconductor Corporation, 2002  
* All rights reserved.
* 
* Program : Implementation of Glue Functions of Model Code
* Abstract : 
* Author : Louis Yung-Chieh Lo (yjlou@realtek.com.tw)               
* $Id: rtl_glue.c,v 1.5 2008/04/11 10:12:38 bo_zhao Exp $
*/

#include <net/rtl/rtl_types.h>
#include <net/rtl/rtl_glue.h>

#if 0
int rtl_down_interruptible(struct semaphore * sem)
{
	//return 0;
	return down_interruptible(sem);
}

void rtl_up(struct semaphore * sem)
{
	up(sem);
}

int32 rtlglue_drvMutexLock(void)
{	
#if 0
	spinlock_t lockForCC = SPIN_LOCK_UNLOCKED;
	int flagsForCC;
	int needLock;

	spin_lock_irqsave(&lockForCC,flagsForCC);

	needLock = (int_cc >= 1)?FALSE:TRUE;
	int_cc ++;

	if ( needLock == TRUE )
	{
		uint32 dummy;
 		saveGimr = READ_MEM32( GIMR );
		
#if defined (CONFIG_RTK_VOIP_DRIVERS_PCM865xC)	
		WRITE_MEM32( GIMR, 0x00080000 );		/* Note: DO NOT disable PCM interrupt because users might be already on the phone call at this time
												==> Keep PCM interrupt enable for RTK VoIP applications
													==> RTL865xC, bit19: PCM_IE 
											*/		
#elif defined (CONFIG_RTK_VOIP_DRIVERS_PCM8651)
		WRITE_MEM32( GIMR, 0x00040000 );		/* RTL865xB, bit18: PCM_IE */
#else
		WRITE_MEM32( GIMR, 0 );
#endif
		/*
			For RLX5181, LW/SW for external IPs (ex. GIMR) would be slow because one
			CMD queue is implement.

			So, we would always read GIMR back before calling <spin_unlock_irqrestore()> to
			make sure GIMR has be set before spin-unlock.
		*/
		dummy = READ_MEM32( GIMR );

 	}
 	
	spin_unlock_irqrestore(&lockForCC, flagsForCC);
#endif
	return 0;
}

int32 rtlglue_drvMutexUnlock(void)
{
#if 0
	spinlock_t lockForCC = SPIN_LOCK_UNLOCKED;
	int flagsForCC;
	int needUnlock;
	
	spin_lock_irqsave(&lockForCC,flagsForCC);
	
	int_cc--;
	needUnlock = ( int_cc==0 )?TRUE:FALSE;

	if ( needUnlock == TRUE )
	{
 		WRITE_MEM32( GIMR, saveGimr );
		/*
			For RLX5181, LW/SW for external IPs (ex. GIMR) would be slow because one
			CMD queue is implement.

			So, we would always read GIMR back before calling <spin_unlock_irqrestore()> to
			make sure GIMR has be set before spin-unlock.
		*/
		saveGimr = READ_MEM32( GIMR );
	}

	spin_unlock_irqrestore(&lockForCC, flagsForCC);
#endif
	return 0;
}
#endif