|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
/ t9 _1 E. |/ D5 R- X& a" C5 z#include <linux/init.h>( `; q. N0 h5 r @) h; l7 ^
#include <linux/module.h>
& i3 @6 H6 U/ f, X0 C7 L#include <linux/kernel.h>' Y/ r# s& G5 i* |6 M v- l4 R
#include <linux/types.h>8 w9 y3 B) S: ]( f5 ?$ j5 a
#include <linux/gpio.h>
5 I( B2 \/ W" J6 c6 n% V#include <linux/leds.h>. s3 J8 Z' g1 {. r9 g8 p
#include <linux/platform_device.h>
( v. k7 `+ z# _% ?3 S
* y3 Z" D& N& Y#include <asm/mach-types.h>
' x! J% T, A$ P* _' H" c8 Z; i: a#include <asm/mach/arch.h>5 r, [+ @1 u, L: b( C$ H
#include <mach/da8xx.h>
0 V1 K$ F5 ^: ]& T/ @/ W* T$ S! c; `#include <mach/mux.h>
: y& J" S7 c5 F$ C" e
X& K) S/ u, v: k" K! }#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
( T6 {' [4 r! @' m+ N9 r9 [' O0 D#define DA850_USER_LED1 GPIO_TO_PIN(0, 5): [2 `! l( a" v# z9 f4 p. [
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)# f- K8 I' Y7 S
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
8 C1 x! E0 `0 m8 I* B8 U
% S) M* e6 T6 P0 y/* assign the tl som board LED-GPIOs*/& q# K1 |: f6 ~/ I
static const short da850_evm_tl_user_led_pins[] = {3 v2 t2 G0 a+ O* k) T+ N/ A( d
/* These pins are definition at <mach/mux.h> file */& D$ b5 m+ ~/ t( i
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,- J- S8 e0 q/ D6 z+ V$ L( y1 _3 y
-1/ t3 F) L Q: L2 h: H
};
8 I4 @' ^, K7 X' B* n
4 y$ f: O# u1 r7 n' b' a' bstatic struct gpio_led da850_evm_tl_leds[] = {
5 S1 D2 h; v: L4 |) \$ U {( I% w- ^( B- c4 h+ F
.active_low = 0,
( m3 ?/ N7 i$ F) X; S$ w .gpio = DA850_USER_LED0,6 I" B8 a5 o u/ [ s8 n
.name = "user_led0",
! [) }5 D& a% m7 D I- n1 {- K6 t .default_trigger = "default-on",
; g" E, M/ J; o$ V },# m. D4 M; D# }$ W- g3 o) q5 w
{
W) _0 T8 f6 `% y .active_low = 0," x; U R# T+ E/ [3 t g* y
.gpio = DA850_USER_LED1,# Y: f. D4 Q; W; ^" C! R
.name = "user_led1",
& `, i0 ?" h9 a/ E: L, H5 j- E .default_trigger = "default-on",
# D8 X6 o% u( |1 F% M },
: Y' m5 V! `, w [( J1 d1 f: B {/ n2 t) ^; j5 C5 k0 m* _2 s
.active_low = 0,3 d# ^4 j8 g6 t9 y
.gpio = DA850_USER_LED2,# F8 w6 g7 V" c* H, V
.name = "user_led2"," V) I: b7 L- p. K, B9 c# {: V
.default_trigger = "default-on",
7 o* a. x( r5 H/ v9 r5 W5 P4 q },; C$ \6 L k/ j
{
9 E: B5 S) N9 [, k* q7 A; Y* S .active_low = 0,* |, K$ q, q3 x+ Y6 @2 U9 o
.gpio = DA850_USER_LED3,8 u; f2 X3 [ h( I. k
.name = "user_led3",) x7 y: V- ]; b. O
.default_trigger = "default-on",) m2 A) K: H: t& h
},3 j. X- f& U% Q: i
};" f5 u! f. r0 l( B9 l8 r* s
' |( O9 m% v Q4 jstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {& `, h; X5 U2 A, k+ x
.leds = da850_evm_tl_leds,0 r+ y! W6 X1 C8 m s; x! x6 x
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),, C$ h1 X7 j5 B6 t! i% f$ O8 r
};
. P; ^" ]; h) S E% K; M$ T t$ Y0 f+ O7 k2 G
static void led_dev_release(struct device *dev)- T. k) `: ^2 \4 P
{: N% N1 `+ s2 V' |
};
/ q2 i! X+ I% [) j# B1 D3 K w; a
8 T( n. f% s8 Cstatic struct platform_device da850_evm_tl_leds_device = {
# y; U2 V/ {; F .name = "leds-gpio",
6 y$ q2 K; D+ b' M .id = 1,( G9 w( M; R/ R/ `- j4 b
.dev = {
) {1 e* {9 B6 _( S M9 R. p .platform_data = &da850_evm_tl_leds_pdata,
" O# Y0 B9 ~4 \7 ~7 i7 \% @ .release = led_dev_release,
: C/ j# f% G* N: G8 ~) y }% V7 E0 N; A7 t( I
};
' ^3 S: M5 r2 k6 ^5 ]9 B$ L0 N6 P. a( e2 \+ N$ [+ w
static int __init led_platform_init(void)
0 _/ A5 ]; J! \' M$ V{
$ V3 Q2 k* u# i' |& a! { n$ U int ret;' {0 w' q% B- a# w
#if 0
) f2 X$ z1 c4 a ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
0 w) b6 Q X0 `3 x7 |! C5 j if (ret)' _$ H) E. N# L1 u7 s# Z
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"- b) j; f; F. z
"%d\n", ret);
' @/ \; X V. f% q* }#endif
: Z3 t7 s c7 I2 E+ L ret = platform_device_register(&da850_evm_tl_leds_device);2 H% Z6 ^, u" M x9 O
if (ret)) |( A- @- o9 i+ f4 X
pr_warning("Could not register som GPIO expander LEDS");+ Y7 Y3 v: W; `$ x' `) [
else4 Q( O- x$ `7 p& f W4 o' t
printk(KERN_INFO "LED register sucessful!\n");7 V* C/ i1 N& O; k
4 _8 R. R/ e5 b( ?9 [; h5 a return ret;
$ |- L+ Z, P7 [7 N+ j8 G* K+ D}
$ u v, a/ {6 Q9 X# e# ^
8 w7 m0 g& \+ g1 l! ]2 gstatic void __exit led_platform_exit(void)
& U: N* `7 @$ ]. S) K8 ?{
+ U3 d4 y2 B4 j9 ]" T3 d' Z2 N platform_device_unregister(&da850_evm_tl_leds_device);5 o2 l- d# S' A5 A6 ?' O& ^
( n$ Z, r1 F3 N( a( g) T& @
printk(KERN_INFO "LED unregister!\n");
2 e3 O+ `, h' D. w+ a5 Y' d}
. M1 W# ~1 N l- d
; ]* l4 w5 N. j' ?8 k1 E% I+ Pmodule_init(led_platform_init);
3 z% U9 F3 n m" Umodule_exit(led_platform_exit);
0 v* a" d* i1 ?2 W3 p# z9 _3 P
0 m1 n. \9 F; O8 `9 t% e% p; w) nMODULE_DESCRIPTION("Led platform driver");1 D K9 V5 g; D$ d$ i
MODULE_AUTHOR("Tronlong");
# m8 B1 j7 y. g* BMODULE_LICENSE("GPL");
2 F; X9 ~+ E5 u4 S+ M2 M9 T- A* k3 V! i
|
|