|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
: d9 C1 D* C+ K+ D" j% t# C#include <linux/init.h>
# Y i0 O+ I# O( f! B6 B#include <linux/module.h>
7 w5 S4 z Q V- A" V+ d#include <linux/kernel.h>6 ~% c, [ _: c" Y, s
#include <linux/types.h>* Z a* j0 R" S( o
#include <linux/gpio.h>7 m' S2 ~% S7 j7 d( |4 n
#include <linux/leds.h>$ u0 C! r7 h# t: ^! t, Y
#include <linux/platform_device.h>
! k2 r* s: e# {' w7 ^7 h+ X
1 b& q8 |3 c S( F#include <asm/mach-types.h>- g1 [: g/ i* J* @) s) K* s1 d
#include <asm/mach/arch.h>7 H. Z- E7 f% l
#include <mach/da8xx.h>
( G& K& z. I+ ]+ W& l, t$ i#include <mach/mux.h>4 r4 B& v+ `, Y6 z/ Z9 N$ S! ^
% u% H) Y/ |, Y0 S; N6 k3 M6 H1 N
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
, X4 [5 N- s0 o4 |+ c5 @/ Q#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)5 K6 o- s4 B* s/ F
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)2 ]9 k& n/ J9 ?: l9 g7 f; i
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)# H- y" w' {- F
* b0 [- w5 `+ ?' F f0 `* g: i/* assign the tl som board LED-GPIOs*/
3 ]% f, h/ H7 C4 Ystatic const short da850_evm_tl_user_led_pins[] = {
2 ~ ^- p* y* {! F5 t /* These pins are definition at <mach/mux.h> file */
6 ]: U" X; f$ y+ ], r, S DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,3 [. N+ }, L6 |9 T
-1
0 W9 @3 ^5 s( |0 Y5 C. B$ D};: x( {. h8 D/ t# W# H
: A6 W8 p$ R6 l$ |6 astatic struct gpio_led da850_evm_tl_leds[] = {
. h( t) P1 F3 K" W8 R {! t, W! c0 y2 _$ i& j+ u( _
.active_low = 0,3 I$ b: v2 X- ]4 r9 O9 s
.gpio = DA850_USER_LED0,3 g9 I( h& T8 G3 }& {- p7 Z
.name = "user_led0",
# i# t* k, k' U' r .default_trigger = "default-on",* f8 O: c+ Z' T2 ~* z1 }( o
}," Q7 F2 @8 f" E; S9 {
{
5 s3 d4 @% |( r" Y; ~; I2 S9 y* t8 T .active_low = 0,* @* m- H0 E }1 I
.gpio = DA850_USER_LED1,
, }0 x# Q: c! n/ X; f& u5 ? .name = "user_led1",
3 A) O6 P( a7 l; n1 i! L4 g .default_trigger = "default-on",
& D# b: t; O- Y. {, O6 o6 l+ z },
4 a7 G" a6 {4 J/ c! F2 ]; ] c { `6 x4 Z7 n8 }2 y
.active_low = 0,
" r* p9 g1 c; F .gpio = DA850_USER_LED2,: k2 j1 [2 |% N0 [
.name = "user_led2",
1 k) \! I6 V M8 y# U' z& b .default_trigger = "default-on",
" R& V0 L3 f1 ?" l. p& x },! b; @5 s" e8 ?& x+ Q6 `1 l& h: E
{
) i& `3 j$ @- C5 y3 ? .active_low = 0,
8 A; J% p( `( k- F .gpio = DA850_USER_LED3,
2 f$ t" |; \! p) ~ .name = "user_led3",: }# }9 `9 x5 f0 F+ ^
.default_trigger = "default-on",
: U! R9 K! z2 [ },7 c \; T( ?! }% j0 ]7 _
};
' G% F3 f2 k$ k* F$ M7 S9 j7 V! X
" Y2 V% U5 M& ?9 n% g/ F+ Tstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {+ L. {) g c: X8 @% K
.leds = da850_evm_tl_leds,
7 J. t! k7 F5 h+ U3 Q2 }& V .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
* \2 f! }' {! a};
3 j* R* W, R o+ t3 e
6 ?7 Z) D$ r3 N5 d, h$ x6 H; t3 sstatic void led_dev_release(struct device *dev)
! x" U6 M1 \- Y6 O; n! e{) g0 l4 }2 E/ q
};
, L$ L+ e# \ E4 z2 Y3 M
1 e4 s: z- _6 A- I$ Gstatic struct platform_device da850_evm_tl_leds_device = {; {6 U6 V9 ?( U& T3 V5 Q( r
.name = "leds-gpio",4 t! g/ _' u. i: G
.id = 1,
3 Q4 L3 y/ A! {( c/ W; e# _4 T .dev = {( G! M) G9 _) N0 H: z
.platform_data = &da850_evm_tl_leds_pdata,9 m0 p, x! ?" B# \+ H* t! D. ^
.release = led_dev_release," O& p, P! I) c; U: @& T% E
} u& K) C4 M/ y9 @, l' ^
};
7 K: R/ P& R; h+ |2 H, r* C1 [# P5 e7 L8 D2 @
static int __init led_platform_init(void)
9 p8 Q8 g, V$ q& D1 _) N5 Z{1 a* b Q* w6 ?+ L/ I6 N1 Y+ i
int ret;
8 }+ k9 B2 F/ j8 L% P) j( e3 o#if 0
: n1 Z; |. o/ i9 q- c2 c/ I5 u4 } ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);% V) w4 n2 U4 `. `- @$ K |5 B/ v
if (ret)
; @) L0 S$ D8 C4 B, F7 N pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
1 O( `% V! B' W6 y: @ "%d\n", ret);2 V+ {, _ N2 a( S
#endif
; F8 Z# Z2 F: U1 g5 L4 b; _1 H2 U ret = platform_device_register(&da850_evm_tl_leds_device);
+ b4 a, o( g% E8 s$ Q4 y if (ret)4 C4 c4 T, P+ {- H T/ c
pr_warning("Could not register som GPIO expander LEDS");
9 r0 d% d6 ^) O% D& o. n else1 y0 L8 x' ~3 o
printk(KERN_INFO "LED register sucessful!\n");4 {% H+ e7 a$ n% s
# }! @. B0 ^9 X9 S) |5 w5 Z8 L return ret;
) ^. F2 K. Y3 i& R# \2 u}
( b/ c6 c9 f% ^8 O6 @# o
/ Y8 U" ]7 O$ U0 j. d1 i2 Estatic void __exit led_platform_exit(void)
& y: i+ c& s( Q5 \" |{
' N5 i; x" n+ d6 D i5 l1 b) e4 f3 ? platform_device_unregister(&da850_evm_tl_leds_device);
; K% R, k8 w4 W( X: h3 P# |
0 d6 u- r+ c& F printk(KERN_INFO "LED unregister!\n");
/ H C1 ~& @. x* h: _$ {}9 E4 s. }: | K z( \: _) s- `
, {: y: r6 H3 a
module_init(led_platform_init);) I! c/ ~- c4 f! y+ x3 z
module_exit(led_platform_exit);' h1 u& `* O b7 u7 H, H
0 E- m/ p* l- E" k* qMODULE_DESCRIPTION("Led platform driver");
% V- A$ e: t2 |2 j$ r- pMODULE_AUTHOR("Tronlong");; ] e2 l( p" r3 J# P
MODULE_LICENSE("GPL");8 b) K$ g+ E1 G9 g% U
9 O; l0 v6 T5 O6 [& L
|
|