|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
o6 R1 b9 [ c3 E! @#include <linux/init.h>7 j: o6 ]4 R; t4 L) b
#include <linux/module.h>% }1 b1 B7 g5 e1 ?+ L. y
#include <linux/kernel.h>
4 x. i' y* W, Y5 S3 k; N6 U#include <linux/types.h>* @# Y) ~! B9 G7 X( @
#include <linux/gpio.h>
* d- j) B( I. _4 w#include <linux/leds.h>. H- Q* Z$ B2 X7 t( H
#include <linux/platform_device.h>
6 F9 k( C$ G" P; X) Q
- T; f& y; C0 Q* h#include <asm/mach-types.h>) Q: K7 ~+ u/ @' t" A. d4 G
#include <asm/mach/arch.h>6 l0 H& B. d; j. ~8 G9 ?
#include <mach/da8xx.h>
6 ]4 _ P0 h+ n6 S8 ^2 M/ [#include <mach/mux.h>0 C2 J, W5 L. H) a: z
, i( R4 e6 ]1 \, V
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)" V2 b) \1 I* D7 g; {
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)& K8 _6 C# I% ?- M8 L, ]" j
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)9 f' g }* @$ S* [) W% L
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
5 Q. ^0 {. \( b- L. r8 }% [( ^. U# j5 X( U+ A' a0 D
/* assign the tl som board LED-GPIOs*/
0 `0 M q! q7 x# ?# O7 Gstatic const short da850_evm_tl_user_led_pins[] = {* Y8 y! c: I G# ^8 `0 L8 M. t7 J- r5 M+ Z
/* These pins are definition at <mach/mux.h> file */
% ^" N a* B! ~8 r3 @ DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
: c8 ~: e: {2 O/ W" A2 a, N -18 l2 W5 t' _+ i, H$ m `
};
* I; m! w3 ~/ j, C; h
6 d) S2 ^; @& \0 }static struct gpio_led da850_evm_tl_leds[] = {+ Z$ n2 Z! T! s8 x9 [$ w
{
* ?" P" e5 \! v+ V5 L .active_low = 0,
[9 @4 @! S" U1 g6 _& w7 _ .gpio = DA850_USER_LED0,
5 I5 {$ m7 Q! J8 n' K .name = "user_led0",' c( X" ]2 y0 `2 m; x: _' G* \# n& D
.default_trigger = "default-on",/ d1 R" h! J( M5 Q/ X
},. V6 A" t& c. N& o6 w, k
{
3 w: ~; l- c8 ?& J7 J' u .active_low = 0,
5 l, T. |) F2 Y. ~* h# i# y0 E .gpio = DA850_USER_LED1,
& o* w( T- I* P7 M$ w5 D! h .name = "user_led1",8 y. \- b+ z8 }
.default_trigger = "default-on",
( ~- N/ t. t, G0 f },3 ?3 ~$ _5 r, t$ p: m3 g% o
{
' ~! U6 z% h2 R# S9 Z# ^7 `( X$ N .active_low = 0,. E3 _4 T- o" u( Y7 ]9 v' r, y
.gpio = DA850_USER_LED2,
v5 @% A3 c% n' p .name = "user_led2",
3 t6 g9 b. _8 I3 A2 A .default_trigger = "default-on",
: H& S% I% S |- N8 z/ @ },$ v! j( q: t x5 d4 }6 |/ Q
{- U' j. P! v6 c' B$ U
.active_low = 0,. L k6 F* G1 K
.gpio = DA850_USER_LED3,! U- W4 f& Q- @/ x6 o
.name = "user_led3",: F% E* T7 K6 t
.default_trigger = "default-on",7 P* b- S- X7 K+ e/ z+ s
},
0 [8 |2 }( q; G! f% H$ I};6 ~* d4 L8 }+ B- U
7 _4 ~% D& N! C/ I
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
! P- W2 v, d. }1 L3 Z .leds = da850_evm_tl_leds,& u3 Y) ]5 u! G
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),
7 A0 y* K2 M( @% M};- A1 o- k: F: Z) ]
( i7 V' y* [; p0 C: z1 ?& M' U
static void led_dev_release(struct device *dev)# Q; A" r! a* |! b& b7 n8 f |& U
{3 x8 W) @. {- n
};
* t/ q6 S# W+ ]4 d6 c$ C- G4 `
1 C( x# i7 y, Z3 ?+ j% h$ Lstatic struct platform_device da850_evm_tl_leds_device = {
6 K% \& J5 H8 j! Q7 f .name = "leds-gpio",1 W, f3 Q7 [+ n4 k" j5 |
.id = 1,
! @! ^, y6 U% w' ] .dev = {
7 p5 l0 f+ y2 t3 M+ V5 n; d .platform_data = &da850_evm_tl_leds_pdata,
0 U7 w1 e. C5 ]; ~: r .release = led_dev_release,5 K, j5 G% S2 r) p/ Y! i7 _* a
}
3 B4 N9 i, T" U9 y};4 n9 ^ ~$ Y+ ?! x
: I- U2 h0 h" P ]1 S# W
static int __init led_platform_init(void)6 q* }# c) k1 U4 L. k3 b
{
- b9 A# ]) }1 X int ret;2 r+ z9 c J% |0 W7 y
#if 08 A* i) v2 T; k D Q
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
$ d+ W" ]$ K7 x: R% R3 X. v& J if (ret)+ o3 q; W$ r) f+ i8 J& C1 X* z
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
$ o" V. ]2 e0 Y "%d\n", ret);/ M$ g: ?% ^3 L# K: H4 Q; o
#endif
" S$ @& K4 U! a ret = platform_device_register(&da850_evm_tl_leds_device); f0 O! ?8 E. \$ i" u
if (ret)2 d0 n8 S' Z9 |, B9 W
pr_warning("Could not register som GPIO expander LEDS");
6 ?6 i1 U, G/ ~9 k else/ e# V) R1 }- j+ G) k
printk(KERN_INFO "LED register sucessful!\n");
' p" o3 z! P9 K' x, P+ W' g* I) B
0 j( H2 u; n2 u9 I) ~ return ret;
# ~5 Y# N3 O" Y: Y' E, p}2 H: v( M) I: d! {# h
- z9 D9 k# R. \( b9 S6 Ostatic void __exit led_platform_exit(void)
) c- o+ ^8 C. C( i# N. N{: v: M1 x% r: @4 ^+ m
platform_device_unregister(&da850_evm_tl_leds_device);
% A4 [9 Z$ ]: T' C0 o
1 H. g1 Q. V5 u7 K+ S; ? printk(KERN_INFO "LED unregister!\n");
+ z9 L! r( K; K# I; g, |}+ b' @! x( Z! a* h3 r& R
# I: D1 S* B; Bmodule_init(led_platform_init);
" }' B0 C2 N7 |3 R6 Mmodule_exit(led_platform_exit);
5 q# N+ j, r% v) x& Y' E+ ~7 d: \& G% ]/ s4 M: A
MODULE_DESCRIPTION("Led platform driver");
9 @, J1 R' x4 o1 P tMODULE_AUTHOR("Tronlong");4 Q% z3 m/ `* A8 l' \
MODULE_LICENSE("GPL");
6 R" n( \) }9 e3 ~
* f) {3 Q1 k+ F |
|