|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
! E3 ?/ X3 n1 F3 @#include <linux/init.h>% v' J9 j5 _. b: l
#include <linux/module.h>
2 @1 z/ A7 P9 g6 i/ A1 J5 |) z6 K6 V#include <linux/kernel.h>
% z1 S: c# V5 N/ k* Q#include <linux/types.h>% ^1 m8 V# U8 }% w% z5 R
#include <linux/gpio.h>0 o4 X+ z. U* m o" ]( _
#include <linux/leds.h>
: K4 `( d6 J0 J1 a+ B3 v( G" n#include <linux/platform_device.h># ?& Y2 G O8 d2 [$ o
& U1 T$ [: n: W' P0 c#include <asm/mach-types.h>- E K" {$ \# Z' A) c
#include <asm/mach/arch.h>& _ W' m5 }# ~1 i# `
#include <mach/da8xx.h>
. ~" X, b$ W& h$ ?8 v- Q. ]#include <mach/mux.h>
: O/ @' `6 i% V* _5 U0 O; g: ]1 r, V0 X6 b
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
# B V2 h( c; q' X9 U#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)+ N6 b; N9 e7 ]5 F: y6 @+ K
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
8 s# ]0 I/ ~1 r# C- Q#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)8 Q4 b/ x7 W ~0 _( t
f8 a$ r; {. j# [: ^# ]) C
/* assign the tl som board LED-GPIOs*/
) U+ ~) C+ u9 w6 O( l0 }. wstatic const short da850_evm_tl_user_led_pins[] = {
6 P: U+ v( X* y7 g- p8 z* x) ^8 g, a /* These pins are definition at <mach/mux.h> file */
, X' h; w& T1 z" {1 g/ d# ~ DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,( r3 h; p# B( x; p X3 e& s3 S
-1" W' h6 V* v" L4 v; b: C) B
};0 M2 c# g0 Z4 t+ e2 G0 i' }
7 C, P! c' k! j& C0 L3 Bstatic struct gpio_led da850_evm_tl_leds[] = {; h6 q6 B0 T7 S* b$ p
{; ~) _ c6 a1 `
.active_low = 0,
; I" d3 [/ W! {3 c .gpio = DA850_USER_LED0,
& J9 Y* n' E, T- j4 I5 w" t+ E .name = "user_led0",) e" a5 _ h0 G) r4 \
.default_trigger = "default-on",
8 b/ v7 v& _, k! R5 E9 \* Y },
& \# N; e' y" B! o {/ J4 ]$ P5 l6 \6 L. I; a; B( H
.active_low = 0," E4 J& a* F* Z! M; j, o
.gpio = DA850_USER_LED1,8 U7 A% A" F8 D. w9 m) X
.name = "user_led1",
: I# |) K" m& s, a( C! A. a6 d* X9 } .default_trigger = "default-on",: |& F Z: Q" t2 m. F: A N; [" e
},
; d4 S0 X6 W2 u7 g4 h {
* f! `' l) a' k1 C .active_low = 0,0 W* J+ m8 i2 ?. R: f& b
.gpio = DA850_USER_LED2,
) R+ X( p Z( o4 y5 s" k3 J) z .name = "user_led2",% ~# I9 t% M# @4 i
.default_trigger = "default-on",
4 G" @# |+ Z: w% x5 y( w# R" \ },. I3 g" R7 q2 m) G- A$ `, ~' b
{. A- s7 T# t% J. P( p G3 ]( p( K* f
.active_low = 0,4 S3 M; h" C& k0 k+ ]: v
.gpio = DA850_USER_LED3,
. A% L/ T" g) `$ Z, T6 _ .name = "user_led3",
( _0 ]4 X( [; F5 Q1 e0 l .default_trigger = "default-on",
$ }( f( U" {0 m ~& k6 h" {& Y u* b },+ x0 i9 t* `/ b
};1 `! c3 ]+ u$ O4 B! Y& _) ~9 @
7 }6 p7 M8 B$ l9 a+ K9 P& \# }
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {2 \0 D! t; `) A2 P% s, ^( z. V1 m
.leds = da850_evm_tl_leds,+ o0 n+ F& c3 z5 z
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),
7 c4 ]# }. {3 q7 r" L$ M+ i3 c2 {% T};
4 {% W$ ` o6 h* M: k; c
$ o% B4 I; k. d$ z$ \% @5 {% O9 Rstatic void led_dev_release(struct device *dev)
* N# ^% V Q/ C& `/ u" t5 ~{
% u' @3 s, W5 Q( r) O' O, m$ i2 \; P};
* j, {9 V* z# Q4 y0 h' d3 G
. [/ X# L3 p. I6 x0 x, C0 x) K9 Istatic struct platform_device da850_evm_tl_leds_device = {
4 S* A" l1 H: u2 u/ k# i .name = "leds-gpio",$ V; q. M5 |4 M( ^, S) q
.id = 1,
: K7 M3 N% C: @5 o: _% x .dev = {5 L$ t" P/ V% u. @( ^
.platform_data = &da850_evm_tl_leds_pdata,2 I$ e1 h6 N& t5 d+ H3 p
.release = led_dev_release,. V; q O0 i* d" ~, V
}( ]! E9 o: o7 L( g+ i
};8 B$ n) o- P5 ~6 t
! N) |5 c5 l7 @$ u7 l. ]static int __init led_platform_init(void)
5 O% F9 ]- A+ p$ l" _1 C) \& A{
1 O# ~9 Q! m) o% M; I7 A int ret;( v" ~* }7 D, P$ ]
#if 0
" m& M+ P7 y0 g4 {6 E* { o ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
) j' j5 h1 O L! m4 ^ if (ret)
3 { d& U1 x& P! k2 e pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
% [* h" Q! c! [- K4 U "%d\n", ret);
) }3 t( x5 E- j( b, l7 ]#endif
2 @( S7 I U( u% o# K ret = platform_device_register(&da850_evm_tl_leds_device);8 F- X* i! I- I7 G) Z9 J: N
if (ret)
% ]! J- J" v! h. A4 Y, P pr_warning("Could not register som GPIO expander LEDS");1 J$ {. R# ~* h3 W* f
else& N/ ?; W. @( `7 |: B
printk(KERN_INFO "LED register sucessful!\n");3 H) b4 f2 u. Y9 c) |
5 E+ A9 a$ Q7 Z4 h
return ret;
; v4 @) i/ I2 O( [}# I6 @2 h9 Q0 i$ L6 m
- U) d0 U2 x2 |* R# ^0 [, j! Dstatic void __exit led_platform_exit(void)
! b6 W& I# \- k# n' m{
: q O8 V* Z; m0 P* Q. I9 e1 M6 O platform_device_unregister(&da850_evm_tl_leds_device);1 n- t. g$ R" R+ G, W
( O6 G- H( t; J# q2 d: C4 ]
printk(KERN_INFO "LED unregister!\n");
) o* `) x" ?6 v0 f- R" p, M9 v6 b}5 Q3 i( C) s& [7 {
+ G0 O# e; M( i3 s) fmodule_init(led_platform_init);
2 i! l4 X% ]4 X& [/ Umodule_exit(led_platform_exit);
2 l6 C& ^& x$ i. G2 }
. O9 l( B) m4 T2 U# kMODULE_DESCRIPTION("Led platform driver");
% I: C0 V; V* U, B" fMODULE_AUTHOR("Tronlong");: x% W& `/ X3 J/ B9 {# e
MODULE_LICENSE("GPL");7 e5 q/ _, a0 a
6 q: `9 A( n4 x4 K8 Z! A. ? |
|