|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
: n, l8 E @; c# N6 ]9 X6 E' V#include <linux/init.h>4 s# h4 W$ y$ V3 ?
#include <linux/module.h>
2 |0 S/ I) x3 l6 L$ `2 _#include <linux/kernel.h>
3 K, u+ T5 A4 q- ^) P& V: f) \#include <linux/types.h>) u/ F; Y- [7 f v# n
#include <linux/gpio.h>" s% C, a5 n* L* |5 Y0 ?3 U
#include <linux/leds.h>
; U. d t) X( y8 p: S7 N#include <linux/platform_device.h>2 u# b& `% N, t8 w% {1 G
5 M: W! z/ B8 a1 g! b- H#include <asm/mach-types.h>3 N* a8 h: D; g3 ~, ~
#include <asm/mach/arch.h>
. p) }* s3 f' F0 k+ n, S! Y1 c#include <mach/da8xx.h>
8 u; _ A* d& C5 H& D" A5 a7 ~7 T#include <mach/mux.h>" l! Y6 c3 z7 V. N, R8 h) l
3 [. ^5 E7 b& G8 S, \" P0 M" x L#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
5 \+ {, q9 ?9 N; U+ ~" k2 e' b D#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)6 L3 X B6 @( x, |1 b
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)) C' Q6 A% P s- r1 S
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
: [' U+ f' {$ o# |% T" L
7 E8 v0 U" A3 o6 ^: F# W$ o* J5 i" v/* assign the tl som board LED-GPIOs*/" A) |! Q" O( e6 T. Z0 C
static const short da850_evm_tl_user_led_pins[] = {* H0 N+ W7 M$ g l6 o
/* These pins are definition at <mach/mux.h> file */' C8 B% a4 Z9 @7 u9 ^& g$ Q4 t" K
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,9 h$ [! ?, n. G, s) j( P) Z
-1& a8 r8 y& B9 `6 h: V4 }% n
};
7 s! R4 b! `5 U
; e* E3 B7 E& g# l9 g8 Tstatic struct gpio_led da850_evm_tl_leds[] = {8 A9 M: {/ P. e; ]2 o) W; C0 G
{
! f# z8 q) n$ ]& z5 D5 U1 ` .active_low = 0,0 a: V; j: `2 T/ a. b Q
.gpio = DA850_USER_LED0,
$ E K* Z6 g+ w; l& O6 @9 ~ .name = "user_led0",& |# d, G0 H T# p, ?& _( w
.default_trigger = "default-on",; P$ }0 J L* K: a3 \; ^
},
# w. }% W" R7 b# d9 T& l0 F1 l6 I2 C {
7 Q- s4 i$ @; Z- A1 w .active_low = 0,* `- ]# \) g2 g; a/ J
.gpio = DA850_USER_LED1,: G5 o. R# W" i7 R3 o: F
.name = "user_led1",/ |) _' @: [$ t+ Z' {
.default_trigger = "default-on",8 {- l' s& ^8 r3 _/ P
},/ T& k7 V/ V) e: j6 E& ]* ]
{
: x% E2 E$ Q5 j2 w; V .active_low = 0,9 }. P( v( v- W0 Z6 [
.gpio = DA850_USER_LED2,9 T7 _7 ^. U/ [+ l
.name = "user_led2",
1 D3 {& V5 K' J* M k/ s .default_trigger = "default-on",
3 \6 t: Y" L! j f },8 q- l* N7 b4 v' y
{
3 `0 L+ L; i/ K2 ~8 I2 z, u( d; { .active_low = 0,
6 ?) ^$ H B$ G& u; J- V5 k .gpio = DA850_USER_LED3,( m E" b z/ J
.name = "user_led3",
% y% p3 u8 l9 e3 d1 D .default_trigger = "default-on",
( X' `4 i8 p9 H) _% l. \ },
: s; X7 w" z- ~" `4 q) W3 b};" V& |$ U6 O. A; J! T/ @' t
8 p! i# U1 ]* qstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {. W! O4 M9 R' S7 ?2 N/ E9 T7 J
.leds = da850_evm_tl_leds," B3 a9 i3 @9 i/ ^8 K: ]8 A
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),
5 i2 j8 p9 I6 j! d% g3 l3 p0 c0 W};
' r5 n! _0 i' p( v) H& K/ u" I! ?6 L0 a2 f9 g
static void led_dev_release(struct device *dev). w4 M1 @; P% I+ v8 }. j
{
( Z! U9 a7 G9 b3 ?$ S$ B* h};
: T' ]( `+ l v- o* f$ \9 ~. u
8 ^( z: |* g K, u0 Xstatic struct platform_device da850_evm_tl_leds_device = {
; O: m6 }% V: R" e5 e$ O' t7 k8 N .name = "leds-gpio",) U3 x' j% | G+ i) K7 o
.id = 1,$ A& d) S2 Q1 I( F$ _2 W! w2 }
.dev = {
- \) p8 }# G* {! [% q7 o; B .platform_data = &da850_evm_tl_leds_pdata,: K, ^+ e' N R
.release = led_dev_release, r! t* ~3 {7 b5 _3 M% ]
}
" _3 O F" u0 Q9 k) P};1 ]% x7 C+ G: n
7 @& C, P& r8 F' G# Z M
static int __init led_platform_init(void)8 D3 i0 v6 C" f/ a
{! }' s7 o' X* S7 w. U6 _5 S
int ret;. M. D6 e" m3 J" n
#if 0
# V4 ?8 r: }! r, m5 B4 G ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
6 d* w5 G) W* p" B! f y if (ret)
. y ^- r" y% ^4 u, F3 A7 n( c6 h7 h pr_warning("da850_evm_tl_leds_init : User LED mux failed :". W0 S4 ]" V2 w$ I
"%d\n", ret);% O1 g% O& h& x& Z
#endif; p8 ~, J- t9 U3 S3 g1 b% `/ Z
ret = platform_device_register(&da850_evm_tl_leds_device);7 X8 O8 d% g6 ^& Q' K# t
if (ret)1 i, D: f: M& n
pr_warning("Could not register som GPIO expander LEDS");" [* R, s" K% _+ F& I
else" ~9 d! r! f0 M+ J/ p
printk(KERN_INFO "LED register sucessful!\n");
; W& X1 k$ T' T( u# P. V/ D5 s/ q- b* d6 @6 H+ D. i8 X7 A$ P
return ret;
$ P: j8 H2 p8 ^, t# ]9 ^. u) ]}
/ F0 B. Z. E# i- U. \) D: {6 a
static void __exit led_platform_exit(void)
X' N* w" P+ f8 T* ~{
* x, z c$ Q! r: t" A4 x8 g3 ~ platform_device_unregister(&da850_evm_tl_leds_device);
" d, D) j: I( z/ |! k, i! i' X0 z
printk(KERN_INFO "LED unregister!\n");7 H" S) f* {1 N
}3 {% |+ \9 i7 J8 R( S# O
2 L* B/ U5 G4 @# T4 G* Fmodule_init(led_platform_init);
# U* U; U+ n. v$ S" N5 Y2 ~module_exit(led_platform_exit);8 G* w7 N! ?% m- j
$ f9 c7 n( u/ d; V5 |( DMODULE_DESCRIPTION("Led platform driver");
( _! M6 C3 R# {* r9 Q! RMODULE_AUTHOR("Tronlong");
7 y1 q" J6 N3 zMODULE_LICENSE("GPL");. x8 _ y+ w" u- E! j# c' F) g+ O; `# u
4 e: r. o8 U2 r' B1 z, N" f
|
|