|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
3 n3 U- T; v6 t" X) C#include <linux/init.h>
2 W! o9 j$ D" d2 I0 @#include <linux/module.h>4 l; E+ G h: ~+ ~& h3 e6 M
#include <linux/kernel.h>
. Y$ w4 Z+ h* z4 `% e e; i4 q#include <linux/types.h>
, j7 E1 Z4 \" _5 D0 L, l: J#include <linux/gpio.h>, Z! H; O- M5 G" K- i# \
#include <linux/leds.h>4 `+ L& |# S+ Q; E( p% P
#include <linux/platform_device.h>* _, S4 k7 ` t. `; h/ x
d) P* ]: w% d$ l2 y#include <asm/mach-types.h>, \' A) T" u7 K, |" X
#include <asm/mach/arch.h>
2 h* E( |. Q4 w' l1 T: l#include <mach/da8xx.h>* F. N4 [( O& {7 @; @% K5 o
#include <mach/mux.h>
: L4 Y; _+ T: T2 M8 S
% c9 L, v1 _2 I4 y: N- Q0 ]1 p: A#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
9 G* ], {0 z5 \" J#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)2 @0 P( O0 s. G' u, m
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1); n2 X( w( H6 u" o, R! p
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
' ^3 Q4 P4 ?2 Y: A+ y' b1 E# j! t* ?+ G( m
/* assign the tl som board LED-GPIOs*/2 W& A7 S1 ?* L$ i! \1 b
static const short da850_evm_tl_user_led_pins[] = {( _( n: w2 g1 t# k( D
/* These pins are definition at <mach/mux.h> file */$ w r {1 q: i2 P0 T; X
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,/ e$ w8 H7 j7 M2 S
-1
1 c' y T) L- c- n8 [7 ?7 V};
3 y4 B2 ]7 B+ G T" b# t
6 ]( h7 |5 t4 N0 xstatic struct gpio_led da850_evm_tl_leds[] = {
+ z0 `' N# A C) R9 Z {
" r- [1 ?0 q8 L! P0 R; y& O. C .active_low = 0,
1 ~3 c! {' T! u8 f' s .gpio = DA850_USER_LED0,
$ i0 y3 F* G6 v6 y5 r .name = "user_led0",- a" U. Z! ?. e2 _, F* k Z
.default_trigger = "default-on",
% p, _: `; W$ P, @ },
* T: d' L& {% _+ Z {
# L- g# D! V' B8 S( v3 w( Y .active_low = 0,
k" d( ]0 E' t( g7 d) A .gpio = DA850_USER_LED1,8 X# \- J+ y1 e r8 F
.name = "user_led1",; S7 C+ O9 L3 ~, B
.default_trigger = "default-on",7 u/ l7 P8 g; |0 V
},
5 U* P; a, _9 o3 [" e {
+ y& c( x5 ~" U' o2 _! y. ?, T* R; Y .active_low = 0,7 o1 j/ U. B2 W3 B4 P
.gpio = DA850_USER_LED2,5 J$ D. S1 b0 P9 D* h' T; T! g
.name = "user_led2",/ v. w+ `) y* |! F E
.default_trigger = "default-on",
' n, u* Q' _5 o/ o/ n/ {& P. b6 q },
! {2 H; E1 B0 [, J* J9 i( g1 ?" w1 ~ {0 o: Q% Y# q( p; m' `
.active_low = 0,* x/ i0 {1 y) P9 u; _3 r
.gpio = DA850_USER_LED3,
0 m0 a7 S, Q# A .name = "user_led3",7 q1 L8 ?4 [. J& |; G2 L- ~
.default_trigger = "default-on",
8 z0 K7 f+ U. p# J { },
3 G. E. @$ Q1 d( X% [! o1 e};
* X% U( k. O) ] |5 a/ a7 y8 V8 x! u; w5 i$ [: y
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {5 x2 ]- Z$ M" P0 `4 E
.leds = da850_evm_tl_leds,
( ^/ S' M6 L9 K8 K, p! E1 } .num_leds = ARRAY_SIZE(da850_evm_tl_leds),/ d _. T1 p2 D8 Y
};
/ X% P4 D6 Q3 ]( g3 H# m' w/ P7 x
static void led_dev_release(struct device *dev)
1 f5 m) [% z6 f$ S$ U9 g- a{! f. t' p7 ~% d0 Q- J8 K( i/ o3 ?
};+ i4 O1 ?. y D) a3 C1 ]
$ X7 l% i2 v" d6 P% Lstatic struct platform_device da850_evm_tl_leds_device = {
% z: \9 G' r. S2 E .name = "leds-gpio",2 P. t" I+ h) A- `
.id = 1,% V0 e8 ~/ c: m! U3 c
.dev = {
! G* j9 l" \3 u/ n% v9 Z .platform_data = &da850_evm_tl_leds_pdata,
7 T% [! `9 _4 c3 t1 c8 N8 F' p .release = led_dev_release," Q9 S; s) ~! m: t
}! L$ d1 h$ o) s1 B( S5 y
};+ F% i9 {+ d0 a
p$ s3 s s8 V: G# [
static int __init led_platform_init(void)
2 C3 R( h& x) d/ v t% }1 Y5 y{' T1 L. G- b1 Q' [ Q
int ret;' \+ W- `' \* G+ o' r' j: v0 N" V; L" h
#if 02 S; U# U0 h4 e2 C8 F/ [. {
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
6 B) W3 a# z% r+ K/ s( E% m+ ?# \7 r% v if (ret)
3 h6 w* \4 o. o; V$ \" ~ pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
$ ?, e# v4 V% M/ i5 l3 m) L4 n "%d\n", ret);
( x8 \8 |1 R: `$ {1 q- x#endif4 h0 B1 k# E) C# x
ret = platform_device_register(&da850_evm_tl_leds_device);
' R' B0 |1 b& w. v# l4 W& P if (ret)
( A5 [) {. R& A pr_warning("Could not register som GPIO expander LEDS");
' A% f0 _9 B1 P else
, J; a! A; j8 d+ J, g s X& j printk(KERN_INFO "LED register sucessful!\n");8 B' ^' O" F8 h3 E, K% B y! x
$ Q3 d- Z5 h) [9 g6 [3 k return ret;
: S8 [( z" O* Z4 t/ G6 N}" E6 L! _4 h8 u
" E( H% N% d# a4 X, ~static void __exit led_platform_exit(void); i4 J* Z1 ?6 l5 [2 G6 r
{) P; Q" j: x3 k0 ]
platform_device_unregister(&da850_evm_tl_leds_device);
+ b0 O o% t: d3 u, `9 S! C0 f, c, t$ Y$ Z0 I
printk(KERN_INFO "LED unregister!\n");! O. N2 p8 q7 ]+ v- Z
}
' B/ u6 Y. S# f ^2 I% N( Z# ] D1 ?8 {' K* k
module_init(led_platform_init);
8 }$ r+ K9 r/ E* b$ s3 d& imodule_exit(led_platform_exit);
5 C) _; t3 u6 `7 M: X2 U' c& s3 s$ A1 f; V+ q# w7 O# y
MODULE_DESCRIPTION("Led platform driver");; ?/ l9 e' T1 A! S. ]5 |% E. O
MODULE_AUTHOR("Tronlong");
: g0 m0 J$ W+ R8 ]MODULE_LICENSE("GPL");+ y. F- q3 X. ], {. w1 g
; W _0 t5 j. Z6 Z4 n$ x |
|