|
|
求大神给下面的程序做注解,请稍详细些,谢谢。, u! v' k& w* a
#include <linux/init.h>6 D" u/ R2 ?2 D8 X" o
#include <linux/module.h>( d8 v& ]+ `% h' q) O2 f$ w: g! h
#include <linux/kernel.h>3 m5 x' H W4 @; W( ?" U
#include <linux/types.h>
) l0 |" N' T# F3 G#include <linux/gpio.h>
. M. R2 N7 H- g8 c6 T0 g#include <linux/leds.h> F5 \1 ^; G8 t& N" t6 T
#include <linux/platform_device.h>
3 M* y; i1 }1 n- R
6 h a! V* f6 A; S#include <asm/mach-types.h>8 B2 g' Z' M' ?
#include <asm/mach/arch.h>5 Y7 q- e: y4 m' P
#include <mach/da8xx.h>
5 B6 W7 k1 k R) R8 [/ H#include <mach/mux.h>
8 l7 ]1 n3 g7 ~- [- C6 B' {0 T; Y1 q1 E6 U# d) u# W
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)! P* }( p9 X) m8 Q. C. [/ s. i3 A
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
g3 v# I2 q5 Y4 J#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)% m3 t/ |! g9 b. k3 j
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
( S& F" ]4 _1 A9 \. G8 {) Y+ p; W) [
/* assign the tl som board LED-GPIOs*/
; k( L6 G) P7 \! T7 E ostatic const short da850_evm_tl_user_led_pins[] = {8 c0 [# G, E' \3 M# a
/* These pins are definition at <mach/mux.h> file */
# ]+ j' z% w; [- _8 d6 u DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
9 A! u+ A4 ~" \ -1
- O7 m* |& Z9 z" h1 L, M: \( E* \};$ t" a" a' }4 C' [4 ?7 c
8 G& w, D; G& L G
static struct gpio_led da850_evm_tl_leds[] = {5 S; S5 z1 E9 g' x
{3 x% Z5 h. `6 ~% }6 r( P
.active_low = 0,+ f+ S1 e% @) w( n
.gpio = DA850_USER_LED0,
4 h3 _' M' A7 N6 e( R; i: U' }% V0 j% ? .name = "user_led0",* k+ u- Z; v4 `; Q
.default_trigger = "default-on",( Q: p; t2 a& G5 t' _
},
9 q3 {1 S, ?5 l {$ k8 q/ k. y; C% V& I* |( y
.active_low = 0,
+ g8 j V; [6 f" r" s7 C: A0 S .gpio = DA850_USER_LED1,
1 j. ^' D! s! Q .name = "user_led1",! p# _3 k, O2 h. y7 |2 V: n( B
.default_trigger = "default-on",# H" k+ Z2 u) w9 x
},
# {! T* T: G8 }$ X {- p3 ^8 z. v, k% K4 j& F
.active_low = 0,2 u% d+ d7 K) _3 n, C
.gpio = DA850_USER_LED2,6 \3 q9 o& b( I; t& k% G8 _7 I
.name = "user_led2",9 B. P6 ^3 m" g3 R% \' {; N/ @
.default_trigger = "default-on",
5 k5 d/ n0 y7 ^1 P6 |. p, ~- { B },
% Y# g0 ]3 B O9 D4 F% P0 S; _/ } {: q0 K6 d( |6 _7 n( g
.active_low = 0, I ?* L7 R3 B+ f4 M9 p
.gpio = DA850_USER_LED3,9 Y" f' i7 ^; C( E+ \6 c
.name = "user_led3",
9 z$ d1 S" C/ a- h .default_trigger = "default-on"," o/ ?( i/ U5 U( _
},
$ d$ x4 g: \' W$ Y7 @: m f ^' v};
- D9 A) H6 B) G/ ]0 V( @4 g5 K8 a+ o3 }. D9 r
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
! u' c+ g, j4 U J% ^6 {& P .leds = da850_evm_tl_leds,0 w9 P6 K; N- e; C4 P* d; l4 h# A
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),
& e7 Q* b0 Q$ c* L# G};) x9 i3 K8 c1 B5 Q
/ I& L z2 h7 m# s) p7 _/ pstatic void led_dev_release(struct device *dev)" a/ E- m# n, ^0 x4 `
{. T& p z6 u" Y
};
8 r* Z3 {4 F4 M. }: r
# u7 p% w0 c9 ^9 `0 P- gstatic struct platform_device da850_evm_tl_leds_device = {9 N) D9 X$ b6 B& c. [) M
.name = "leds-gpio",
1 t- z3 _( }+ E( U) n9 v t .id = 1,
: a n4 [+ j1 t2 i .dev = {
, P1 W' m5 r+ x, D .platform_data = &da850_evm_tl_leds_pdata,
1 j- j# V: Q2 p4 } .release = led_dev_release," v+ P# s& Y0 [0 U3 H/ l
}: n) b1 A' q. [! H7 s0 R% D
};
- c# O( a6 S6 Y' j( E( b* [. m, u# R* z+ E- {0 W
static int __init led_platform_init(void)
$ U9 }; i7 d! X# b+ A% t{
/ ?' K% {, g3 s% h( C8 t int ret;
1 x+ f; k% Q7 o7 ~. p2 X$ X0 ~' s#if 0: y7 v, N% f) ^& g, [2 L @
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);0 b3 \$ w+ `4 O$ o7 g" k
if (ret)
1 J; b3 q, ^% ^4 O. Z pr_warning("da850_evm_tl_leds_init : User LED mux failed :"+ [1 m; P$ ^1 x* N3 N
"%d\n", ret);
5 `5 z, V6 g d2 g; u* Z#endif, r( k) H- `6 d0 g
ret = platform_device_register(&da850_evm_tl_leds_device);
4 j' c; M' @8 ?0 Z I if (ret)
8 ]/ M8 {/ y% o4 E" {) K pr_warning("Could not register som GPIO expander LEDS");
0 A( U7 Y: H/ V+ _ else$ h( V$ D% W o, y; u
printk(KERN_INFO "LED register sucessful!\n");3 H0 [1 t; U/ u+ C
3 E' q ~$ P+ ?0 H+ m, g- r4 D4 a
return ret;
$ Q8 `2 z \ Y9 _3 y! }}
k/ m( G# V3 X2 V, A( j, _
, e) A+ ~; U! O( N, jstatic void __exit led_platform_exit(void), C$ k: u3 E; S8 t& T
{
" B; B' e: N/ X, j, Q- u, p, o/ k; f platform_device_unregister(&da850_evm_tl_leds_device);* N; O! H% r' e6 h' k
3 K1 C6 h3 h! S$ O2 @ printk(KERN_INFO "LED unregister!\n");3 n+ |+ {) e, ?- q' }
}
, _! ?, _" T( J$ u
0 [6 M1 D1 o4 Q) m5 P2 `module_init(led_platform_init);
2 e' a2 A9 [9 ~* Pmodule_exit(led_platform_exit);
( O+ a0 M/ X8 R
, O, ]8 x: l3 D! |1 b% q% J4 ZMODULE_DESCRIPTION("Led platform driver");
. Q5 e% {+ u9 JMODULE_AUTHOR("Tronlong");
; w, q1 G9 s/ w) H/ b5 FMODULE_LICENSE("GPL");
7 N3 F# E! G: Z
9 S. r: z* |. W$ j+ @" X |
|