|
|
求大神给下面的程序做注解,请稍详细些,谢谢。: J: n1 [$ V$ z* f. b( Q+ y/ k/ W
#include <linux/init.h>
2 k) X0 m: D- @( B: q#include <linux/module.h>' N: t0 ~1 M$ ]# I, X! A# }' [
#include <linux/kernel.h>$ Z) ^0 Z p3 k$ M
#include <linux/types.h>
5 h+ z( Q- X# c H3 R! y( W#include <linux/gpio.h>6 V$ O4 d2 ^, U) m8 p# Q
#include <linux/leds.h>: p5 r% }2 Y* r# J6 T) u
#include <linux/platform_device.h>
3 l9 _+ a0 U3 K* q7 j7 D) B$ v. R$ a# M+ c9 O; X L
#include <asm/mach-types.h>
/ ^$ O* M0 q+ g4 J- |#include <asm/mach/arch.h>. p) T( {) S2 A4 w7 U
#include <mach/da8xx.h>
1 r( j* s! p. K& c#include <mach/mux.h>4 h2 ?/ I' @9 b9 r# K
5 X0 ]0 F ] B% ?6 I( p
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
: R0 G0 H: F/ ]6 `#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
; f7 |" a+ I7 D4 l% I7 A n#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
( \& \/ x3 X' M#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)* S5 r* e. |+ y! O1 i* J
" R6 t6 K# m" Y7 `) H/* assign the tl som board LED-GPIOs*/
2 t. L8 d: C2 M o, rstatic const short da850_evm_tl_user_led_pins[] = {
, c" ~9 ~6 D3 ^! g, H /* These pins are definition at <mach/mux.h> file */5 q1 x q% D( W \4 m1 X( c
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
+ A7 j: B/ ]& ^0 V -10 C$ ]4 L( _. s! g
};
! c/ H- T/ T+ ?5 U
& V a7 T. Z/ i! [static struct gpio_led da850_evm_tl_leds[] = {/ ^7 g. f" G: a* p; T! I3 {4 o
{
( q8 y# s! t# p }8 \1 S) g .active_low = 0,
& d3 i' L1 C; V6 s/ a; t/ ~( V1 b .gpio = DA850_USER_LED0,
) [4 \6 _2 }4 ^+ I* e& v. v .name = "user_led0",7 |% f% q( B% X! ?& U3 @$ ]
.default_trigger = "default-on",! `; z. }; [# K7 n4 E0 s
},) M% ~+ u0 ]5 K+ O# d6 l: E
{' |2 k7 p5 C4 B* c( R# M
.active_low = 0,% Y5 X( O5 v8 q# s! g g
.gpio = DA850_USER_LED1,
: k, I: j1 T5 v+ q .name = "user_led1",4 V- I+ W# L, b1 T+ k3 d
.default_trigger = "default-on",
( b+ r) }& ^+ J- ] x% ?* L- X },) w- M+ X1 s6 M: H1 J% K
{0 w& O/ e/ A% Y1 I2 B. k" o. R! ]
.active_low = 0,
3 e) J6 K W7 |0 N, r .gpio = DA850_USER_LED2,$ P3 J9 ]' u! p5 p
.name = "user_led2",( l+ K! V, g0 d: i" X0 \2 W( Y
.default_trigger = "default-on",) I# M" k& T B7 K8 c
},
* S/ g- W) l* b+ y% {, U {6 ]% v# `4 w" h# z6 f, `
.active_low = 0,
; @; }1 f5 c3 w .gpio = DA850_USER_LED3,5 Z" z" M/ c4 Z
.name = "user_led3",) h7 v- u: Q( e0 O$ M' P/ a% k/ ^
.default_trigger = "default-on",( m* x! T, C" ^
},( D3 V# {6 m2 m
};
& L' c* q: \$ G) `. u+ y! B% R7 A R8 O& P# F' M' q9 ^
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {0 a' f1 [# n I
.leds = da850_evm_tl_leds,
( e* E* ]( ?* j* L# a' ~ .num_leds = ARRAY_SIZE(da850_evm_tl_leds),* E1 g5 r3 F1 [ j @
};
, V' ]2 R5 t: {# Q G$ u6 M l i+ A7 j* n
static void led_dev_release(struct device *dev)
+ y6 Y j# C k! o( R{
A3 l& C) {6 N# Y};* o+ Z4 T1 ~7 U) j" n
( D5 k" ]$ i1 B0 y j% B5 O
static struct platform_device da850_evm_tl_leds_device = {* d3 @& p. ~3 Q) y( f( K, w
.name = "leds-gpio",# w1 n% u5 ]' p5 e1 i! L T
.id = 1,9 s$ u& C- y* K* K9 n7 R
.dev = {
& F m7 h0 ]' q% J$ W# x .platform_data = &da850_evm_tl_leds_pdata,
1 H* @- s) i% t/ v% D# u* P .release = led_dev_release,: I9 j9 {. _& A' N' V, e8 M, G
}
( G8 l0 o5 Y" a4 `. w};& n1 U0 a1 l3 a
% v4 j- E3 Z- I( S ~2 r' `9 pstatic int __init led_platform_init(void)
9 G& Z [+ ^# X' r5 y2 F8 n- z{
$ [5 w7 z9 p' e0 v1 }) b: i. ]# u. W int ret;
' O' l- O% ?- b#if 05 ~: |( l1 j) @
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
% @3 |$ ]0 L, R: h9 c" R) Y if (ret)! o' x. F# ?1 b1 j% a( f) U
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
( |. k* r. a5 _6 M5 | "%d\n", ret);9 X4 p- G$ X' M
#endif
5 K8 g! ]; F1 Y2 @, u9 c0 ?; L1 Z ret = platform_device_register(&da850_evm_tl_leds_device);2 e& V! C2 d& Z* w8 q
if (ret)
) ?# m0 b v" g1 w" S% V$ |% J pr_warning("Could not register som GPIO expander LEDS");+ ]1 L J5 _% X; B. u$ u
else
/ @' e! [5 B1 ], v* q6 x printk(KERN_INFO "LED register sucessful!\n");
8 a. z0 A/ S% p7 A+ N5 l8 v/ x C' a* S# L& N
return ret;' q$ L3 e/ f$ P! R5 g
}
; s/ ~! P; V. N( @1 d1 Y+ i( ]
. M" E3 D( T" Z1 Z. n+ h3 j5 ~static void __exit led_platform_exit(void)
9 S9 Q( [+ U/ D) p- @{
: B) c1 s2 ]" f0 s8 P& y: i3 z" ` platform_device_unregister(&da850_evm_tl_leds_device);
4 f/ `+ }7 o$ \( ~) S5 \
4 }% K+ C, ~ D, I; V printk(KERN_INFO "LED unregister!\n");
. r* w! T6 a3 k8 {6 ^1 B}1 k, X' Y* }& j' y; v, B- F$ \. j
+ C& T' m+ D" w9 d k% Fmodule_init(led_platform_init);
& ~; C( o9 X8 e( t* I* }module_exit(led_platform_exit);; N/ K& I" x9 ?6 a' x: [, q
9 n6 N5 c& C/ @( WMODULE_DESCRIPTION("Led platform driver");3 g1 m. R* J _/ f0 L* D" D2 E7 t
MODULE_AUTHOR("Tronlong");3 ]/ F3 R+ S2 w" ?
MODULE_LICENSE("GPL");8 ^/ n% |* v( R# [+ \
6 D( [ u- d, b# \: z
|
|