|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
( o' y: p, Z N, E#include <linux/init.h>2 y: T/ X8 j8 t3 o/ r8 Z
#include <linux/module.h>
6 i, E( [; j! d( a- r( I7 m2 ?#include <linux/kernel.h> a3 f; R, _3 S
#include <linux/types.h>
0 U' j7 `7 x" I9 o S `( }#include <linux/gpio.h>
4 P2 o+ g; d3 t7 l#include <linux/leds.h>
3 W B- q0 n( z#include <linux/platform_device.h>9 K S& }/ w) U5 d6 q5 o
! b2 `" B. b" j! T' X
#include <asm/mach-types.h>8 c; p& ~* k }+ H, ^' Y/ p
#include <asm/mach/arch.h>; J# G2 L* x2 |; ?$ G* m
#include <mach/da8xx.h>
, d: L3 u0 ]3 o7 I7 }#include <mach/mux.h>
5 Z: y7 H9 v& W) a" |( }8 w
3 Z8 @4 M t P9 e y6 l- `#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)5 L+ D# D! J' J! h6 V
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
9 k7 @0 Z. f) O0 t" _8 b/ S% g, f# b, W#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
; g2 I8 Q8 b. a# F7 v- \4 z# g6 @#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
' ]6 B' d6 c }" m( y! C/ ?) b" I f4 }. s1 F0 A/ a% _0 G
/* assign the tl som board LED-GPIOs*/
4 {" b, J3 R3 xstatic const short da850_evm_tl_user_led_pins[] = {0 f2 ] }# M9 T" V1 Q5 b# J
/* These pins are definition at <mach/mux.h> file */; P) w% s: l( ]1 a" g/ I+ @
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
6 f5 v. d1 b& C" }' a) X/ M -1
% n9 | M7 t' W D, h, n$ t. \& H};
* Y$ q) M7 c1 r5 K! q+ U' h6 b: u# y* ~$ K1 _5 B, U
static struct gpio_led da850_evm_tl_leds[] = {
# Q! c" a2 E! A8 P9 i {
+ A1 y8 @8 m4 m .active_low = 0,
+ h; O# @ s2 A+ \6 {% C .gpio = DA850_USER_LED0,# o& J2 \1 T+ S) J" g% s( b/ d
.name = "user_led0",
# x: d: j; x- ^, o# H .default_trigger = "default-on",
& t# z1 E r9 I' j; K, O& @ },
1 \: Q# n* b% k' `& I4 g |" d {
& l, e9 C Q4 P6 G .active_low = 0,
& }, v1 O9 M+ r6 @, v .gpio = DA850_USER_LED1,
. v! c9 t a, {- ~1 k# ] .name = "user_led1",1 O* K( V3 K: {( l4 Q
.default_trigger = "default-on",
/ g5 p2 [4 c y$ X2 ] },
1 K9 l# N0 i: \5 l- c {
+ G. g8 n& p! U1 Z% L' ?! h .active_low = 0,- C* q2 J& b! R' b9 Z" \# X
.gpio = DA850_USER_LED2,
7 M3 Q) R0 A @7 z .name = "user_led2",
1 P4 x: @: T; [ R( r K( N) ` .default_trigger = "default-on",
. E; ]9 ]5 C" s" `) _ },
+ a! m* V- ~! K% D6 O, R {
7 V( {4 U" d; K .active_low = 0,! u- x5 S1 }$ N: |$ [
.gpio = DA850_USER_LED3,/ ?3 a/ e4 G+ y% J" [" u$ ]* j6 z* z( S) E
.name = "user_led3",
6 [- M+ S0 `% U: M7 z .default_trigger = "default-on",
$ {" h4 H1 J x7 M },
% j& m2 k4 `8 q N, D9 t};& l9 L3 _0 c( c' n
/ q3 u7 Z/ H$ H- {8 ~
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
; ~5 m- \9 X& x; p4 l6 | .leds = da850_evm_tl_leds,. }% v5 V# M. P3 C
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),
! u% j# r# u+ V' w' Z};6 e, ?0 z9 s9 e9 i
R1 o2 v; g0 C+ o
static void led_dev_release(struct device *dev)
1 C8 N6 c" ?9 v9 _0 M8 P{3 r) `( q8 W% M
};% L( b' z' }* J: A4 G0 ^6 T
7 ~0 E. ]& [# o# C h. g3 ~
static struct platform_device da850_evm_tl_leds_device = {
5 \$ a5 C, `3 }" u0 V7 l .name = "leds-gpio",4 v( [4 `$ }$ J0 A- O4 F x
.id = 1,* F6 L2 g/ e" G! b- B9 f
.dev = {% T8 M4 ~+ @% `; N* A& y
.platform_data = &da850_evm_tl_leds_pdata,
2 i8 b, ^+ W8 V: j9 | .release = led_dev_release,1 v2 |/ V- L- W5 G# g8 b
}
! |6 R2 z4 T5 |! @/ Z% {+ p};( q* n5 q! |5 f [2 X Z. X
1 z1 z g+ P. L W1 F2 z1 x
static int __init led_platform_init(void)
A/ f% S& z0 b& H) k{% i( R/ d/ F, ?/ n2 o
int ret;) t4 ~3 f+ k0 a- L6 G& Q H8 ^$ N* y
#if 0
" A8 ^1 v" W7 w4 @$ }1 t ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins); P& \$ O( ^% m4 C2 D, F9 h r
if (ret): S" [# M5 s/ `4 `9 e; V
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
* C1 e+ b( S! a9 D7 y "%d\n", ret);- I$ G# K/ x ]& ], x5 y0 T" M
#endif, F2 [* A. b" u$ P0 Z2 ?: F
ret = platform_device_register(&da850_evm_tl_leds_device);% L. s; h$ @* W( {5 [% x3 F: q
if (ret)- t. Q; ]& n V8 ?9 u
pr_warning("Could not register som GPIO expander LEDS");+ v! }' `- R7 z4 o9 n7 l$ H7 |7 m# {
else
8 D3 T7 y2 ]6 q" i( | printk(KERN_INFO "LED register sucessful!\n");
: c. o. h6 l6 n/ I) J/ E& V' Y2 {' U5 r: S7 h
return ret;% F& b) ]& K8 g
}
5 m5 \2 H/ O9 H3 g1 \) O% F( n' d% }: W, @9 r0 I5 }
static void __exit led_platform_exit(void)9 t* N; }- o7 e
{
7 n3 T9 c; v M: q platform_device_unregister(&da850_evm_tl_leds_device);
1 G$ z b7 d- i) \' N) [5 P2 s4 p
. n. D7 v' y7 }. B printk(KERN_INFO "LED unregister!\n");
) ~& P7 J" ~8 r/ ]}5 k% L, N8 L6 `% W* |
$ K! L" _ ^1 A8 \! s
module_init(led_platform_init);$ q- D X3 z5 q7 ]6 {9 K' ]) A# C
module_exit(led_platform_exit);
2 C4 w. K* Z3 Q: l
8 {! ^; U9 Q" |* T) ~' ^' W. NMODULE_DESCRIPTION("Led platform driver");' Q2 z- o& _+ R1 |. Y
MODULE_AUTHOR("Tronlong");
. s) B4 x' L6 M$ n1 hMODULE_LICENSE("GPL");8 C7 I5 d; S2 p
8 X6 t! Q% }# l/ G+ _
|
|