|
|
求大神给下面的程序做注解,请稍详细些,谢谢。9 q5 z- J0 f' E" p/ O
#include <linux/init.h># ^% T1 U( [0 |/ M. r o& d
#include <linux/module.h>+ V# s% @( C+ g
#include <linux/kernel.h>
3 k+ |0 s; A9 Q: E4 m#include <linux/types.h>% \: H- d& d2 s) X7 A
#include <linux/gpio.h>2 T5 m6 H5 Y8 D- ?
#include <linux/leds.h>8 u9 u$ q$ B6 c$ l- B7 q& R1 H
#include <linux/platform_device.h>' N {+ ?! {' t! \
3 |. E; V% b7 \$ \% ^
#include <asm/mach-types.h>
' r/ z9 F" F3 D. z#include <asm/mach/arch.h>- ]4 R T: ], _
#include <mach/da8xx.h>
$ \. @* H" Y& Y6 J4 F#include <mach/mux.h> e/ v0 }3 s' L' r" }2 _% e
5 y' @4 F# L9 S8 |- A- x2 \! y+ C( P#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)* c0 }0 a6 K/ _
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
& X. }- i- ]+ i- |, N8 I L2 o#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)* d: F0 u! b2 m. G) C( ]: z, n- J* E
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)0 J, O8 h" H, A- W6 h/ M, {
4 s, N z- [2 T9 N
/* assign the tl som board LED-GPIOs*/
5 \9 H+ w. ]8 W2 |static const short da850_evm_tl_user_led_pins[] = {
1 W) q, d6 ]2 N' _ /* These pins are definition at <mach/mux.h> file */. d8 Q! m6 l2 V% i O
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
3 H; j- h) ]0 B -1/ c% I& m+ x8 r. O z
};
9 Q9 c7 f0 V) N: C+ S" R* q Q, Y8 H; I
static struct gpio_led da850_evm_tl_leds[] = {
3 z0 z* x) S% Q. z) t7 ` {' f8 D0 T1 Q. Q3 V9 ?4 W
.active_low = 0,
3 S& E0 ^% X9 o' M .gpio = DA850_USER_LED0, o8 C' A9 S- H0 r ^
.name = "user_led0",
% [+ A0 d; Z K1 r/ Q .default_trigger = "default-on",
. T$ ^! F, B i. u& [ },) x- ^, f: q5 T+ m
{
+ `% @5 K$ m! \4 ~+ g .active_low = 0,1 W U9 N3 G% M( P
.gpio = DA850_USER_LED1,
8 @ g' f. \0 K .name = "user_led1",
3 a" K/ G% m% W$ f .default_trigger = "default-on",
( T- B8 d' q8 d+ n },' C& r% T6 }8 @+ m" Z: d
{' s$ T( A- _7 {; c
.active_low = 0,- J' w+ |* Y0 N5 W6 I6 o5 `
.gpio = DA850_USER_LED2,
( L* o' t3 S! ~( f .name = "user_led2",
" T: J" F4 [* g .default_trigger = "default-on",
9 K' u! p2 y. { },
/ g4 ?1 O6 \- @& a$ T {) a7 S0 u8 J$ B$ @1 h8 p; P j' h* L
.active_low = 0,4 Q9 B: R6 ?. A
.gpio = DA850_USER_LED3,
' ]; c6 J9 Y3 s" D( l .name = "user_led3"," ^. L* l. D. m
.default_trigger = "default-on",
, u2 `. X+ c" o; J0 L% K- \ },! q# i0 d0 d% W+ Z# M
};
# Y2 T2 R; T# z- q0 z% D$ w6 v
+ J" U' j/ l1 Fstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
: O. D' g9 R5 { .leds = da850_evm_tl_leds," v: R6 K! Y. b) }5 ?
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),2 B7 R* c: D0 t$ ^& n
};
6 t8 y. W; r) d: [# g- Y
* a S/ k7 w2 ustatic void led_dev_release(struct device *dev)
: U, \' }4 S% p{" O* V. }- I/ H+ [: m* e* K. a4 E
};
9 t% \ O: k" @) w( ^. E) A9 u g9 D6 y# A$ B& ^% Y' L
static struct platform_device da850_evm_tl_leds_device = {2 [% v8 Z4 Q. ^* _% k
.name = "leds-gpio",6 s7 ^( z V# l. X
.id = 1,
; r% b( E$ u6 v4 t1 T .dev = {
7 g0 e2 _3 h$ s+ W .platform_data = &da850_evm_tl_leds_pdata,
! k! s& R" a9 ^ e! R/ p, | .release = led_dev_release,2 @* @7 A; B5 t1 e* h
}$ o! r6 \! ]6 R+ d
};
# S8 W6 z& q) G0 x) Y/ R) m! m" t% H4 t6 s d* f7 y9 D. U
static int __init led_platform_init(void)
$ m$ Y k0 J5 V' E{
; E. t1 B- ~& x8 |+ z2 F int ret;
' S- }! @( E: Z/ z#if 0
G8 l2 o, ]2 [7 E8 J ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
1 G- C$ W) Q) b1 F( a0 i if (ret)
]$ H' r! N& ?2 l3 e pr_warning("da850_evm_tl_leds_init : User LED mux failed :"( s" G4 W% \; `* k, I7 _
"%d\n", ret);
7 m \, s, z/ f6 x' t0 i8 E, I5 X#endif1 @7 f: Y. ~4 E/ J( X0 s% E; v8 y
ret = platform_device_register(&da850_evm_tl_leds_device);
; L! W0 ]( c' v1 a* J% V8 f; @ if (ret)
" n2 @, Y4 ^. g0 H) } pr_warning("Could not register som GPIO expander LEDS");
) r0 J' a# \, T3 O else/ `9 F( |% ~# n- t2 Z+ [5 A& x3 U
printk(KERN_INFO "LED register sucessful!\n");1 u& S" \5 z1 Q2 y+ _; O
0 |, c q G: o5 w6 U: g( ^
return ret;
6 B r ]" Z0 H1 R- M/ R}
- l3 q( A( W4 a; V9 Y
1 r1 f8 m2 W2 n" E2 Z0 x7 Estatic void __exit led_platform_exit(void)( Z9 f5 H/ A* j! e1 a5 \
{. R2 L' o% U) }( q7 z+ {& @* V) \
platform_device_unregister(&da850_evm_tl_leds_device);7 R6 ?) J ?0 p; U7 E. X0 r' W" h
0 F8 S( V! q' }. n- q$ i0 M- H
printk(KERN_INFO "LED unregister!\n");
& B8 k1 f1 g$ Z' ]4 }, V& \0 k}
/ s3 {/ q- ], z$ [, }8 x
: z5 V5 w+ N2 L/ l2 M8 F0 Zmodule_init(led_platform_init);
) j& S; t' y$ F/ g, W2 U% Nmodule_exit(led_platform_exit);
: N2 Q/ n+ s3 F+ Z0 M2 d6 P0 V! i, K% x+ {, G: o8 T
MODULE_DESCRIPTION("Led platform driver");3 M8 K. z# u( h Y& ]. C9 M+ U+ b
MODULE_AUTHOR("Tronlong");
& q1 K$ W4 @% ~& e! R: V/ cMODULE_LICENSE("GPL");
, e$ o: F9 Y; L" H( d0 E9 B+ s$ r: W; ]
|
|