|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
) s W( }& d1 j( ~#include <linux/init.h>
) M4 e9 e! q9 d& A, S#include <linux/module.h>! b$ h! L) l8 b1 J; A* q
#include <linux/kernel.h>
6 V2 y$ R) r2 E( z. I#include <linux/types.h>; R' w$ I) k5 i8 u% q
#include <linux/gpio.h>
2 }" U; A; S& z" b" Q7 M#include <linux/leds.h>2 `8 ^$ A$ y4 i0 [# o V. p
#include <linux/platform_device.h>
& H2 `2 t- O" }7 T* ?7 E
. S& }2 [+ ^6 S( k2 ^#include <asm/mach-types.h>0 { {- C% _7 [0 s
#include <asm/mach/arch.h># A: l6 T% J+ L) e2 t& i7 b: N
#include <mach/da8xx.h>) d/ Y% b8 U1 p, M! o, u) f: [, }2 v
#include <mach/mux.h>2 n, r0 H s3 o3 f* O- e
, R I) C8 Z7 [: f5 C) t#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
2 x& i; W# N( Y8 J8 h; j#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)6 ]5 E, U! M6 X( X L: O* u! z
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)7 E; x8 v( B; N+ C
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2); K: q s6 v+ K$ Z; h1 R
+ C2 e: Z+ H0 N& }) J
/* assign the tl som board LED-GPIOs*/
- S5 Z; f( s! J& J, }! Ustatic const short da850_evm_tl_user_led_pins[] = {
4 L$ x- g5 M6 H: Q /* These pins are definition at <mach/mux.h> file */
1 k; w0 t0 j* a2 r. {' V. t DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
6 w8 L& Z% O# j! ~' |9 w- x: o -1
# ~5 a" a& x- C x+ g};
# A& x, |: G6 \/ s4 _* l
, \- A* n- n {( A! I# Q% l5 l- \static struct gpio_led da850_evm_tl_leds[] = {
: d! ], k9 ~0 x. l4 t9 z$ _ {$ `: V1 I$ [- ~7 V( E2 S
.active_low = 0,
/ X7 I4 U) H3 |* t' r* t6 K5 G .gpio = DA850_USER_LED0,) \3 T% |7 ]2 d8 O' k# o& v
.name = "user_led0",+ [9 [* U) U6 y4 ^
.default_trigger = "default-on",4 n# o8 i3 m0 T7 V- k+ n& u
},
5 \! S- b# ?% ^8 j. O {( j% X! C; R" l5 B- S7 H1 W" P
.active_low = 0,
% @8 [/ R) q7 N$ C1 o6 @# B .gpio = DA850_USER_LED1,
3 [6 @ `) ]0 d9 b0 {( w .name = "user_led1",
. {* f, O+ {, J. c) O .default_trigger = "default-on",
+ z/ O/ }, r. [ },8 o' N0 s7 Q: n* s% O# Q% ^ R A7 s
{$ |* c# q/ r! F
.active_low = 0,; }, B( }- X/ O" H3 M' b# H
.gpio = DA850_USER_LED2,; B! z- Z: @. S h/ q# Q$ ^4 m
.name = "user_led2",! S' W* [% K1 W* ?5 u5 Y1 g: h
.default_trigger = "default-on",' f2 T# Q4 [! k( l; y' G
},
8 R7 G3 I! S. M! a3 Q {; _/ f3 ?& u: A# t: J% B, G* @6 h0 I
.active_low = 0,' v& Q7 B; |- m/ n ]! F
.gpio = DA850_USER_LED3,
7 c3 Z+ R6 b2 b6 G! O* O6 U4 Q- a .name = "user_led3",
' K: I$ N. ?5 m4 E; J' | .default_trigger = "default-on",+ u! { v7 i% C, j) Z
},9 b0 j* x- ^4 T6 x
};
N: V$ Y( h; q. F2 {! f# j4 l4 c- ~/ e
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
& s/ X$ s* A" b4 N .leds = da850_evm_tl_leds,
3 f$ t+ Y2 K4 v& v8 F/ A .num_leds = ARRAY_SIZE(da850_evm_tl_leds),3 C/ v( N% t1 I+ g. G
};
% W) G* p7 D- y. j' L4 R
8 q4 c: e0 x* s- P. B/ @& vstatic void led_dev_release(struct device *dev)' R- k4 {3 y# b& A- ?
{
7 M. a& H' Q9 a. S};
2 V5 {, v" k, Q" m9 C5 S* ]
* m; r+ x7 \4 m- |0 q/ e# [9 v& Sstatic struct platform_device da850_evm_tl_leds_device = {- L2 P$ Y- v3 D; ]5 W( h
.name = "leds-gpio",6 f8 S: v( M" @7 v- x# p
.id = 1,
! r( V" V! e( ^. `+ B: f .dev = {
9 z e. g& d1 h2 a .platform_data = &da850_evm_tl_leds_pdata,
+ ^9 z U9 c% o/ Y# a/ k .release = led_dev_release,1 k; Z0 F7 o/ t+ i2 k& f1 q
}
2 Z' d: Z+ B* v3 c8 W {9 j};4 `7 Q& l" y) J3 [
" {# J3 M' d9 @# T0 j! U4 wstatic int __init led_platform_init(void)5 R' S, y8 _8 a7 R: y; ^) {3 {
{. P: g7 R8 n! k9 F1 E0 Q
int ret;
0 m8 F3 l4 x9 `; t2 C#if 0+ u, Y! z: V- B0 O1 A
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);2 j; V: Z, @1 c7 Z# X, W+ H
if (ret)! S" Q4 V$ g( L+ K9 T
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
% D5 u4 g1 N8 j! _ "%d\n", ret);
, s/ I) t8 W. Y4 t" {( f# B) j7 N+ f#endif9 w! }" l5 M9 ^$ {. N3 U
ret = platform_device_register(&da850_evm_tl_leds_device);4 d7 i' [, }2 l+ m
if (ret)) T# R5 R8 p% Z9 e- s0 c
pr_warning("Could not register som GPIO expander LEDS");
6 H. h& p! p0 j$ W- F else
2 e* `" M d7 k+ R8 i& v printk(KERN_INFO "LED register sucessful!\n");
& Q: x8 J0 v& W) L
3 Z r3 R0 F/ n3 J return ret;+ I6 I" p( m2 G/ G7 G, c
}" N" U/ Y. K* [( L% P
: t$ r. K6 I9 ]+ u7 o- ustatic void __exit led_platform_exit(void)
" [ E9 M# \4 Z% P" z{# ]2 B9 _; W- q* [4 l1 h6 M
platform_device_unregister(&da850_evm_tl_leds_device);
7 l+ E! T- G8 }2 ?! i
5 P+ E* a" j) T( x8 A8 s" E$ { printk(KERN_INFO "LED unregister!\n");
; u9 E, p! U$ V- L}" E0 r- M$ O1 s8 a
% B7 S6 \0 F% `9 u, V: G' N
module_init(led_platform_init);
" v7 y3 M" }+ o9 i K6 D2 n" zmodule_exit(led_platform_exit);, n$ `% X, k& C; l0 I: d( W
! F) ~# l6 z( {5 K0 MMODULE_DESCRIPTION("Led platform driver");
* m L3 Q& b* d. Q1 n5 gMODULE_AUTHOR("Tronlong");' m! {6 y8 j/ k+ R% G: [+ z1 l
MODULE_LICENSE("GPL");
/ Z1 J9 B/ j" X, _9 j% J, }1 a) c. H8 {0 w- W
|
|