|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
6 ~ }: f0 n! X" u#include <linux/init.h>
% v. Y+ a: O* X#include <linux/module.h>
# g! a" s5 D* D( |' e) C+ a3 G) ]#include <linux/kernel.h>, @+ N2 D" }$ v4 C; O
#include <linux/types.h>% W6 R0 F8 `! U) s6 {
#include <linux/gpio.h>
1 i/ X: d' l2 z- ^. c#include <linux/leds.h>
( X' L+ u9 h# W& O* M; G5 M#include <linux/platform_device.h>! O2 z1 R3 ?* u, n6 q$ P
% N3 \: ~' }* f' d% y" ^- g#include <asm/mach-types.h># k; \3 X' \2 D
#include <asm/mach/arch.h>% u; Q; |. X% p3 Y' r$ _9 r
#include <mach/da8xx.h>( C7 e. A+ {2 t: U3 g- U" a" y6 F# W' o
#include <mach/mux.h>- J3 _ L# l, U$ o- ^
$ n4 }% k2 t* |" `#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
' l) }% ?' J' P t: e& Z#define DA850_USER_LED1 GPIO_TO_PIN(0, 5). b' Q) v% D6 i P7 K8 w8 O6 v
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
2 Y* l7 l4 V) d" R) ]. I#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)8 G z5 X" P8 {% B- F
' p' M3 L+ O- k2 Z/* assign the tl som board LED-GPIOs*/+ W3 z( r( ]$ L
static const short da850_evm_tl_user_led_pins[] = {
( B) [; {# Z* N/ s! a% Z) w( ^* N z /* These pins are definition at <mach/mux.h> file */4 W( e% y1 n- M+ T4 N. V
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
; U3 T0 c3 m9 d8 ` -1! L8 ]" [7 ~! \% G! l1 h; h
};' ]. p/ t& u9 W- H8 d1 j
* n$ s- x( t. l3 k/ {2 V
static struct gpio_led da850_evm_tl_leds[] = {
4 O& j8 S2 G$ } ^7 O; `8 P7 ] {/ n; z; g% V7 l' r8 w. H* g
.active_low = 0,7 P' H" g( a# F% `( q5 {
.gpio = DA850_USER_LED0,$ S! J. [' S, i7 N, z9 n0 l
.name = "user_led0",
7 {* S* O0 k) \( L5 [, v1 Q0 _ .default_trigger = "default-on",
4 Q7 |0 N! L. @( ]. v },- ?2 f! k+ C# X
{
: \/ w. T3 g* m% v .active_low = 0,
! s" N R$ z, o1 y .gpio = DA850_USER_LED1,0 h( E* p. B6 h& q. N' X
.name = "user_led1",- H6 y! ]1 F4 H8 K3 v, S5 o
.default_trigger = "default-on",1 U; k6 _" | x$ t7 |1 o3 I. r" O V
},
# z% i% u% }# @) _. y {
/ U- s$ O! [- h& D .active_low = 0,
7 X* y N% x% q .gpio = DA850_USER_LED2,
0 ^6 Z' d6 G% }* Z; U7 K8 e6 I; f .name = "user_led2",
/ u3 `: G. `6 T( z .default_trigger = "default-on",
. J Z0 v* L$ x2 K; ^7 [3 t },
9 @( M8 T# f3 ]$ _/ K; p" d {% O+ G: o" I, U/ ]9 M
.active_low = 0,& v! W3 K2 Z+ w5 S* t$ f' @
.gpio = DA850_USER_LED3,6 O, z7 _; A& X5 X) `
.name = "user_led3",4 _5 p7 Y8 J: n9 s, x3 b
.default_trigger = "default-on",* w4 o" K" U/ R0 H4 d
},
2 H' Q& D: U: H! C& a. L- _$ C};2 W+ _% S6 U, h t0 k2 B
; \7 `; j* G; I# v: T% y) rstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
1 l. `3 B& Y' M3 ~# `* B7 E .leds = da850_evm_tl_leds,
* z( `4 r# K. k5 w) S .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
2 J( r# n" m7 w};8 ~8 |8 J7 e& {8 K* Z* F. i& O
0 O" D. C7 `% Y R8 G/ H" Nstatic void led_dev_release(struct device *dev)
; @# {8 q8 S# B4 b{4 \6 }2 c+ a9 Q9 U) i. v% a
};
7 |' ~% V. t f0 v, q% z9 o, I& q* h# N9 q
static struct platform_device da850_evm_tl_leds_device = {
5 Z: s& j1 ?- K4 A" n4 U .name = "leds-gpio",/ ]4 Q1 ^4 H% h: i; u- @9 P
.id = 1," S- N- V( J- N; ^- J! g) |: G$ y
.dev = {
( j( l1 H* M* a4 v .platform_data = &da850_evm_tl_leds_pdata,
/ Z( w; R* |5 `+ h6 P .release = led_dev_release,/ @( s3 M) E$ _- w8 P1 V
}; g+ W4 H- T2 [
};5 T. D: J3 J2 e U, U4 F4 b
8 P( e. C8 P6 b. O, V7 |" x+ Rstatic int __init led_platform_init(void)
4 l; Z/ ^6 ^) _2 ^) }1 F0 ]5 z{$ p6 w8 s+ u% E! G
int ret;
$ k% F& _% O# k( u% n4 ~#if 0: l: h/ X, K: t% t2 j
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);" J5 t3 S* ]- e1 P2 R
if (ret)! l1 t( D8 f# z2 w+ p, l
pr_warning("da850_evm_tl_leds_init : User LED mux failed :", a! w; l6 D9 W8 T5 o7 ^4 p& j, X ^
"%d\n", ret);
- Z8 j2 @" |3 p#endif6 j& X, L8 ]4 T) u0 ]$ a8 P9 b ^
ret = platform_device_register(&da850_evm_tl_leds_device);% R0 ^7 s5 \2 [% N; S7 _* U) u1 E
if (ret)
, S/ M3 ~( F) i* S" j- R% R pr_warning("Could not register som GPIO expander LEDS");( ~- B3 y. ~- ^7 |# f
else, e6 ^7 a- I2 A9 N
printk(KERN_INFO "LED register sucessful!\n");3 b W; M& ~1 \ P. d
* u$ b- `2 q1 z ?& B6 j$ `
return ret;
2 z: g. d( l7 o$ D ?}% u: j; g) v# ^9 k7 k. C e
- ]+ }9 {1 P9 G% p7 r
static void __exit led_platform_exit(void)0 e4 |9 C, V# w) |% C8 U
{
1 w: K. ~+ y8 X platform_device_unregister(&da850_evm_tl_leds_device);
@, X7 A/ F7 T$ j4 G% T8 j. {0 u- r2 c5 y# \3 K) f5 g
printk(KERN_INFO "LED unregister!\n");
1 n5 z' i7 b2 ]: {}; H i3 J# ^3 a3 U# f2 q. W
; _# P9 b% u1 O; ~' N5 }: M) B7 [module_init(led_platform_init);3 |: }. ?7 Z* n& a1 `
module_exit(led_platform_exit);
+ k+ ]- s8 A0 G% u: Z* Z$ q+ N% e* x0 ^7 ]% M* w m
MODULE_DESCRIPTION("Led platform driver");
; r) w- Q7 K" i% {9 o6 `0 i0 SMODULE_AUTHOR("Tronlong");( W+ F: J; b' q: U
MODULE_LICENSE("GPL");
: J+ f8 ^. U8 ^+ v8 z0 F
) ^+ b+ q: {0 B2 P |
|