|
|
求大神给下面的程序做注解,请稍详细些,谢谢。: i* o2 H! y- s$ k5 P
#include <linux/init.h>" A% _2 Y$ z! d
#include <linux/module.h>+ H' t2 t" F, Z
#include <linux/kernel.h>3 I$ h' X* s% y1 }
#include <linux/types.h>
6 Z+ l! F6 |1 E! p0 H$ M#include <linux/gpio.h># f4 d& h$ P* A0 R/ ^& g( U/ W
#include <linux/leds.h>
& |$ b/ V% K, W3 C* L6 c# c7 S8 K#include <linux/platform_device.h>9 x4 m0 O1 Q9 F% s( \6 `1 B# M
, y& a. e+ P- \; W
#include <asm/mach-types.h>
% k5 d4 L7 k. |: E& G#include <asm/mach/arch.h>
& i' Q, j+ _4 F* X#include <mach/da8xx.h>
6 N2 D, J% w2 {/ d" V; m#include <mach/mux.h># z1 S; a6 L7 A& }0 D! n
8 a7 _- B4 n1 b# @, |
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)0 u8 Q# O4 f, N+ h& _
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)+ A I" `3 x3 u3 L
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)6 {9 f4 @( c7 y$ r; x
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
1 D! M6 l C+ m, q6 d. D3 z5 y$ l
/* assign the tl som board LED-GPIOs*// S+ c: x7 D4 P- M1 @3 r
static const short da850_evm_tl_user_led_pins[] = {
# H' N7 ~6 B' { /* These pins are definition at <mach/mux.h> file */8 x1 w% `) L; ~& r$ |
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,! @6 x! Z- v- c$ \' ~' O
-1) d) ]) j6 C% I/ ]+ ?2 \, ~
};
- L0 |, D& l* Y- Y+ _6 N. r% i! R. ^9 ~1 { c
static struct gpio_led da850_evm_tl_leds[] = {: s. k1 E3 ^/ v8 k0 i/ v3 W
{
9 S$ q8 E5 f/ H* a .active_low = 0,3 X Q7 _, {# _
.gpio = DA850_USER_LED0,' m a [( m! Q/ z( A
.name = "user_led0",( O# s" W3 N: E# i; H
.default_trigger = "default-on",
2 `# h2 `+ {# G: M },+ l' x% u; m8 L! E, A" E
{3 _0 Y7 C2 L# ?
.active_low = 0,
. }( e. ?/ o1 B3 o4 l8 h .gpio = DA850_USER_LED1,
' e* Z4 t2 ?7 T2 w .name = "user_led1",
5 W/ u H1 D7 @: }# ? .default_trigger = "default-on",8 e& _. X$ t. `" |6 s1 n& S7 I; b5 E
},: n7 _) d- q, _( I1 \
{7 b9 G& q& p: A% a9 Y' i
.active_low = 0,. u) X3 g) v3 i5 T c6 c( R9 b
.gpio = DA850_USER_LED2,$ U. r: y# |! K! s
.name = "user_led2",
`; q' s2 o# ^7 p* q .default_trigger = "default-on", D) t+ T- ?' u8 e6 b0 E5 M1 m
},
0 j4 p( H! c) l9 P; D% [ {4 E( [& F4 T1 d2 w) B+ T1 S0 [% S- x
.active_low = 0,
( ~3 b3 ~7 d8 o$ J! G$ h/ m; _ .gpio = DA850_USER_LED3,: D& i1 C: R1 g @8 ~
.name = "user_led3",
1 L7 g5 {3 `4 d0 j" A+ C3 [ .default_trigger = "default-on",1 Q5 x+ h% `6 W- X7 c! X, _' e
},
4 n' ]! G F8 ]/ V};
1 t2 M+ Z4 v9 h* Q# w9 V# P3 }! C# V4 P; B. Z
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {5 t6 ~5 \9 s, m
.leds = da850_evm_tl_leds,
2 b; f) y0 S3 u7 U3 e4 _3 b .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
2 X/ }" N' j6 {3 p6 d};
3 I) w: q3 h! l3 w8 V0 @7 j1 z. R2 `
9 j: h( b/ c( y1 I* r, Qstatic void led_dev_release(struct device *dev)
' w6 X$ f8 ~3 P+ k* C{' ? y+ u+ U; x$ _& R- y$ j
};
. M" s, W. e! K" c. L/ ~: S7 ~2 [" ?/ G$ s6 U+ g! E, \
static struct platform_device da850_evm_tl_leds_device = {7 n$ O( E7 ^! D/ s3 F7 s' Y5 R$ D# A
.name = "leds-gpio",( M7 a+ K) s# z' {5 c* L: S, T
.id = 1,
* e) E6 P; A9 ?& x' p. q2 C .dev = {; J' T2 n2 [& m3 I/ q
.platform_data = &da850_evm_tl_leds_pdata,
8 c7 x% I2 ?4 D .release = led_dev_release,
( H7 Y7 v) m4 S, Z: c }" B2 Y; p$ ?/ f* `( I1 h0 p7 `5 z
};; Z5 n9 w* c0 [; M
+ c2 m2 l+ y' }1 E$ I, ]1 astatic int __init led_platform_init(void)+ A1 w2 n7 L B! a. v
{
5 e: u( r) q9 f int ret;1 j- V; e5 v$ I2 m& c& B% E7 V
#if 03 o! t: d( z; i
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);) H2 E4 w9 b Y- P2 D" `: T& L
if (ret): f/ Y1 J# v% Q% G
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"- j8 B4 I/ S R9 @; F* r. X
"%d\n", ret);( Z6 f5 ^% j9 Y7 n, }1 T7 _
#endif
: }2 x* l7 w9 V( ?. ? ret = platform_device_register(&da850_evm_tl_leds_device);
- Q9 p3 o4 ^& M6 d if (ret)
0 b. b/ C- T3 Z9 P' s3 X2 { pr_warning("Could not register som GPIO expander LEDS");
( J0 X. R# D4 F else
) {! r9 ~5 J9 R) ]% K printk(KERN_INFO "LED register sucessful!\n");$ t% f4 d$ d& h0 F; O
$ ~% x9 L8 D* j! @1 q# V return ret;
8 J4 ^. J( R( C5 m% }2 z6 K* F( e}/ ~6 h1 p3 H: m5 G( P& F' v
' u( k+ y+ [( B* Sstatic void __exit led_platform_exit(void)8 l6 W+ w. \* b N/ ~2 b# |
{
) g3 J) n' _$ S/ {+ T9 r. O platform_device_unregister(&da850_evm_tl_leds_device);
9 W0 ^/ Y& U8 Z9 z8 ]) {1 c: `
* S; q( ]$ I2 p; U6 n" O printk(KERN_INFO "LED unregister!\n");) A/ G8 @) T+ U# C$ ~( M
}, t1 B+ R& w9 s9 q! A' g/ y
; j9 E& [$ ] C4 c. M- [! `2 |module_init(led_platform_init);
8 Y# Z2 Q8 v8 F1 p1 n) O. d* `+ \module_exit(led_platform_exit);
$ l3 q4 e3 D8 S# w8 z: Z
( V9 u5 u% g# E" n" U1 d1 r8 \- WMODULE_DESCRIPTION("Led platform driver");
5 s5 B2 A% G+ p* \" l1 ?MODULE_AUTHOR("Tronlong");
: X. k! T2 J2 z1 Z$ y. m' C0 NMODULE_LICENSE("GPL");; S' u: N; V# J
$ w3 ~& o' t' ?, [) T6 {" {7 b
|
|