|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
+ c" K4 ?; U2 _( h4 k( o% t/ U#include <linux/init.h>
7 e7 B1 l- _2 [& A& v q3 \/ t#include <linux/module.h>( [, C0 G: x" P7 W
#include <linux/kernel.h>
7 F4 l5 r0 f) Y( w. X#include <linux/types.h>
/ z9 q L" X" d#include <linux/gpio.h>! `1 k% Q- @6 P8 |; i
#include <linux/leds.h>
8 h: R, K7 k/ \* y5 a' s#include <linux/platform_device.h>
9 i8 j8 i* C, Y) H9 ]4 h# ]# V4 B) x1 f7 P
#include <asm/mach-types.h>, E0 c } i1 N4 g! [
#include <asm/mach/arch.h>
8 {# C2 y s: R/ c% \3 N6 m% V#include <mach/da8xx.h>( T2 q% R$ W4 c4 I. }3 s- G% k8 ^' [
#include <mach/mux.h>+ f: V( ^! g* ~) E
6 u0 U/ `' I! Y( F8 C#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)3 H6 q' G9 [) o% V" U( p, s+ F
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)1 I2 Y7 v4 Z: _6 P" t- f, G# q1 G
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
# {: [* K9 z: y5 ^7 j0 v. S" V#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)# L/ S$ l! x5 O( c2 I
7 P+ p- l6 w/ C# U) d
/* assign the tl som board LED-GPIOs*/
" @% t1 S& g6 Ustatic const short da850_evm_tl_user_led_pins[] = {
4 d5 ^! k# |+ w" G- _8 U /* These pins are definition at <mach/mux.h> file */
* {! u' i, A7 ^9 T. h1 o | DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,4 T5 g F5 F. V4 U4 u
-1
/ n9 h* G: I* d2 c2 a7 W( b, T3 s$ ^};2 H* Y" x! ~: t" Y
! W* X% {3 E' {/ q T
static struct gpio_led da850_evm_tl_leds[] = {, u& o" @* Q2 p" b5 o
{8 Y0 Z) h: \' z) T' I7 T
.active_low = 0,
8 x9 b9 v) G: o/ }1 {' H7 E+ \, N .gpio = DA850_USER_LED0,' D2 |' P- b2 y0 C% F) t$ A
.name = "user_led0",
% n3 H5 h/ P/ p5 g2 Q2 T .default_trigger = "default-on",) a8 Z" E" }1 k
},
4 H [" S* e, r* f4 k8 O. Z* K {* \, {% q' J3 i, s( L7 X$ h
.active_low = 0,
$ T3 U# K( H% q' {7 _5 K; ? .gpio = DA850_USER_LED1,! |. b& J& W! K: P& y
.name = "user_led1",
2 I3 n& Z% e( w0 g .default_trigger = "default-on",, E5 C# q* [ g
},7 a& S- Z1 {7 ?- }3 Z
{
! I; y1 ^! ~$ G7 N) [( m H .active_low = 0,
6 h3 e: S8 t. {+ R: Y) c+ o( ^ .gpio = DA850_USER_LED2,
8 W" O4 m% }: x3 J |7 j: i .name = "user_led2",0 | b7 ^' I+ A- V' x
.default_trigger = "default-on",, F+ b& o( U+ r& K( L5 E
},
' Z) o v, y$ ^" `' p% q9 \' h3 P3 l {) W& X0 ~% b- m3 p1 L
.active_low = 0,$ f7 F: W! D6 a' i& p; k2 s4 U! n+ z) K
.gpio = DA850_USER_LED3,0 i; P1 l' p6 [+ q
.name = "user_led3",* z/ G( x- L' J; ?+ L
.default_trigger = "default-on",# l4 u- h( @) [) P, V
},
8 ~) P% \6 S$ ^% X$ s};1 G7 Q/ W% }- Y/ m
' |; w1 n2 L$ K! H( A. ~static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
9 L* \. x' [5 s/ S5 { .leds = da850_evm_tl_leds, L f" h' G% ?% y
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),! ~+ U( U g2 w9 ~
};1 A- k A- [/ A# s$ T9 C
% r: s% N- u# s8 _% C1 |9 D. pstatic void led_dev_release(struct device *dev)
7 g+ x9 m2 _7 O0 a9 W1 j{- N5 h9 ?% |8 C# } S% [: |
};
' r9 N. [+ ?9 r7 Z$ z j* u# w& E: `& f5 ]9 C; I
static struct platform_device da850_evm_tl_leds_device = {
: K5 x* u4 z: @7 @ .name = "leds-gpio",
; j% T% j f* d, V" J2 ~ .id = 1,+ D9 ^9 @/ D3 w8 u& u; k t& @" P6 ]
.dev = {9 N! z! i$ s5 ?. t' w5 |3 M2 m
.platform_data = &da850_evm_tl_leds_pdata,7 J! E4 ^1 t5 H
.release = led_dev_release,
& s/ ]' o0 Q8 d2 v0 D7 f }2 _$ R7 ?+ N; F
};
0 W1 R w, } c+ c+ e
# l+ W+ X2 T) ustatic int __init led_platform_init(void)
. F, M3 L7 i$ k* A4 v{
3 `, Z% \" b1 ^% S+ ^# d% ^0 } int ret;) e' z Z- W3 x% @8 D8 h7 Y
#if 0 m3 z; p. U6 `( `9 a: `
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
, `1 B4 N8 X! N0 U" R! t if (ret)
r/ ^% o% J& T" d pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
6 h. e. `0 X3 r% b& {1 _ "%d\n", ret);' n5 f6 y3 {9 y' O& a% M! l, _) N3 T
#endif
; X# t& K& R0 l ^- E( Z0 [$ q ret = platform_device_register(&da850_evm_tl_leds_device);% k) a7 ~# R1 b' j, e! M
if (ret)0 ]+ A& V% S3 d- {
pr_warning("Could not register som GPIO expander LEDS");9 A8 |1 M7 w. |7 r4 ~0 j
else6 x1 [* o( e/ P# F4 O' v
printk(KERN_INFO "LED register sucessful!\n");
% l$ a E2 H5 j6 {; E% ^7 D# _6 \3 ~+ ]; R5 g+ z; B$ I6 h1 v
return ret;
& `7 ]: t9 c- {) c. p* ^$ o5 ?}
5 H+ z9 R: K4 ?1 D- F4 \& Y! Y4 |9 b5 p, Q6 u5 q
static void __exit led_platform_exit(void)# `$ _% V0 ~& v3 @4 n9 j2 d
{& g Y6 u# w3 o( \
platform_device_unregister(&da850_evm_tl_leds_device);
% m5 ^* w7 Q3 j, G/ p) o5 r! o: J3 z: u& F
printk(KERN_INFO "LED unregister!\n");
" C" g9 ^! W' U8 J( Q}6 O( p9 r+ ]& D: Q
& N! X4 R1 e! `0 omodule_init(led_platform_init);4 x! ` H9 K# W; J/ w, Y* H0 F
module_exit(led_platform_exit);
. W! R* R1 p0 x" h# {# S& `2 K+ V* D# b5 }* h- R2 ?
MODULE_DESCRIPTION("Led platform driver");# k. r" h% w0 [8 p' ~. ?& T
MODULE_AUTHOR("Tronlong");! ~- Z) J2 U9 [$ {- P0 w) @* |
MODULE_LICENSE("GPL");
& X2 u4 m% ?6 p5 {, H, p. p" {" d' x+ k; x5 W3 e3 n
|
|