|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
5 K8 O' A) [1 D$ U# D#include <linux/init.h>
" r5 z+ ?- P4 I6 O+ A#include <linux/module.h> \3 G) C# U4 z& c* [
#include <linux/kernel.h>
% @: v) d( e n T#include <linux/types.h># S$ k# M/ o0 ?( z" z
#include <linux/gpio.h>
+ w: y' ~8 U# i0 }2 N#include <linux/leds.h>- J& _! L L- x; \6 f
#include <linux/platform_device.h>) z; Q8 Z) I4 X* B* z
5 A" |4 g; n# b. X- C#include <asm/mach-types.h>
' L# O6 h( T, K! Q#include <asm/mach/arch.h>" ? T6 s3 F& i! D) z
#include <mach/da8xx.h>
; F% z' D' B; y/ @: t$ c ~- D#include <mach/mux.h>
2 K! j: Z% ~7 V9 h2 \& W
1 Y3 Y" u7 S& I' C* k#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)) T7 C* k* p1 h$ `/ d: @
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
; C$ v1 ?6 r* f- ?' c5 {% i/ e1 \#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
" C7 I1 [5 k+ S0 a. O" `9 l( l#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)( L4 ^, n- p, c" h' x
$ ^+ B& t" G0 r/ Q/ a
/* assign the tl som board LED-GPIOs*/. w) T! z# ^1 G9 n* e: g
static const short da850_evm_tl_user_led_pins[] = {
: \) T2 x& u- a, \) s5 D& K# c5 u/ Y /* These pins are definition at <mach/mux.h> file */
% u9 n5 `' }! z, Q DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
7 V5 B! q) j7 e -1
& |2 o! {& U) H$ g" c" }};" D' D. V4 u7 j$ n, T$ h" E
& M: X% n) S, i. N9 ^4 Kstatic struct gpio_led da850_evm_tl_leds[] = {
3 M( n' q/ @/ t+ i2 e- i+ n+ w" | {1 x) Z* X0 ]' G! H/ Q7 }+ {. y
.active_low = 0,' N8 ~1 f& [/ @' }
.gpio = DA850_USER_LED0,7 @7 X' X/ j* K; t, G
.name = "user_led0",: o j \: ]. v( k2 [- h* S
.default_trigger = "default-on",$ C2 S: `6 l/ q! d( b7 r& u {5 l
},
' s! Z/ w/ N' L# W; J! \ {
0 z1 ~- D$ r' N! \9 T .active_low = 0,
5 v! X, G% T" b6 s .gpio = DA850_USER_LED1,
. h; |* s1 Y3 d9 v% u: v9 W .name = "user_led1",: u3 C" x* I3 `1 m- L' t
.default_trigger = "default-on",
0 Z' ]* Z s* n0 |' h },) `7 A" {. R# ~( D1 N6 H
{1 X% L# e- c4 ~
.active_low = 0,
' L7 U1 B% `! M0 z# i7 c% o .gpio = DA850_USER_LED2,- u7 c' U& K: G1 n! q
.name = "user_led2",! z! X' e$ O- G) }
.default_trigger = "default-on",
r; {* P! H! R% `' |2 `9 N },* n5 g3 a, K; m6 N/ W
{
- c* O. m# F: }: d4 @- r .active_low = 0,8 k/ I- F& l1 Q% b4 E" Z) y- B g
.gpio = DA850_USER_LED3,8 C5 `9 s; C" b! Y$ j" m
.name = "user_led3",
) J8 G4 I0 R! ^' R/ [4 a .default_trigger = "default-on",
/ y& Y- M% M3 J; y8 B },
8 }& U5 h7 S; e0 G; z/ m6 \};) m0 T5 z# v3 O# ~
5 Q q' }1 M8 L
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
) }3 s0 K3 v. E, m8 z4 E6 w .leds = da850_evm_tl_leds,
" `0 o* y* J5 x. V/ X. _9 e: v .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
2 {: ~7 x" a3 [7 ?};) Z; z# a$ R' E1 ~) u2 z
8 p( q5 p$ L0 Q+ d, T$ rstatic void led_dev_release(struct device *dev)* n" S' g* K9 C/ J3 \
{
c! p# p$ B: k1 i! w};0 ^) B4 u0 d, e3 X! v
% Q/ n" R2 n6 h* ustatic struct platform_device da850_evm_tl_leds_device = {
' b. _5 R2 t( ?6 ^+ ?1 H! P0 o .name = "leds-gpio",7 n; u+ E V9 y" r9 F
.id = 1,
2 g7 Y+ G i3 r8 N .dev = {
8 a& x P h( y: x9 G" n .platform_data = &da850_evm_tl_leds_pdata,. @1 t( v$ [6 A8 d+ ?
.release = led_dev_release,
% k- J/ ?- b6 j4 g }
) I& r* P3 a5 ^7 \};
& j3 t. a5 ^/ w
# d4 x0 j7 L! z) r7 {static int __init led_platform_init(void)) |- |' I7 r9 }* i( X8 p
{
" \: Z5 n" B/ ]+ W" Z int ret;
, V" j+ W+ y' m/ `+ r& ?#if 0
' f5 j- L, |- A( _$ K$ U; ? ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins); T2 L, l% Q; {1 a
if (ret) h Z+ \. o5 d/ `
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
# h& E8 H0 e( P: K; t1 p "%d\n", ret);3 a4 H% W W0 I6 w5 w
#endif( g' z; N8 ^/ j
ret = platform_device_register(&da850_evm_tl_leds_device);* ~- \. R# n% _
if (ret)" ^0 R% I, \6 B
pr_warning("Could not register som GPIO expander LEDS");3 }$ G9 w9 S+ T$ c$ @' m/ }
else: B8 R, _9 d8 E% h3 Y3 @* Z: T' K
printk(KERN_INFO "LED register sucessful!\n");, {0 a- p' g/ x7 Y9 n6 C
% A- }4 }! S# q, \
return ret;
& ^( P1 u7 {* w8 e" _}
/ g2 O9 D3 q/ `$ n
; x9 w. h& V# f, ^4 }6 Q Istatic void __exit led_platform_exit(void)
8 Z; y9 b7 P& f* _4 B5 G! e{
. s5 v- A. W1 T2 Y" e$ k/ _# b platform_device_unregister(&da850_evm_tl_leds_device);" j6 ^ @ t5 ^# s- O
M& D' h" [- v" [ printk(KERN_INFO "LED unregister!\n");; j7 \5 p8 @0 ]% T- |/ f6 R
}
% I, Q8 R' P& q; z7 c
) o# R: T: S) P1 S. amodule_init(led_platform_init);
2 A( a/ x; l" H& j3 N0 pmodule_exit(led_platform_exit);+ Q- y/ K b! V6 ^. s
* l y. u" {! O1 V5 V
MODULE_DESCRIPTION("Led platform driver");
" Q2 j) p% O) S! y# gMODULE_AUTHOR("Tronlong");8 U N1 U: N! o; C; I& j5 |
MODULE_LICENSE("GPL");6 k; ~- n' y/ f" [/ N3 Y' W
3 T/ v9 |8 n" q _2 k |
|