|
|
求大神给下面的程序做注解,请稍详细些,谢谢。; h2 q' C" \% a3 ?! J$ k% \& \
#include <linux/init.h>
9 v+ G* }0 A x1 s# c#include <linux/module.h>
; I' w1 ^$ {* ]6 D( i0 D3 j#include <linux/kernel.h>( M' }5 o4 e3 d! j
#include <linux/types.h>
; X0 g' N% G. j5 v+ @#include <linux/gpio.h>" }# N. F3 ^- a; Z$ @ C: j; r$ E
#include <linux/leds.h>8 M1 U3 H$ p0 x+ u Q/ w
#include <linux/platform_device.h>3 ~$ f- k+ y1 O/ Z; r5 a
4 `! U, a/ J. k+ F
#include <asm/mach-types.h>
5 ~' _6 b* J! V#include <asm/mach/arch.h>
. v/ W! h, _ E: p0 f5 g#include <mach/da8xx.h>
9 i1 e% q9 O" _: P; m$ J$ c0 X6 t#include <mach/mux.h>
8 B' S; i5 ?6 d, b" V1 i1 B; A! ]/ ^, F" p
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)% [" U. U6 P; @3 Q9 {! ~8 ^
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
4 H! M/ |" Z: U0 x: K, e- @8 |9 u#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)* o# S5 `' w- j/ t; ^: y% K, R
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
r% ~& u+ x. g% T! o0 Q8 h; v* F1 X U( ~' J3 U& `
/* assign the tl som board LED-GPIOs*/$ N& F% L1 B0 y( c" b; W
static const short da850_evm_tl_user_led_pins[] = {" q- z" a: Y5 G9 F, j
/* These pins are definition at <mach/mux.h> file */( c$ \2 l) y+ k& \6 W" |* C
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
/ O' Z$ Q4 h/ m' F- _, s -1
3 w' B0 v+ G1 Z- A8 F; }8 E2 Y; E};( ~2 K9 Q3 m$ X( _
0 K- t7 t. o/ b' ?
static struct gpio_led da850_evm_tl_leds[] = {
7 H( g4 s6 y2 ^6 i, ` {
# k4 X3 t$ J$ n* t+ m5 t8 \ .active_low = 0,
6 U8 P: C' |8 q6 Y .gpio = DA850_USER_LED0,) n7 n5 J; i, n/ b+ {
.name = "user_led0",
/ Z# S% a9 Z) W) h. u/ G .default_trigger = "default-on",+ J) j& o; Q O
},
, D" }* t9 B& _$ j+ M ` {
6 g0 U' I* T* x5 P* U) l2 @- V6 r5 G .active_low = 0,8 e6 i* J( y* N, U& B. I
.gpio = DA850_USER_LED1,% J: p6 Z: D$ |4 H5 B; T- v1 Y+ X
.name = "user_led1",
# ]+ S3 v5 J( Z0 | .default_trigger = "default-on",+ V* b6 ?( B0 [% K, B
},
/ k; q) Y, ]0 p& z+ k5 t7 V) C {
3 ]- Y7 `; Z- E4 ^2 q .active_low = 0,$ T% k: s: ?5 |+ U$ o* C0 S% p) M
.gpio = DA850_USER_LED2,, i* L" y3 ^2 O/ D- e& c6 Z
.name = "user_led2",
+ }8 \" y: ~6 T+ P! U .default_trigger = "default-on",8 ]0 @$ j; K5 X, G3 [) L" N
},1 P: p: A. L" }7 J
{
1 Q- e1 }5 I4 B# \5 } .active_low = 0,$ j& C; r: j+ E1 A
.gpio = DA850_USER_LED3,
4 v, g9 a* B! c .name = "user_led3",# ^0 z/ u$ u$ x6 }1 ~
.default_trigger = "default-on", H5 Q; _6 J2 K6 {! v- J- a9 I/ R
},! G$ J V: y- ]5 f, f
}; F* ^9 k' a. N, T
1 r: E: v% v$ estatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {. M, [% M! y: {' F" Z$ I5 l
.leds = da850_evm_tl_leds,$ ^1 U+ u& I9 n0 A
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),& I) s: ]3 l4 y/ Y8 x
};
' J6 V/ Z; T5 O1 i, N* U) P0 R, \) D7 h; h9 J! ]
static void led_dev_release(struct device *dev)2 u; M- n1 p) h
{
2 d1 y' T9 ^0 K' Q};
% [! S- V7 ?6 E
: K! E3 b9 `7 q+ @; g4 c7 H1 Y& cstatic struct platform_device da850_evm_tl_leds_device = {
1 \9 N9 c0 e7 t .name = "leds-gpio",
6 t( a, Y( ~6 M) V$ q7 s2 ?7 T .id = 1,
) y4 _" V( p7 F( ?/ L* P .dev = {
# k& S1 _+ F% x6 p v4 M: r .platform_data = &da850_evm_tl_leds_pdata,$ }( z0 t% q7 @+ M! \
.release = led_dev_release,- W7 K& \$ E: j$ M1 r5 s& _$ k" X- b. {
}
1 N2 a i& U1 b' }/ O- c* L};
2 p I: Z F+ g7 H) V" P0 n3 M Y, ]+ U
static int __init led_platform_init(void)8 ?- ?% D& x; l) b0 D/ f7 Q" R
{
3 e0 S9 D! i s% ?- H6 ` int ret;
6 ]3 v, J. {8 ]" S#if 07 O% T3 I( I. E8 `$ ^3 ?# x
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins); z. c9 m$ | v2 j6 q# {& K
if (ret)/ n! Y0 D6 }1 M) e* k2 \% V; B' Z. K
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
' k0 D( r( o. b: n "%d\n", ret);/ W, g" j1 K* ^. Y7 e& F& V; C
#endif! a" z7 P& j+ M; Y$ \
ret = platform_device_register(&da850_evm_tl_leds_device);4 L( j% m2 g- q* B: V% T
if (ret)( }8 V( s' X9 @8 V" q* T( q# u6 A9 o
pr_warning("Could not register som GPIO expander LEDS");- s3 W0 d* ^- W# N1 H: o
else5 k4 y o+ c3 c" x1 G; X% Y0 B+ Z
printk(KERN_INFO "LED register sucessful!\n");+ q& H& ~; G& K" _! \6 a4 X1 {2 P9 \
8 z( e) K2 J' r1 V5 L+ o5 ~ return ret;# M) l4 [! k& X7 h) Q4 A* H" y$ C9 K
}
$ F" O' D2 R, f H3 D2 F$ d
- J$ t# D$ ~- }' istatic void __exit led_platform_exit(void)
5 D0 U( f" {" }) _) U6 \{$ o( ]8 ^% y! n$ w' T
platform_device_unregister(&da850_evm_tl_leds_device);; ~9 E+ e+ s' M
: z$ V! x5 ]9 J9 T- _6 h- I
printk(KERN_INFO "LED unregister!\n");
+ S$ V/ d; n, I, \6 t& n& n- C}+ g" i( k( @0 F( `5 ?
5 m( f$ {: _4 x. u* L
module_init(led_platform_init);
c c# B# ?4 g2 j& l% \7 f2 Umodule_exit(led_platform_exit);& Y" O5 l9 ?7 F$ a
% D! ~/ N- x; i
MODULE_DESCRIPTION("Led platform driver");
9 O- a7 n0 F% }) RMODULE_AUTHOR("Tronlong");- [* T( b. \% s9 x" \, d7 a
MODULE_LICENSE("GPL");; G/ E3 n! E2 @
$ {/ @% s9 f9 ^+ _. f
|
|