|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
2 E2 e @$ }9 z: w6 m. O2 Q/ z) d#include <linux/init.h>6 Z* s/ h, C, M* M8 }
#include <linux/module.h>$ X+ b8 l7 g# @1 i4 U2 u0 M
#include <linux/kernel.h>2 \8 y M- l! ?# _! l2 @: p f
#include <linux/types.h>% B8 N3 I% P0 s6 p$ l2 E v
#include <linux/gpio.h>
1 o# Q$ b; N& m" d) q#include <linux/leds.h>8 y, O; G& q# ]2 o( S+ d+ r
#include <linux/platform_device.h>
& W. Q$ z! v" o
# m/ S! R- S* h5 H#include <asm/mach-types.h>
: G8 _' \+ n2 y9 G7 B9 n0 e$ Q5 m#include <asm/mach/arch.h>6 a$ X) Y9 P, ~8 ~- V
#include <mach/da8xx.h>7 F- D8 K7 i* q2 ?' B
#include <mach/mux.h>) S, }8 {7 b* Q
& X; k! M+ u7 Z5 I* f/ b" P2 m% A
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)& P! k9 X' k2 B( T% K# y
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5); ?/ H- n& A5 c, I, p
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)8 ^0 E9 U" d# T+ F b
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)7 F8 S1 x: o7 Z* ^4 u" G% d
' P) s v$ T! Q- w, {& }
/* assign the tl som board LED-GPIOs*/
\' `' F# [% |% Y7 j" }' V" b: Wstatic const short da850_evm_tl_user_led_pins[] = {
. y! \6 O: F9 Y c8 g /* These pins are definition at <mach/mux.h> file */( g4 ~- J- a$ f( K5 Z) v
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
* p- o0 K, w7 e+ j -1
, `5 o: i# i b( |* {}; z( O! o. K0 |) ?9 l
$ [$ A/ @ ^( x, O" e L3 s
static struct gpio_led da850_evm_tl_leds[] = {# u$ Q- k0 J/ p3 y2 i8 X* F
{
7 t( W$ `5 J: ^, y! i1 [% L. K. g; w: A .active_low = 0,
. B; N" Q3 A& z. |7 t .gpio = DA850_USER_LED0,. k3 s4 J4 n9 U M
.name = "user_led0",
) F5 d+ t! g; F# A F .default_trigger = "default-on",/ s1 D0 ]3 v6 F8 X+ Q: s
},
0 X3 ?3 p) ]* X s {/ h7 x" ? w' F4 W3 I$ B, M
.active_low = 0,
e9 R" V( ~* h& V( q .gpio = DA850_USER_LED1,- G( M6 n, a' _; q* s
.name = "user_led1",
: m/ I! ^- v6 g. |( h .default_trigger = "default-on",1 V1 V8 ? O9 O, u9 R7 P
},# }* Q1 U$ J: b! a
{
) v& a; {( ~; \$ a% D .active_low = 0,, E, y, f( W/ [8 `& A
.gpio = DA850_USER_LED2,; l' M$ j: p9 v$ M
.name = "user_led2",0 b. O) }1 v) l8 u/ E& B( I4 G
.default_trigger = "default-on",& y& g; c$ [+ P+ Y
},
- W+ F }. i% f+ w! W' w {& B0 A0 l. y. J
.active_low = 0,
8 X+ b- t. s! ], n& k .gpio = DA850_USER_LED3,# ~- ~+ X! U* ~2 \ i
.name = "user_led3",+ A% y4 d9 Q9 I6 r5 t* v
.default_trigger = "default-on",
& _" V& L% t1 p/ S* d/ B' G },+ G2 X* G# s+ c* x
};; }' t2 ~* t% O. W. V6 j
! c! C! e" Z& B' V! J( dstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
# w( @ a: n! P* C" H .leds = da850_evm_tl_leds,
0 ^: H/ V3 ^# v9 j! [& w: K/ B5 M .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
3 [3 L* a4 w) W& {$ q: z ^# N0 V3 w};
5 v! Y6 q* U* p5 n! E
* ]- y. I* O7 ]( _static void led_dev_release(struct device *dev)
$ X& x+ C& S A7 H( F) T8 w{4 y0 o. _* C! _# l! m$ Z5 d
};
# } E, k4 ^5 r1 z
% ~/ {' S8 F) Y7 i: Ystatic struct platform_device da850_evm_tl_leds_device = {9 {3 t5 I# c$ e( `$ B+ V3 C# S4 f
.name = "leds-gpio",
/ s$ u& Z6 j/ x. G9 P) Q .id = 1,
- f4 \1 S5 S3 X5 Z- P& Z$ y. i .dev = {, k8 x: a9 V) L; y' z! L
.platform_data = &da850_evm_tl_leds_pdata,
. b5 f$ W4 b1 E: M. ^8 c .release = led_dev_release,1 [, y/ @$ F7 ] A
}
8 Z. [) R! ^5 g1 s};+ L6 t0 H9 W R* S5 d) O
* T: M" j3 `+ c3 J
static int __init led_platform_init(void)
$ T3 \. R! `1 B" G{
2 J& m, d7 j; y& P3 x2 y; B; R int ret;
- ^2 J* m. B) Y+ T* |#if 0
( ?6 O8 W, b) f( m$ ] ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
4 H+ |5 {; V0 m+ t if (ret), x" w l& S/ S6 k# _! j1 a
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
' o( X4 t2 e2 ]1 `$ `# a3 ?% c "%d\n", ret);
, B3 u/ u3 ^! _+ s% G7 h#endif
* F- ^- p* ]6 b( Z+ \0 G ret = platform_device_register(&da850_evm_tl_leds_device);
& H2 e9 ]$ I5 H) ?( F& C1 I6 ^ if (ret)) J3 ?. Y( u. _7 k/ O- P3 f N
pr_warning("Could not register som GPIO expander LEDS");
% I/ E" M: M! M: _ else
* ~$ x( n+ |& D' j2 f printk(KERN_INFO "LED register sucessful!\n");
0 e7 @; n1 A( H, X. H
+ l+ o: l" m8 Z# H0 o return ret;& p4 U/ Z. n- O" p
}
, u+ x7 a' X7 |* q* |
. I" ^8 M1 L2 `8 jstatic void __exit led_platform_exit(void)
7 }. q6 v% G5 b: R{* d) l8 G" R' e& t- Y
platform_device_unregister(&da850_evm_tl_leds_device);
9 [( p4 M; Y2 q& P y& H8 _
3 W( X% [: Q( ]3 E7 ^ printk(KERN_INFO "LED unregister!\n");# Z9 s; T& x/ d$ e
}" [4 Y9 I; Z) l7 v! l U* f% N, u5 n# t
- M( u1 M) Z( i3 T; c: n; R) }! `module_init(led_platform_init);
. `' _' o# t$ H$ c* a Z9 F0 Imodule_exit(led_platform_exit);
# }8 C* N4 p( e' H: V" P
0 ^2 Q" i% w( d. \/ W9 NMODULE_DESCRIPTION("Led platform driver");) h% X1 ]7 N/ a7 z: W# O
MODULE_AUTHOR("Tronlong");
7 L5 v* X' D& Q8 n* J% UMODULE_LICENSE("GPL");
7 p* G- W; J6 ]1 A' v; F
7 C) W' p3 w7 f6 I% C' ` |
|