|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
$ w$ F- O4 [2 j( Y8 w% v+ Q" K- e8 F#include <linux/init.h>* v# A6 a- _8 k, y' i, d
#include <linux/module.h>0 ?$ H, r' D z3 b* x
#include <linux/kernel.h>8 \0 h& o3 G0 J5 @ r+ W4 S1 Q
#include <linux/types.h>& n1 ?% |0 v+ \$ y
#include <linux/gpio.h>
# m! w- Z) R! e4 L* w5 P3 Y. t#include <linux/leds.h>
' n8 J. g. |( A% s" D6 C#include <linux/platform_device.h>
$ m$ e, B" [4 y' {1 K" t5 n4 y+ t) q. |% @. `8 |* K' E
#include <asm/mach-types.h>9 i( U! c# }$ d1 D, e* J, `
#include <asm/mach/arch.h>
( ~* d" I3 H* T m# T8 r8 S#include <mach/da8xx.h>
* @: x+ E) Y5 O: Q2 |: m#include <mach/mux.h>
, q7 Y4 L( L& ?
' ]) b% l9 s. q2 s: ^9 y. R$ O#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
) t) z3 u z/ P9 `8 p( G#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
* D0 d( J4 D, w$ ?#define DA850_USER_LED2 GPIO_TO_PIN(0, 1). y0 W# N4 N& ]# y# P) |. B0 H2 h
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
$ a3 T Q, }: @9 o S: S! p4 s; |7 Z! p
/* assign the tl som board LED-GPIOs*/0 O% I/ ?8 q5 ?9 i$ }5 Z
static const short da850_evm_tl_user_led_pins[] = {
# W* H% @/ M' M9 ^ /* These pins are definition at <mach/mux.h> file */# S( p0 W, J0 @* b+ R
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,9 ^+ l% v& e$ ^6 S$ o g* k# Q
-1
( _: N6 {6 f& H) n+ ]" I};
( o5 z6 z4 t+ b1 V& T
# i4 ^2 r% V s& p' m0 ~static struct gpio_led da850_evm_tl_leds[] = {
4 U. A5 e3 E* \! X: I, r {2 w5 j. M% k+ W- W
.active_low = 0,# w, D h9 d, I" t) S4 B) r
.gpio = DA850_USER_LED0,
9 B6 e Z% ~" E3 E7 T* Z$ ` .name = "user_led0",5 u2 r" R4 Q) W* ]* \
.default_trigger = "default-on",4 z# I! W: h) ?4 M* b# j- d# D' w3 a
},& E' s5 W# K Y. d! _, n3 J4 P
{* U1 }" F5 D5 M, G& N7 ~
.active_low = 0," O4 l# n. c' c% \" ^
.gpio = DA850_USER_LED1,
% F% ]7 r8 x: N7 \; K5 I5 s' e .name = "user_led1",
* c1 A- L! {8 _* E9 w2 Z( e .default_trigger = "default-on",1 `$ f0 _# O W, F
},7 U3 a5 v4 ]3 z
{
) Y+ U! ^/ }3 W0 f .active_low = 0,
6 X% b( {! f' C3 k7 w0 _. I3 X5 h) b8 y .gpio = DA850_USER_LED2,) ?9 d* ^7 e6 E* P" r: X% p& \
.name = "user_led2", A5 Q$ F/ F' Z* N7 {5 |
.default_trigger = "default-on",, G2 t% {- h/ ^! q- S5 L
},; y m9 o6 ]' R1 D3 `/ P
{0 c0 r+ k$ V, o4 d8 t( O& X2 H
.active_low = 0,
. x2 |" z0 ?/ U# \- Z9 t$ c% w. g .gpio = DA850_USER_LED3,
, T o) J7 M! F# _& T) w .name = "user_led3",
0 ]6 ?- v" H; @" F* P0 q9 c2 R .default_trigger = "default-on",
1 j' v5 G5 ]% a+ Z8 e; K6 ~ },1 X2 C& F- k6 h {. D' ^
};( r0 y3 ~! j( Z" v
; Y9 U4 K! j% G" y2 ?* C
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {( D4 {( R% Y7 I# S* g$ S
.leds = da850_evm_tl_leds,
3 ]: O$ \" ^; D2 B( L K4 ^ .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
( C; |" G& k% b, H$ r}; M" K9 n) o4 T* O& n0 X0 K* Z- @
: j, J& L2 l( h# Z- P( |# L Bstatic void led_dev_release(struct device *dev)& T8 G( {# X2 M2 k0 Z- |+ T
{
7 R1 h9 f$ M7 V$ r3 s};
; [: C2 p l* `! T; Z+ k* `! Z! T; q( J* v! y9 r1 p
static struct platform_device da850_evm_tl_leds_device = {
7 ~$ Q4 i$ D d( D8 i$ W .name = "leds-gpio",2 C: g- f( V- t' l
.id = 1,
- W& ]3 p8 g5 z( `3 ~: n- W5 m .dev = {
# J! N! x% G: Q j5 b: V .platform_data = &da850_evm_tl_leds_pdata,# Q: W7 f! `# c3 M
.release = led_dev_release,
1 ^) t, p) m; Y+ o% ^ }
: P3 O+ q) B! z' a! I};
! L& g' k. [( D4 r7 P
$ q- R# x7 M% J0 M# ~- pstatic int __init led_platform_init(void)
* G$ h4 t' k' f: m{$ J7 _! [4 p" f- \" p3 [1 @2 t
int ret;0 V- _ I# Y( J4 q7 U) [9 n
#if 0* Y. G& D( Q% t6 k8 S
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
8 q, c% u& u- L' R- }. X if (ret)
( P4 z% T( ?, A! O; c* o pr_warning("da850_evm_tl_leds_init : User LED mux failed :"/ r1 Q) G/ P7 c: r( s
"%d\n", ret);0 _' i0 p: Z5 e/ R% V
#endif
) F) u9 C4 F" k) I6 [ ret = platform_device_register(&da850_evm_tl_leds_device);
9 q: w& T5 K% e' s% @; W if (ret)* b3 f+ }$ x! i" P0 ]) y
pr_warning("Could not register som GPIO expander LEDS");
7 g' b# m% G; c# M else
, H7 z3 n3 T5 w$ W$ T3 S printk(KERN_INFO "LED register sucessful!\n");
) J m1 u1 m6 m6 M0 {( k( {$ i6 e
3 W5 l( H- Z# z5 j! p+ t return ret;
& y+ {" T2 r" u. j# \}
1 Y" z9 E" O2 V8 ]9 N: {- F
, I; |! K( P; k5 s: e3 i! lstatic void __exit led_platform_exit(void)
4 }1 M' X- U/ |# z/ l4 B4 X{+ B- W6 E, N& t
platform_device_unregister(&da850_evm_tl_leds_device);
& s7 Y: g3 G j
8 P; V; g3 T' Z1 T, o" h' a4 z printk(KERN_INFO "LED unregister!\n");
8 r- c/ a2 J: P}
/ q1 r1 L: J. s t
; g& G' m+ f- w2 f& j& Y1 ymodule_init(led_platform_init);$ X- u6 t% L) o/ L
module_exit(led_platform_exit);( [ y# t2 l; C1 m
# ?6 C" z' s7 I$ M' L nMODULE_DESCRIPTION("Led platform driver");% _/ [& X2 T7 o: b
MODULE_AUTHOR("Tronlong");9 i' p& h) |: g) J0 ~( r: @
MODULE_LICENSE("GPL");
4 S3 ? |' E0 a" U* g
! `( Y% m7 B; ^# J* h |
|