|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
8 P8 g" h7 v8 }2 ~#include <linux/init.h>& u' ^) e/ @/ F
#include <linux/module.h>* z+ u' B! k& W( F* X7 {
#include <linux/kernel.h>
" r9 F" G7 K5 d/ W I#include <linux/types.h>' H! @% H2 f. ^5 E# e2 C- r1 o
#include <linux/gpio.h>
' x; K, j1 f9 k* L# x* B#include <linux/leds.h>0 W" k- ] x/ D' t$ c" |- u+ {
#include <linux/platform_device.h>
$ f8 S: |- j: K& n, C
J Q; W1 Z7 |! y+ \" i4 r#include <asm/mach-types.h>
( i4 l2 c, s7 H0 t# O$ |#include <asm/mach/arch.h>+ A- g8 @( @5 Z' F/ T
#include <mach/da8xx.h>! F2 w( e+ V: w: g/ o/ h
#include <mach/mux.h>; V, y `) ]( ^2 n5 T+ J
8 i: r+ N' p7 L
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
0 E8 A0 |$ A" f+ r#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
- b# S4 I& M2 q3 ?6 ?' T/ H3 i#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
+ @4 d) ~3 [4 w#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
4 \3 `8 c, E5 H1 z# V- N( O& K3 Y4 x7 u/ S3 z
/* assign the tl som board LED-GPIOs*/
; G1 B* ^* z: A3 d& k/ Astatic const short da850_evm_tl_user_led_pins[] = {
6 _& _1 K6 N" O /* These pins are definition at <mach/mux.h> file */
4 M3 H s) [, e DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
# o7 v9 ]! e. y; J9 }/ t# x -1* G5 z: m7 ^3 L5 N+ B
};/ j x% M9 ~% _% J E
; M, @* Y o C9 ?static struct gpio_led da850_evm_tl_leds[] = {
0 [9 B. p9 X% ?& z: K7 ?- E {
* M6 X' T; R% Q+ g% F4 Z0 d0 \5 o .active_low = 0,
5 l$ g( K0 K- _: S `% ? .gpio = DA850_USER_LED0,
% V# C3 A# M1 m; j, r/ R0 f e- D7 O .name = "user_led0",# a; n) s1 _* I1 A& U$ }( g5 \
.default_trigger = "default-on",8 E! e; l2 F& l5 Q( Z" w: E; J1 _3 ~% t# b
},# S! @7 F+ `/ p; Z
{
/ U8 o# d% ^1 r; e .active_low = 0,4 n5 ~3 h* G O2 E8 x3 q. m& `
.gpio = DA850_USER_LED1,) W2 ~- ^: E8 q
.name = "user_led1",
) a. Z- ~( t7 Z1 V, u .default_trigger = "default-on",
8 N; o9 Z3 D" u6 l2 T- M- L },& d& P4 e# `# |$ @, f, [) P
{
- n7 Z& y7 w( q7 { .active_low = 0,3 `# O5 X/ I0 }* ^- |) z
.gpio = DA850_USER_LED2,7 o( J1 i- n/ _7 L2 G! }4 \2 {' v
.name = "user_led2",' E% X; a- V# S5 \' R
.default_trigger = "default-on",
! ^( ^6 A2 p/ G8 n5 _ U9 E },
" f. @. T0 }% Q7 S( ? {9 Z1 Y1 A0 R+ N# a
.active_low = 0,) h, v) U, \: m! y3 A+ r
.gpio = DA850_USER_LED3,- i+ V1 d/ D3 n, W$ \
.name = "user_led3"," W8 h" s% {; g" a, O0 i4 l7 U
.default_trigger = "default-on",- r) w- E ~# }4 ]4 }0 s! C2 e/ a
},
9 z; |: X" Z& j9 t' w7 f- _/ Y};5 v A( W. p. j+ {" F5 E
7 _6 P% M) O0 T! q& C" o9 W
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
0 T! W$ x* V' b j% W' H: f! h6 X( x, @ .leds = da850_evm_tl_leds,2 p% {& G0 L6 G+ N8 M% I
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),
& {- q: ?+ ?; L) v1 v2 ]" |};' |) R( F( ~, A% L$ @0 \
- o+ v& J- [0 {" K0 e7 F% G
static void led_dev_release(struct device *dev)
7 @3 n/ U0 A# ?4 V \: C3 i/ ?2 ?. p{! ^' s1 ]! C% n5 J$ l" E. {3 ^% c" s' g
};8 Q! p7 u4 l/ R' ?$ x. y
; Q9 e6 U8 V! Q' Sstatic struct platform_device da850_evm_tl_leds_device = {# H: l/ g$ W' t: `4 `2 x
.name = "leds-gpio",7 D9 @- L8 a6 w: D4 g C& Y
.id = 1,3 y$ D/ k ~$ W
.dev = {
! X% K( N$ v3 a: |$ v+ A- X .platform_data = &da850_evm_tl_leds_pdata,' X$ m3 A3 R+ q9 n1 h6 M" O
.release = led_dev_release,
6 i. k: w7 @6 `# g. m }% k6 g6 r( H% h/ E3 Q% _( {
};
- K* E1 T1 R& K+ @ O5 g% N$ {
$ ?1 G) n5 `& A9 ?- C- {: {static int __init led_platform_init(void)
( E$ Y3 Y) D; k6 ?8 x/ B6 N{
* @- a, a8 I, Y" }$ W int ret;) {, J) S% ?7 g+ _
#if 0
0 T3 `$ i& k1 `9 v# [ ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
5 E1 Y5 b! G3 l if (ret)" x% o T- P1 y$ b" U
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
+ j6 D7 v& R1 i5 z "%d\n", ret);
; a/ o3 b+ k# X; @8 M z0 d#endif
5 o* R3 u* p* X' G, \ ret = platform_device_register(&da850_evm_tl_leds_device);2 h v. l7 _$ h1 D
if (ret)" S% P! H! H( j/ W8 a, ]
pr_warning("Could not register som GPIO expander LEDS");1 @8 W5 f3 A9 z# K# Q3 N, q& S
else
. b" \5 G e* u printk(KERN_INFO "LED register sucessful!\n");, ]) P2 G8 h# y, Q
( P4 l0 @5 P o o% v a( B% b1 y
return ret;
& D0 c1 y3 E7 Z1 b8 G1 Z7 }$ p}
# O" k: A- B$ E
1 x+ n7 Q+ _: n+ X. b) istatic void __exit led_platform_exit(void)% E3 e# v& o; n7 U0 W
{
+ l# H# R! F4 o/ V platform_device_unregister(&da850_evm_tl_leds_device);
, }9 W4 D. E9 c3 T& j+ C/ J0 o+ c4 Z0 c* U# R7 P% p; P
printk(KERN_INFO "LED unregister!\n");
: k+ h7 F7 `# W J9 I7 k}( u2 p0 Q7 b$ K
( M; l4 N4 x' V |1 S
module_init(led_platform_init);/ P# N Q1 y* u) p" M
module_exit(led_platform_exit);
9 |6 |# t1 E1 i6 m- T( }
: T4 |6 p* c) oMODULE_DESCRIPTION("Led platform driver");8 O" m w7 [$ u4 @ O
MODULE_AUTHOR("Tronlong");
$ r C5 Q9 ^$ j+ k: o) I( DMODULE_LICENSE("GPL");3 i+ L3 L; N/ a' x. j1 b
) h2 ^4 A/ U3 x+ ]9 X2 d- D
|
|