|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
1 e1 e+ \9 D" E0 s* |& Y* A* P#include <linux/init.h>
; r* w: M g$ {, O% J. X#include <linux/module.h>
' f8 W' R1 J, G' F#include <linux/kernel.h>
9 x) ]7 m. b0 K7 _2 x$ @#include <linux/types.h>
' L+ n0 p2 a! {7 x# X#include <linux/gpio.h>
) G& y6 |- h$ |. W8 s1 o#include <linux/leds.h>6 \' b( X9 W" x3 F0 H# ~
#include <linux/platform_device.h>5 d0 ^9 d4 L: m7 X
3 f- N; H; d# D: n#include <asm/mach-types.h>
( R- q" M; U5 u! `0 s5 V H0 [0 E% S#include <asm/mach/arch.h>6 Y( d# S' |& e
#include <mach/da8xx.h>
% A! E* t: ^4 u#include <mach/mux.h> o7 E l3 |7 W# V" ^
* _0 U D# E( P
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)1 C& q# }0 C" I; i+ c( H- t! K J
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
9 r, Z/ {, Q+ n g3 c% X#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
; B. K6 c0 r8 f9 b#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)4 O1 k! t* _5 v, C! \9 l6 k
0 ?$ w/ G& L: c# J
/* assign the tl som board LED-GPIOs*/7 s* t2 K! {, [ u
static const short da850_evm_tl_user_led_pins[] = {# U2 T! q3 k7 O. x1 v2 a, S# A
/* These pins are definition at <mach/mux.h> file */
, Y5 f% A$ q/ L# a# @! L: B DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
* ~. A7 ?, Z0 H6 J -1
0 o5 w, f1 [# _6 l* f};' @" Y& R; S8 L
2 q6 T2 x; W" F
static struct gpio_led da850_evm_tl_leds[] = {
4 h1 _: V, _ h2 k) X {% |+ b( [3 y6 S2 G3 T9 I
.active_low = 0,
, }) W9 ?5 \. N .gpio = DA850_USER_LED0, q1 \$ M5 d ] E( q0 T( `
.name = "user_led0",* D8 `. T7 U6 s) B( E+ ^* k
.default_trigger = "default-on",+ A2 H0 T; f- s4 o% x
},
) ?3 {, p4 @) u. y6 V# n {
0 H$ V- Z2 A* [/ d k; d .active_low = 0,$ R2 N9 ^; J& S
.gpio = DA850_USER_LED1,4 j3 S- I% g9 L, c
.name = "user_led1",; @6 z% j w! G6 ?
.default_trigger = "default-on",) h8 @6 y, h/ j
},
- x4 r) N' K- `3 l4 `9 p6 ]# o3 c {
( c% H. w1 o& y9 V$ o! b" a .active_low = 0,
; Z$ L8 J: W4 O; w3 L# \; G' P .gpio = DA850_USER_LED2,; A) m W0 f( q" R( g) @% _0 ~
.name = "user_led2",
- o, \6 i: ?( |! | .default_trigger = "default-on",9 X1 f% P9 z6 \+ ^/ v( K ?
},2 G. X9 }. f/ t# v6 s
{- ?# e& H1 ?+ P' J4 }6 ^9 \
.active_low = 0,
& O: b& B$ n1 V$ B .gpio = DA850_USER_LED3,9 }4 b7 ~/ s/ J' V* e) R' A) W: q$ v
.name = "user_led3",
4 s) b; c( r3 k1 S .default_trigger = "default-on",
# i4 ~' Y1 l' z! ? },* K# ~6 Q6 V6 D7 B: [& O! d) r
};
, T C! r# u1 B# e$ A' ~* d" b
( @. w0 k( Q( Sstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {9 i& j, h2 U# |& Y
.leds = da850_evm_tl_leds,
+ g/ N% C8 z4 n+ m ~) }0 m .num_leds = ARRAY_SIZE(da850_evm_tl_leds),+ _8 `" h& L$ m" @: a4 D- U, _
};
, A2 \! r% d- e) ^2 \" V) c6 c* s2 H5 o
static void led_dev_release(struct device *dev)
9 x4 ]3 X; `* W{1 m9 J6 X1 M7 Y& ~
};
6 R: l% R& |6 E% q2 H7 P" ?2 F
/ S' f/ Q+ S5 }: {! Tstatic struct platform_device da850_evm_tl_leds_device = {
2 ?* D5 [2 K3 o+ w9 A .name = "leds-gpio",6 q" j. C7 u5 O9 K, S
.id = 1,; {7 X+ j* M- T+ G! a
.dev = {& t2 o" \& `! P
.platform_data = &da850_evm_tl_leds_pdata,; r7 A3 [+ V! o8 S: `% ^/ o2 \" L# n
.release = led_dev_release,
: H- R; `- w; m' o4 \3 i5 P) G }4 S: Z; P7 Y' `" E' t
};2 F% g; p* H3 Y _4 W( q: C; ^3 T0 c
! S( T1 {! u' G7 Z- e
static int __init led_platform_init(void)0 T* v" G% G: J' n
{
: W2 v0 c: ~* g! L6 {3 Y# ? int ret;! e/ [& t g) K
#if 0
6 S, R* a7 g u' W4 ^ ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);$ l- z5 T% U! ]5 T1 ]
if (ret)
# E2 b* x( ^5 I: ]$ W6 u4 [ pr_warning("da850_evm_tl_leds_init : User LED mux failed :"$ |+ `4 ]* N1 b0 |- @% J' i5 N
"%d\n", ret);2 `& J- m x9 s X F
#endif% N; \& I/ Q& ]* O% f
ret = platform_device_register(&da850_evm_tl_leds_device);
' y$ ] Q2 N0 F/ W0 z. O4 u if (ret)' s2 {+ F5 x( Z2 ]* O, S
pr_warning("Could not register som GPIO expander LEDS");: K$ S$ s) Y) w& R( {
else
4 s4 K7 n' r6 R% g printk(KERN_INFO "LED register sucessful!\n");7 g7 C# j1 O* M# S
3 ]& e7 k/ b/ M n7 d+ E) w return ret;
7 j* Q* z+ R' Y4 [! X7 E9 w}6 C8 ?+ T5 K$ y/ c& j- Z
1 z: u6 j2 L' @3 t, astatic void __exit led_platform_exit(void)
/ ?( e9 z/ @ I/ A3 S4 T5 ~{
4 X2 `1 h: g, B5 {+ q4 o platform_device_unregister(&da850_evm_tl_leds_device);4 F$ D$ N* o: l& p4 }6 \/ E6 A
7 I- T8 ~2 L3 T" O, I
printk(KERN_INFO "LED unregister!\n");
M8 A" T$ q9 |}2 G# r, H; J. b+ j- Y$ F
9 e6 y, ~+ i1 V v# f
module_init(led_platform_init);
+ g# h, ^9 O; X, {' A+ zmodule_exit(led_platform_exit);/ f& ?/ t, O+ p. {* f+ n
$ i6 `$ z3 j- m% Y2 g2 \0 h
MODULE_DESCRIPTION("Led platform driver");. U3 c; G6 X* R# P* J8 {
MODULE_AUTHOR("Tronlong");
% z3 |, B$ b/ c( F- p, c# `5 w' D' a# JMODULE_LICENSE("GPL");$ D: i! T/ P5 M- w6 y
8 Z! R% e1 w' W/ n" Q( _& B |
|