|
|
求大神给下面的程序做注解,请稍详细些,谢谢。4 p3 S9 E6 U/ Y1 x* P
#include <linux/init.h>
6 t" O& L* f2 b# P#include <linux/module.h>
6 e+ t9 x, N8 M% k# Z" ^$ E0 X% M#include <linux/kernel.h>; x4 ^- G0 j1 d8 _
#include <linux/types.h>- p/ H, x1 [0 e" b9 e4 K! _# Q, d+ U
#include <linux/gpio.h>& r1 ?* P/ r. ~" X& n5 s8 @5 M
#include <linux/leds.h>4 R9 y Z- m% S& s, U
#include <linux/platform_device.h>
. G" s# a. g, a) i) ?- c! [# h
; A- ^; C' T$ R' O1 _* X#include <asm/mach-types.h>9 |2 Z1 `. a0 L; ~
#include <asm/mach/arch.h>
$ F& N$ o. r. H& E- F#include <mach/da8xx.h>) s* A$ l$ t# u$ ~" }) p; N1 y8 l) `! J
#include <mach/mux.h># @7 _* m, B* p7 P# Z
9 C+ r1 M4 a0 K) P/ k
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)6 E& ?" j( a1 t
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)2 h; v8 R) G4 Z v1 i: r
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)) F( d3 e4 {& _2 V1 Z. n5 F g0 F
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2), v2 p- e: r7 |, V& A) W' o7 S
- m+ \: z& h% r+ q. i! |2 ]7 E
/* assign the tl som board LED-GPIOs*/
( e! t3 x2 t; {7 d( Dstatic const short da850_evm_tl_user_led_pins[] = {
; ^' @' {$ G( J3 ]6 N; g# V /* These pins are definition at <mach/mux.h> file */
" _) ~! W5 I/ P DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
. S5 q) e8 L$ B x. f& z -1
. A8 {. O- t- c7 a( j. [};
# C+ i0 P j# W g' r5 b9 ^9 G; M0 C3 U
static struct gpio_led da850_evm_tl_leds[] = {
4 V: Q5 K. i. a% g {, E! N6 R' s+ @+ T! e* G h( y
.active_low = 0,! x0 }$ q3 t; g Q6 D
.gpio = DA850_USER_LED0,
2 |9 {1 S/ w1 L& j8 d6 W$ L, l .name = "user_led0",
* y- ]& |/ ?3 J. R .default_trigger = "default-on",$ L# n6 r% H( E0 F
},
?3 B# g/ N1 F# O {
3 }8 ]5 H. N% |9 }2 W .active_low = 0,
0 h2 y* q# g. q; N9 B+ e .gpio = DA850_USER_LED1,/ K8 Y5 j6 S+ a' R; z5 J' N
.name = "user_led1",
& ~5 j d" i8 e0 D9 q% W) q .default_trigger = "default-on",
1 c3 P" Y% n I: m- h% n },
2 u, P. s/ y, p {! f- d: K7 H& e; N# ?
.active_low = 0,, w+ o" h) K3 @% l4 c
.gpio = DA850_USER_LED2,
7 G- e* i' \& o8 y5 X( V .name = "user_led2",
6 Q2 y% x1 [0 ~) L$ j- X .default_trigger = "default-on",
/ J, n" O) F2 B2 R$ l% d1 G7 c },3 ^1 @; o$ W& e# L1 n2 A! \
{, w% l( D( H* w1 ]
.active_low = 0,. t; g0 n- U2 A: y7 B+ Q' A
.gpio = DA850_USER_LED3,6 m1 @. T+ ]% v) J. Q
.name = "user_led3",
) |, u* i% y, u- ?) i .default_trigger = "default-on",
' O5 |5 s- S1 i! R j2 P },
6 ?9 a# Q* o# U# j};
& v/ }% S' |4 r# z
; f% J I$ V5 p% \static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {1 a4 o- l; i8 J4 g' \; H
.leds = da850_evm_tl_leds,$ l. \ H3 O. H5 g" j& l4 T1 j' g$ X
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),3 ^, ]+ @( g% ?& u# j
};
) ]" o# A7 Q2 S' q8 ?+ {' T1 r- @- D+ q1 `/ I0 P& f
static void led_dev_release(struct device *dev)
8 c8 x2 \ R; H) W* U/ ~) }$ g. P{* N2 ^1 a) G" r# a0 o4 ~8 u
};
; H, S; g" e' G( k
& k0 {( ?# W, {* s6 M* @2 `/ I6 ?static struct platform_device da850_evm_tl_leds_device = {
1 S' p7 I& S* J' ?, ^! Z) ~ g .name = "leds-gpio",1 O* r/ i2 Y) g7 d6 W
.id = 1,
+ f" A8 M3 D" b- ^5 ] .dev = {
]) ~& k1 z& r* ^2 t .platform_data = &da850_evm_tl_leds_pdata,
( j: e" t# G1 R$ R @9 T9 _ .release = led_dev_release,
+ N* i7 g& Q3 H }: W- ?, _6 ` @% B" R
};
; R; D' r4 q, K1 c2 G7 I" T/ n+ O( G% e
static int __init led_platform_init(void)
6 P7 i# R/ t0 ?{
5 T2 A3 L9 m9 c- ~1 L0 l int ret;
8 p V6 j, z7 Q3 g% y. U#if 0/ _# B0 H+ U0 m, ^. d
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);; [6 d. v6 @, o2 U( V' G, Y" Y
if (ret)* b5 N8 P( Z- a# Z. L p. ]" h
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
9 R! X4 x( ?% E8 j1 ~$ Z4 E "%d\n", ret);- F7 `, t7 u0 X
#endif
. \$ D4 {% d3 {$ x+ D ret = platform_device_register(&da850_evm_tl_leds_device);
2 [+ p3 ~; p7 f0 O5 s if (ret)
2 L, v1 a5 Y1 w! h9 B pr_warning("Could not register som GPIO expander LEDS");7 D. F; \5 e2 X+ ?8 G4 {# q
else5 E3 h. w; E$ k. K4 _! _ x
printk(KERN_INFO "LED register sucessful!\n");
/ G5 M$ N" k* |: `0 j3 J, y1 n' F5 y/ X) z7 q
return ret;/ @+ d9 \ ~% V5 b
}) @4 A) C; `3 x& g" x( O8 y' h, ?9 ]. l
1 k, ~& a0 B+ b# R7 e' Astatic void __exit led_platform_exit(void): W! u% e0 L: G+ V0 a4 h* x6 D( G4 V0 g
{ L2 w" l- n M3 }, i1 S
platform_device_unregister(&da850_evm_tl_leds_device);) k4 G3 }+ E) J5 [
% ]) t% M" E$ u Z- B printk(KERN_INFO "LED unregister!\n");
6 F. {( B" n3 L1 e5 z; }) G6 c}4 S" w3 Q) u( g8 J" v ~
: ~9 b% [) J0 [
module_init(led_platform_init);
4 M4 ^1 q0 u; i7 ~" lmodule_exit(led_platform_exit);/ n5 w4 J/ `, i) l+ h
0 o- `/ [ U) z" K3 `MODULE_DESCRIPTION("Led platform driver");
, I5 `: D- T3 y+ J- {MODULE_AUTHOR("Tronlong");4 n" w; v# ]" l% a9 ]2 l* q% P
MODULE_LICENSE("GPL");& @' A' v! X/ B3 c7 u( n
" l) [, c1 D' a" r+ x
|
|