|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
1 k% v4 s1 r: s/ U$ |) I1 M#include <linux/init.h>
: O) \( q( w: U& V1 a#include <linux/module.h># C: C- ?- M3 B: H/ P/ x3 T O6 v
#include <linux/kernel.h>+ c" Y- P7 w, r/ S: [$ u
#include <linux/types.h>
. _: T0 o# C$ h/ p2 W' r$ O#include <linux/gpio.h>
9 P8 M/ e. V" @$ r" t( b( G5 s#include <linux/leds.h>
+ y8 X! i, z$ d+ ?" t#include <linux/platform_device.h>
: K' N5 e" k+ K4 E- w @7 W1 t
8 V' T# j2 J7 ] K: N#include <asm/mach-types.h>, v( v! _3 J9 l2 c
#include <asm/mach/arch.h>
8 t l: R; T% p0 b+ [#include <mach/da8xx.h>1 l) \& z s9 n+ o8 k3 I4 z9 m
#include <mach/mux.h>6 z- |( Y A* o% n; A- A
8 t8 ]9 H0 \0 Z4 y8 ?
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
/ O, k5 _/ \/ D( O2 E! e+ O#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)0 a; z C: [8 m4 \
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
' P9 l0 m0 A4 a#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)/ l6 ~, @+ V3 w$ {
% _' O# y7 W% P9 m
/* assign the tl som board LED-GPIOs*/5 f: H8 P% ~" G! S
static const short da850_evm_tl_user_led_pins[] = {5 f9 d$ c; R) x. p& x# f9 g
/* These pins are definition at <mach/mux.h> file */7 ^% T2 Z9 S; s. U
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,- ~: k% L, }; R+ E
-1
, R' D: r2 ]) [& S};' U) _8 a, q1 k! a" f i
+ C4 `4 i$ |+ N6 Istatic struct gpio_led da850_evm_tl_leds[] = {# ]& N. K- h @$ s* `9 D) _
{- e+ {0 _9 [. L3 n5 T+ J
.active_low = 0,% V$ J2 A; J2 I2 P
.gpio = DA850_USER_LED0,
0 e# _+ W. @! {" {9 R+ f- s6 } .name = "user_led0",5 u h+ }1 v; R2 v
.default_trigger = "default-on",1 f! J9 n3 ^: w6 k+ l. @
},; v6 n' o. k' G% u9 B: \" B4 Y, H @
{4 Z% s, L! K' S5 s
.active_low = 0,0 i+ U' {3 n: W; v4 H
.gpio = DA850_USER_LED1,
L; F' |: W. p .name = "user_led1"," d5 W/ Q. u/ ?- ^2 i- d4 `( \% n
.default_trigger = "default-on",0 N& s- o! \) y$ f3 I) l( ^ ]# x
},
5 ^; `0 r) E b+ ^1 n {) @7 d+ c3 h, G3 `2 L& U& g' q) N
.active_low = 0,
0 {* d' a* }3 q! ?7 | .gpio = DA850_USER_LED2,: P- x6 K6 b/ v2 K: B) S- v
.name = "user_led2",
- ^: R" Y5 q7 P' m8 l2 l .default_trigger = "default-on",
5 N9 A/ D) g) ` },
5 y, t: r% V8 J0 f3 r8 c6 Q {
. O9 d6 A/ f7 b. \6 t .active_low = 0,% K8 J3 d, _" M" S: }
.gpio = DA850_USER_LED3,9 [/ H. ]5 H) c) v# ~) I- @
.name = "user_led3",# k- Q8 C/ c0 V( t4 b3 ]* Q
.default_trigger = "default-on",/ k) F7 n, e/ r/ }; t
},
! A9 b$ D: Z6 t4 g% U9 |) R};
6 \5 v. A1 R* N% m# j4 s! w+ }
, j; Q* s3 Z; n1 z# @static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
* R2 ]6 S/ m$ I* ]* J. u) q' ] .leds = da850_evm_tl_leds,+ j) q) w$ S1 F2 m: U) [
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),
: t6 E$ W4 Y! h};
% _- U! _3 ^! b! q. T& W- t o% \, T6 J
static void led_dev_release(struct device *dev)4 E4 F6 t( Z: u8 m7 O
{
% F# h* u0 `; {" g Q9 G};0 j* {+ \: ~# m
. `% ?$ f' Y8 X8 U# t! ~
static struct platform_device da850_evm_tl_leds_device = {3 C: e4 V5 d( w/ i
.name = "leds-gpio",+ Y4 z$ a3 _& Q5 W
.id = 1,0 E- {, z7 u9 X6 X* R
.dev = {
' l! @# o0 k! f% E .platform_data = &da850_evm_tl_leds_pdata,
9 v/ {) L3 S. K" Q4 d6 v8 S .release = led_dev_release,& @$ ^! b. u+ m& t7 ]- O
}3 V" i1 m+ o, |6 r" U
};( \7 d* ]% O1 g
+ u0 v7 j0 R* @static int __init led_platform_init(void)
( G2 m9 l6 j, t2 l: s; Z+ F8 s{
* f& Q1 v/ q" s7 ~7 c; G: I* } int ret;
4 J2 `: {1 {2 C% H) h#if 0
' U- K! N; H" B# I; f/ O- Z+ z ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);. `+ x5 q: {$ K0 k) n
if (ret)
7 ~ m8 D1 X2 j, ^% @2 { i pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
+ x7 V- B- F+ }/ m+ v) w "%d\n", ret);! S0 ], o1 [6 U4 p+ T
#endif, ?9 ?2 M& @% [3 O4 c! n7 C
ret = platform_device_register(&da850_evm_tl_leds_device);
0 {% {% t6 f% e if (ret)6 ~: N3 B7 p7 ?5 ]8 {2 R
pr_warning("Could not register som GPIO expander LEDS");
7 \) a$ a" A! Z6 V& m2 U, ? else
9 B: Y0 z" v/ I( h5 ~, I0 | printk(KERN_INFO "LED register sucessful!\n");# U1 U' o7 \8 t5 M! o. w
0 ]! {, K5 X L' v) ]: J return ret;
, [4 ~4 G/ @8 w7 @}
/ u0 j0 F7 n2 p( o6 D: m5 `( x
/ ]% b- E8 h( P1 p- istatic void __exit led_platform_exit(void)7 A( f0 z/ Q! e; T
{3 ~; }( C& C/ t
platform_device_unregister(&da850_evm_tl_leds_device);
$ O/ A) A% u# c4 g! Q5 j+ G9 Y5 ?# N" E; B1 v" a
printk(KERN_INFO "LED unregister!\n");# j3 Y4 q. A5 z+ M+ Z: l' U: g; y
}
; Q: s% a/ [, A0 o* W6 g
8 [ M% d# y% C9 T$ Q1 S9 Imodule_init(led_platform_init);6 T, V6 ]% V0 r3 w) x& P: i
module_exit(led_platform_exit);
( Y$ V7 t. X* p( T5 o. l; B; K% ~
/ ^9 M' l+ g4 A& t& Y+ V2 q" oMODULE_DESCRIPTION("Led platform driver");/ \) I; C: c* ^7 [0 {% D6 q' `0 d
MODULE_AUTHOR("Tronlong");
/ O6 Q4 l- X7 c4 S U6 xMODULE_LICENSE("GPL");
* K. }1 F0 |% Q
2 q& P# W! _( a( {* O; |! e' m |
|