|
|
求大神给下面的程序做注解,请稍详细些,谢谢。6 ]4 R W) `. ~' Y! }
#include <linux/init.h>& Q( i. t& H1 k! G
#include <linux/module.h>$ Q4 I# Q6 \( d" G4 \/ L
#include <linux/kernel.h>
0 a1 V+ ? l' Z#include <linux/types.h>5 W7 H& q8 p% l# k0 O# q
#include <linux/gpio.h>
2 u& K$ N7 q" Z* ?, L6 Z#include <linux/leds.h>
' u/ G1 q( @6 e#include <linux/platform_device.h>2 E! r+ _* u6 c& U' z7 o
3 Q s- t; L% W( a0 Y& d7 L* A, C#include <asm/mach-types.h>* r- G8 P9 H: {1 |. v
#include <asm/mach/arch.h> U- n/ H& \! y+ Y! c6 {; B3 H8 e
#include <mach/da8xx.h>
( ] A1 X/ c4 O J2 c! O& J9 L#include <mach/mux.h>5 B/ e4 V( H8 \7 J' I$ B ]* v& T8 h0 {
, ^0 J) Z5 q; e1 U#define DA850_USER_LED0 GPIO_TO_PIN(0, 0) D2 ~ e* }5 V4 ^
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)- `: i- B3 N! H
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
$ i: q$ {& G6 }/ h. N) q" P#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)8 f, V& Z U W) K: w
+ a% U8 U; T4 u4 {$ Z+ l$ W* B
/* assign the tl som board LED-GPIOs*/
$ |/ |/ B1 t0 q+ mstatic const short da850_evm_tl_user_led_pins[] = {3 A) z) l9 j1 d- b+ u) K8 x# t) h
/* These pins are definition at <mach/mux.h> file */+ c& m/ l4 S( X
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
/ n1 a0 J+ o. W -1
+ T3 B8 l: A# e6 k; n: |! e# n};/ T$ ?3 q3 Q1 V! d% @: T. z4 g5 `
2 c( }/ O/ r) e: C' ^7 {static struct gpio_led da850_evm_tl_leds[] = {/ S- O8 |4 Z% r
{7 q8 |) G, P5 W6 I. U
.active_low = 0,2 d. T; j! ~ \
.gpio = DA850_USER_LED0,
9 N7 p0 ?9 d, ?, H6 k$ U7 E .name = "user_led0",( z. _4 L2 J% J, q
.default_trigger = "default-on",
2 ~$ I* {4 q% ]1 G2 Y' K' f },
2 D: U- q, A; H8 K3 w {
3 l4 J' o# \9 f+ u4 Q I( x .active_low = 0,
- {1 |& d. H7 h! [8 Z: U9 g! [ .gpio = DA850_USER_LED1,. _& H. W; d5 f2 C" T: }& I) L
.name = "user_led1",
9 k( v, l: g6 U! f6 s1 v .default_trigger = "default-on",
/ j f. l# l+ p- U. ]* @0 w* h$ w, C },
6 C! w4 u2 S, F! W( P {& T1 H, z$ `7 R# L! R
.active_low = 0,
$ q6 m0 {. [2 h$ f" ?" F .gpio = DA850_USER_LED2,
& n. ]# P9 S1 t7 B .name = "user_led2",: n) {9 F* n5 r9 l2 J3 P
.default_trigger = "default-on",0 l$ q( ]0 ]. L( y
},6 Z. F- o8 X! \1 p
{# l& H7 @% x* T" _$ Z; u6 F
.active_low = 0,3 q# |- F) D$ w8 k8 D
.gpio = DA850_USER_LED3,- q8 j4 ]- b3 O/ R
.name = "user_led3",
2 P5 O( a$ K, K, {) t" @ Y .default_trigger = "default-on",7 @& E# A" M+ o/ Y
},# N- `, M! f' r0 U- z7 x
};
% C' C, C! t, E5 [: ^( ~* @
% n% f; g3 y! \2 \static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
' V8 i9 `& Z4 z .leds = da850_evm_tl_leds,
+ x$ K* r+ R' d# C/ a .num_leds = ARRAY_SIZE(da850_evm_tl_leds),6 c+ T g/ b' @3 S7 k0 N7 i
};+ @7 ~+ E- J$ z# M1 c
2 l' `" R, m2 U! c& k) |static void led_dev_release(struct device *dev)6 K+ f' G$ P4 E4 H6 Y
{6 q5 }; x. F5 n5 f, f1 s$ O) t
};
' C. F4 z) C) T7 }( T \& ^3 N
9 d) y* N+ Q8 i* Q5 }static struct platform_device da850_evm_tl_leds_device = {5 m6 z" |9 F! [& }' ]; T
.name = "leds-gpio",
+ U/ j( U7 ~& M# T9 ~% s% Z .id = 1,
) T8 W: I2 X) V; [) m$ K .dev = {
) T* M% Y5 }4 A4 Q .platform_data = &da850_evm_tl_leds_pdata,
9 Z0 @$ Z- g8 s .release = led_dev_release,
4 ]- H5 u: o& \8 d. Z0 J }/ l6 ~8 k, _7 f4 N4 ?/ w! l
};8 n. Q3 }( y* P8 G
3 A- g8 C% ~, t Y
static int __init led_platform_init(void)
( F0 y$ X0 Q& \; S6 |! J: \- {{
: m( C* l+ K* n! i" \0 t8 c int ret;* ^- e; {6 m- r" @- L
#if 0( c$ [* O. A( s0 V* O# k
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
' l" C7 c& a: W if (ret)
8 {7 ~1 ` ?& k3 h$ Y' r- {9 w pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
# s+ i8 k& r2 F# N/ i "%d\n", ret);/ n# N9 Q' c& ~* x1 T
#endif
. I/ c @2 h3 J/ d- Q ret = platform_device_register(&da850_evm_tl_leds_device);8 ?4 b/ N) ?0 G* Z
if (ret)
9 s3 x; q- } y pr_warning("Could not register som GPIO expander LEDS");( C& P2 p& f1 h/ P) M
else
' ^3 f4 D* p* l; a4 K: h. h1 F4 M printk(KERN_INFO "LED register sucessful!\n");! |; D6 F, O6 \2 [5 e1 c9 K7 T
3 c- S2 K+ F8 W) Q- `& Z( S
return ret; T# C4 @. V! Q+ r
}
2 b1 m+ ~/ P0 Z5 `
/ a2 J i2 X" n" S- Istatic void __exit led_platform_exit(void)
5 z3 d. O% T' u+ d. Q{
4 p2 `: y3 S. T& S: R2 }- v platform_device_unregister(&da850_evm_tl_leds_device);1 f4 m$ q, w3 Z* ]1 n1 c2 o
\" O2 o. q2 [& d5 I
printk(KERN_INFO "LED unregister!\n");
! d; {3 a: Z3 p+ B: U}
) T; `+ R' B8 j% d7 N( g8 `- [6 @
module_init(led_platform_init);" i- @+ A) b0 ]0 x* @0 u! `6 ^
module_exit(led_platform_exit);
# Q( [! S! L0 C% V# o. u; i. ^8 g$ C' e% ]+ X- F3 S
MODULE_DESCRIPTION("Led platform driver");7 h/ @1 _$ p9 ]7 M4 E
MODULE_AUTHOR("Tronlong");
* t& P" p& J/ [% ^* s g xMODULE_LICENSE("GPL");
/ }* w8 V8 O' u6 b5 w
2 t! x* L( D2 `* ^ |
|