|
|
求大神给下面的程序做注解,请稍详细些,谢谢。% }% y8 s4 B7 m+ X0 y3 ]
#include <linux/init.h>
/ v, M% y( C t2 ~4 {/ E1 V6 S#include <linux/module.h>
! K$ Z- S: Z9 O7 b#include <linux/kernel.h>
" @; W0 b2 ]% S* C2 F#include <linux/types.h>8 S# O" N. \& c; C, ]
#include <linux/gpio.h>; Y7 b( ~* Z) a0 p2 G0 G
#include <linux/leds.h>& D' ^; y; V7 G5 K! X$ T( z
#include <linux/platform_device.h>$ l+ ~3 L0 J0 |- u1 p' j K9 W
! N1 B+ `" ?; Z/ L9 f: \#include <asm/mach-types.h>
8 j3 p+ K8 n, R9 `# d( Z" }5 l4 x#include <asm/mach/arch.h>
! o' r, [( W# Y, T, ~ k#include <mach/da8xx.h>1 u; ~0 ?9 ]; b( Y
#include <mach/mux.h>
7 A- @5 `7 B: V9 O& @5 \+ f# v0 j0 u
9 k* Y- l; p: z6 A5 r _! g#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)9 [& t+ b9 ]+ t8 [, D8 d7 J. Y
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)9 ]! d2 `9 f. x7 T
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)2 J/ I* y% F. C9 V
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)% @( _; u5 }" q! ^4 {
2 k) b+ i/ S1 }! y& C1 V( ^
/* assign the tl som board LED-GPIOs*/0 o6 b$ ?7 z3 S% {, D7 l
static const short da850_evm_tl_user_led_pins[] = {* S7 S$ Z Y. q. r9 r/ K
/* These pins are definition at <mach/mux.h> file */& F$ w. T3 g2 [( N* T, i
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
/ d5 M. Q( b, V( c! K0 j -1( o4 F3 K$ L+ K4 i6 p. k0 P
};
% ?) b6 J% N5 C) D% Y
# y: ~6 z' h" T+ Sstatic struct gpio_led da850_evm_tl_leds[] = {
9 N8 h* G# R0 z$ y7 |3 a- M; o2 l2 _ {
/ L N0 b# S1 E, `( R1 z: } .active_low = 0,
; H0 M2 V5 M! }: _7 ^ .gpio = DA850_USER_LED0,, a; x" v1 c# }2 f. h* U- o- h9 g
.name = "user_led0",
& S7 @# r& c- @: ~: P, L# P9 ~& C; M .default_trigger = "default-on",
- i7 I0 s r: D$ p9 W* A" ?% `6 z+ F },
) e: @! F! x2 f& D6 a& M V {& k; ]5 n# b: o
.active_low = 0,8 n( E, W9 c h% P6 P4 d- c
.gpio = DA850_USER_LED1,
* S( {$ X$ q' z+ ]: L' Y8 Q9 W .name = "user_led1",
- |6 r* r2 p2 p( @) v# X .default_trigger = "default-on",) \! Y9 X, d+ I, D8 l
},
% \. g# ^. ?" }" I8 Q& E* c0 Z {( c( N! H$ i) w" y" a
.active_low = 0,
0 ~/ F# l/ q3 L8 I .gpio = DA850_USER_LED2,
* B. U2 o/ p% D! _4 O- P6 H .name = "user_led2",& O3 Q1 U/ H1 D3 q) D
.default_trigger = "default-on",4 ^, h9 t" G% O
},& F7 s1 l# T0 A, w/ A) u T3 P8 k
{
, w" b9 |$ {7 ]0 S4 M& H6 X .active_low = 0,
: K3 L5 t- P+ d- d0 b .gpio = DA850_USER_LED3,2 k) e' K1 ?1 U; U w" {
.name = "user_led3",, ~- t% |" R2 Y
.default_trigger = "default-on",
% ~* e) J" L5 X# O" y: c },
* [9 D+ }6 P8 g) ^ f+ K8 D};
- N2 {1 k# K! b0 N6 x" ~! E5 e1 H6 {
5 H# U" G7 M3 h! A0 Z, C: Dstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
) D2 g6 l0 m" h1 } .leds = da850_evm_tl_leds,
' p8 V- G. Z! r X9 d .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
# H1 h% f1 w' s6 `4 }. |/ M};& v$ e& Z+ ^# q0 A" E
! ?+ o5 W z- h, W, N0 o/ t
static void led_dev_release(struct device *dev)
* d/ j8 Z% i1 e, [4 @ K8 b{5 Z& X0 {! I/ B( W+ J) q3 t9 S
};2 K* l0 @( v$ E5 s
2 d7 d1 c3 h0 }; d8 zstatic struct platform_device da850_evm_tl_leds_device = {0 Z4 a% x5 a5 V6 t$ z1 l- o
.name = "leds-gpio",
7 V& P p( @9 I4 }, p# W+ D .id = 1,+ j5 `+ Z/ ~: q4 e
.dev = {
* y- }) f7 w: @9 t. t8 F .platform_data = &da850_evm_tl_leds_pdata,9 ~; M& c2 b4 S& q5 K/ ?" k" o
.release = led_dev_release,/ t5 K. k, M5 D6 u, m+ S# a p
}5 }, L9 A# Y$ l7 h! Y l5 I
};
( Z" X* t. ?3 [1 h/ D
" |1 d9 u# O' z0 W _static int __init led_platform_init(void)
: F9 M1 S- d6 I7 E0 {# J$ q{
! ` E- Q3 ] ` int ret;& B" M/ j1 Y6 a1 f
#if 0
' @- P. N" ]4 P/ A9 O& P5 m5 s ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
9 S3 q3 R/ b( I5 l1 e% h: n# n0 c. Y if (ret)
1 c! K% s4 r7 X4 b+ ]) N0 h+ f pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
7 U: x; B' y8 D% m3 E "%d\n", ret);7 Z5 Q! s; L8 W5 r1 B3 S# G$ l
#endif
1 W2 {5 Y7 J5 N5 D/ M- Q+ ? ret = platform_device_register(&da850_evm_tl_leds_device);" f3 s" u8 w9 a
if (ret): Z+ Q# j( S8 ?- O2 F4 h6 z
pr_warning("Could not register som GPIO expander LEDS");7 _ _3 e4 H) y6 ?
else
, d; v/ k7 ?; a printk(KERN_INFO "LED register sucessful!\n");
' z' g1 Z+ j. ]# w! o# {4 d& y! m! O$ K4 D# Y6 [
return ret;
5 K, D6 M+ n. u) U1 u4 W; s% r' l}4 T; v3 ~$ |( V9 P$ ^2 K
" u: a% v' l" a; e; P( jstatic void __exit led_platform_exit(void)7 ^; s/ Y ]" q# Q) I
{6 }9 L& p. e% l7 e
platform_device_unregister(&da850_evm_tl_leds_device);
' r- ~+ `" u/ b4 Y9 E" O; B) |! r
+ r% H' ?; x" j* U0 K. B printk(KERN_INFO "LED unregister!\n");
8 D: x h2 r( I" Y* Y}. A; K3 `8 @& J# E# `/ O
* C: j$ i) l" O. omodule_init(led_platform_init);
# w4 \( x& T2 a$ U5 I/ I bmodule_exit(led_platform_exit);# c& }3 n# L" z) W- m# {, o6 l
4 K9 W6 V5 Z5 }) T) X* ?
MODULE_DESCRIPTION("Led platform driver");
% X/ o+ }$ M t: f' _! SMODULE_AUTHOR("Tronlong");
4 |$ H. k( i- z; ]$ l& k2 q* V$ h( qMODULE_LICENSE("GPL");
: x- }; s I& _ z# E, ], [
' P5 _; X" z" v- B" O: d |
|