|
|
求大神给下面的程序做注解,请稍详细些,谢谢。' j! G) L; l* A9 w2 e# E
#include <linux/init.h>( s& B* P4 T T# u# [( Z
#include <linux/module.h>
7 w( L5 u' V$ [* y" Y# l#include <linux/kernel.h>
- D5 {0 n5 c$ C& w! G/ q& h#include <linux/types.h>
0 @; @7 M9 ?0 g+ y v" `#include <linux/gpio.h>
) e# q- R8 d) }, }5 b T#include <linux/leds.h>
$ v8 h6 V2 F# c3 W#include <linux/platform_device.h>, P; n0 v! |( Z2 {9 B' c+ B
9 [- \0 h: n8 {7 Q#include <asm/mach-types.h>9 B+ D2 [; e' e9 j2 g) d. e+ `
#include <asm/mach/arch.h>! u: p v! K: E1 j( d5 }2 D( R0 X f
#include <mach/da8xx.h>
$ s0 N& {2 ~9 u& \#include <mach/mux.h>
' i% D! b9 E% T5 |2 d% r
) x$ p1 k3 ]0 G#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)( L g% J" S# }. e
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
; T: {; y9 i" T2 V$ @* i: y#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)" }8 x, S$ w. D
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2) U$ m5 T) R- I1 D" i
: J) t) \: b" m( X/ I
/* assign the tl som board LED-GPIOs*/
$ _% F; P- @( M+ Ustatic const short da850_evm_tl_user_led_pins[] = {
4 M$ j( l1 g+ I! C! L5 |/ J /* These pins are definition at <mach/mux.h> file */
) n- P0 m+ B9 N: ? a DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,' o( ~2 g5 L6 X# \; a" n, O2 d" o
-1
$ S( \: r; \2 q |) M};
* R/ G9 K6 e" ~" T. P; G/ \! I8 ?6 ~9 m% A
static struct gpio_led da850_evm_tl_leds[] = {
2 n- N3 |. G" O- {( w( c1 B8 Q {
* p2 F2 T0 Q$ r; T .active_low = 0,% r+ U R4 w! T, g" C: N& H
.gpio = DA850_USER_LED0,+ j4 f! Y: x+ l/ F2 Y
.name = "user_led0",
, x( M F5 y+ K; o .default_trigger = "default-on",
5 }; O& V% ~0 T' R: x: s3 _ },
, v" b# N0 ?# O) ]. L6 j {
, t7 Y, G0 g; ~" E7 s6 G# e .active_low = 0,
/ A H$ e2 ]2 L4 _ .gpio = DA850_USER_LED1,
! i Y, f# O9 ]' Q. A .name = "user_led1",. Z6 @' ^8 R4 ?; y% ^
.default_trigger = "default-on",' T* z: L, m) o9 m5 b, j/ C
},8 R: n8 s) a% o
{
2 Z8 V1 ^5 g/ e4 Z/ A8 x .active_low = 0,
0 i! [% G5 c6 q9 j1 `5 l .gpio = DA850_USER_LED2,* u$ y/ i+ O- C8 t4 K
.name = "user_led2",3 `7 D' p5 S+ c
.default_trigger = "default-on",3 {1 P8 B8 `: u7 @ Z; e8 i1 V
},
/ G4 e C8 z: Q) C# d- g {1 L: b* R6 {+ B# k& l _, N) b5 Q
.active_low = 0,
; o+ O e- {; t& `6 j( ` .gpio = DA850_USER_LED3, {2 p [% n& {+ i6 w3 i; L0 D$ l; U
.name = "user_led3",! V6 \6 {6 W/ L8 _9 d( ~+ l
.default_trigger = "default-on",$ J5 ]3 J% @, @& O1 E2 ]: O* w
},* F5 J5 R2 j) s
};
" {' k; z" i! @9 J
. V7 S/ s2 i3 g' C1 }static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
# `; x+ T2 _ H& j .leds = da850_evm_tl_leds,9 U& N# n4 ]) n7 ?2 J# Z
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),
5 |6 l1 C# w. t- C9 H$ N4 J3 p+ N* i};$ W+ d0 Q% \! N6 \0 @
# D; @7 U: H+ A, w$ z
static void led_dev_release(struct device *dev) O: b2 o- d2 H7 s4 @: X4 A$ r
{
- ?& @' L( ^1 Z};
9 O% @! g+ i" }' y( o. n' o
5 @9 y% c& E3 p: ^1 Istatic struct platform_device da850_evm_tl_leds_device = {
$ s' y' `3 [, J .name = "leds-gpio",
" w" G( s3 @: w& W7 g* S; `- U .id = 1,
6 [( ]/ h3 U- @- c3 ?; F .dev = {1 A7 U. y% T# ^7 \7 h' s& N$ ]5 C
.platform_data = &da850_evm_tl_leds_pdata,7 O- N! x; Z# A# s
.release = led_dev_release,
% n) L8 E) x6 M }/ [2 E' J; {- h- M2 W+ d
};7 u& }/ a# s1 r! ?& m7 K
) y( |$ q- R# [9 i7 r e/ lstatic int __init led_platform_init(void)) I# A" O5 H. ~) Y$ q* W' f: K7 u
{
$ v3 ~5 o+ Z# W' K2 P4 l1 s; m int ret;1 g5 y+ ?; f: X7 i4 k7 q9 H
#if 0
Z4 w. z( o5 ]: Z ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
" {7 B5 C4 j! h$ ` if (ret)
7 m6 c3 k7 w7 ~% D1 X* F) o pr_warning("da850_evm_tl_leds_init : User LED mux failed :"+ I: A! Q' t% q7 V2 T2 i8 X
"%d\n", ret);
% x% u( D% [& O4 Z% i#endif
$ D7 e- {% B8 i& V: I ret = platform_device_register(&da850_evm_tl_leds_device);
) U( Y. z4 D# U2 Z/ L7 j if (ret)' y; Y# P1 ^& V1 e' [: X
pr_warning("Could not register som GPIO expander LEDS");5 v# q% ]0 q3 U! c3 C7 a5 k
else. h, z" ~% M$ z8 u/ \" e. V0 G- y
printk(KERN_INFO "LED register sucessful!\n");
2 X5 ~( u1 q0 F: a
% S- S" P2 E% X2 i6 M return ret;3 X! p( A/ F8 m
}. }% r- D, I `( g. s
3 {. H$ n5 r3 H( [- N k* [, {. G
static void __exit led_platform_exit(void)
) m6 z/ H* I4 G/ |/ K! w, i* H1 H{4 o% _, D7 x) {" ^) i* t% \- U
platform_device_unregister(&da850_evm_tl_leds_device);; Z p$ K* z' Y/ }7 R
" a% Y9 F7 H) L2 l
printk(KERN_INFO "LED unregister!\n");
$ Q8 V/ |, W8 B0 m3 A' b) C}
7 x) o" ?! H9 b' [0 Q' G4 A4 a3 M9 q! L- p: c8 N
module_init(led_platform_init);
9 Y: n4 s1 O2 a: a+ G- g; Qmodule_exit(led_platform_exit);' V& k4 I) I; ?3 j6 |* X% n- O9 J
5 M- B i$ k7 ~7 g% v, ~: g w7 WMODULE_DESCRIPTION("Led platform driver");+ ]' v$ h4 E- k, ]
MODULE_AUTHOR("Tronlong");2 I/ F% l. I8 [2 Y
MODULE_LICENSE("GPL");
/ H9 R9 @; t- J4 e6 o4 J) I9 m& m2 I) i* q4 u
|
|