|
|
求大神给下面的程序做注解,请稍详细些,谢谢。& ~3 Q$ }- z" S3 @# H8 q
#include <linux/init.h>& y( @6 e5 s, V% U8 ^: j
#include <linux/module.h>
5 k- j3 i" y" G! h- v8 Q#include <linux/kernel.h>
6 g6 G2 T- m# k" S! F#include <linux/types.h>& H4 G& w# K7 Y; \' N" p7 S
#include <linux/gpio.h>
. v4 f8 _% y5 a% r; C) ?#include <linux/leds.h>
+ Q( C: d2 N9 Y#include <linux/platform_device.h>
# |+ N5 m8 U! p9 c8 c1 M3 [# ^( l3 W# K0 N
#include <asm/mach-types.h>
) e z# q, Z+ G9 d* d% I. J% e#include <asm/mach/arch.h>) c9 V' H1 r6 y! v2 r
#include <mach/da8xx.h>
! b) B! J9 J4 k* ^ M6 R#include <mach/mux.h>
8 t) F |1 ~8 V: ^) j, A8 j8 E# S
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
; f7 T5 Z i5 N7 ]" m1 _6 G#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)7 H2 B4 W5 ~- M i( @
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)5 z; g0 T+ b. F, W( H! i
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)6 V7 U0 A8 r2 B/ D( n
& q" d2 M0 V0 {8 i u) N+ r5 i/* assign the tl som board LED-GPIOs*/3 k% o r9 m- S, N
static const short da850_evm_tl_user_led_pins[] = {$ E" B; R- l3 u+ X9 d9 W6 w
/* These pins are definition at <mach/mux.h> file */! p: h, v) b' c: l; H
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,; A+ ?7 e6 X1 C; q
-1
2 H" N7 s) \9 z4 u$ B};1 P% y% Y4 _+ v* U( d* {4 z
% d! q8 Z7 J6 h1 K' n& |5 {( Estatic struct gpio_led da850_evm_tl_leds[] = {2 Z! V: n! I9 C K! X
{! ?( ]1 e; x2 n5 d
.active_low = 0,
! F- ^7 f F5 T0 v6 j .gpio = DA850_USER_LED0,
+ z' ^* @. |* u& X" [ .name = "user_led0",' x- ^7 U2 ^) n5 L# S
.default_trigger = "default-on",$ d. N( E9 H c
},
3 J0 _$ B2 @2 @$ w7 p {
6 @1 D) `! i) E5 g1 g .active_low = 0,3 @7 u5 \- D% W
.gpio = DA850_USER_LED1,
" f% z0 p* Q* g7 H .name = "user_led1", ^. O! F1 J D! B9 Y) \3 i+ S
.default_trigger = "default-on",* e8 l5 G, s+ Q% ]4 o
},
, {+ X% [% a, ~# `9 |% @ V. { {
5 z* U1 `% z" {, u b$ | .active_low = 0,$ q+ n. V4 G( p: J0 X* S. Y
.gpio = DA850_USER_LED2,
N2 c" |/ d& D" | .name = "user_led2",6 T1 Y# Q+ J2 J' c; h, y- e- Y
.default_trigger = "default-on",
/ C7 V: C+ ?( } |) W% b },0 T1 C/ J9 ?! [9 W0 C
{5 H3 S# q& v0 l$ Z. P" M0 j/ b+ {
.active_low = 0,% u- ?% w$ p( n9 M, W
.gpio = DA850_USER_LED3,
1 x! p: u. ]' V" [2 W( L# N H .name = "user_led3",
: a5 J S _% C. Q x) h9 o .default_trigger = "default-on",
, K9 {4 f+ W% n- V; F$ t },: W- j/ a0 z' u# N8 _9 m$ M
};
+ J% N p# [' S6 ]4 M) H
. u0 k9 Q/ i/ f8 p" w7 c0 Q0 x$ pstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
1 E% X$ o0 w2 s' C7 @" m .leds = da850_evm_tl_leds,
1 t+ T8 c h v* ]# S; c .num_leds = ARRAY_SIZE(da850_evm_tl_leds),, i, x/ l# {7 ^+ K; T" b1 u# R0 x
};
9 u9 X9 K( A& _5 N$ @7 b
% E1 [) J! y3 M1 nstatic void led_dev_release(struct device *dev)
( v+ {! y! N7 s3 t' \' |( ^{
7 H7 u4 h, W4 P8 O0 y% C};2 B. Z% U. B2 H- y1 P& V, d+ s
3 m5 T% r* s/ n! m* I0 R+ N8 X1 i, J
static struct platform_device da850_evm_tl_leds_device = {) v% z4 j8 Z( ?% g3 K* m Z
.name = "leds-gpio",- A `! q1 v/ @& z0 g
.id = 1,
4 V( B' @" H: {8 B .dev = {% P% O! ?6 F f! v. G% s8 h7 A) B
.platform_data = &da850_evm_tl_leds_pdata,
" p" B& M6 i7 N0 f. Q5 l .release = led_dev_release,4 Y4 g- o3 Q6 x/ w
}6 Y: V9 }( W% Z
};
, K7 u% C" l( y& D: y( x2 k6 T/ y" R3 l- e2 n5 j; {
static int __init led_platform_init(void). T6 }7 J( x) E$ Y7 ~$ j5 B
{
. r% V- |/ o% E6 ~8 u7 P" f int ret;
+ n- @: U+ F$ P/ u) o3 S#if 0
0 `* D8 p5 H5 L$ A, M: p ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);7 T4 U" t) `9 \ y( y; k
if (ret)
$ A* Q5 w. l9 [" s pr_warning("da850_evm_tl_leds_init : User LED mux failed :"& E0 B; N9 G2 U4 h: ~' y& X
"%d\n", ret);3 k" x [, V' R- k2 G! Y
#endif
* u& {- V/ V, o6 L, m8 m1 w( w9 P) G& y ret = platform_device_register(&da850_evm_tl_leds_device);
7 s4 R7 m5 |9 b5 Z# s+ D if (ret)( C. O7 _" {) @0 B: i# O# ^( G
pr_warning("Could not register som GPIO expander LEDS");7 [8 O5 O8 S4 N" O1 i/ ^
else: J8 @' M" {. A$ u
printk(KERN_INFO "LED register sucessful!\n");( ^- r& L0 ]. o y
% C L/ E) Z4 P1 C2 ~: l6 U
return ret;- l) M5 ]$ ]3 ~+ L' v! |" p
}- ~2 p- R( \' F% U' X3 V
) M) {, j, h1 t6 ~static void __exit led_platform_exit(void)
' i# q2 c+ ~% e, d" B% L{
0 K$ ?, k% o0 o8 {& r; x% | platform_device_unregister(&da850_evm_tl_leds_device); ]& t" t# M* \8 w: M/ ~4 c- _
" T q2 U* |0 [- v. f) @ printk(KERN_INFO "LED unregister!\n");9 g, O) H7 [8 e' g9 `* u' V
}
2 W3 j6 p9 i1 W! H) c( J! M) A- H' t- \
module_init(led_platform_init);
. R4 C" I3 l$ _6 Nmodule_exit(led_platform_exit);* @% f8 f, ?" a {
7 Q2 L% F) s4 P$ F R* _4 z
MODULE_DESCRIPTION("Led platform driver");
; w6 ]) S6 r5 ]5 wMODULE_AUTHOR("Tronlong");
( I. L6 }2 F( S, |. GMODULE_LICENSE("GPL");
& P' s5 ?+ U7 P O, ]( \8 T
! @6 S9 U- E e9 y9 I5 `- C |
|