|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
! O8 v2 H" J# C! D4 i#include <linux/init.h>
4 m m0 s3 g/ P1 n0 ]2 X% B4 H#include <linux/module.h>
6 O6 P$ }& z5 u( [1 k/ Z#include <linux/kernel.h>
7 m. n( v3 D' W3 Z7 ~# I+ x9 Y# g#include <linux/types.h>9 P6 }. V8 z! }( N6 W
#include <linux/gpio.h>
8 l; y- E/ w2 Y$ D5 [3 F#include <linux/leds.h>
; v' i( e8 q, I M3 Q: H" \1 I& X#include <linux/platform_device.h>
, b6 n F: ~. ?5 e& n% i
* N/ B" k. a$ V5 Z1 C; E; w Y# ?#include <asm/mach-types.h>
; f$ F1 [) K& ~6 V#include <asm/mach/arch.h>
5 g: C& g; w" J5 J0 x( v5 f#include <mach/da8xx.h>' R( w; ~% Z3 e
#include <mach/mux.h>
# ~+ ?5 c" U( x+ ^$ Q [# R7 X- M0 o
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)7 v# j! W/ Y& q" j3 u
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)! I4 {, k" L9 F4 a
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)" y/ O, ?6 [3 L. y8 }
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
6 V# i5 C- p( T% V8 \$ w- N0 z# ?" l' T9 @- d
/* assign the tl som board LED-GPIOs*/# c2 m& f& U: G
static const short da850_evm_tl_user_led_pins[] = {
, F9 c9 C1 u. @* n8 n /* These pins are definition at <mach/mux.h> file */0 q# g! t4 \' U" Y
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
. u6 i9 x# [; k; I N5 _8 j -10 ~6 B: }5 N) X4 V
};. d% }+ n* @- g$ y% Q# W
9 ^' ~) J f+ Y, B3 Z$ E' v3 w* zstatic struct gpio_led da850_evm_tl_leds[] = {
$ N! x% n- }/ ^, b: `" l2 t) m { i- V3 j1 W4 b- v6 o r& Y9 u& B. P# b
.active_low = 0,+ Y2 D2 v1 C! }( M, e
.gpio = DA850_USER_LED0,
/ Q; J, X6 _% Q6 m9 T0 o% ~ .name = "user_led0"," _; [$ d& N& F
.default_trigger = "default-on",/ @% K4 ~; f. z# @5 |8 `1 \
},
9 ?( C: N3 N. T" F+ j) z {
8 K2 L& q7 _; R( {: J .active_low = 0,
" R, I; ?* B4 W. r .gpio = DA850_USER_LED1,# M" r! E( p: |: r1 M
.name = "user_led1",
8 u7 n @. ]$ P D0 Q; V" Q .default_trigger = "default-on",
3 P: a( D6 A! o+ H: r0 q: v },
) o) O* m. f- ]# ]' X# o9 k1 o {# D/ y7 T0 c* q2 q4 u
.active_low = 0,3 P! }( J) M: y$ E; v8 C2 T; E
.gpio = DA850_USER_LED2,
! L7 G9 V) ]1 d4 Y .name = "user_led2",
% z8 h0 f) e+ g0 ]. U% ` .default_trigger = "default-on",
5 O& f; Z/ Q" s& U' v. n },& W) C7 `& f) E$ l. h
{! Z) h2 ^( T2 d% O$ a
.active_low = 0,- I( E" j9 m* {# C3 g3 J
.gpio = DA850_USER_LED3,
0 i A( w# ^/ s% S- ^5 X( ? D .name = "user_led3",* u" o8 g! L9 R1 B9 F
.default_trigger = "default-on",
4 c& z- v1 O+ Z },1 T, v% \1 o5 k' m' V
};& T6 \1 Y) o0 o! Q, F
" q- B6 z% [2 V
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
% J% n- ?8 r0 j* u .leds = da850_evm_tl_leds,
8 r# G8 I& w2 c; c. w. D+ c7 Y .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
) Z2 {* N) X+ ^) d7 R3 b};, V3 n Z8 S" F [8 t( n6 N
3 V+ o3 P; C# t% f( S `static void led_dev_release(struct device *dev)
' H$ Y4 O( a; G{/ r, a [; N u8 d, V! V! R& G
};5 I6 Q* U! u) X4 R3 V2 t
4 E/ G& P3 ~" _- {6 qstatic struct platform_device da850_evm_tl_leds_device = {4 y) [& c9 ~! _4 _0 @+ e* ?' i0 H
.name = "leds-gpio",
& q8 N* g7 C5 U# _7 {( L .id = 1,
# S1 j- f- @% @7 G/ Y8 u .dev = {" y2 P3 C9 M6 f2 N. J' D, w6 E
.platform_data = &da850_evm_tl_leds_pdata,; C' x/ H& Y/ a" C
.release = led_dev_release,
4 t) ^$ p' }4 j7 r% ~2 g }
?% y: V+ [- t( X$ S};
' l" r8 V4 Q; Q( Z+ i W4 w* o4 P J& J& }" c2 W
static int __init led_platform_init(void)4 o/ B' s+ T0 A$ B
{
/ Y1 C0 _/ V. R4 b) y int ret;! `) q4 W) F6 }1 }# R3 i( v- b
#if 02 M6 l. V+ N) W* }$ P
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
- e/ u7 U. E y4 m$ J( b if (ret)
& @1 i- i* {8 a- j pr_warning("da850_evm_tl_leds_init : User LED mux failed :"2 u' u8 A2 x J! a
"%d\n", ret);1 [0 b2 g$ K3 Q* s4 j2 ^+ ?( M
#endif+ J" L4 H9 s( o9 ^! f
ret = platform_device_register(&da850_evm_tl_leds_device);
0 s) [3 H; H7 Y4 Y% q if (ret)1 t8 w) W/ i8 m' N6 h& `# l! D4 e
pr_warning("Could not register som GPIO expander LEDS");4 y+ j8 d# o& ~6 @5 ?" G% g
else
* K! B, y: m5 i8 i printk(KERN_INFO "LED register sucessful!\n");
" _% w1 n' D2 P' _+ t% n/ C0 Z( E" {
return ret;
2 |2 Y: J' o3 x' E- m}
7 |$ `% t" k& A, e: m' v+ A* E( T& G1 N3 E' \6 Q1 O
static void __exit led_platform_exit(void)
# c: @1 q) P6 V{6 \: g$ B8 o* \7 w, c3 I7 h
platform_device_unregister(&da850_evm_tl_leds_device);
, y/ y9 [9 N$ e I5 {3 e: d& }% }% T, { F+ M8 ^8 G
printk(KERN_INFO "LED unregister!\n");# z8 ?( s- S3 b
}; J6 R& L. _: b- i
* [/ W4 c- T' [+ u7 \module_init(led_platform_init);
3 w5 [ b5 g, u( F! rmodule_exit(led_platform_exit);
6 J$ i- p% `1 c9 z
# B9 Q9 Q3 D) T* o! I1 t" w: I, Q: w8 mMODULE_DESCRIPTION("Led platform driver");8 u! I( C& [8 A! h g
MODULE_AUTHOR("Tronlong");
5 X% F% O3 }5 D/ eMODULE_LICENSE("GPL"); g0 P( Q" d5 ^, V+ F! h; ?
% U* G+ ?7 n! u: s. [7 S
|
|