|
|
求大神给下面的程序做注解,请稍详细些,谢谢。9 W+ q* F0 {* s* I3 i, h3 F
#include <linux/init.h>) C" J: y7 b5 N4 w
#include <linux/module.h>1 B# O( [$ J5 |6 m
#include <linux/kernel.h>
8 u' l. m% ?& M" L) E#include <linux/types.h>3 o; Y- z/ [* C `
#include <linux/gpio.h># S) E# \" V/ m+ B% x
#include <linux/leds.h># o7 {/ g5 U% l" E' z& r% Z
#include <linux/platform_device.h>
6 v, g: d$ p' X( p5 K2 V1 J
! Q. J2 y' Y6 i* G2 [' H0 h#include <asm/mach-types.h>
% R4 {7 g, Q- G) t* E7 i#include <asm/mach/arch.h>2 J( s* Y2 @/ O3 o! o; u& N7 P* | V
#include <mach/da8xx.h>
1 ^6 J' k4 ]8 M' p9 ^#include <mach/mux.h>
- A {" J% |. z+ W. k4 W# e" u* W( A/ A
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
5 d' @: ^1 j( R# V7 ^#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
, u1 q9 u3 B8 e#define DA850_USER_LED2 GPIO_TO_PIN(0, 1). P* l4 V5 M" T) e" p
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)1 F9 f) G2 E. D/ R9 ?; h1 v
W4 L( B% `4 i# M' i( V1 B* s! x/ R! m( t
/* assign the tl som board LED-GPIOs*/
. d1 W, b7 ?! q1 A2 \+ k. B: gstatic const short da850_evm_tl_user_led_pins[] = { ?) W! r( o0 J% K9 z# T
/* These pins are definition at <mach/mux.h> file */
& X$ t3 b4 t1 `/ i2 d DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,. R' M" l k! g3 v" ~* k3 j% T5 [
-18 E. r) A+ ?6 c" V" ]1 B9 S( G; Y
};
) B9 d ]3 n. _' ^) t) l' b; O$ m+ z
static struct gpio_led da850_evm_tl_leds[] = {
8 T }8 {8 Q7 @; c$ f& ] {
( O4 |" \; F% ~1 o/ J } .active_low = 0, V3 N8 h% d- @- d* J: Z' o" Y
.gpio = DA850_USER_LED0,% V1 y1 k# n8 K) O
.name = "user_led0",( n) w6 w: T: B& q' g3 Z
.default_trigger = "default-on",- m6 T9 N7 U. J K5 z+ x8 R+ M
},
+ X5 r( {8 r2 T$ e7 `1 x0 \ {
3 c4 N/ {+ f$ A, [9 b; i9 `% c .active_low = 0,1 R/ Y) m; Y6 m( p2 G2 i
.gpio = DA850_USER_LED1,9 d, X9 [4 r7 Y' o* K
.name = "user_led1",
$ Y8 J, _0 I( g; g; }7 L6 }( ? .default_trigger = "default-on",
4 P4 r% E2 l- E },: x! d' f/ o0 T" q8 Q0 a! x
{
3 F% l5 Y, l: G& d w .active_low = 0," ~0 O4 ]4 z6 A) b% u P8 V; x
.gpio = DA850_USER_LED2,6 k% x5 R: \7 |8 d, e9 g& {8 P% A
.name = "user_led2",* [# c% { H. _: H: B6 @
.default_trigger = "default-on",% b: u0 S5 e4 b- T4 Z, Z6 z
},+ d- M. \( R' f/ {) a
{1 Q; p* ~& ^; y# U8 Y8 x
.active_low = 0,
$ q" Y" a& R1 s' E .gpio = DA850_USER_LED3,) T2 f+ x$ }& H) I. }% }
.name = "user_led3",
$ l1 k, x9 ^6 U, q7 O2 G$ K, ^: X6 v .default_trigger = "default-on",
7 G# a* i& ~; ^+ z! l },
+ S0 U( N6 T* @2 E) u};
( c9 H- m' u9 [
. L- ?& \! r* E4 }static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {6 ~( |0 I2 E8 K0 W/ ?3 J
.leds = da850_evm_tl_leds,9 J! Q1 U1 l) ?2 e5 R5 ]
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),
% ^" c& D$ B' [1 G6 X( N};
" T8 l( ^& x& n3 U0 k8 b( j# ?
, Y$ e" q1 U% r$ mstatic void led_dev_release(struct device *dev)9 X9 Q; S* W- u& h4 P( ?, s+ {3 r
{
3 C7 c" H6 N a3 t5 N: m};/ t0 i2 X$ }2 O9 o) @. {
7 x1 f8 r, e2 Y2 Z3 N( W8 P, e: H
static struct platform_device da850_evm_tl_leds_device = {
9 @4 G( W9 E$ C7 b1 ], V. | .name = "leds-gpio",
( d) V6 m( P. Z9 R5 c" W .id = 1,
/ q% E# }# \6 C7 m$ C .dev = {% }) R5 _6 {! A
.platform_data = &da850_evm_tl_leds_pdata,# r: `- O& R _ |, p: s B$ R
.release = led_dev_release,
) \- @8 i J/ k) y4 A }
, E5 v+ S1 C+ N% W};1 m; E. d5 R& B# \- F% J- [
. E( D: }9 {: M4 A' K' U
static int __init led_platform_init(void)* E1 @, \# C" X
{
5 z/ Z: t) h4 `: |- O; | int ret;
R. o# [/ D% c: S" q& q8 r#if 0& |& _7 U4 g& ~
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);5 q' y7 o" l7 e9 T2 J0 r5 S5 i
if (ret) w4 _9 F* ?% A( D) G* @, L
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"9 N8 r! o- J, p7 g
"%d\n", ret);
: Z1 i- Q7 a/ l k8 }: p#endif4 N! a0 F/ f8 u% Z
ret = platform_device_register(&da850_evm_tl_leds_device);" V# J" D) F' S4 [" t
if (ret)
4 y3 Q& v1 ?( q3 H ]! Z pr_warning("Could not register som GPIO expander LEDS");
1 x% P' p% \5 G3 y* U Y' v2 p else4 p$ _6 r- Y! W
printk(KERN_INFO "LED register sucessful!\n");
P6 H# P, Q- b; Q
! E- {% Z/ M/ j ^) @% a return ret;
$ t9 s7 R+ a" l$ y}* k9 H3 p: \8 q' H" w: w/ v8 t/ a
/ A4 ~" ^) }1 [% h" C3 j0 d+ wstatic void __exit led_platform_exit(void)
* y6 T$ w1 a% `( P- X" f& U{
; Y$ a- j9 r1 E1 H+ ~6 l platform_device_unregister(&da850_evm_tl_leds_device);
. ]! h8 z, z1 y \. g
$ k9 K9 a5 F4 U; p5 f printk(KERN_INFO "LED unregister!\n");: R5 N: u& T5 t6 D! r3 w! }
}
8 t( ]' n1 P& _2 s2 l$ n
) e+ u. ^7 v( K' o( Pmodule_init(led_platform_init);. ]1 T& q% S4 ^" W5 a* j# Y
module_exit(led_platform_exit);
+ I: c) l0 T) H3 e( j5 b$ O, d( v9 o; r; P0 t0 l8 C
MODULE_DESCRIPTION("Led platform driver");
% ?, q3 g( |( a5 n1 yMODULE_AUTHOR("Tronlong");# G: j5 d% z: J- d6 |- F
MODULE_LICENSE("GPL");
/ \8 y4 Z0 K) K1 P. H
7 e3 P h" _ e. \, `- s& ~ |
|