|
|
求大神给下面的程序做注解,请稍详细些,谢谢。+ V# j) }6 z5 n/ r/ B: n5 p% a* c
#include <linux/init.h>
2 O7 b( x4 o4 q0 R* ~: N6 a4 g& V5 t#include <linux/module.h>: I4 d; b& S% Y& S8 z0 U
#include <linux/kernel.h>1 {8 i: e5 _7 M& V5 D
#include <linux/types.h>
% _6 _, _5 o. V: i* p#include <linux/gpio.h>' C# G- `, d k! a; I
#include <linux/leds.h>
L0 _) I1 r9 u4 P4 J#include <linux/platform_device.h>7 ]/ Q" k# |" N( m }+ P
# f. u. K* q7 q' J/ V$ n# e a
#include <asm/mach-types.h>
) w, ^, g& b( A& e: R6 T) {! [#include <asm/mach/arch.h>6 ]8 m7 N8 m: K, I
#include <mach/da8xx.h>6 N% y/ U( B/ V' {1 z1 l
#include <mach/mux.h>$ }' ~7 K3 a# a8 Q& m. h
* S( {1 V, p! l, V- j: b
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
5 n) U* j7 V0 e#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)2 h% k, i! ?# P% U. w, }3 _
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)# [3 W# I/ P3 J& C
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
7 l/ [: i9 o, W5 Z/ J) w
, A+ [( ]/ @% I3 V/* assign the tl som board LED-GPIOs*/$ t0 ^; L* E# S* M1 V
static const short da850_evm_tl_user_led_pins[] = {
7 @# _/ d" Q+ S7 K- H) @. [ /* These pins are definition at <mach/mux.h> file *// ]0 s- K% ]: V& |
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,2 G7 A' I! Q/ d' E( U/ D) y
-1
' w/ ]0 }4 L# [9 m# Y0 n b5 ~+ l};
9 M# Y6 C) x$ J- z: A( W2 f
6 k7 @4 X6 y! X; fstatic struct gpio_led da850_evm_tl_leds[] = {/ V3 O+ f+ V4 f; ~4 N
{5 c1 e5 k+ |( b4 u& F) [6 G5 u+ r
.active_low = 0,
' j" C% N# N1 C: {. b .gpio = DA850_USER_LED0,
4 a6 d* z3 F: O' u .name = "user_led0",
( x) ], M4 n; R; N ]' M+ T# R .default_trigger = "default-on",
+ v9 X- X2 a* U1 c6 ]- Z },
3 A" D P7 Y- M! i' m: o) G {
+ ]0 [6 B* q$ A .active_low = 0,! M. W1 X0 p2 J
.gpio = DA850_USER_LED1,! L2 N/ y! c! B- Z& P5 w
.name = "user_led1",8 t" c# r Y! R7 t
.default_trigger = "default-on",
* K: h) d% v; n8 G6 T },
. ^4 `' Q! ^, r {
4 J2 ?/ Q3 h- O' A3 @; K .active_low = 0,
! q: k/ @( I/ ?6 B1 {: M .gpio = DA850_USER_LED2,
7 H n* t( C2 k0 g& E. } .name = "user_led2",: c; K# z! a3 }& k
.default_trigger = "default-on",
1 Y b/ p) y a# s# r },3 L; z( |0 ?; {$ `2 p
{
) r+ m- ]) D4 J4 }1 j) Z& a .active_low = 0,4 I: U+ ?/ J( p! C, F- z6 U+ R
.gpio = DA850_USER_LED3,
+ g; y4 S3 H/ l1 Y, z .name = "user_led3",
+ s% n$ ^0 Z- d; K( t$ h: n6 }/ S .default_trigger = "default-on",- M: V" C' j) G+ M9 V& ?
},) t8 ?; T# V3 A; a7 T: ?/ u
};: D+ P- R9 w+ v( }$ ^8 P9 b
) G" Y) R- ]& _) ~1 D7 @static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {' M" \: I* U$ n6 Z% p
.leds = da850_evm_tl_leds, ?7 x# I3 C+ v
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),; L4 X2 x- B' {6 d3 M6 B5 z6 `
};
6 p& v6 \9 q+ c5 g$ M, k6 W1 Y* ]2 T) o" X! Z$ p
static void led_dev_release(struct device *dev)2 Y$ i( N# |, V- g; t0 A
{
; q0 q+ R- y; m6 u};( i. S: i9 L# V. e
1 B4 j: O8 V; `' O2 Ustatic struct platform_device da850_evm_tl_leds_device = {
, g! U! p. f9 C# H I5 ~& H% g .name = "leds-gpio",
* G- z' f+ {3 _; W$ W% r .id = 1,( p4 T. F% Q) @7 q4 n
.dev = {' D* J# n4 W. O8 H! y
.platform_data = &da850_evm_tl_leds_pdata,
5 \6 F' }+ K1 t- I# u/ e1 G .release = led_dev_release,% h. o8 l6 P* q& @! }. Y
}, u" D8 Z( P' b# @; z) f. }
};! K4 i0 F+ i- P. R0 G5 A8 ]
# F) a8 U* f8 S, \; s, t' a9 V
static int __init led_platform_init(void)
% @) ^# Z- M2 _5 R$ J* |# q{4 `( j/ j" q# [- F3 e5 N/ B2 {
int ret;; ^' J9 b- b4 O* T
#if 0
5 v2 W" t' a- q ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
) C) p4 j/ C p if (ret)" B+ O* Z, c! k' a) q
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
5 I: F' t1 B' g9 ?$ q3 f) H "%d\n", ret);
8 x0 ]4 J+ G+ A/ L#endif
) H* A+ ~, X4 c" k+ T ret = platform_device_register(&da850_evm_tl_leds_device);
7 E; A+ I' i4 k* G; l) R, k if (ret)
, K% f; j7 p" S. D t4 @$ O pr_warning("Could not register som GPIO expander LEDS");
/ Z+ N, S2 _4 _3 N F else
0 H2 |2 h2 \4 P c/ h printk(KERN_INFO "LED register sucessful!\n");& w' v! N- q8 J1 u$ z
: r9 b3 q5 R- F! ]- F: e
return ret;
9 _ A1 ^+ B, Y# }8 K# @}
: p- T, t. u. i8 J* F; J5 p: T/ B( e/ L& }% P; e- p1 a
static void __exit led_platform_exit(void)
( z" r" ~& w" W6 M{
3 r o B) m: ?; k. o3 W platform_device_unregister(&da850_evm_tl_leds_device);/ R6 Z+ r% W0 Q. R5 x1 p0 M
' ], ]) n4 [9 U- g# l$ J* }% Q/ j e printk(KERN_INFO "LED unregister!\n");. s$ U T( i; m1 T# Y! K9 n
}
+ f8 D9 G; V4 s# l% C+ Q d( z' V! ^1 d4 a6 n# ]$ Q3 Q& u
module_init(led_platform_init);
- o$ J; z, q9 }* jmodule_exit(led_platform_exit);
9 [) a4 }0 Z! S: G1 I! o. m2 |% \
" R% l% k ^5 B% c9 i$ I7 W3 V( lMODULE_DESCRIPTION("Led platform driver");
/ D- N: j8 z5 n0 ?- UMODULE_AUTHOR("Tronlong");0 L4 c: e% y- z- h) J3 |) k7 Q
MODULE_LICENSE("GPL");
/ s2 U5 Z) O1 k9 {* z, Z$ W) j& f' l" }4 ?2 Q
|
|