|
|
求大神给下面的程序做注解,请稍详细些,谢谢。& h) H) H) J1 s9 J/ l# H: x; Z
#include <linux/init.h>
* T6 G* a- w: p; D3 @9 D#include <linux/module.h>
7 c* h% W" l( r1 V: N" R#include <linux/kernel.h>) H6 u, t- B+ C+ X7 S2 f
#include <linux/types.h>
. ~ d% h8 M/ e4 P" T+ ]" ]#include <linux/gpio.h>
1 T$ g! K3 O9 | C0 ~( |#include <linux/leds.h>
0 U; W V. M0 q#include <linux/platform_device.h>
' T6 J [; N6 \* u- _8 f
3 O" [3 F. I0 z. K! H+ f#include <asm/mach-types.h>6 |+ D9 H: S2 |$ o* I0 s# C7 N8 ?
#include <asm/mach/arch.h>7 n5 k( A% ]7 i- J7 Q
#include <mach/da8xx.h>
& c, U( O* x( G! d#include <mach/mux.h>
2 _# }. }1 b5 ?) k% ]5 N, @
N) o, g4 S( A3 L: U) w#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
6 v [3 n3 [3 p# M#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)! [6 y' U1 c* m& C9 p
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)$ {/ |3 ^1 ?! I- M. [ w" i" J" l
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)4 B# o1 I c0 H. S% ]
6 m4 {: L; O9 m, M; a" F2 R
/* assign the tl som board LED-GPIOs*/) A( G$ A' n. d8 n5 T5 K$ `7 ]7 K
static const short da850_evm_tl_user_led_pins[] = {5 Y; k+ R5 b+ D0 |: e
/* These pins are definition at <mach/mux.h> file */
9 z! y2 P R0 @) K8 L DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
" ]7 P$ \7 x" V/ ]8 |' Q -1
$ O$ _4 P+ ~% @/ B% d$ r, ?};
k7 J0 T4 t) O& h5 x7 w# V2 f, `: y9 g
static struct gpio_led da850_evm_tl_leds[] = {
7 O* r# l/ R y {/ Y6 u; k4 N- G
.active_low = 0,( p/ Z% j G! W+ q! r
.gpio = DA850_USER_LED0,
4 x! L9 e8 o# b& T8 S .name = "user_led0",2 f% K0 E! G" B7 i/ b. P" d+ b+ X9 q
.default_trigger = "default-on",
0 i9 @4 ~* ~5 m+ _; ` },
' S' p+ w# l. k. g1 } {6 p# ~$ l8 R4 N* @& v
.active_low = 0,9 k: o9 b- V* R' ~- E4 M
.gpio = DA850_USER_LED1,& ~2 z# A) x& k* U- D2 o: t& g
.name = "user_led1",- q. U, L1 U7 K* B
.default_trigger = "default-on",
8 m7 R) V5 Q8 C$ H }, @4 R+ C7 G6 X/ j
{' Q( j# Z, ?3 x8 k1 ~
.active_low = 0,
e8 ~/ F: z$ |+ s7 V* q .gpio = DA850_USER_LED2,
2 K# j% u/ U9 h# I .name = "user_led2",6 g- u9 |) p3 \& R/ i! [
.default_trigger = "default-on",: x. Q9 `; r; m' G( }: ~" t* _
},
0 x& J/ I; |; B) B$ r: _7 x {& S- }. V% a3 A; D* j) s
.active_low = 0,; I0 i2 n. o3 f% x! J9 x/ p4 ]
.gpio = DA850_USER_LED3,7 e0 k7 T$ Y- @% S) j" K1 p
.name = "user_led3",
# f8 n' K, z+ q .default_trigger = "default-on",
( i3 u! `0 ^# p3 \+ A4 r' z L( C },/ O @. A& k) H2 a7 L; r
};8 \7 j: A. \1 ~* g5 H& i) Y. q9 n
8 _9 o: |, n6 C. ^static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
& j/ e/ l8 h6 ^% r; c .leds = da850_evm_tl_leds,
8 H5 B$ `' k+ v; d( `& { .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
' F Q) u! W" ^( |" O8 K};; f# \! t) d1 x p& }3 l4 f
- f, A5 s4 `6 _8 q
static void led_dev_release(struct device *dev)% n7 j+ U* E) {5 `
{
3 O4 E( r5 n5 v6 @" Q( ?6 I5 [( o. Z};! o& K- j: p3 ~+ }, U% k
. ]1 `7 O" \! p9 V. l) Q1 Jstatic struct platform_device da850_evm_tl_leds_device = {/ I$ D/ p' U) k3 ^) s3 z
.name = "leds-gpio",6 I6 ^) N3 ]- {' G4 W
.id = 1,5 m! Y: D }/ M( X9 p2 @: s
.dev = {8 \. a* w3 D/ F# Z3 ^0 u
.platform_data = &da850_evm_tl_leds_pdata, s; Y) u* U' K n& A: k
.release = led_dev_release,, A+ c+ p8 E- j; C' l8 c( P; B
}7 z. c# t; _6 C$ r- g
};# U) W/ _9 z: D A: q4 U
P) @+ }3 x3 m9 t$ ^8 b4 g# Ystatic int __init led_platform_init(void)' K/ K$ r% @. y/ g) O6 A# W
{' W- ~% Z1 `6 S3 @9 E( r7 Y3 C
int ret;
, i9 Y' N' g s2 w4 ?#if 09 ]+ l$ q7 D, B- ^) E, W
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
/ u% f+ j, Q. z' m/ k, R if (ret)
/ S" o1 Y/ g: s2 _+ B pr_warning("da850_evm_tl_leds_init : User LED mux failed :"& q! I$ }" t# ]+ p
"%d\n", ret);2 `! ?9 |# n+ a2 Z2 Q: B
#endif; @. ~/ h4 g; \5 A& O' x& J0 ~( L
ret = platform_device_register(&da850_evm_tl_leds_device);
1 Q0 G* D! K4 x6 x- Z if (ret)- s' h) Z! D, g$ v+ Y+ q0 S
pr_warning("Could not register som GPIO expander LEDS");
! ^& `: P( v2 B, w( h else
2 T) }1 p9 ?4 B* D0 v printk(KERN_INFO "LED register sucessful!\n");
4 n0 \$ W! O0 r( F' p4 E! F# X, d9 M
return ret;/ d: V9 c' S* ^3 B' h$ ~- b# T
}, q2 G+ {4 q+ t+ _
9 ~2 L3 i# \! h F0 h3 J6 {
static void __exit led_platform_exit(void)! e* `9 ?0 h+ W7 n
{
3 H' @+ E! `8 ^7 p" ^2 w platform_device_unregister(&da850_evm_tl_leds_device);
3 T- ?3 j$ g; e: [3 z7 e
/ l2 T3 b y# @. m$ e printk(KERN_INFO "LED unregister!\n");
# f2 A4 `8 {2 L5 \}; A4 C7 o' x3 w9 S% x* H
" J% O. e* D, e
module_init(led_platform_init);
. h% [6 O0 n/ u% Amodule_exit(led_platform_exit);
$ ~( Y- n& s- d$ O) V+ Q$ Z/ r
8 D2 G* R7 k: Q/ {' S$ w9 d3 ]MODULE_DESCRIPTION("Led platform driver");
+ c: [8 V2 f2 O z. r6 bMODULE_AUTHOR("Tronlong");
2 Y& y% c8 s8 j0 S( h6 zMODULE_LICENSE("GPL");
9 e# y$ j* U+ `. q/ p: W, A d6 b4 a' ]" E( `
|
|