|
求大神给下面的程序做注解,请稍详细些,谢谢。
8 j$ f8 b) W0 |8 t5 o! t+ N#include <linux/init.h>
8 H5 a, j8 m' i& ?9 [# G#include <linux/module.h>
! y, A) B: _6 E; a- d. H& v p4 T$ N#include <linux/kernel.h>
* O. W- C2 g: J#include <linux/types.h>, j8 o& r$ Q) R( M2 a
#include <linux/gpio.h>' V4 l Y1 }8 ]
#include <linux/leds.h>0 L$ V/ O, v$ q7 y
#include <linux/platform_device.h>- T1 }( l' v6 Z4 {
. ]. ^+ T9 `0 h. a/ Y) G
#include <asm/mach-types.h>, h& h3 \0 @& h4 a9 X
#include <asm/mach/arch.h>6 c: X3 s0 J5 i* X7 {
#include <mach/da8xx.h>; Q% j; K/ I- j! j
#include <mach/mux.h>
/ u( L8 u. k5 C d
, O; K! ]" x5 T4 c: k6 ^' P#define DA850_USER_LED0 GPIO_TO_PIN(0, 0) E0 I% h9 p* u
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5). m4 x! ^7 k* y L2 E/ a
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1) g0 h- e: F$ E4 M5 e2 X
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
7 `0 S- j3 b! m+ B E( }
7 ] @, L+ I# k7 c3 a- L) K/* assign the tl som board LED-GPIOs*/* I! S4 P" R" m, |9 r
static const short da850_evm_tl_user_led_pins[] = {8 r2 M9 k! ~6 k2 u5 {) t& m
/* These pins are definition at <mach/mux.h> file */2 [0 K- ]# A% d9 d8 q( c
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,2 f9 z; M* @& c$ n% `
-1; O$ L9 c" F$ I% W/ ^
};+ w5 W* f# E4 ~) q! k
" x5 L; G5 r& h" Nstatic struct gpio_led da850_evm_tl_leds[] = {5 U7 r7 t# D! `0 Q6 n$ O
{. ?- m, ` ?/ F5 P: v
.active_low = 0,
9 k3 Z0 Q8 ]: _; Z .gpio = DA850_USER_LED0,
7 `* o3 W* ~; t' E; p- s .name = "user_led0",
4 w" i# x2 d4 C) P .default_trigger = "default-on",
3 ?1 l% I- u& M# m- I0 q6 B1 ^ }," r+ W0 V \6 n& A) m% j
{
1 }7 X1 k5 [, `4 a- _, c1 W .active_low = 0,
3 }- A4 ] ~) E3 j .gpio = DA850_USER_LED1,
1 r, u2 S/ L2 Q .name = "user_led1",8 Y3 l. G+ d+ H$ a* c' x* c) f
.default_trigger = "default-on",
0 G% Z+ X; v4 R6 w' P: ~! W },$ B* N j! r, P( T) u7 S- l
{+ R! d& G! a% g
.active_low = 0,% ?7 U6 D; Q3 C% k
.gpio = DA850_USER_LED2,
' F. @; m: I# U" s; W* q .name = "user_led2",: c) Z; c- V) S C9 Q' l8 c. {
.default_trigger = "default-on",
u" ?6 E; l" X0 Q6 D },) O0 Z& B! Q& ?5 e
{, q2 y% W" W4 A: J6 k
.active_low = 0,. B. Z# @+ h: Y- i% V: R2 N% \: \8 E
.gpio = DA850_USER_LED3,$ b1 d( j0 `6 S) o8 @3 e
.name = "user_led3",
9 \ l7 h5 _( Q& t .default_trigger = "default-on",0 [0 y% t8 z9 J3 n. P/ w% \/ S9 @# s
},* s8 P+ ]3 \9 Z2 m* [$ x
};
0 k: L# x" v( g3 S) g. ~% l) k D1 |4 [) M' T
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {# P) u' K- l! V/ q+ S; d" K3 T* d
.leds = da850_evm_tl_leds,* x% ^+ B! ^0 J0 V2 s9 Z& G
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),% v$ P2 ?& ^( ^# R( Q$ Q8 O
};1 |0 {- }7 {; j
/ g: ]0 s: K9 U5 p
static void led_dev_release(struct device *dev)
, n* b# j7 P0 S. g. [5 K- n{, |; p6 _. W/ h
};
% P& t& L3 U) B) q6 z- E
# d0 ~& a+ x/ a9 M1 w P# J5 |static struct platform_device da850_evm_tl_leds_device = {
' R U% q& y$ x- _. J .name = "leds-gpio",
1 _6 _. h- E& F/ ? .id = 1,1 b8 S" l# d8 c% [* q& m
.dev = {& U4 {* s; O& Y& d. V
.platform_data = &da850_evm_tl_leds_pdata,6 v/ r: Y: \/ z4 W8 E# `2 {/ e8 I
.release = led_dev_release,
& g) ?. Y3 `4 I }
1 m# x9 K* A. v1 y2 N};( b4 [0 A3 A5 N6 O# F* n
$ F$ H$ ?) e, S6 v
static int __init led_platform_init(void)- X% f8 ?' l' b, [0 w# U/ y* y; J
{$ `1 S4 i* B1 ^+ m! z
int ret;/ X- @2 u4 O: j8 c
#if 0
/ e' U( z) B4 L3 j ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);( v D, z+ z) R
if (ret)6 {0 ~8 T7 ^7 v% `7 Y. h! U$ K
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
. B$ @: c4 V/ o8 X2 P) N! ? "%d\n", ret);
2 S5 i2 I9 x; s4 O/ S* G2 d#endif1 h9 [) ^5 J5 L0 N
ret = platform_device_register(&da850_evm_tl_leds_device);/ X1 t* W; ?2 h, t5 F
if (ret)/ s# o4 i; @0 W j3 s [( V6 ~
pr_warning("Could not register som GPIO expander LEDS");( _1 k$ i' I0 L$ P
else
. E9 M% l% l( f+ [0 ? printk(KERN_INFO "LED register sucessful!\n");* b7 a! Z$ M p" v0 A- h
5 P8 d( _6 s6 A
return ret;
+ V- @4 {" o* Z2 v9 a4 R}' s$ U, G) m5 J; a! A9 e* E2 b
Z$ g) r3 i9 ~( \
static void __exit led_platform_exit(void)
) Z/ \' M; f/ ^, a) r{' z+ I4 c! W3 p- `
platform_device_unregister(&da850_evm_tl_leds_device);& \* ]; J" }* ~4 A/ h0 I
* S* z+ t+ w y$ D
printk(KERN_INFO "LED unregister!\n");# q! m% U# T3 O/ ]/ ]6 z! }! u, V$ o
}7 S; A' a- n4 y
0 c- T) k) k. n D5 [: ymodule_init(led_platform_init);% j% k9 |1 n9 b7 F/ V
module_exit(led_platform_exit);" g7 W; m: t5 C) A) x
; M: S# V w7 j0 ^MODULE_DESCRIPTION("Led platform driver");% o# e/ w! p. K" B x Q+ H
MODULE_AUTHOR("Tronlong");
9 N# N) D5 A& D/ U& bMODULE_LICENSE("GPL");! ~6 [- |8 p. J# H; X7 p- l
: [4 }$ d0 y. h1 ?* w, l) h1 \ |
|