|
求大神给下面的程序做注解,请稍详细些,谢谢。
3 l- S% W8 n9 a: y3 g#include <linux/init.h>- b( m7 P# O, J" {4 A
#include <linux/module.h>
! C- O/ @7 E& A: R$ U#include <linux/kernel.h>
/ j, l H5 V) y( F D' E#include <linux/types.h>* p4 z9 A/ d2 `" e8 f6 I7 e! C
#include <linux/gpio.h>2 b3 c. f' m- r+ R7 D) o2 R
#include <linux/leds.h>* s- P4 E# r0 a) k
#include <linux/platform_device.h>* ?8 n3 B) H# F! H$ d
- D+ V: y# ]4 M2 O Y6 T2 v#include <asm/mach-types.h>
9 x' M8 _- W: h) W4 e1 p4 N' M#include <asm/mach/arch.h>5 g3 t( k: ?! D4 p4 y
#include <mach/da8xx.h>0 D0 G; \- a1 H4 Q
#include <mach/mux.h>9 |% o" H3 s# h- l
3 e) n" y/ {9 J! h5 X! b v
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)8 P2 V+ q1 K- o3 ~ E. {/ B! f
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)! W7 X5 M1 J e. m# E B* w q2 f$ B
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
8 [7 ^, \, g2 |" t#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
2 y7 I* Q* v# ?3 y3 V* o' `" Y4 ?3 ]# e+ z2 e& v- F/ H' F
/* assign the tl som board LED-GPIOs*/
9 X# P8 F% J" d+ }" ystatic const short da850_evm_tl_user_led_pins[] = {7 I, l% V& K1 n& K/ i' [' J
/* These pins are definition at <mach/mux.h> file */7 R; @2 c) }& t' l& ^
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,: O. p' A" t, D6 }
-1
- h6 `+ S; J* h% w+ i' A5 M};- E. W# p, d& }* X
' G& V# `0 f$ r& f& b- O- \! a5 `
static struct gpio_led da850_evm_tl_leds[] = {
1 G7 R# I- p/ A$ n {
9 _1 ]. ?! ] }8 o .active_low = 0,
' X1 i Y' J9 V0 g$ g .gpio = DA850_USER_LED0,
7 ?7 B2 X/ }8 s* _( E+ \ .name = "user_led0",
! M) i3 k+ N9 i; ^! ? .default_trigger = "default-on",
- m6 G. R+ U2 H1 o: G, J3 R- @ },
b: [0 j8 N' Y2 J4 H$ E {
7 F* j3 P- c4 t7 g1 r+ w+ c .active_low = 0,
+ [( l9 [' ` ^ .gpio = DA850_USER_LED1,0 @9 k8 S4 T1 |; `* b
.name = "user_led1",
' H1 l; b/ I" h$ c .default_trigger = "default-on",; U6 R" }7 C- C
}, ?$ T" A7 o) J% h: J0 q
{3 y3 i7 O) E! E& V8 h4 ]* D" Y0 l
.active_low = 0,4 a; C2 y" q3 J6 F' h9 }6 X/ s
.gpio = DA850_USER_LED2,
, S6 O* n& \% ^" k T( g+ q) M% K .name = "user_led2",
( p7 }4 _ H0 p6 s, t# s% Y; C .default_trigger = "default-on"," J7 ^: L2 Q1 g9 O
},6 j% j/ ` F9 a9 O
{
3 A3 ?+ V+ M+ \4 Z1 a .active_low = 0,
: Q6 ], p; G+ U) {* @; {1 l' w .gpio = DA850_USER_LED3,
$ ^' B5 O. Y8 {5 J9 w .name = "user_led3",
; e9 I+ p& e; L- l .default_trigger = "default-on",0 c5 \, o; x1 I- G- r& a) G
},: ]: k1 m2 j% G
};
8 y' \2 H2 }+ E" K, ]6 w$ K4 |! s# c# W; o9 M, l
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
. b; p$ e: T- t$ M6 H+ a$ R. U .leds = da850_evm_tl_leds,) [4 _. x9 L$ m
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),
9 l( \7 x0 }2 H, b4 J6 {/ t; }};
, ~' a# R0 f. O$ k$ {$ j+ N% `1 r5 }/ M2 }( T8 p
static void led_dev_release(struct device *dev)5 B6 z* J+ [& n" v1 }; B. B) o' S5 L$ `
{8 d' y' ], S8 D" o! O, h6 C q( ]
};
# i* E$ i, j8 J0 E% s% m$ ]7 O8 H$ _, n
static struct platform_device da850_evm_tl_leds_device = {6 w$ R! w" I7 T7 r2 p/ `, ]7 Q
.name = "leds-gpio",* }7 `# O+ P- Q
.id = 1,( `% L% a. H# S
.dev = {/ I* c5 I1 c& E, K
.platform_data = &da850_evm_tl_leds_pdata,9 D9 H0 V- R" a; P1 B
.release = led_dev_release,! r4 a3 \/ U+ d' n$ d% J. v. \9 j# X
}
: V$ G( D) y( B4 i2 k# X1 |};
. e0 y0 h% o. I4 W) x- e, c' {1 i' N) {/ T0 a
static int __init led_platform_init(void); z2 P+ f8 a2 Z! }$ J, y, F
{) s5 D& T: q0 ^/ @( f5 j9 ]" S9 ]$ ^, @- @# v
int ret;
1 D5 e- g1 x0 y; ]% m, m+ h) z1 O: Y#if 00 P* k: s N. t* x3 L6 t8 F
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
, \& A$ M) n0 j6 o) Z( V; x; F if (ret)* b, d7 K8 b& u: ?2 M
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
( M3 l+ h6 s8 z) A3 V' ~ "%d\n", ret);) o6 O3 l4 s, N6 l- v: r
#endif* u( M Y5 R# `" _. ?
ret = platform_device_register(&da850_evm_tl_leds_device);
+ W7 Z( j7 @- l) j if (ret)
6 e; R: c6 D: y9 e# ~1 t* n1 Y pr_warning("Could not register som GPIO expander LEDS");
Z1 F2 T t6 E* ?: S; o else
# x/ Q! I! t0 S6 p( Y printk(KERN_INFO "LED register sucessful!\n");
7 }8 W7 I" H" V% T# M
/ ~; Y4 l! ~$ e8 ^" ^# U ]7 W/ u9 N return ret;/ _1 E3 |/ q% b. _; [& Y+ E
}
. {$ O' ]0 c9 {6 q
7 a. X' w6 H3 q$ H# W% A ^static void __exit led_platform_exit(void)$ z0 |8 g1 U! N" o0 F, ~: V
{( s% ^/ n$ p7 a; G8 r, X) e
platform_device_unregister(&da850_evm_tl_leds_device);& h2 i6 F+ l7 O2 [
0 Z% _- F- I3 U
printk(KERN_INFO "LED unregister!\n");" ~1 O1 N8 [+ Q4 c
}" K8 k+ \; p* B9 S7 B
4 R. ?7 y, M3 s( m hmodule_init(led_platform_init); E5 r- Q4 c' V* J% O [
module_exit(led_platform_exit);& P4 b* H5 o5 N
; |" ^3 s4 I7 `1 _* oMODULE_DESCRIPTION("Led platform driver");
+ b- P4 P3 r6 H, `MODULE_AUTHOR("Tronlong");; J E9 E7 _+ k
MODULE_LICENSE("GPL");# c2 g8 ^0 T, y
" k3 n' ^7 s# S |
|