|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
7 s' M% N7 _$ \#include <linux/init.h>3 ]9 m0 H' C1 c+ Q% h% L
#include <linux/module.h>: R) R+ G+ G% r
#include <linux/kernel.h>+ z1 f9 o& K6 I4 k! r; Z, D% t8 i
#include <linux/types.h>
- @) [6 K5 F& a7 @6 t' `7 y( g#include <linux/gpio.h> `# H$ ]: M, n q( G8 e- K3 P# _
#include <linux/leds.h>
9 M) [# I [0 {7 O#include <linux/platform_device.h>
8 c6 W' J+ J6 {* N2 G7 ?# K+ u
% p( M1 c4 d" \+ j. o# f#include <asm/mach-types.h>/ j' N6 ^ `* T
#include <asm/mach/arch.h>0 ^% U+ V5 _& B
#include <mach/da8xx.h>
8 p, G+ L: I8 J# `3 m7 i; R#include <mach/mux.h>
" y: ^5 p& p6 F- S, F- E! E" W( z
2 v, N% t O/ p4 h/ h/ w#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
! B+ v4 X/ C" `$ d" k) s#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)9 U3 ^. K! e& I$ s9 r
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)% A: F# ?4 W2 Q5 y, Y
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)6 {! {, c* g9 H5 g
# B/ S7 a2 q6 [7 k/* assign the tl som board LED-GPIOs*/
. o7 g8 s- J7 y istatic const short da850_evm_tl_user_led_pins[] = {% [" W( B; Q" v
/* These pins are definition at <mach/mux.h> file */# E+ i- [2 s% X0 I, y
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,$ Z( Q3 k9 l3 Y0 [0 G
-1
3 H* ]. B T1 H6 I0 @: I};! @' ]3 Y7 B; A3 N% U
$ Q/ W( [- S L( G0 A7 e
static struct gpio_led da850_evm_tl_leds[] = {4 g4 m' g& f! {5 O6 |* O
{0 M k3 \' n2 }# j0 R# i# ]
.active_low = 0,$ d q- h( o" }5 G' x
.gpio = DA850_USER_LED0,7 ?3 s. f5 X, ^
.name = "user_led0",
[: S$ r! ^& U' [ .default_trigger = "default-on",
& u9 o' X8 t! T, W },6 { k$ p- ~5 J' C& l/ W
{! D. I- F8 {; h! H
.active_low = 0,, Q3 d* m( l0 t s1 V
.gpio = DA850_USER_LED1,3 G9 K, P% f7 W
.name = "user_led1",
. g/ x; [2 N O0 I .default_trigger = "default-on",
$ k% g2 v) y, x( p, q% o },
" H e8 I. n2 N3 L- b0 d: O6 {( H$ V {8 w7 T6 E8 V3 ~- f! z$ Z
.active_low = 0,4 r |% m6 U, I4 x" Y; U. Q
.gpio = DA850_USER_LED2,
. C5 @" {9 j* H4 i. w3 S1 ~ .name = "user_led2",
3 G% I2 G! u* S0 K6 N. [" U .default_trigger = "default-on",
! y- N8 S6 j$ x/ |+ e' C* w },2 X- o8 W+ B) w+ \# T2 c7 R
{
7 d+ |3 r5 @& K# X- D .active_low = 0,
" s" ?' @/ q% B& Q; G Q s% g .gpio = DA850_USER_LED3,
% X- ?5 e) o8 g3 d3 N .name = "user_led3",& \9 ?0 O+ X1 Q) V% W1 s
.default_trigger = "default-on",4 t( G! S. c$ H+ w" \" ]
},
3 Y: V4 `) o& W* }5 j* F5 x' A};
9 }. }3 l4 j% B B7 q' [. c0 Y+ T: d- T8 u# e
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {/ W0 c! U4 ?9 R
.leds = da850_evm_tl_leds,6 n3 c, V: p4 Y1 O8 o( [: g
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),
# t; |2 a( @& ?2 f, p. b1 K};
2 Z' b3 _( D; _
- E" H5 x& q& Lstatic void led_dev_release(struct device *dev)
* @* c( y* v7 A* ]& J) x- Q% I{- T0 V6 _) |2 `4 e. k8 l
};: u; j4 Y4 m! `/ k- h
9 p8 Q, e0 N% V
static struct platform_device da850_evm_tl_leds_device = {* Q, R+ c9 R" g9 j: x B p
.name = "leds-gpio",
1 w: E+ o* h( a4 o .id = 1,
9 K* y4 ^5 l$ @5 b3 Z/ h .dev = {* M+ o9 b, Z! ^; W! n F; e$ ~9 Y: J
.platform_data = &da850_evm_tl_leds_pdata,
4 z# v7 h( e1 b d0 x0 G: N .release = led_dev_release,5 M- O3 V' O! P5 M% X
}8 K: c9 q7 z8 j* \8 |! _& }4 J
};- G. A7 c+ d/ w' \ G
% I' K; F0 W9 d8 h
static int __init led_platform_init(void)
2 l7 ]5 P; d4 M/ [5 U{- ~4 m. I6 C7 q- Y
int ret;
: O- r. ` x Z#if 0) S% r5 t4 w6 K+ U f6 v4 z- S5 x( X
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
+ H. H6 v% T' U; \* r if (ret)
" H, }. t( X1 A% A pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
1 I, q$ j# l0 J "%d\n", ret);
& H" g# m$ q) d8 |#endif3 r2 f) ]1 i+ Q+ @) \" K
ret = platform_device_register(&da850_evm_tl_leds_device);: q1 f; I7 S4 M$ ?+ l
if (ret)
7 H; W5 n6 h S" x6 B V pr_warning("Could not register som GPIO expander LEDS");
: X& }) N' K, v3 u else
6 O1 s0 e( w3 z# g0 H" O printk(KERN_INFO "LED register sucessful!\n");
% k+ _& f- R! z- [$ F, D( H0 w' a- |; G! \5 t, g$ ?% w8 Z% _
return ret;$ i6 Z+ |1 _# P8 K$ P" K
}
! H1 V4 n: w- f$ y9 R7 `* h0 D
static void __exit led_platform_exit(void), s& d$ s2 h7 y/ B) e1 @
{
0 ^' ?/ L1 @$ N: S5 I7 j! ~ platform_device_unregister(&da850_evm_tl_leds_device);
, T: t& }8 O+ j- R. p) Z# o& A" ~3 @0 ]& q) J d' x! m% N
printk(KERN_INFO "LED unregister!\n");8 k7 |0 M2 }- a+ D
}
& y! q; H( {, t. H' `! f9 t7 c ]& z( |
module_init(led_platform_init);
4 i+ c, b+ i6 h; X" qmodule_exit(led_platform_exit);- ~: ~- A' l& a6 `3 F
) ?2 S9 F. `6 E. zMODULE_DESCRIPTION("Led platform driver");& n" y* _- H( v) H3 u
MODULE_AUTHOR("Tronlong");
5 \" U. r) F- ` y# S! l$ p8 iMODULE_LICENSE("GPL");4 e, n: c' y8 ], w
% X( I) w0 r7 p3 _& R/ y8 r4 S$ o
|
|