|
|
求大神给下面的程序做注解,请稍详细些,谢谢。! v" D+ t* E" J
#include <linux/init.h>5 j7 Q0 h' {/ A8 i1 x+ u9 g
#include <linux/module.h>
. w! w' K; H! @" D( d+ Y, n) V#include <linux/kernel.h>
3 y7 t4 j8 n; E1 }9 W; N#include <linux/types.h>9 i: X" N5 {; h, @
#include <linux/gpio.h>% \. N$ C4 v) y6 D: Y
#include <linux/leds.h>
8 `: R. C$ I2 ^3 U#include <linux/platform_device.h> _5 X. N/ M' z$ b( n: U
+ L/ V6 Y: B. Q#include <asm/mach-types.h>
* m4 [) ?8 J( u) y% _$ B#include <asm/mach/arch.h>
* U1 N1 W/ i4 W0 ?' s% {8 N#include <mach/da8xx.h>
2 U( n1 h' ?3 `$ j#include <mach/mux.h>
8 A$ M( S; a/ t3 s1 X5 ?3 @
1 A3 q6 N4 G4 L7 W#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
' t+ ]# @5 ?0 I/ _#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
( }7 b" _1 l3 X! F" D3 C; P1 R#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)* o7 W& G6 R1 O
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)+ @" h% Q& [* B9 {6 Z7 J6 s
; H6 g5 v, L3 R, e
/* assign the tl som board LED-GPIOs*/
* J* }" }3 f5 N: Estatic const short da850_evm_tl_user_led_pins[] = {: H2 n1 v+ @: P8 ?
/* These pins are definition at <mach/mux.h> file */5 P5 S+ G5 t# }6 n
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,. i6 S6 m% `! G# O. ^5 u- V
-1
0 I. a# o5 A' B# @};
7 K1 r% e& t$ Y% L; [; e5 y2 v. B
( j' L/ _% [) O/ C$ Lstatic struct gpio_led da850_evm_tl_leds[] = {* t I4 x& r, C* w
{1 n3 F3 Y+ ^) w, ~# w& o. m
.active_low = 0,5 D( z) \/ B2 m7 D8 ^
.gpio = DA850_USER_LED0,; v& J J! R: @/ X/ U& u$ v
.name = "user_led0",
1 j; Z- @+ y2 h+ k* w/ \! j& e: w .default_trigger = "default-on",$ s8 p5 Z' Y6 l/ s% ^# s
},
! J9 I; F. B2 k" V1 z: r {
[% | Y! _2 L6 ~2 u' o2 J7 m .active_low = 0,% F4 z: P7 }; o3 L
.gpio = DA850_USER_LED1,0 {" @9 K _5 H5 Y, F
.name = "user_led1",! G& Q. `. J# e& I- \! c# l
.default_trigger = "default-on",5 q8 K2 E6 I0 u
},) c) R. \ g0 z
{- ~8 U: P& k9 C. Z1 `2 Z* G
.active_low = 0,
' o0 D; B4 z2 O t .gpio = DA850_USER_LED2,( l4 f C1 K$ q1 `* U4 w- |
.name = "user_led2",
+ m6 @5 Q+ r3 b& K! w3 X6 T* s( ` .default_trigger = "default-on",3 ]5 E: ?% B, W2 i1 {0 e/ X) E
},1 [+ `! c8 w, i; W" t
{& H: a' y* E$ @/ ^: ~* ~% D J: Y
.active_low = 0,# w3 A! @- P/ j5 |9 ]" o: n" A
.gpio = DA850_USER_LED3,5 N# U4 Y8 p* ~ V& ^+ @: z4 u
.name = "user_led3",1 g( z6 A' J0 e4 H/ k6 F t
.default_trigger = "default-on",
4 t1 v+ J1 A. K& `( _2 e" ] },2 R! U. \; S3 l
}; j8 V Y) j8 m8 h. R
! q0 O6 Q; l0 L8 l. e
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {3 Z3 g3 R" J* d+ o v# V% Z8 W
.leds = da850_evm_tl_leds,2 G4 |" T4 w' ~/ d" K3 G
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),
4 u M2 ~8 V2 l# C2 C7 M) n! V, Y};9 U# M9 [. X# W9 y, q$ Q% H3 q- @) X" G
- u' u$ k' u4 U9 Y' a: b3 tstatic void led_dev_release(struct device *dev)2 O) U3 P8 ~9 n8 J
{
\& W0 K8 f% j};8 {! `5 d; w) Y9 v
- v: i2 B7 }4 z$ Z' ^' \
static struct platform_device da850_evm_tl_leds_device = {
" W- R* x' ^% h3 n .name = "leds-gpio",; D4 d; P% L' ?0 H* m
.id = 1,
+ R; C7 `2 Y7 C1 U+ Y6 e3 } .dev = {3 e0 Q) c8 p3 v
.platform_data = &da850_evm_tl_leds_pdata, {5 r& [4 M/ K1 I; j0 E
.release = led_dev_release,7 U9 ~. P* p" y; X8 `. F2 Q1 [% o$ T
}3 e# T, E/ x) N7 v: L
};
# N- w5 ^7 X* N, \$ S @5 X* a/ Z/ {/ |; d4 Z* Y8 W; g6 r
static int __init led_platform_init(void)- Z2 P6 h' n( K- R v
{( R* w" ^& n% Z* d
int ret;
w2 q" u8 j1 F% O#if 0: x' H+ Z7 K4 b7 C8 [! F
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
$ R: `6 X8 P" ~8 B" l. l if (ret)
& E. E' u# |3 j/ Z! S pr_warning("da850_evm_tl_leds_init : User LED mux failed :", a3 k' c% T% ^) h- Q
"%d\n", ret);8 l3 ?4 j! O2 S. R9 K% h
#endif
, ~ Q# B! E" ?3 A" o# g+ ~ ret = platform_device_register(&da850_evm_tl_leds_device);% U( g4 \: |! b! i: a$ z# ~5 \. r
if (ret)4 z/ E, S" P3 `" m# e/ }: v
pr_warning("Could not register som GPIO expander LEDS");& I, h- K- A# G8 r8 T) Q# ]" u) @6 Q
else9 S* k" R- P9 i" |8 u/ l
printk(KERN_INFO "LED register sucessful!\n");4 S6 ?5 F) ~" ~- r
& d1 E% [+ K, m- G# S% c. e9 G return ret;
5 S& H1 D3 F8 r: Y6 H, W' G}
7 v% V, L; M* Q" K6 ? ^' i' o; P, |3 `: g, N7 G
static void __exit led_platform_exit(void)
8 t' V. L' u0 F4 E{
. A5 ~" r1 v) r$ T platform_device_unregister(&da850_evm_tl_leds_device);* k0 y8 g; D# U
, Y7 s( |7 @( Q" t* I- f/ G+ p
printk(KERN_INFO "LED unregister!\n");. G( l4 M; L4 \- ?+ E- b
}! n) ~. D2 c2 Q* ]5 t
- n9 ~. Y: n5 m1 Z1 w1 y$ E
module_init(led_platform_init);
4 i. O: U) g3 y$ m& f1 h) L: u( Umodule_exit(led_platform_exit);& D' I, P6 C% v' R
) k- x b$ T- @% o
MODULE_DESCRIPTION("Led platform driver");) n: I, M# W4 T% j4 q' s4 m
MODULE_AUTHOR("Tronlong");
5 z+ q3 Z0 B! S, }3 b& wMODULE_LICENSE("GPL");
* `# _( E8 N8 ]! {9 z. B& |# i9 L" A( B. _
|
|