|
|
求大神给下面的程序做注解,请稍详细些,谢谢。5 `$ k! c4 i" j3 I( b
#include <linux/init.h>& ~: X/ Z- L9 b+ x
#include <linux/module.h>
/ t! b! p( U; ?3 d0 b#include <linux/kernel.h>" G0 x4 D& H5 L. Y" U
#include <linux/types.h>+ R! S# Y' q, J4 V- ?. I: x! X4 |
#include <linux/gpio.h>
/ P: Z/ J' `; \" s% i! U#include <linux/leds.h>
* ^$ s' |! M5 c/ ]- e#include <linux/platform_device.h>& O2 v2 e* [7 ~" K+ Z/ L
6 S% b) T7 C) @#include <asm/mach-types.h>) c1 Q+ f% s8 d
#include <asm/mach/arch.h>; r0 |4 q! T5 H+ @
#include <mach/da8xx.h>; y6 c8 Y, E: V
#include <mach/mux.h>6 _+ _: }0 Y& G8 J7 s
- r& }2 E) ]# p/ |- @' F J D
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)1 ?6 { B/ _6 F# f+ P2 t
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
: h" v- l2 I$ M9 V- Z7 C4 `#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
( \8 D! [5 q/ \. g6 `#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
# g3 V2 T1 \6 x& C0 A8 {# @& m& M. U9 X: @0 P) I+ d
/* assign the tl som board LED-GPIOs*/
. D% a/ t; s# d) R( Zstatic const short da850_evm_tl_user_led_pins[] = {* v0 x; e4 [# ?% i; z! g+ {1 ?
/* These pins are definition at <mach/mux.h> file */
! a3 P8 A# u W- K2 x7 Q DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
' g/ X, K/ h% X) Q+ I. [( S- q' z" K -1
. e8 F/ x6 }8 b5 i! I9 O- q};6 D9 ^6 }& D8 ?) V! O" @
7 |7 h3 _! p# L5 kstatic struct gpio_led da850_evm_tl_leds[] = {: f- Q& z6 b: `, @0 X* y# m: j* G
{
8 L. X7 E" ]# Q4 W. F6 P( C; a9 z .active_low = 0,
* B3 I8 C! p% v q0 j0 c" N .gpio = DA850_USER_LED0,
/ H2 z3 ?5 V5 E. j .name = "user_led0",2 m; p9 H/ C4 z8 U3 C' K# f' w5 E+ G% `/ d
.default_trigger = "default-on",
1 |5 {" y, z0 r1 W% `, M. M% Z( L },8 x( @; k& J, \' v
{
% ^; y3 V: q3 o2 n2 S% [ .active_low = 0,
7 l! ~" D6 b) o e .gpio = DA850_USER_LED1,# X3 M1 o; ?% v6 z
.name = "user_led1",
- G4 Z! e* w$ r& _. E3 X& \ .default_trigger = "default-on",
+ f$ }7 P$ Q, Q1 m- J |, z: C },
5 x* B$ D; C# {4 ^3 @ {7 a) L' g7 U# E5 _
.active_low = 0,1 R1 C4 B+ D* b6 x
.gpio = DA850_USER_LED2,
: Z! B F' s% C# r! W .name = "user_led2",
, i, c/ s+ _! C! w8 H; ?# S+ d .default_trigger = "default-on",
" l" Y( s6 @/ w },
. m: }8 Y( g& E2 y, { {
7 p" q$ l2 Z! W1 ?8 i .active_low = 0,* q& n: J. n! \) y$ @7 f: H
.gpio = DA850_USER_LED3,
' z* R( S j" Z* X" o( v% c .name = "user_led3",& a8 \: n2 G: j' F/ }9 g
.default_trigger = "default-on",0 a1 H' V: U# s$ w
},8 y2 \* h) S6 K: \0 t! @3 S+ g2 }
};
; H. F* F& K! u6 {. G4 I% M; G" g5 e' d
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
# @- y4 h3 w8 P% p5 G& d0 W .leds = da850_evm_tl_leds,
' E' @: W: m. I/ }, Z# N .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
/ \7 N- z5 H/ ]* _2 t# q. ^}; E0 z2 u O6 V( t" d: R: r
" L3 l8 w& r/ J' ostatic void led_dev_release(struct device *dev)
4 ^$ c9 N' G W6 o; G: Q{" s _0 U" M; _3 i& b
};
9 m3 w" Z ^/ f8 i$ Y! c$ ~
3 o/ r$ q' T: @8 u4 ]static struct platform_device da850_evm_tl_leds_device = {
$ U/ W+ A6 j9 i0 e* i2 H" L7 d .name = "leds-gpio",
: Y* M1 S. t. {5 W8 l: H6 Z .id = 1,
* U; T' }3 p, k2 `+ N9 F .dev = {
, m7 A) f9 d% p* U+ u0 H .platform_data = &da850_evm_tl_leds_pdata,
- S: o4 e6 L# r .release = led_dev_release,
) _" m6 d8 M1 C5 i; h5 N }4 h- X9 e0 ? F5 Z$ l, a2 m
};
% ?2 \4 G! t6 O' u
# {& c) i; I* n7 d+ g3 ustatic int __init led_platform_init(void)
% r) S) H: h. p: H4 n \{
& A- Q4 N. u! n3 G2 p1 g int ret;
* [, \+ a3 ~, S8 V; K. g#if 0
, V$ w8 ^0 V4 _0 p' I ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
, s7 i" ~5 H" J8 i# ]# L8 s; b if (ret)8 A- ], e$ k1 O5 {9 `
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"- j+ U3 a" F a1 D
"%d\n", ret);
9 m7 ~. H6 V4 i6 f) z* `3 ]1 u#endif# q( C7 I, p) z, h
ret = platform_device_register(&da850_evm_tl_leds_device);: b, Q1 }! M' x* ^
if (ret)
# e; e+ T! X& N; T Z pr_warning("Could not register som GPIO expander LEDS");6 @/ ?, `$ C; ^; F% p+ ~
else
+ `- _7 K! u/ U# X printk(KERN_INFO "LED register sucessful!\n");2 V8 k2 {6 z6 i1 I. r( {* d/ j
# P, n- u' Y; B return ret;5 W' T( H& k& `+ w
}4 P, ^/ y/ M! \0 V
% k, m* Q. ^: I- } r5 G1 gstatic void __exit led_platform_exit(void)* M4 M+ t( h$ ?- o! K- z
{- |0 A4 g# Q0 x+ w8 t6 g
platform_device_unregister(&da850_evm_tl_leds_device);
; D- F ~4 V8 t% `4 J8 ^# V* ^+ \( y' `% t; L
printk(KERN_INFO "LED unregister!\n");
+ e; X% T- J; T}- U) ?, j; k7 K( I' B
" L6 P' F( t9 Gmodule_init(led_platform_init);8 ?0 }2 w( g( |* [
module_exit(led_platform_exit);& [# @, U- @5 P/ f3 O" T5 D
. a5 p& l& Q) B/ X9 Q( u& e
MODULE_DESCRIPTION("Led platform driver"); L' Y f) N, O5 ^# R! y( {
MODULE_AUTHOR("Tronlong");
8 Y5 Y6 c7 y$ h# b Y+ |1 o/ [MODULE_LICENSE("GPL");. N2 v- y/ R, M8 E- U, I, Y
+ Q; k9 n7 k6 V: s) ]3 \ |
|