|
|
求大神给下面的程序做注解,请稍详细些,谢谢。: r" U' @7 _2 ~7 ~
#include <linux/init.h>
# j4 a E4 B9 d' G; `#include <linux/module.h>. ^$ n/ X. x# b( V7 Z. n
#include <linux/kernel.h>' f4 @% S! E6 j
#include <linux/types.h>* x7 M S7 v" u+ U% k& i& I
#include <linux/gpio.h>
1 F( g, f5 J- ]% A1 q#include <linux/leds.h>
% ~. `% L s, F; e& P#include <linux/platform_device.h>
1 \0 W1 n' K3 `0 s& t8 S0 [- c3 M$ m5 W2 g0 Q, d! P R" b; ^6 C$ h; F7 @
#include <asm/mach-types.h>- @1 V0 W* n- P- i" E
#include <asm/mach/arch.h>
! f4 A5 Y7 Z! ~( a, ?) M#include <mach/da8xx.h>
3 q( `; ^+ G2 i( G9 Q' [#include <mach/mux.h>
6 l6 V; t2 z0 C: ?! W- |2 f6 i, s$ _+ [# A7 [* s! @. d* M
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0): B; o9 b) G9 n7 L5 o. C5 |: @
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
1 f ^7 R1 H+ u( v5 Z2 B/ K- Y" B#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)3 {& G; V, Y* s; j' [6 f. t4 X8 p4 }
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)" I9 b0 ~ e- {9 t+ K1 ?6 E
+ N4 u- T* Q6 K( i7 G/* assign the tl som board LED-GPIOs*/
! u+ D* E# ]. t! C1 Cstatic const short da850_evm_tl_user_led_pins[] = {
" {5 y9 M7 w; g3 F% |; g2 g2 g /* These pins are definition at <mach/mux.h> file */8 T# b- d+ r* }2 V
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,3 d1 ?; c9 X6 L8 Z' g7 O
-13 Q( O/ N( b- G# D+ S! @* f
};
8 n. d0 R% t0 b8 L0 K* N6 {
2 {! }) P7 u# x. s( B `; ?& t* wstatic struct gpio_led da850_evm_tl_leds[] = {
/ _; z3 b+ E' m {$ R, U' f% f7 d# n& m2 w
.active_low = 0,1 H$ ?9 t4 g5 B% @9 U, j; B
.gpio = DA850_USER_LED0,7 b, X, q5 O" E M3 h% g: i2 U
.name = "user_led0",
- X7 A6 X) V" M' L2 ? .default_trigger = "default-on",
6 U1 Y% K# z# r# r) B9 A },+ _* {$ {8 M) b- `. |
{
+ l7 ?& q$ H8 ^ .active_low = 0,- @% q! h+ T+ ]! S G
.gpio = DA850_USER_LED1,
! H2 N: R+ X. n# P. x .name = "user_led1",
3 H8 \+ R1 }5 M0 F; \2 q, u" e .default_trigger = "default-on",
5 m6 e9 A6 |! r8 I: M# P },
5 H8 ]7 t- T% v) k: @5 B {
( {" w# d: Z/ k; ?4 U! F .active_low = 0,, I* r# z3 @4 b( Z- N6 Q& {8 j9 o
.gpio = DA850_USER_LED2,3 ?9 q6 D- g. d2 s0 C) |8 |0 p4 s
.name = "user_led2",
/ h4 u& o3 X9 I1 I+ H' H5 P .default_trigger = "default-on",
! r0 o8 M) l; w+ B% e1 p },( P! O" H+ @$ Y4 o2 ~
{4 T0 R2 W* x- P! \2 O6 j! w
.active_low = 0,
% f( r2 a5 A7 ~+ _5 m6 @4 A .gpio = DA850_USER_LED3,6 I1 ^% w4 f4 a% Y; R$ h5 H
.name = "user_led3",
2 L- u+ ~0 b; b. G" b! y .default_trigger = "default-on",6 L) J% @2 k& l! Z7 J" v3 O, A9 V
},* a1 O8 u8 d! t5 S) y. v5 z
};
0 A2 Q! d! g# s) a
9 _4 M* _ R, rstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {" V7 o! ^2 w+ q7 k
.leds = da850_evm_tl_leds,! L9 G. Z3 d2 j; H: J7 `
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),
9 w' y8 I/ U D6 }+ t3 L};" ]- l. ]& h. Q, u
! Y* y: [' N3 @5 h& [! @static void led_dev_release(struct device *dev)
0 x* Y. p* }1 e' a# M{' R5 n* Y, m( j8 m1 C- [
};
/ b/ Y( C: t) Q; A/ b$ O8 j# G( q$ \6 M2 U( O! A0 V, f% C2 ^ I
static struct platform_device da850_evm_tl_leds_device = {6 ~2 S' V8 G. n
.name = "leds-gpio",
! z& [4 {; d0 [& ? .id = 1,
0 B- e% j& {$ r% R$ t L4 Z1 _/ _ .dev = {$ s( x0 A7 I1 q0 R; K/ C3 c9 F9 R
.platform_data = &da850_evm_tl_leds_pdata,7 z) b- f+ [6 n* l3 `/ q$ d3 n \
.release = led_dev_release,0 c: g: k Z- d! n
}' e& z4 Y) q9 O1 }! z6 c
};
! n% k7 o, H* S6 t2 q9 f3 j0 V: w m8 g B& h
static int __init led_platform_init(void)' l- e7 w* ?3 f( j# i
{
$ h9 p8 `+ t2 k, r! Y( C, U0 E int ret;: q: q$ a# }2 d
#if 00 S# y0 J& F2 Z: G" e
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
, `4 m8 z, T% b3 l8 _ if (ret)
2 @4 T/ J: Q# N6 N6 {/ K pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
5 A; Y6 q3 U; R) i7 x8 C* U1 \ "%d\n", ret);2 F' U2 [ Y% H8 g
#endif
" v% A+ B! u6 o$ E- n3 W ret = platform_device_register(&da850_evm_tl_leds_device);# ?1 S4 Q8 D6 u; Y7 Y( b
if (ret)4 P1 |& v4 ?# O6 H
pr_warning("Could not register som GPIO expander LEDS");6 D' Z8 W8 }- T# H/ ], q: j, q H
else
8 i: _+ e; V; M5 A. z1 }* `1 O printk(KERN_INFO "LED register sucessful!\n");
. e8 L6 F! j1 d2 t' J5 l# Z6 }. x) ~* h5 w
return ret;; Q& L& Y2 G2 h
}
' S6 v) }/ C) K) ^1 j; F% @
/ T# ]2 N1 u3 {; a/ h; V) bstatic void __exit led_platform_exit(void)
* ~5 L \ e. s9 _) e: z% m5 Q7 Z{. s/ n' s3 L8 b, |/ G& w
platform_device_unregister(&da850_evm_tl_leds_device);5 S4 Z* I! O0 x
. q# }8 U, V' {3 z& X
printk(KERN_INFO "LED unregister!\n");
& q8 R, |6 ^& [ |8 t* |8 r}
- c- ?/ Y3 K% s+ ?. x0 [' c) _% `1 Z; g6 d2 l; B, S
module_init(led_platform_init);
, k4 b K9 U% }! R# z# |/ wmodule_exit(led_platform_exit);
; H& m' X# b5 E0 m8 @* _% ]
' w5 a8 x: i1 \' X" \' u8 _& O" VMODULE_DESCRIPTION("Led platform driver");( E1 ~( A; J u& j
MODULE_AUTHOR("Tronlong");
+ g J2 M( W- V- }8 {, r# aMODULE_LICENSE("GPL");
7 X& ~0 R$ |8 u$ ]. v) Y5 t% G; c# X4 A) `7 o1 j+ K
|
|