|
|
求大神给下面的程序做注解,请稍详细些,谢谢。# V2 D' E5 V0 {; R
#include <linux/init.h>
. b1 |4 `/ ~6 m( l$ J2 h2 |#include <linux/module.h>$ H( U% d0 v F% f7 @
#include <linux/kernel.h>
1 d1 Y( r# f: Q. t3 S9 v: Q#include <linux/types.h>
% I; s+ }9 x; k+ t2 w" q#include <linux/gpio.h>0 [, y0 e! p% h2 I( F
#include <linux/leds.h>; H# Z) s! d' a
#include <linux/platform_device.h>
( z* S) t" W- m4 B
* Q: T: v0 p& Z& G( s#include <asm/mach-types.h>
$ c4 j! T- @$ W' s6 P#include <asm/mach/arch.h>
: r. @/ t) p9 Q) k9 X#include <mach/da8xx.h>
/ K6 d; `! Z+ d* s( A8 k3 t7 V#include <mach/mux.h>
) I/ v) C" M- a: J9 V5 A! L; b+ C& B: R7 l
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
" \! u1 e& i) o#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
" E6 h, r4 c5 S7 j. o/ _& y#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
$ }1 \5 L8 w" H; o! T#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
4 g/ h, B4 S3 f# K7 S* Z) _! O2 e5 |/ N
/* assign the tl som board LED-GPIOs*/
& I; s' I; [, |8 a- B- Astatic const short da850_evm_tl_user_led_pins[] = {
2 _' r* K* U9 X /* These pins are definition at <mach/mux.h> file */' V4 l6 n% p$ |5 F0 o" V
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,) ?; P( s( ~* |5 J) h, V
-1
6 x% ^9 {4 u8 N};) ~; Q& g' H Q# F
6 e- ?$ ^; L% R: r8 lstatic struct gpio_led da850_evm_tl_leds[] = {* \% x' W. e, k s
{: ]0 e/ X- R9 O% X( A/ i. j
.active_low = 0,
S$ Y! r' m: V8 A& A .gpio = DA850_USER_LED0,8 d1 p2 o1 z7 |( k& w
.name = "user_led0",
2 O: C5 Y# E/ b .default_trigger = "default-on",
- h+ C$ `, H" V9 X( I },4 x1 ] r- o f- G' P3 _- ?( c
{
, M9 l/ ]& L1 f7 z7 u3 ]& N8 D3 W .active_low = 0,' x/ Y z0 c8 v
.gpio = DA850_USER_LED1,
s* X( m1 f7 @ .name = "user_led1",
* K1 j% M1 a S* C$ k9 c .default_trigger = "default-on",
. [0 t6 b5 f1 h" ~- {- d },4 z" U8 C; S" U5 p* M: k
{
4 F0 h: W5 I1 x& f' V* T" v! X8 w .active_low = 0,
9 Y" z1 ]2 G0 ]7 X" |4 V- v4 h n .gpio = DA850_USER_LED2,
, V( }# \, w* I! u$ K+ N- `+ y1 W .name = "user_led2",3 M$ [% f+ h2 V& C6 ?
.default_trigger = "default-on",+ D" H. `* H# ~" E7 r
},! g" |4 E+ ?' r- x W: w
{; s" P+ y$ n" w( H
.active_low = 0,. e1 i4 W- z. ? }/ H2 k( H" n a1 h
.gpio = DA850_USER_LED3,
8 [1 M% s2 F0 E .name = "user_led3",6 K! g+ F( N! c- {# L* z
.default_trigger = "default-on",- [$ h: ]6 o% X
},+ h, ^* q3 C2 S; ]7 v' m
};% y/ j$ Z+ Y5 w' k* s! d+ E7 e4 L5 Y
: [! q) e+ y6 C; J. {
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {- @& H- E( H! N
.leds = da850_evm_tl_leds,& K( y3 w* A5 X
.num_leds = ARRAY_SIZE(da850_evm_tl_leds), M0 I- [: p: z* h; L
};3 l I; f9 U( l1 ]- K
5 ^& _- n! X; i! @2 \0 nstatic void led_dev_release(struct device *dev)7 n: i6 f+ t# ^ Z$ E* R$ _# d
{
, N5 ^+ b a0 N" l: j; A};3 ~; j' |/ D' j9 h, C: X6 J
- }$ ?% q2 c4 J6 Hstatic struct platform_device da850_evm_tl_leds_device = {
! G6 e% w- K* v3 p; Q o7 \ .name = "leds-gpio",$ [: M! r/ t, x P1 H7 O
.id = 1,- Q/ b0 Y- t" ~
.dev = {
7 {# ^. P% A4 ?) F7 ? .platform_data = &da850_evm_tl_leds_pdata,: f( _& d+ B$ [
.release = led_dev_release, n3 T+ Q$ ^: z* B- z
}
) q4 ]' w1 n z9 Z* S};
) K9 S$ ^( `4 V9 h2 x! K& V" c, R4 P, W' d. O
static int __init led_platform_init(void)
7 ~: k6 A) l+ Y7 l; W" [" @{0 R) v* ~+ a& c( v) x* O7 h4 w. |( `6 e
int ret;
4 D$ v' R1 i* U2 C' g; Q/ V#if 0) w" V* T7 c& e" e* q
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);, Y+ i/ X7 c+ o4 V3 S; R) E: b, Z2 O3 B
if (ret)
* a' ^, i3 H- Q- y1 ~/ e% F pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
; i. Z) }3 W! F: U4 O "%d\n", ret);3 T1 R2 x- _& u. B' Y
#endif
$ p& N/ {3 S2 g* P ret = platform_device_register(&da850_evm_tl_leds_device);8 e; w, W8 @. ]4 U
if (ret)2 i# z5 Z9 \' G0 P: ^1 d
pr_warning("Could not register som GPIO expander LEDS");
% K, S! U5 Q& c! g$ T8 \/ ] else
7 \7 f/ R7 f1 H( @* ^! } printk(KERN_INFO "LED register sucessful!\n");
* e' w% F$ Z: j$ i% ?+ `
. t+ y; e7 M" u, V: B& U2 ` return ret;
& q% R }% {/ r/ `3 |* F8 ?}! d. W+ f2 P; Q T0 M
2 o% R! Q' R* E% K- Q7 Z
static void __exit led_platform_exit(void)
+ \ d# q$ v. ~- {# A{$ |; c5 s3 j Z* [ } D; r
platform_device_unregister(&da850_evm_tl_leds_device);& x8 E; V1 {3 j
. i2 ?& J" E/ A' h# t printk(KERN_INFO "LED unregister!\n");
4 ?9 o3 I) Z3 p6 ]}: u: }6 g9 e5 j4 q1 Z/ ~! e
8 C. d0 z9 } y+ P# ^module_init(led_platform_init);5 ^ b0 A* |, C
module_exit(led_platform_exit);* \0 {8 _5 J. q! A* m
0 Y: t8 `$ G( c) d
MODULE_DESCRIPTION("Led platform driver");2 s, W$ a, f. F% z* J8 r! M
MODULE_AUTHOR("Tronlong");
+ q. J [8 h$ ~4 h' aMODULE_LICENSE("GPL");
, M7 @0 s7 A: q3 f% C( S( w% W F h
|
|