|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
# V1 f5 | c4 W. n! i5 K#include <linux/init.h>
) S& S' G( r. t5 g# R% D2 g#include <linux/module.h>8 S7 r/ n$ j0 v5 P; L
#include <linux/kernel.h>6 H2 ~0 S, D, J5 B0 ]( ^3 f
#include <linux/types.h>
: q' T2 ]% M& J# o5 `#include <linux/gpio.h>
1 B+ ^! k& \5 N% I4 Q5 ^& m#include <linux/leds.h>
$ D* r, j3 p5 }5 M% \4 r#include <linux/platform_device.h>7 H! X6 y) ^$ f
8 r7 w9 y! _% u: w, {#include <asm/mach-types.h>( u t' I7 C# f; P
#include <asm/mach/arch.h>) \3 O# a0 m& q |, r7 s; I
#include <mach/da8xx.h>6 M ?5 w1 i) l6 x& T
#include <mach/mux.h>
3 M0 v" X/ X# J4 E& r6 T+ n& R/ y- }1 E% [! u6 G. L: k2 h
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
# W, o* e1 ]7 L#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
/ K: n7 o5 R" v; j6 a0 _0 g#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
) H. n" W. H: t( l2 |' Z: k#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
4 j- z1 b+ J7 Q
+ d2 A) }0 L7 P3 |& e4 T/* assign the tl som board LED-GPIOs*/. r1 E. Y9 l; V' ]# o
static const short da850_evm_tl_user_led_pins[] = {# ^; g6 J. F& Q
/* These pins are definition at <mach/mux.h> file */
% L1 V4 d j) |* p DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
3 @( \9 M! J1 o( r4 H( C1 I% h -1+ y: V- E5 N1 _9 c% t4 R e
};& K" F' }) r& @* z
8 C0 g9 }- Z, j7 ~2 E0 [
static struct gpio_led da850_evm_tl_leds[] = {5 o, s* p* N0 P6 O0 S+ s' @
{
' Q5 b* |2 R3 K& Q2 d2 ?; i0 N9 D: w4 \ .active_low = 0,( ~' h# f( d7 T# z2 d1 g
.gpio = DA850_USER_LED0,
) u. L1 d( n. E .name = "user_led0",& i# y9 b6 U% }: W5 w
.default_trigger = "default-on",; B7 ~& W8 m" J" \6 |2 e; t
},
' I! f% \! Y0 p& f {
; r' E# {3 Y+ l/ ?' m .active_low = 0,& p7 J5 S- l* Y5 i% k) h1 L
.gpio = DA850_USER_LED1,2 l& h# C/ z0 Q& ]$ B
.name = "user_led1",
5 K/ v$ b+ G ~5 r/ P .default_trigger = "default-on",
6 Z1 c* \! C9 e+ s. J8 ^& P },+ Y s6 j8 @5 _8 J/ t+ e) O4 k
{- _" u6 K. H6 C+ K9 J5 Y% K" ?1 M
.active_low = 0,6 W& T- n5 p/ i" k3 b
.gpio = DA850_USER_LED2,
( @% J. _" u2 |, V% h .name = "user_led2",8 e# ~3 S& C$ Q4 g! q0 @% S
.default_trigger = "default-on",
# A* y8 j& n: @9 N6 C" N% f1 i! Z) L },
0 w5 f; G$ Q1 t J; f {
o! ?& ^- z) I* a+ g2 c6 v' y .active_low = 0,
' q( Y7 U" c1 b& j6 a3 ^+ U .gpio = DA850_USER_LED3,
. S, O* J# d) X+ z; b: e .name = "user_led3",- |* U: R. _4 y3 J
.default_trigger = "default-on",
* Y0 D% k- W6 @: x2 J8 y# g$ Q },8 P5 f( d& H! K
};7 M* c) a) [& y, F! c4 W T b
: c( w' E) A9 Q$ wstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
$ D: b% c9 v6 d .leds = da850_evm_tl_leds,
0 D2 h8 c+ @2 R% U .num_leds = ARRAY_SIZE(da850_evm_tl_leds),( Z1 C( a5 d/ R0 O: z0 V
};* I( }; x& {8 Q5 E! M
6 c( x2 q% N0 ?, Qstatic void led_dev_release(struct device *dev)
* i7 I5 N7 A6 V! I/ c/ s$ l. o{
* _' s4 K! R! I4 p' X5 n# k};& S2 T: v9 [9 h
% w* f5 S4 r) R1 J* u; hstatic struct platform_device da850_evm_tl_leds_device = {
+ _5 N4 e8 b5 U& C U; F: d x .name = "leds-gpio",* v; ]- s' y" K( P! R, X8 |' Y
.id = 1,
$ ]. \# _8 _3 J7 \/ E# E* r( j- t5 K .dev = {
7 z2 b" \5 h' p: |/ \ .platform_data = &da850_evm_tl_leds_pdata,
/ L0 u f F- ? .release = led_dev_release,1 e# ^5 \8 D; a5 }2 H+ K" `/ a
}" u, | Q- ?3 k/ i' O
};5 h: N5 @5 e3 y2 H8 k" H- p
( }" Q1 z: o9 d' _4 a4 }static int __init led_platform_init(void)
v; U: D7 ~1 I4 N, Q+ Z5 U{
/ I- E# d- Q7 c; B int ret;
- y8 E/ R; Y6 S8 K1 q7 E#if 01 @% s' T: Z6 U, }
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins); F- M0 S0 _# W9 T' \. Z
if (ret)' p' [ d y1 B, U% I+ ^7 l! p
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"+ Z2 a; ^$ A( s/ R, \( H2 f+ @
"%d\n", ret);
' P: W3 k! V R7 Z0 f0 y S#endif, E1 c9 x. u" w; m
ret = platform_device_register(&da850_evm_tl_leds_device);2 r- |3 s2 X h( W* r+ J8 f1 H" |. m
if (ret)4 ?+ h W" q! }7 E7 a9 M" b) p5 I
pr_warning("Could not register som GPIO expander LEDS");
6 `. [/ T1 d e3 p( k$ j else6 h$ C2 t2 }" f2 B* @
printk(KERN_INFO "LED register sucessful!\n");) }6 N; a9 }7 E0 i" B* k
# T+ q7 @. {; H; }9 H
return ret;
r% X2 ?! Y; t* W9 M8 [" V: ^} n# d9 o$ w8 I) e9 V# l
' v3 m8 r' s' w# o3 _: v+ y( Fstatic void __exit led_platform_exit(void)
# r( }. F* d$ S, D{' y' G% K$ a% t8 ~
platform_device_unregister(&da850_evm_tl_leds_device);- t& R8 b% D$ g$ ]5 d
" r! G$ M( O( I7 U" n: H6 o3 F
printk(KERN_INFO "LED unregister!\n");1 O7 M% W* E; [; I# L0 | U# K
}8 o7 `2 O5 x5 Z, G( `! H
- r7 H2 D/ o0 r- w6 y" [( q$ F" h
module_init(led_platform_init);/ W# Q9 R( B% s
module_exit(led_platform_exit);9 e: ]& R( f, l
! i3 r p: @" j/ A
MODULE_DESCRIPTION("Led platform driver");4 I- Q9 _/ k, c( e. `
MODULE_AUTHOR("Tronlong");% l" |( J9 |6 L# w% r7 u* E
MODULE_LICENSE("GPL");
. V6 B9 B3 S/ K' Y: Y, R
) [7 l" {/ U X |
|