|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
9 U( t, u# F) T7 p: @6 T# |: p#include <linux/init.h>. z/ z+ t! W0 F$ F
#include <linux/module.h>$ S: q! D g' W; P- I
#include <linux/kernel.h>% @( u# \- y( o% I4 `
#include <linux/types.h>; x2 ?6 ]( r+ M6 g5 ?5 t8 `
#include <linux/gpio.h>4 T1 b. T; t" b3 z
#include <linux/leds.h>! m" V) H/ j3 R P0 V9 I
#include <linux/platform_device.h>' A: f% V& S9 C) n" A- I1 K8 X- t8 P
h$ f) N, N7 G5 j/ o9 A; u#include <asm/mach-types.h>, u( W9 b, b3 e, v$ `. C7 B
#include <asm/mach/arch.h>
6 V* O3 x" W4 \#include <mach/da8xx.h>, c: a, q& i3 Z/ L- y) W
#include <mach/mux.h>8 I' R- s. Q& S1 h2 H7 R/ Z, ~
3 w9 f0 Z z2 p% c#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)" {% J# ~7 y& z$ j1 M9 [
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5) b& }! y' s4 a4 n
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
5 f* Q. g& C+ v5 m2 I4 U( z#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
! k! d& M! v8 Z7 `+ N2 V8 D
1 \' o) L! E+ H7 m) w9 F/* assign the tl som board LED-GPIOs*/
$ L. d; J, k% C z: _static const short da850_evm_tl_user_led_pins[] = {
% X: r2 K# l @5 P g6 H4 H /* These pins are definition at <mach/mux.h> file */
. u+ X7 K% V+ M! z; Y7 ` DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
4 p' j7 [! D! s5 z1 N1 X0 [# W, ^* |+ D -1/ {& e: }0 v% \5 a3 S! E5 S! x
};
$ l V3 {, {" c% \3 Z8 G6 S; {& a& M/ m1 c8 y. i* t7 L: v. g( ~( w
static struct gpio_led da850_evm_tl_leds[] = {3 n. x8 \& d( `* g& z* O+ n8 h6 G
{
$ H& B1 D: s# A3 \/ U. p4 p+ ?3 X: k .active_low = 0,
* ~" Y. l' c- ~# x) u7 U x .gpio = DA850_USER_LED0,: T5 Z4 v' a* d' H0 q+ T9 R
.name = "user_led0",
3 |9 g0 d# o1 i& z* B$ `+ {7 a$ }- A .default_trigger = "default-on",
# J. s+ e8 E+ c2 C7 L },; j0 ]! {/ a" { a3 D
{
2 Y# A8 }8 ^# f z2 } .active_low = 0,
U5 E$ U/ S3 S8 w .gpio = DA850_USER_LED1,- k/ R6 X: s3 V& ?) _! a4 r5 q0 G, z; Z
.name = "user_led1",) H+ o0 [. t9 z/ b0 ]
.default_trigger = "default-on",
$ T7 m* }8 _4 ^* R& X6 A },
' N0 A8 W4 i7 k {, Z# G4 f7 Q/ f
.active_low = 0,
0 a* c4 r+ h' e3 a .gpio = DA850_USER_LED2,8 K" i" ^5 e) z
.name = "user_led2",+ C3 R, o! b) b
.default_trigger = "default-on",5 Q/ g" o1 \8 {/ s* a! I
},# p6 z1 [+ ^# ]+ n
{
9 k- Z. p( w4 ]( W' ] .active_low = 0,
/ B( n# o; D, U* G% D0 v( ? .gpio = DA850_USER_LED3,' ^- z, u2 K N/ L9 ?# Q2 i: G
.name = "user_led3",& E7 [- e2 n* j$ Z4 S" P7 a8 O
.default_trigger = "default-on",% Z5 r1 ?& Y$ v' r6 |
},& ^" n$ p( m( {- j1 k. ^! N, J
};
; l8 V# k% s- W. }% e e
; e. X/ F/ q7 `static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
- `) G$ a M' l+ ? .leds = da850_evm_tl_leds,, {0 c3 b4 W9 P
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),. Y5 s+ ?6 m3 [6 A
};
" R2 o& `+ S, l7 i" |2 ~% G4 @1 S$ t/ f. J' N* S. J' C
static void led_dev_release(struct device *dev)( l: [5 j8 k/ _- y, x
{' G9 l" n$ _. O- f
};
/ e% t7 M2 K& O6 Q# \' h _4 g3 O3 e& w
static struct platform_device da850_evm_tl_leds_device = {
0 ^% Q- `3 C# U8 u, F .name = "leds-gpio",
4 S8 G' k% P( x* T- A .id = 1,! Y- T C* J) U8 |) B$ S" L
.dev = {& C+ G5 {) W6 O" I& q# |' M- u3 Y
.platform_data = &da850_evm_tl_leds_pdata,
: @& | T# ^- a; } .release = led_dev_release,1 U p2 @( R. k# x! T7 g
}8 a8 @% h' F1 g( E+ P
};
$ m* X/ {5 [9 D6 Q7 A K; a3 V5 v. C* k; G) e
static int __init led_platform_init(void)
/ m6 c& r0 g% I' G. q) u{$ q: @1 u5 g3 P% ?9 `7 |: n
int ret;* B6 k$ d& f5 f' u* a/ O4 ]. ~2 P
#if 0
7 h0 [2 A, W# d# u. L+ n7 u ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
6 `0 F9 m- A/ E1 `! c( X/ ` if (ret)
8 D2 }" X3 f4 M# Z/ ]* {5 z) d pr_warning("da850_evm_tl_leds_init : User LED mux failed :"! q4 E: e |3 q+ o2 J8 M- M
"%d\n", ret);8 w2 R! b s' ~# p4 Z/ k
#endif
. e$ U8 |* z @% l# |* z4 n ret = platform_device_register(&da850_evm_tl_leds_device);% j* l8 m+ l/ U2 D, G# z1 l
if (ret)5 q* x9 I* H9 d1 d
pr_warning("Could not register som GPIO expander LEDS");, Y) p% X- P" J/ C% B2 p; F* y
else/ p9 `8 A ~" h7 m: L
printk(KERN_INFO "LED register sucessful!\n");
! J) ]1 S2 O/ k, b/ {1 O" L% H. E4 p. y5 j5 Q! z! s
return ret;" Y- H! s0 i- l$ K( y
} a( n: l) Q4 T# r4 \7 x* w8 S U
' A) \6 i4 [) E* y, o8 q# Y: K. qstatic void __exit led_platform_exit(void)
( g2 } V: |/ o0 o2 |) @ L9 ?{$ O/ y0 J7 x' [3 ]6 K8 i# b% t
platform_device_unregister(&da850_evm_tl_leds_device);% d) H& a1 Z+ n5 |
8 c" f2 M3 Q7 ?$ {8 U$ y
printk(KERN_INFO "LED unregister!\n");! p- a3 P0 k* j0 B9 e5 K
}
9 P/ W' x- D: _6 n" _
8 Y( e; }# p! d( o( Hmodule_init(led_platform_init);; Q. E8 q2 V1 S! q
module_exit(led_platform_exit);
& ?6 ^2 M: K- J8 G1 Y# I4 p. M H1 q3 `0 l! r, m5 x
MODULE_DESCRIPTION("Led platform driver");
2 H; X/ w* ~+ D) q& mMODULE_AUTHOR("Tronlong");: S% l% f/ P, E: w" P: `: ?( p
MODULE_LICENSE("GPL");
' J- q& b' L( k8 g; n+ ^, Q# _! A/ i0 [; C$ N+ v( F" D
|
|