|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
, U3 v; r- |; W#include <linux/init.h>
# u7 c6 {( a9 l% D, H1 s/ y" S#include <linux/module.h>- o2 H) v; o) ]( ]( v
#include <linux/kernel.h>
8 b/ Q! ~5 w! j& d, L/ g#include <linux/types.h>: s8 X1 a& @* D. j. e+ g
#include <linux/gpio.h>
0 x' c; a( q4 X7 K# L0 o#include <linux/leds.h>9 c7 O3 i3 }+ G. u
#include <linux/platform_device.h>
) j* O' g) Z3 Q0 k
5 n' i/ d5 b( e* y#include <asm/mach-types.h>2 @& ~+ _9 K( D+ ^
#include <asm/mach/arch.h>
# o# K& a6 {. h: B8 Z#include <mach/da8xx.h>( n2 ?: e8 \* Z- L% Y8 s
#include <mach/mux.h>' B7 H& L+ X, P' L& Y5 `* x$ k
0 y9 f+ q6 R6 {8 e+ s
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)8 E# D: C! u" T! r' V! E# V; D/ Y
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
Y2 c' b% M8 `! {#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
9 {1 w* t$ g/ B( b# n$ N. S( G6 \#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
; |7 K/ J |6 s7 U4 X1 ?3 h, |# @
9 r$ s. V0 m) x ?6 W/* assign the tl som board LED-GPIOs*/
6 @# y5 K; ?$ M) B/ p7 ^static const short da850_evm_tl_user_led_pins[] = {
) `0 m& S! g4 ]# m/ E /* These pins are definition at <mach/mux.h> file */* C9 I' y% N" b. q m5 Y$ X
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
' A- U4 x2 w* x* _% b -1
: b. s/ `+ }3 O2 M/ k2 ?% y};
3 d! d/ t5 |9 a0 a
K% \+ S0 Y* F' L d$ _static struct gpio_led da850_evm_tl_leds[] = {4 ^& i) D/ L8 i; K
{
( k# r3 b7 u- J# ?5 T) ^/ } .active_low = 0,) A/ d# j/ [ \; G4 A
.gpio = DA850_USER_LED0,
& E% j7 t3 \& r$ C8 s3 m .name = "user_led0",' h% w/ A' I# ~4 ^% H
.default_trigger = "default-on"," p# K9 ^7 ?6 r' X) l8 k* K H; D: l
},2 e8 x Z" `# L+ Z
{; n/ s! o; N7 _- m4 q
.active_low = 0,: E" F* @4 X) h( g) F+ p8 N& K
.gpio = DA850_USER_LED1,
. G- G* `# a% q0 W6 c2 j .name = "user_led1",4 c! e. M. ?$ C/ W
.default_trigger = "default-on",
3 D0 V" M0 U9 E- j" o7 M },# k6 F2 @, q+ @5 z8 H9 u4 j( {
{" ^! Y9 Q: v8 ?! m/ u
.active_low = 0,8 o6 A+ x0 J; Z0 g1 [* I" ?
.gpio = DA850_USER_LED2,' T" h* {. ]. e+ w/ z) C
.name = "user_led2",% {/ u# I; B$ s! B0 E! a
.default_trigger = "default-on",: ], R# T) z) W) s& z$ t2 k! O
},; s9 k. u9 B0 b% f4 P+ m
{) u: ?- ~/ b& r& e4 T
.active_low = 0,
- ?; f# L$ ~' R6 S) `8 z .gpio = DA850_USER_LED3,3 c. K& ^8 Z# O" p3 M* v; p& K
.name = "user_led3",
, `9 }/ d1 ^3 P. N/ A7 S9 k0 |( e .default_trigger = "default-on",1 p; _! j+ Q; P
},
8 A- L2 S+ |" W& r: d};5 W9 k" I% a" w& t
) N8 V8 K" a( c
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
- N4 X8 n+ r, `* a4 f .leds = da850_evm_tl_leds,( j2 y6 _5 J7 N1 \7 W0 b
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),- I G% X" [% s# ~/ b
};6 I' y4 F# N; L7 t
) {& c& E; [( M, g% Sstatic void led_dev_release(struct device *dev)
6 F {0 L; U" r+ o{
# S6 F* h7 G/ Y3 {9 Y};0 S' g* \( _4 U* l: z
4 c, U1 I* {. B; o$ p$ S
static struct platform_device da850_evm_tl_leds_device = {3 Y/ I! b. x! c2 g0 l& m
.name = "leds-gpio",3 v& `, J& [) E7 c# T* i
.id = 1,0 i% r' l) ?* v& K D# E; B
.dev = {- l0 g- g, T; T: t' `2 b* |
.platform_data = &da850_evm_tl_leds_pdata,1 r8 Y# P- R }6 B. g( J
.release = led_dev_release,/ o/ [* `7 t6 J6 J5 e
}9 M' x9 q, h: }6 z, {. K6 f
};
/ Z+ Q# q3 A J
+ }9 F9 v. E% Dstatic int __init led_platform_init(void)
5 n! G6 O2 R9 Y( Y2 j6 t4 W{
( [( Q M' o" P) J# U0 ~7 i int ret;
% l, w4 K( ?' u$ F#if 0
# P, q7 D6 ^; V0 g( F8 g; L' T ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
$ v1 h K7 `" u) J if (ret)
3 U& o# e& D. Y. v* q8 v" W/ w pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
- m* p7 w) E2 v, J "%d\n", ret);
1 p# C- M3 Q) S! o- }( O6 ?. x( n/ j#endif
D2 B) A) a: s! l. j ret = platform_device_register(&da850_evm_tl_leds_device);
1 f3 A; ]1 X1 r; F6 p: |% u if (ret)
$ c8 `8 o8 f: [6 z; O; S pr_warning("Could not register som GPIO expander LEDS");
1 q. G+ p( x- y: W `- |. g/ K! h else) _! F% Y4 f/ @+ M7 P$ [% J( ^
printk(KERN_INFO "LED register sucessful!\n");3 |! d- B! k2 w- e- n* W8 H
6 { w9 M2 L$ \5 X
return ret;
' I7 f9 g7 h6 q1 H2 K& G$ _}0 [5 O1 T2 J; q: Y# H
# a0 O- I" q5 L; Q# _8 dstatic void __exit led_platform_exit(void)
1 i8 D, v" e6 ^{( \, [3 {$ e0 P! i2 M/ e
platform_device_unregister(&da850_evm_tl_leds_device);. ]2 o% P( I% x. ~7 I
y; v3 P) F$ {# H. ? printk(KERN_INFO "LED unregister!\n");
# @7 ~# o9 I# A: ^/ J8 F}+ {" F6 U! Y* @. a. @3 L; S
! Z0 t( }+ _4 D8 Dmodule_init(led_platform_init);
' a8 L: J% T' x: n: n3 zmodule_exit(led_platform_exit);: X) b4 c+ M. v
! F6 R0 h. U" a* dMODULE_DESCRIPTION("Led platform driver");
: i/ ^5 z! b4 a8 |MODULE_AUTHOR("Tronlong");2 }4 L; g( M+ @
MODULE_LICENSE("GPL");; k4 Z s, R _4 ?
' X Z% v L3 a. q
|
|