|
|
求大神给下面的程序做注解,请稍详细些,谢谢。+ {& N. N& U; s) h, y
#include <linux/init.h>- T# `. [0 S R4 Y. R
#include <linux/module.h>5 J2 F4 f. V' P e% f
#include <linux/kernel.h>
3 o/ P3 V" J7 I; C, y#include <linux/types.h>3 Q, w, G" u; k$ G/ ?" w
#include <linux/gpio.h>
; g5 G8 @! U. ^0 A! k' p#include <linux/leds.h>
' Z' Y6 c6 a4 k1 Y#include <linux/platform_device.h>
3 p" ^) d5 K+ L5 `2 I" c, X, }# @2 @: l0 K r4 X6 _
#include <asm/mach-types.h>* ]3 V: }" w8 y$ \3 W/ s
#include <asm/mach/arch.h>8 b8 ]/ z$ H( y
#include <mach/da8xx.h>
$ p. y6 K& ]' Y1 L#include <mach/mux.h>6 B* J# V% K: S5 ~; S
& e+ V c+ s9 t8 R( I#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
0 |9 y9 u8 L- c+ [3 d# }#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
6 L$ Q+ W4 }+ O4 r/ ?* T#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
& P+ f; P1 u+ C7 s+ U#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
5 k( @( q8 a7 a0 _' x' Y
, n( T( |! v4 J% e/* assign the tl som board LED-GPIOs*/: { ?& V1 t# ~5 v+ x J4 b6 C
static const short da850_evm_tl_user_led_pins[] = {5 A5 m5 p* Y4 ^
/* These pins are definition at <mach/mux.h> file */
/ [+ t) y( d+ \ DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,$ ?5 ?5 A) }5 {5 \
-1
" v- _+ u: p% E3 b3 h @/ A};. M+ j$ }- ^; e+ i% b* f! P+ ?
. b7 t; ~( t. f6 m2 M! w
static struct gpio_led da850_evm_tl_leds[] = {$ C( r7 a( ]; C8 Z: C; ^% T- w5 L+ i
{
: T" m/ ]# A( p; m. t .active_low = 0,
2 E4 A. m- `- P( N .gpio = DA850_USER_LED0," T4 t w" b- z
.name = "user_led0",7 I: ~* n1 @! Y: M. ]! `3 ?
.default_trigger = "default-on",
# z" d$ j0 \0 o# ~& _8 \3 F9 l },; S6 x) L: k& s) [
{
0 Q. n* |" N2 C+ c7 n2 N .active_low = 0,
+ e! K, I% W6 U% k% @, g% r0 B .gpio = DA850_USER_LED1,0 z. @0 a( z, t1 V Z; d: z/ [5 ]
.name = "user_led1",) g$ O4 k2 x# E, S o
.default_trigger = "default-on",* R; {, b% S" T% c2 y2 H4 {
},
6 L% L: w. |. @. u3 w& X+ A) H2 p {
5 J1 i2 ^4 o6 t- O .active_low = 0," N( l. E6 n3 C$ p9 s Y0 e" Z
.gpio = DA850_USER_LED2,, U" {. @1 n' h' G" i* i! c4 j Z* E
.name = "user_led2",
" v, R* X. Q9 S/ p' O9 h .default_trigger = "default-on",- Y9 X' k4 Z n: i
},
# ]- _( B" ]7 P; ~! @ {! a9 K9 N5 s9 t+ J6 K) W0 m, q
.active_low = 0,
$ ?% S' v" T' P; U .gpio = DA850_USER_LED3,7 z6 ~' p8 v3 o2 h( o
.name = "user_led3",
- c4 L! @0 ?2 b3 r* G7 s( z/ B .default_trigger = "default-on",3 D2 `9 w+ B5 \4 n
},
L+ l0 m; j& _/ w$ j w9 l};* P* l, A% m2 H# W) N- |4 S8 i
( K/ @5 c9 z8 W" rstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {$ U5 h- {& Y1 n( m6 A
.leds = da850_evm_tl_leds,9 s% k F+ E: d/ ]
.num_leds = ARRAY_SIZE(da850_evm_tl_leds)," }' O7 K$ L) ~- l' ]9 b% C
};
6 f7 X2 i [9 @) M3 A% B0 h1 ~
& A# ^ F( ^3 r' tstatic void led_dev_release(struct device *dev)
( d3 k8 }5 D* ^) n9 L. }{* u+ k: Z. _# F6 I$ o
};
# r9 N9 g* z1 k
0 S( z$ L( n, c, m1 }static struct platform_device da850_evm_tl_leds_device = {9 \9 ?. a% v8 J9 T. r( R( x
.name = "leds-gpio",
$ [4 u0 b0 L% W .id = 1,& Z* |& g0 I% r
.dev = {
& F V' r6 s3 B .platform_data = &da850_evm_tl_leds_pdata,7 J0 y2 f" P! M1 O) ^
.release = led_dev_release,
$ a# b2 b" H0 }7 L* w$ I }4 M% J7 [6 x% [( i1 w1 r
};
9 g7 ~4 F4 W4 y* |8 P5 C) E! o8 N0 \ b2 ?# e9 @ D( U
static int __init led_platform_init(void) A, K. x8 Z5 A8 H" h. m# g( m
{7 @5 i$ T6 t# D- _# B
int ret;
' B; u+ t! y# j#if 0/ I& E5 k4 O' s
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
, _9 a5 K" z+ U# V% M7 P6 M if (ret)
. J8 @6 l# a- y2 A pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
M( b7 Y3 |$ H5 O2 P6 ^ "%d\n", ret);1 A& d. b' j; D5 X# S% g* x: @
#endif
" h- r& c( \3 M. q. b# q d4 m$ \ ret = platform_device_register(&da850_evm_tl_leds_device);
* c' w9 R2 g3 _% x1 J$ C if (ret)* F& E }2 F- K, Q+ A3 Z0 n
pr_warning("Could not register som GPIO expander LEDS");/ j, Z) l! g e+ P( M
else
* J8 l) m2 Z. A" o. j* G printk(KERN_INFO "LED register sucessful!\n");) y0 U% t0 j& s0 {
. W8 k, m0 r! N. a% d
return ret; }2 p& ~( t# E0 S6 \
}7 L! } F2 W" v1 u% p( L
+ t7 S6 P, q% s: j. P4 w+ Xstatic void __exit led_platform_exit(void)
* z% L( J9 Q' Y8 d{
, o; t: H+ |8 I$ }" _4 Y6 g$ F platform_device_unregister(&da850_evm_tl_leds_device);
. x) t: F6 u$ L1 W7 z8 @( M8 y/ B4 w: u( D& C
printk(KERN_INFO "LED unregister!\n");
! ?7 y; E# z( p2 G5 r6 R! f}
d# o0 \ D, R% P) C
( ]; x6 _7 j& n: Kmodule_init(led_platform_init);( J0 }* L; ?; p* V! K
module_exit(led_platform_exit);$ f! t3 l b2 J; M
/ N, Z4 R: v% u! X4 E% aMODULE_DESCRIPTION("Led platform driver");
* n! v' u" |# S( z+ p) TMODULE_AUTHOR("Tronlong");
8 p8 r) ]8 }( S" @8 V0 FMODULE_LICENSE("GPL");% V, J/ T% |& Z1 Q" ?: a
6 {" a- Y, d! n8 l
|
|