|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
, b* R2 b; Q- T9 \8 Z l#include <linux/init.h>
y8 u: E1 A8 n: e5 ]* O K, U#include <linux/module.h>
. T3 q, h! d( E% q0 Q8 l$ i# c+ L#include <linux/kernel.h>0 L4 L/ }% z* i& X. L4 A& z2 n
#include <linux/types.h>
4 U# k; J: P0 ~# q#include <linux/gpio.h>8 M3 }$ j9 V8 L! q
#include <linux/leds.h>6 }5 l( o+ r6 M' L* u5 V: ]
#include <linux/platform_device.h>: n: r5 A2 _# D- U4 U3 P3 ^
7 v! V4 Z5 |3 S" o: ~' R1 c0 G
#include <asm/mach-types.h>1 u7 @+ J. M7 I
#include <asm/mach/arch.h>9 X2 q/ d1 [$ {& o
#include <mach/da8xx.h>( |/ G- V5 _ @. p6 r
#include <mach/mux.h>
* f& t% G. @9 x* |( V# E3 c0 b( ?" Z3 J$ f3 u' z0 |' i
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
( D2 j0 x$ l( d#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)" ?! E+ w5 h/ Q2 w# v8 F4 E+ f5 R( h9 Y+ M
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
& a6 t/ r" s- h1 \+ U4 a" p# l#define DA850_USER_LED3 GPIO_TO_PIN(0, 2), F/ Z' ]" T! l) N
7 Q+ |$ c j G* G# k/* assign the tl som board LED-GPIOs*/
8 {( o& p( P7 Y+ @static const short da850_evm_tl_user_led_pins[] = {+ J* c1 s4 D) d( {0 b
/* These pins are definition at <mach/mux.h> file */3 y0 x8 b$ p0 g% f- q/ n9 R* ~+ Z; m9 v
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
/ Z7 _% a; p1 J4 D5 N -1
& b* m; C* ^, C# d1 j};
# N1 Q: a$ m0 X, ?4 v7 j3 g- A) v0 Y$ ?* c4 N% \
static struct gpio_led da850_evm_tl_leds[] = {6 Y; b2 y$ [0 v7 X
{" I1 g j0 Z g+ h; I$ z
.active_low = 0,0 O( ~$ Q1 |1 R, R9 {+ `# Z8 }
.gpio = DA850_USER_LED0,
4 A& M% I, t! s/ t0 T4 E3 H .name = "user_led0",
& `* W) Z% S ~* ]3 K1 h .default_trigger = "default-on",
- f$ d! l0 V7 a+ J1 e+ J },
* \2 \9 ~1 a) i {
2 D [7 F( C6 o; l/ ?3 Z( u .active_low = 0,
' ]0 e+ s) O A7 b! A* B .gpio = DA850_USER_LED1,
6 c, P- G$ x* t+ K, B .name = "user_led1",
9 S# d* Y1 ?' P1 P2 Q) {2 W .default_trigger = "default-on",/ ]* I; z( g7 I8 v" G6 w
},
; E/ F9 X+ F8 n# p1 g {
, y( h, f( |% D; J @4 S .active_low = 0,
& H7 B) G. m, A4 w8 ^/ d .gpio = DA850_USER_LED2,0 Z0 O8 y* i: K# n1 t
.name = "user_led2",8 C2 T$ l4 ~& P/ t. Y
.default_trigger = "default-on",
+ w4 B0 H c* ^* o1 ~3 n# P% [" B },
; ]1 `) W( ^0 j {
% q6 t5 I5 P2 W# P* S2 s& C u .active_low = 0,
- A u: h( X/ [ i. q/ g9 J' x .gpio = DA850_USER_LED3,
9 O. B w' Y* M6 u! v8 x .name = "user_led3"," t# V, l1 c7 D: L
.default_trigger = "default-on",9 y: {: J* \* y
},
2 ~( K. T( e0 D' X+ D- D" p+ E3 {8 Z};
! W. q/ @1 A. I2 U' L& U% E% h" W2 g
" z$ z3 o) Q1 @: Y* Vstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {; m* y: j* f% i
.leds = da850_evm_tl_leds,
) R$ \+ y/ a- `' P .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
* R P S: j3 T; \9 E/ G6 L};/ L; K7 }( d% O
) R8 N+ o2 I' B& c F! F* B3 A" j7 @
static void led_dev_release(struct device *dev)3 S+ s$ o2 h0 b0 R/ k
{; C: M; H1 [( @2 j e Q, B3 ^
};
9 a" o5 a8 T# v# n" f6 E. \4 m
( ~( i! s4 I% C- `static struct platform_device da850_evm_tl_leds_device = {/ E* D" n: _0 E6 K. N
.name = "leds-gpio",8 d/ k$ k) i* \( T
.id = 1,
! U* n2 v+ d8 R5 U( ^4 k: T .dev = {
: U, A6 y; [* L8 ]: f .platform_data = &da850_evm_tl_leds_pdata,. h" T2 t. r+ a
.release = led_dev_release,
4 B0 C9 d! E S) a. T8 z0 q }
# q% C' n" ^& |" w0 `. M# l$ ~};3 U) |" N* F$ J, C4 o8 Q) ]" V
9 |8 S/ l; m9 E$ f* Z& ystatic int __init led_platform_init(void)# s: K) W n2 d( @" a
{ |0 Q0 q* A: e( D
int ret;9 B) z: ]9 q0 c6 q
#if 0
+ d2 d0 @. ?; l+ F ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);5 }7 F# v7 w' N: u
if (ret)
1 W3 `6 I' |! A* g% F/ \" m pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
9 |8 @$ W& r7 {% V& q "%d\n", ret);( e' q+ d! V% N" ?/ A# C
#endif
* ^* j4 Q2 s. F" ]: C ret = platform_device_register(&da850_evm_tl_leds_device);
7 U- }, v9 i! h4 U$ v6 N0 ^ if (ret)
) O3 L; u8 _! j' Q$ B& M! M% ^ pr_warning("Could not register som GPIO expander LEDS");) P. R9 X! w m6 H% Y( I0 O
else& W! J! Q6 k- z$ T! p% E2 _8 U
printk(KERN_INFO "LED register sucessful!\n");* J1 [( U6 r' q$ V
) \# d1 v3 T# y0 j
return ret;& y2 }( M4 e; w; ? z
}
% t& I# ~; U4 Y! Z% D, ]' ]
n$ O( S q# G: r9 n4 q( cstatic void __exit led_platform_exit(void)" ^% B! x7 n/ A9 t, E9 _
{
) Z1 N; `" y$ H: G- |# I! S1 W platform_device_unregister(&da850_evm_tl_leds_device);
9 c7 d! w' L: D, V, d
8 }7 [" S& C( X7 a printk(KERN_INFO "LED unregister!\n");
% A7 \+ q6 _6 a# q: X- F" @5 ^; b}
5 u* t- }) _4 L7 Y, c. T) r8 F3 }6 N9 a6 D6 h3 z9 A5 b4 K$ l
module_init(led_platform_init);
- A0 h6 ^' r- d' `& Z) j% l: kmodule_exit(led_platform_exit);
3 {0 N1 x) i* T/ Q0 A6 k$ s8 \. N2 v2 H: B" Y' Z7 ~8 I
MODULE_DESCRIPTION("Led platform driver");+ R+ O" q* ?. R# ]# K
MODULE_AUTHOR("Tronlong");
: ^4 \0 `: d0 _/ b$ g+ _8 Y3 bMODULE_LICENSE("GPL");
# q, _9 z! ^4 Q$ i2 G: p8 a- Z
6 L0 N6 x( c+ C) M& A$ Q9 N- r |
|