|
|
求大神给下面的程序做注解,请稍详细些,谢谢。7 a! G4 @: s( N: P
#include <linux/init.h> p) H1 n, L9 u8 S; X
#include <linux/module.h>
' T9 o& ~& p+ [6 {7 T. F#include <linux/kernel.h>
* h, Q+ u E3 x! }' I#include <linux/types.h>
3 o- q& b. T @# C& f# n#include <linux/gpio.h>. m! O/ f# p1 Y8 Q
#include <linux/leds.h>
$ @7 l- U, `, m#include <linux/platform_device.h>7 [* U5 \- t, K9 B0 z8 C' O
* _, n' T* Z0 [) |' H
#include <asm/mach-types.h>8 a; x6 O1 ~" r6 x g- R
#include <asm/mach/arch.h>
/ h& B" B9 C% r- I9 \: d5 _#include <mach/da8xx.h>
" A1 F) {4 |7 ^2 Z0 p! U#include <mach/mux.h>- P" M' _! B& f- X$ K2 x, @" }
+ H. f: X3 @5 ~# j" z; `5 k0 m2 f#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
% D: [0 F1 n G#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)$ n2 ?! d1 A" x! r8 Z! @5 O1 q
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
( z' X f( ^) v# }1 x6 Z#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)% g _4 L+ R. q# [
* i( c; j) W" G
/* assign the tl som board LED-GPIOs*/* u9 B+ k: p6 s( p
static const short da850_evm_tl_user_led_pins[] = {
3 j" e: f2 V9 C; l4 d' u# |) j; d1 h5 Z /* These pins are definition at <mach/mux.h> file */
/ p# O( X3 P! D/ l DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
+ Y% T/ _6 r! U7 d -1
6 \, a( n* p" P U6 u};
$ Y5 E4 J0 J- G, T- R# {1 E* r h
! D# X7 p& E; l- sstatic struct gpio_led da850_evm_tl_leds[] = {8 K, U, R9 O# K$ s" ~% [* X
{+ T7 ]/ f! A/ D
.active_low = 0,2 m4 j! h8 K5 F+ f9 j$ o- i
.gpio = DA850_USER_LED0,. L. w, U& z, n8 n0 ^! I; u% t: u3 ]0 t
.name = "user_led0",
! |* e& p) G' r' s .default_trigger = "default-on",
0 m8 b( L' H G* N1 {/ \" M- Z },0 W h3 r+ t. n+ N0 z# a- U0 M# h
{+ [% ?, Z3 t2 @, t/ b1 f/ r3 A: X
.active_low = 0,: a8 @- |, |% I" |* n4 p* }
.gpio = DA850_USER_LED1,: z0 A. Z" X( G( H5 h6 |2 l, `7 h/ Z8 y
.name = "user_led1",
: `- j3 C( N# v: k" g .default_trigger = "default-on",
3 m1 O6 a5 @0 i2 l9 m },3 z/ d5 ]4 N7 b8 n' ]5 [& B
{ K/ E+ ^2 d6 v6 ~
.active_low = 0,% P1 @& |6 Q/ }* A: J" e4 u
.gpio = DA850_USER_LED2,% h1 Y" a- n& Y6 m8 I# h3 y' H' M
.name = "user_led2",& c0 {$ N$ J+ m6 j5 [9 |
.default_trigger = "default-on",1 o V' n* N" {$ a% x
},
1 s/ f+ d- b6 e0 u {
, U l* i, q! W' a" t8 X .active_low = 0,
# |$ P; l7 u6 O4 m .gpio = DA850_USER_LED3,
! o; P8 N% ?3 d* S8 p .name = "user_led3",8 \$ J- G- n; Z9 {& |3 k' W% r
.default_trigger = "default-on",# Q5 W5 B5 i3 k! s
},
# O. ^7 M- a8 f: j};
; s' O+ x; A( _) O( c; _
+ W) _: z5 b" S) M" V4 h4 K8 |( x4 ^static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {% i& F1 o1 b' m2 B# l9 T0 a- g* Z
.leds = da850_evm_tl_leds,% O. S9 F: f) B' y
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),
2 v6 U- k8 A) t};
& o1 y! {9 N: }3 T
: ~7 c1 Z( o# u8 h; Fstatic void led_dev_release(struct device *dev)+ H1 X, f' z& C
{
$ f* b3 n* X6 e};
+ F+ a7 M- h" w- s. K" Z0 r
% @6 g5 m+ B$ Y8 w" w% [3 _2 Mstatic struct platform_device da850_evm_tl_leds_device = {
3 g1 Y# P. R* i! S3 z2 G. t1 q* W .name = "leds-gpio",
9 E$ ~, u$ x( m- p .id = 1,$ n8 k# \6 m, U6 i
.dev = {
" R. Y7 n* J/ l* K% x .platform_data = &da850_evm_tl_leds_pdata,) J0 d5 C$ y4 E( Y: B( c
.release = led_dev_release,$ Q: F$ x/ s( i
}5 C% B6 V6 }' [7 \6 F
};
/ N# w' J5 e: ]2 e7 ]
( ?9 e' g+ E' D5 t# c0 k$ Gstatic int __init led_platform_init(void)- J% C9 }- P& W: H
{4 o4 @( ]' r4 U2 D' G
int ret;
: f; P; z$ k t2 K5 k, Z$ i#if 0+ g' o* f$ h5 W3 D3 w& m; o
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);% M5 z; b: Q, f r& @. u
if (ret)4 Y, c" a* |% c j/ o
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"# Z3 Q3 o4 J6 f- O5 y
"%d\n", ret);/ S$ }& ?) C0 e! W w" ~5 J
#endif1 x" I0 m/ ?* h: h/ F" S# O
ret = platform_device_register(&da850_evm_tl_leds_device);
2 v: @0 Q* N# a% a1 |( ` if (ret)+ `* E9 g$ u. d7 v
pr_warning("Could not register som GPIO expander LEDS");# ?6 h" ]: `+ l- S# T* k0 _
else6 v& V5 `; T! b) a
printk(KERN_INFO "LED register sucessful!\n");6 j% U9 I$ q% d! n4 K# u" H" ]
7 V6 j/ G9 F, M3 f9 r% U( G return ret;: R2 s9 I9 K/ g' P3 I0 ^
}& q; c6 p" t$ ?& o. d- ^8 ^
! ~0 v- Y) V- d P7 @6 Lstatic void __exit led_platform_exit(void)( `. d; g$ R' w0 g' F& a- f
{
7 J$ @3 Z, F, n6 t platform_device_unregister(&da850_evm_tl_leds_device);
: I5 p" ?6 I2 x5 a
% Z8 E) a, K6 k _ _* m printk(KERN_INFO "LED unregister!\n");
& V$ h" N7 [" Y" Y4 m4 t) m+ s}
0 ~ T' [+ |: m a, b, \4 V8 J/ i$ |" R# D% t
module_init(led_platform_init);
0 a- V! ?/ h# p9 C9 Q3 jmodule_exit(led_platform_exit);
6 _; g) x$ M v2 _2 A7 I+ E% ~+ k7 v3 j5 u' u8 A1 |
MODULE_DESCRIPTION("Led platform driver");
, j, |; F. J2 V4 a$ J' |MODULE_AUTHOR("Tronlong");
: {. |- t2 Y Q$ F: N mMODULE_LICENSE("GPL");* K$ S) F0 w! J/ y' ]; x8 x
1 A. L4 @" E7 S |
|