|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
, q5 V7 t+ `$ Y8 E3 X7 R6 C#include <linux/init.h>
- w2 j/ Y5 A2 d#include <linux/module.h>
3 F1 s3 d$ o9 R8 n) d#include <linux/kernel.h>
C T. N+ l/ u; L6 u& p6 S#include <linux/types.h>* Y' {8 e: j+ g1 U0 s+ k, A6 R
#include <linux/gpio.h>
5 \9 |' O; V: D( E' n4 b#include <linux/leds.h>0 @7 Q' O6 H2 S
#include <linux/platform_device.h>, b, G$ t# q" r4 F& }" ~ Z
0 S8 A/ ]7 d8 F* @4 v" o q( Y+ r
#include <asm/mach-types.h>
% Z( K- v, ^- Y#include <asm/mach/arch.h>
, w0 X$ B) K+ X9 O9 S# s8 i/ q#include <mach/da8xx.h>2 t% v& @3 T# K$ }. B* \) `7 w( r
#include <mach/mux.h>
8 L, M K2 q$ {3 d4 H* A' c# i8 z4 c0 g6 W/ c
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)4 i: S' I9 w! W0 {, X0 C+ }0 o
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)2 f( ] I/ l6 s1 m9 S! O
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)1 ^& L2 A0 U2 }, E4 n( g
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
: S- m$ ? r3 ]
# K L- J" r0 H/* assign the tl som board LED-GPIOs*/" P6 C5 o& W- K3 _, E
static const short da850_evm_tl_user_led_pins[] = {
$ y; w( V( i7 E( o5 i1 p: L/ r /* These pins are definition at <mach/mux.h> file */
/ \ v# f1 N& L* b1 Z! R( V+ ^ DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
: G$ b. w; I6 s9 t -12 h; Y+ a4 o6 u! G T. { u5 o7 W( C
};
# C1 L9 s* A0 d E
" r2 Y+ l' @8 @static struct gpio_led da850_evm_tl_leds[] = {
) H2 v: _' B5 t2 R8 a( J# p {
: y2 U8 {5 ]( {7 J9 L( l5 n .active_low = 0,
7 j6 X2 Y- X1 S L) s .gpio = DA850_USER_LED0,
- y# u5 Z, J8 J4 e( U6 [ .name = "user_led0",
& I! E; g. h1 Q* ? .default_trigger = "default-on",
& y6 V: {, Y2 s0 m* D; I2 V# b },
; t" y/ p% i7 f' R# x8 k0 d4 ] {
! g$ o: e+ m. b! y) |4 }. P7 \( U1 ` .active_low = 0,
6 J% T* W' j/ V1 W O% i4 O% M, ? .gpio = DA850_USER_LED1,/ @( Z' D9 l8 j: ^
.name = "user_led1",+ z- U8 w% B( q0 { U: c2 b. g0 B* L+ S
.default_trigger = "default-on",) |" S; ^: C; r( }2 A
},
3 E6 }" @, ?4 Y' \) o5 N {9 {& Z" ]5 l+ I, r
.active_low = 0,
7 D) `, E4 E4 C r* m3 Q# H .gpio = DA850_USER_LED2,
- _) e' @7 ?# G! q3 ^* v/ w$ h$ k) o } .name = "user_led2",
9 L a9 G) h* }- p .default_trigger = "default-on",6 n2 n1 x3 }$ `# R; ?6 D3 g
},
* o! E% ~; F9 `- J0 E {
. P, S9 L( S' _' ]4 I .active_low = 0,! d3 `2 O; h# J. \! _, I) c7 f. ]
.gpio = DA850_USER_LED3,
% A3 |; h4 X" b# m$ K6 h .name = "user_led3",
3 @5 `: Q3 R$ I' S& D4 g# Y .default_trigger = "default-on",
6 V" _$ Y w- K% k },
0 C3 N2 w9 z) o};9 N0 r6 B+ G4 K, W r
+ r$ S4 ~1 {$ ?& S i; F
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
8 j o3 d& y5 b$ G( O$ E6 r- L) F .leds = da850_evm_tl_leds,
: k( h; e) h; O" n7 D .num_leds = ARRAY_SIZE(da850_evm_tl_leds),: m) p6 s2 S* }: Z0 ^. y
};
/ ?9 J" ^! I( b1 N9 Y6 [4 F7 m$ w6 t8 E2 s7 i: c. F) z1 j
static void led_dev_release(struct device *dev)# P5 v" V; a* V& x3 n6 o9 p/ N4 j
{; v3 ~1 E! p2 R/ S7 |5 I- D1 b \
};
. \- u6 G1 p% L$ M Y8 u( i. G% L+ x- |. r1 C1 x
static struct platform_device da850_evm_tl_leds_device = {( D( T, K) u3 c# L( O# x
.name = "leds-gpio", j3 ]! m H$ t) y3 C
.id = 1,* y2 h2 n8 \7 V- B0 |& \
.dev = {
7 e$ ?! h3 j, [7 [6 f3 _+ Q" w# ]1 k .platform_data = &da850_evm_tl_leds_pdata,
! \6 L+ K( I& v. ] .release = led_dev_release,: m) H' @) c) x" g9 {: F
}
# A, w8 z2 K8 N! W9 ]( W+ t};
* r) u1 q0 k' p
6 j y! S* V6 N9 e6 u- dstatic int __init led_platform_init(void)
" L8 i; g, @ N9 d) v& R{, i8 U1 h5 C& N: Y6 g
int ret;! V D% ^7 h! I( v5 Z0 H* }* l
#if 06 N: e9 } v* W
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);9 n$ C- Z$ d: z$ H
if (ret)5 j2 q- z N5 j4 T# {7 X
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"/ Y, G; ]# |* R
"%d\n", ret);
4 U( s& X; i8 }& _, ^7 ^#endif
' z7 Q% f1 f2 ]6 N ret = platform_device_register(&da850_evm_tl_leds_device);. m( d# [* v; y. r6 l/ F. t$ d3 Q4 {
if (ret)& o# G/ Z+ S1 p; x5 W
pr_warning("Could not register som GPIO expander LEDS");
3 D$ @! _* W$ A. \ A else3 E% P( A! P4 q7 _
printk(KERN_INFO "LED register sucessful!\n");
$ R6 s0 b9 P) R; c P" f k
! [7 H) ^! x" ?. I- p5 c return ret;3 Z7 k6 ?4 D; S- f
}
: c9 I; O: ^# d6 o4 F6 o* \8 u5 S# i$ u7 m1 w. N" G# _1 ^
static void __exit led_platform_exit(void)
; F. Q" \+ H: d% ?6 x" T{
& I. ?7 M& p+ F* m7 M, h platform_device_unregister(&da850_evm_tl_leds_device);" ?1 \( {% L! D4 W! L" @( \
" Y* V8 f- R: G( u# E, l3 a
printk(KERN_INFO "LED unregister!\n");* l# g8 s- [$ N6 Y" A2 i, T F: f
}; L+ ]6 D( N! Z7 L* C/ E6 L
5 t6 L: q' F; b4 `# @- B
module_init(led_platform_init);
2 p! Y6 ?$ b* G. R3 Z4 _* Omodule_exit(led_platform_exit);
6 M1 k$ L6 w( [3 Y$ S
" N4 a! D' D: L! N, ~MODULE_DESCRIPTION("Led platform driver");4 l* P' G! J( ]+ C5 g
MODULE_AUTHOR("Tronlong");
& a! s$ m: k/ X K r6 q2 PMODULE_LICENSE("GPL");
3 h9 g. @0 Y2 `4 B E8 X$ B( V- |' J
2 g; k/ W$ \8 t. }! I |
|