|
|
求大神给下面的程序做注解,请稍详细些,谢谢。+ i( W) I* J* V( _7 y; i$ Z. e
#include <linux/init.h>9 @, L% U- ]: M v1 |+ T- N
#include <linux/module.h>
- x% ?- b- o* c& V8 j! r#include <linux/kernel.h>
3 _( H; v% f1 x2 @& S. z ^$ k; v5 T#include <linux/types.h>0 l$ |6 W6 U% Z! U" Y
#include <linux/gpio.h>: i; k. k" m9 K
#include <linux/leds.h>" Z+ s; u: _6 ?0 Q- v1 P2 C* v5 X
#include <linux/platform_device.h>1 K7 I/ D" C; N1 o
# G0 `( Q) W/ s, {( @
#include <asm/mach-types.h>! \, V' f2 z8 \2 U$ z3 Q) r" i( w q
#include <asm/mach/arch.h>
. G n8 G2 M9 t# @1 ~#include <mach/da8xx.h>$ i( K4 K/ d$ e6 R; @- A% L- }
#include <mach/mux.h>
7 G/ X! ~1 C! X0 L7 H! b! o; O0 T2 K& D0 V. [5 X
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
7 D' \: M% G4 @#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
1 ~6 c$ _8 N7 ?& b" J0 A- j#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
8 |6 n1 @, s2 |- x* D' \+ h, [3 a#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
7 T- @( Q; s+ } z* ]( w8 n7 O$ |+ I- f1 {3 C6 l( M' x' a1 H( v3 Z0 M: j
/* assign the tl som board LED-GPIOs*/$ A+ R9 C7 Z# n6 c/ u" ]; `
static const short da850_evm_tl_user_led_pins[] = {
$ Z0 u' w* w) X. t /* These pins are definition at <mach/mux.h> file */# H+ H# ^) W3 \4 L) Z9 K
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
8 `1 k$ Q5 o! W) e# \' F -1' G$ z% r" u4 E( Z' i
}; Z( Y, _" P1 Q/ _
' ?0 Y8 U0 R& _7 |( ]: ]- l. Ystatic struct gpio_led da850_evm_tl_leds[] = {
0 H9 V8 s- w* K {
: z1 C; A) a2 E7 G .active_low = 0,
( k% Z, e, t+ D% P .gpio = DA850_USER_LED0,
. S$ z7 R$ ]2 q# x- `: Y .name = "user_led0",
2 c! Y6 x) a% k$ ?3 Z9 A8 K .default_trigger = "default-on",( V9 V8 J. A4 v( I) {
},- V6 C9 M# c8 F- a2 N+ j& s% g( z
{
! L. W r. N+ _$ G3 w .active_low = 0,
; O% K, @7 f2 c, {- a .gpio = DA850_USER_LED1,- F) E5 Z; Y/ N( P6 j5 ^* k V$ Z9 K
.name = "user_led1",
# G% u$ I0 e' I* l% z .default_trigger = "default-on",
$ R' J" A1 L5 ` },
4 s- s/ V: Z+ X6 F0 G& M; O1 Z {* ?7 X) N3 @: V5 R4 n
.active_low = 0,3 I: a! z- D& v8 a" K" N
.gpio = DA850_USER_LED2,7 _8 Y) m( Z9 ^. q2 M7 a# t5 Y8 D
.name = "user_led2",
/ M3 s V6 o3 M. ~; P) g1 U .default_trigger = "default-on",
1 r5 g4 d& A! N! o },
6 h! B' o+ R2 X; M% K {# a- U5 ^" C6 o5 K3 i& E
.active_low = 0,$ Y- f" P9 m) `7 ~1 A
.gpio = DA850_USER_LED3,. q! X* |% u" ~7 j { X
.name = "user_led3",0 s5 f% O. b8 Q- F X
.default_trigger = "default-on",5 g5 p/ P2 e/ t0 d
},
2 y) ~, g0 X* Y};& {& V1 \2 }. F5 X
' S3 `) E% D& J( s% T7 q' E( P4 Bstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = { f6 V* s% v0 s/ R: P8 w- ^; N
.leds = da850_evm_tl_leds,/ B3 ?! T [. ]5 j
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),7 B" ^) \+ J' X2 X: }1 x: t1 _
};
* X" y: A Z+ W0 x H
5 \# r9 `/ _" w0 _static void led_dev_release(struct device *dev)# V1 G- T9 x1 _( u6 W- r3 }
{
0 h; V5 u H l}; o2 x4 Y5 y- L- l& @2 u
5 e, v# h/ c( b" M" t
static struct platform_device da850_evm_tl_leds_device = {
& K6 n$ }" u/ P, E! F6 u .name = "leds-gpio",6 n: Q5 l4 ]2 g) Z& G
.id = 1,
2 E+ l" \% a/ z0 V& i! s& d .dev = {8 B- U: _* o: I4 g1 {
.platform_data = &da850_evm_tl_leds_pdata,1 N* E' F9 v( x2 }8 w8 R
.release = led_dev_release,
* o; U" B0 D8 ?* L# j; s/ ?; F3 y W }
% K/ i6 t0 O& \+ B) g) d& |$ S! d, c2 r};
# j! P! K% P3 W7 _. s
& L" t& F+ b9 L9 l0 I8 L3 jstatic int __init led_platform_init(void)
* e# X- S4 W5 N6 [{6 t: O/ g! F$ j" x
int ret;
+ p9 e- E8 |+ A& J) H$ E' u( s. d#if 0
?- }% N9 K$ W5 t* q5 N ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
& {* o7 r* d5 i& s$ m7 W if (ret). n r. Q% e# i, x3 V, ^: k
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
/ [6 W9 d" e7 R/ j0 z: [ "%d\n", ret);% w9 Q2 L9 W* E: e* A5 P9 R2 N# A' b
#endif# r3 s4 K9 P# i* [ E9 Q% g) k2 F
ret = platform_device_register(&da850_evm_tl_leds_device);
h1 E5 o3 [8 N if (ret)
2 r4 s! h% `7 ^% D1 i pr_warning("Could not register som GPIO expander LEDS");
- X; u. W c3 b% L! m$ } ~5 I else
) k( s! V- W$ Q* a4 | printk(KERN_INFO "LED register sucessful!\n");
* h! P4 n/ ?* X; [# M2 K4 ~0 k0 H- {% a$ e* a7 y: k( L9 N
return ret;
- p* y/ P: q6 _}
; {5 O7 ^; e& U! A; u% d( m9 N/ {' a* `
static void __exit led_platform_exit(void)' N' D8 G& q. y' A& J
{
: h1 a4 \( f3 o% Z. j2 t( V- ? platform_device_unregister(&da850_evm_tl_leds_device);
2 E- Y9 @. h3 k% k. A7 j
5 U8 f% d: ]# u. n2 U: |. n printk(KERN_INFO "LED unregister!\n");
- x5 o- E: Q4 P) u+ G7 x D' n: k7 W% {}6 n7 d/ i9 q7 z' ]; w! Y! Y
/ D v4 }" A: K' D) S3 Mmodule_init(led_platform_init);
$ \3 ]! G- r e$ amodule_exit(led_platform_exit);
% T2 |- C5 T' A2 I9 j; ^5 n
0 {9 `' _/ Q# g' P5 e, \MODULE_DESCRIPTION("Led platform driver");# p/ M0 _( d+ i; r4 F" f9 u% y
MODULE_AUTHOR("Tronlong");
* R1 ?0 [ q" `- y8 J4 X+ F6 TMODULE_LICENSE("GPL"); o) t" t3 X/ M: u1 R+ \& C! G o
7 r! R5 ~7 M! F# T0 T6 J0 M
|
|