|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
! ?; A1 d, ~- i9 t2 B#include <linux/init.h>* B( N! }+ Y, o
#include <linux/module.h>5 f+ a$ p. j; A. W
#include <linux/kernel.h> N) P+ {! F# ^% V" ]
#include <linux/types.h>
8 v# T+ }$ a. J# N#include <linux/gpio.h>) s. {( l: \2 N2 j
#include <linux/leds.h>; i/ s4 G" n/ ^. E- I* a n; {
#include <linux/platform_device.h>
b# }. w/ C5 U" `- a1 {8 C7 ~3 T! E8 Y2 M1 G. O
#include <asm/mach-types.h>
, E; Y8 }7 V4 W) n- v4 A9 s#include <asm/mach/arch.h>
! T. q# l; l; L) I* @#include <mach/da8xx.h>
+ t. d9 q2 ]2 H) n#include <mach/mux.h>
& S) R4 a: H G2 a1 d* g" P; N
0 M7 j5 O" e8 ~, `5 `. Y$ b8 U#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
" E5 `$ S% v# m; k#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)0 k/ x3 y. n8 G& C! e
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)' `8 Q0 W7 y7 n' S+ n9 ]( J% E( Q% X
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
* ]7 W$ {2 ~, T6 j7 E* C& U
3 S5 G$ y8 n9 h# g- `0 f5 ]0 V/* assign the tl som board LED-GPIOs*/
9 b9 o1 R" S; o$ s6 R0 u' T) [static const short da850_evm_tl_user_led_pins[] = {
. e3 X3 O1 W+ { /* These pins are definition at <mach/mux.h> file */
* C; k7 m* E8 V: Q9 N# \/ u; i; h DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
3 U4 n V4 w" V9 t0 p5 m+ B8 M -1; B* N0 V' b; B" F4 s4 f
};
. K D9 n9 P7 b( p: o' t" y( N$ Y; O* \( F3 _ q( A
static struct gpio_led da850_evm_tl_leds[] = {
- r3 a( a; v9 Y* l; K! q {' `( N) P' a' Q1 X7 q' n$ |
.active_low = 0,/ |9 a: t K$ ^% S4 R7 ~5 M) h" C
.gpio = DA850_USER_LED0,
4 @; H" \8 k$ }' {7 c .name = "user_led0",$ Z+ |" l# \0 j# F# w, z
.default_trigger = "default-on",- }3 \3 F) I; w/ B) K$ c3 e% W
},
$ n* H5 p+ D8 n" p+ x4 j7 a { x* l9 Q2 X3 {* ` ?
.active_low = 0,
) R9 u4 `# ]: j* y; J$ l" A6 R .gpio = DA850_USER_LED1,
" w9 s! T: T0 E .name = "user_led1",% t: R! I& T8 R0 L" v. F9 i
.default_trigger = "default-on",
# h7 g! D+ o5 q* R. K },
$ _! z- K( K% U( c {
' }0 c) x/ [( x .active_low = 0,0 l9 u- q7 y7 T
.gpio = DA850_USER_LED2,% c$ Y' p! b5 y4 L# p8 w
.name = "user_led2",# F& |3 V' o4 b! n
.default_trigger = "default-on",& F0 N# e; z$ L9 h# N" e0 _; f
},
" w( ^3 w- P/ U4 T2 H+ b1 ^ {4 M4 a$ v# l9 j: K: v/ i3 Q
.active_low = 0,
' T" x' }" t5 q/ e) z: T7 y .gpio = DA850_USER_LED3,
0 S$ @2 w' z; k- x) D .name = "user_led3",
4 X- a& r" r- D- B) i7 y .default_trigger = "default-on",; Y# U, T$ `% V* B8 ~
},8 _/ d% M; s1 V- P$ m; F
};3 }% J) e2 f K& T: {- i
( I- ]; Q5 |) n5 E2 Astatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
, A. l9 ~9 I% n* {. J .leds = da850_evm_tl_leds,
* J7 Q8 H+ D4 q .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
- r, z( z' Y$ g2 E. D6 v- U. N};* j2 C& `" R! [7 F7 W" Z
Y0 ~# C, X1 k; @8 i. ?1 A J
static void led_dev_release(struct device *dev)
+ @# p$ u g* O1 p1 N# `! b$ v{
, v b) V1 v* M( P9 i7 C3 M1 I3 l};
* M* m: z' _) I% R9 q1 b& ~* ^6 @. M* B) [9 s |
static struct platform_device da850_evm_tl_leds_device = {
1 y( o6 s; S0 Z/ C .name = "leds-gpio",& p6 U3 ?- L$ p/ `0 r
.id = 1,2 A$ u) H X$ J& Q
.dev = {
' {( \ `: }: E( @2 O+ R .platform_data = &da850_evm_tl_leds_pdata,
& m/ y6 S8 ?' g: C3 M .release = led_dev_release,
! h/ M1 ~$ g1 r7 b }* j" b3 k+ s5 F; e( `
};) e0 ], L5 b x9 r/ M, n" J" p
* s& F/ g, z& Mstatic int __init led_platform_init(void)
3 b) ?. M2 Q8 T{
: P- t& t+ h! ]& L& M/ ~ int ret;- x4 T7 r0 G7 t% x0 {# m
#if 0
O+ p7 ]7 F; ^( m, s& D: s: p- R" f8 G ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
: ^ v9 t) y0 N4 u8 Q if (ret)
( M: B5 F* P2 R, j7 p pr_warning("da850_evm_tl_leds_init : User LED mux failed :"* m# Y8 o! o7 ]) l( x% x+ p5 p
"%d\n", ret);* h9 T# H& g' O3 q A! {
#endif' O* ~- \5 ?4 T R
ret = platform_device_register(&da850_evm_tl_leds_device); X. a- y9 C( @% Q
if (ret) m9 @2 c! t+ f% z
pr_warning("Could not register som GPIO expander LEDS");
/ o& a+ H$ ^/ g' h0 T else
" U1 H1 N' ?3 v" Z4 `" j% j printk(KERN_INFO "LED register sucessful!\n");
& j) l# m1 l" s% N! J1 x% C. {0 G6 P0 B; @ ^4 F# Y* X
return ret;: \+ z# U+ x7 A( g- r
}
6 f1 {3 @$ M. w, y
2 _( F6 n4 j9 |% jstatic void __exit led_platform_exit(void)
3 d$ a& @0 E! J' }. g# k{1 t/ y% _: t6 }7 g
platform_device_unregister(&da850_evm_tl_leds_device);
. k$ D* U7 J4 Z$ z- c: \6 K: G g! q3 @( B" {2 `9 y+ f4 A
printk(KERN_INFO "LED unregister!\n");
. ? }/ r1 _7 @9 R/ H}, V6 H) W8 y/ s
$ _/ ?) |1 g# ~' s: w3 Emodule_init(led_platform_init);
9 j4 b. q4 n* c/ \module_exit(led_platform_exit);, d& W: @7 ~) q
! q' ?! ^0 x+ `- G
MODULE_DESCRIPTION("Led platform driver");
, ^3 w4 [" H$ |MODULE_AUTHOR("Tronlong");& A- m1 U* V: x* W8 q
MODULE_LICENSE("GPL");
7 Z1 }% O2 N7 [8 G5 {
9 N# e `9 z' }3 k8 D2 b |
|