|
|
求大神给下面的程序做注解,请稍详细些,谢谢。9 C9 W3 @; q( X( a& m" o
#include <linux/init.h>
- `# ]3 M4 e2 \#include <linux/module.h>
+ O$ A3 T: Y! \0 j( R; t#include <linux/kernel.h>. Z! x6 c7 w( n2 u
#include <linux/types.h>% f: W( i8 u' F
#include <linux/gpio.h>
; p( [4 [$ f @; p9 |#include <linux/leds.h>
3 W J9 T/ \; f3 U! M( ^& S#include <linux/platform_device.h>1 _: k2 @& H3 \# Y! a* f* P
) V# K8 L. H* S# _4 C
#include <asm/mach-types.h>& k* q% c. P# @0 n
#include <asm/mach/arch.h>
/ ^6 Z$ q: `; X# Q0 Y9 d#include <mach/da8xx.h>5 j) Q% D6 l* ]6 m1 n5 U
#include <mach/mux.h>
) k( V$ q( w8 D: G& ?5 a8 m# e3 O' i( {0 I$ o: e
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
% z: x7 t- ~9 b#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)! t/ u/ a: I w+ B ~, r) V- b
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
7 B( f9 ~ l: {5 Z+ ]#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)+ f: |, v4 F( [8 z* n, E+ V
- P* L2 f( C8 M! q1 O/* assign the tl som board LED-GPIOs*/- A. ^# H% B; ^+ f4 h6 `
static const short da850_evm_tl_user_led_pins[] = {
5 n3 Z/ t8 p* \& g, D /* These pins are definition at <mach/mux.h> file */
6 e! ` c0 B2 a# B8 I0 f DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
' T' U- a% X6 K8 I9 h/ i0 f1 l -1& W) Y8 I3 }+ W3 H: N
};
3 f) q6 `% P; f! r- b/ T% L* r( i" ~
static struct gpio_led da850_evm_tl_leds[] = {% i$ n7 l$ i* L0 U9 t4 U6 J5 P
{
* }) H- ~: e' _# I: l .active_low = 0,
; q& w l: g5 S .gpio = DA850_USER_LED0,
6 Y) Z* T1 n2 J. u0 c& Z; Y$ e .name = "user_led0",. G+ ^& M' y" E; a% ~! a
.default_trigger = "default-on",8 H6 h( _* g* r8 k
},7 o; q* }; H) @, E+ R6 i2 `% J% i
{
" L/ O7 l5 \% `% y .active_low = 0,# U: c- @( x: B( M& c! @% }/ f
.gpio = DA850_USER_LED1,; f( B3 s# Y2 B3 \
.name = "user_led1",6 G& W5 C0 L& ^4 t* W6 S- a r/ w3 Z* W
.default_trigger = "default-on",
( U) D) X; I4 t; G8 J- N },
/ C5 h K! s- j% ?' H4 ? {
9 }) g4 G# P5 b3 y0 [ .active_low = 0,
) j/ }2 i. y1 m .gpio = DA850_USER_LED2,
& H b; t4 T3 w0 f# k& s3 H7 f) ] .name = "user_led2", m, ?+ N# q. [+ v2 Q5 a
.default_trigger = "default-on",
9 U, H: R) g8 W) P' ?+ N/ W },! b! W' \$ s$ j8 i; \/ F- s3 c
{) H# z) O! z9 |0 q; P# \ n5 C
.active_low = 0,
4 k1 Y3 r5 z- _ .gpio = DA850_USER_LED3,
6 W* V0 q; @* o2 n | .name = "user_led3",8 O2 Y/ a3 K: a" R" {: N
.default_trigger = "default-on",9 c1 E: f7 w1 ?! O9 f$ z
},
3 a& u! W) x5 z* ?( w6 h};
( i( Y C, H& Q- v; X
. `) L( L1 g& {8 C- ?static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
, e( U$ ^( U- M& U .leds = da850_evm_tl_leds,
" s& e. i, W6 W6 D) S .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
. N. Q' p9 o3 G+ H' h6 {& d};
/ Z( Y8 _* g/ `6 q
' D2 U% p" F9 i) F& K9 M; h& i. gstatic void led_dev_release(struct device *dev)7 ?) q* z' U, A9 V# v7 A
{2 I' I' j3 ^ \; ?- ^6 d G
};2 j& h$ ]" b1 `' n) }
) ~" B/ Z3 y& ^$ G* z. `) r$ p }
static struct platform_device da850_evm_tl_leds_device = { o9 O! T' B* u! Z5 n; n- ?, E" D
.name = "leds-gpio",; ]: z2 B/ s) G7 t3 Q {5 v' u
.id = 1,
' V, u" c/ H/ A$ u; O, P3 P7 b .dev = {- ~6 J2 s: p, C+ }7 M' {
.platform_data = &da850_evm_tl_leds_pdata,
6 ]/ V3 j j% u( } .release = led_dev_release,
9 {: B' I$ i: M# f$ L }
) u. E: v* M: z4 s};1 Q% H: i# K. x+ W/ Z
. t/ e; f% M+ |" N7 x8 n+ W
static int __init led_platform_init(void)
! Q- B" d/ @- k& ^% M{
1 F, r& m( {7 V& w2 ` int ret;
* p0 k5 J5 Y5 ~7 j, ?#if 0' P$ w% x+ u( r7 K
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);! l+ S; I0 X3 m$ `
if (ret)
$ D" p3 u# n1 p" N W& C, J0 K pr_warning("da850_evm_tl_leds_init : User LED mux failed :"( d1 F* Q6 B, \
"%d\n", ret);' ^& @. M+ N7 j% j
#endif" x& H3 h; k. e( r0 {+ J
ret = platform_device_register(&da850_evm_tl_leds_device);7 F Y7 B* k/ G; e0 ]
if (ret)
5 k( o4 ^+ \' t0 H2 t A' @! t4 I pr_warning("Could not register som GPIO expander LEDS");- \4 m* |1 F0 W6 i
else" C9 W9 }- a0 M3 o: i* a
printk(KERN_INFO "LED register sucessful!\n");8 u d- ]- {1 T: z$ D
2 z) H$ q# i& |3 c3 B
return ret;. C$ x1 }8 a& b
}, K b' k5 t0 J* S6 M; r, e& _
. f! A0 r* p# v
static void __exit led_platform_exit(void)
% e& f! t$ d; F: n! F: g# V) A1 y{
r' z0 a3 M) Q8 I$ h s platform_device_unregister(&da850_evm_tl_leds_device);7 i6 d7 q/ C" v% V5 S) v
) y* v( w2 G3 N* C M5 w" [3 l
printk(KERN_INFO "LED unregister!\n");/ S+ X* U. \9 N9 L2 [; l
}4 W8 d8 m! g3 ]' Y5 \5 ?7 j7 ~- J
9 \, b' M/ O2 D+ x6 ]module_init(led_platform_init);
+ G& }1 V: F" _; k1 H- j7 C4 s& lmodule_exit(led_platform_exit);
% D+ E& b- n2 l
% n6 ^6 i8 f9 m+ {. i; D! P4 ?MODULE_DESCRIPTION("Led platform driver");- z3 g9 c6 W- d4 b# V6 |8 t- @/ F
MODULE_AUTHOR("Tronlong");
" z) m: |5 Q# P: IMODULE_LICENSE("GPL");
- y5 f. Y: P' C1 x; B
% \/ ?9 i' f% W% ^5 F |
|