|
|
求大神给下面的程序做注解,请稍详细些,谢谢。( M! [- h; [" p- L( X
#include <linux/init.h>8 D( h: b. {$ ^6 ]9 H
#include <linux/module.h>/ [' K0 E, I3 W# M6 ]6 [) f
#include <linux/kernel.h>: w+ Z' J; h1 ~
#include <linux/types.h>
; s3 G! e9 }# l. N. I#include <linux/gpio.h>
$ \! I# e/ N& k: N) R#include <linux/leds.h>' ]7 z+ A" x- T* w. [5 }' C2 D
#include <linux/platform_device.h>
! v A! j9 x; _* L6 y. d2 K- ^9 V4 ^; P3 J6 v
#include <asm/mach-types.h>
$ v, ^5 B1 l4 F#include <asm/mach/arch.h>7 B b+ ^7 @; D8 S- [1 h
#include <mach/da8xx.h>4 i2 e9 u- y$ B# U1 H) i" x5 Z- L
#include <mach/mux.h>+ _5 J' h/ |* |/ Z5 Y) i1 A& y
9 ]6 j7 |" `" T7 z1 z3 R#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
! d5 ~ }0 N5 }/ |#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)3 H" s4 Z! L$ f% Y
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)+ r* \( I/ e4 _; q& h& M
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)6 z* F6 Z' H) z8 I
, @7 I9 j+ v( \- O# Y9 Y$ u, Q
/* assign the tl som board LED-GPIOs*// ?3 H4 Z7 p2 v" O
static const short da850_evm_tl_user_led_pins[] = {" J5 y6 R, _/ d" m" a
/* These pins are definition at <mach/mux.h> file */
$ @/ |# R" d9 O9 P3 x G6 M DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,5 e' @& K! e% d. [4 w: k
-1. ?0 ~6 v# k0 d
};6 Q/ K: [+ Z: p( Q @+ r
F( s5 P- o' R) o/ mstatic struct gpio_led da850_evm_tl_leds[] = {6 u, H) x( S* F/ I( ]2 V8 M- O! Y. x
{5 S' ?# d7 ^5 J1 `2 R; b" G, L
.active_low = 0,
]2 ^& j1 [. q6 V) i3 D$ j .gpio = DA850_USER_LED0,4 @% t( y8 B V7 o, T, M
.name = "user_led0",
3 R" I% [, b- H0 {" L; e; K- [/ z .default_trigger = "default-on",) M5 E! ?# ~1 O1 q/ P7 f C
},
. D! t( j! G- r3 S* U {$ X+ b/ y4 i- C
.active_low = 0,
* }- }* |' k m" T .gpio = DA850_USER_LED1,$ @5 R# s/ Z X% G. z e; Y
.name = "user_led1",1 W; j; Q# m7 V+ l+ o9 M2 B( U
.default_trigger = "default-on",
% U. X6 {( G" X D },1 l$ S. @2 s1 v* x& ^; w# q) f
{
% O6 _& q, H* V) Y! d: z3 w+ D4 v .active_low = 0,4 t2 f4 V F3 Z% H- b
.gpio = DA850_USER_LED2,
6 C$ ]0 N F" k' T4 t .name = "user_led2",4 K: @, q/ F% B Y
.default_trigger = "default-on",
# r) c: z1 R8 p8 u# s },: `5 ?2 u8 v7 D: J+ }. ?7 N
{
; ? x6 t7 s3 N2 Y/ n) E8 z .active_low = 0,/ Z {0 z( |% _. u4 O
.gpio = DA850_USER_LED3,0 n* h9 C! s6 u" k* d( w8 O
.name = "user_led3",
) S6 |) I& B6 [5 m' J0 k4 s- F .default_trigger = "default-on",) y( T5 J- {. o! M. b5 l; F
},6 t0 J7 l: ~4 P3 }4 ^( v3 m
};7 Z w% ]* F. D0 i1 r
1 u: u+ `/ v2 f) A& X! X7 @( D
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
; u9 Q: D D5 u h( |! ` .leds = da850_evm_tl_leds,! ?% V$ Y X" V' D, r
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),
, z( }: a0 D7 s/ d% r) c};
; b0 |. s8 F( ^: ]8 S7 p2 S/ I5 w' @/ A$ G; ]/ w# |
static void led_dev_release(struct device *dev)+ M3 n9 U6 I' @ c* x
{3 T' R! Q% ^5 t* s
};
8 O* g% E# X9 r* L" A7 l% ?) [+ |6 j. S: V' A0 E6 k
static struct platform_device da850_evm_tl_leds_device = {
/ E+ x# G7 L. w0 ^& T* O .name = "leds-gpio",
* X+ G+ ~! W7 V .id = 1,' M h6 O0 m3 B* C* Y: ^
.dev = {! r# e2 D6 p' E2 h7 I3 A, g
.platform_data = &da850_evm_tl_leds_pdata,# Q, t/ P+ g3 q8 _, E
.release = led_dev_release,
. Q4 S, a9 C; k1 E6 M+ r6 A }# P) d8 v6 a4 R7 n
};
" \( s6 _5 }& j S9 e& h) q' y0 G" ~
static int __init led_platform_init(void)
0 N" s" e$ @9 }0 T" r{. N6 ~, [" I. a7 i! B" y ^4 i. V
int ret;
: f2 G x; E- X: q#if 0/ Q& r% [) s7 Y( y$ l8 d8 f
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
8 g& ^+ `, H: r3 M if (ret)( r; B" o8 ?, U
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"& M* X$ k4 y- G. B
"%d\n", ret);( ]% y7 {- k* f2 R9 h" Y
#endif# y+ G& D+ @/ T
ret = platform_device_register(&da850_evm_tl_leds_device);
9 Q* G) N2 d8 M# {3 P5 s" q( I if (ret): G. a) m8 O6 z& r6 ?' F" @
pr_warning("Could not register som GPIO expander LEDS");
% |5 J5 H d7 p6 [! W else5 P6 L1 s, j6 M5 j- @6 m1 p/ t# p
printk(KERN_INFO "LED register sucessful!\n");8 {5 L C; u, `2 h4 ]8 }7 C
% ~9 u ]9 \7 U2 j7 N8 S; H return ret;
( \, K5 v* ~$ u; z6 P9 \}8 L9 n# ^# P8 Z* T
0 a% H1 h! e- H7 p8 e+ w
static void __exit led_platform_exit(void)
3 b! t1 Q1 `, h% C9 X{
+ D0 F1 ]/ Z6 S: d8 h platform_device_unregister(&da850_evm_tl_leds_device);, j2 J' A. Z7 s1 K- G9 o
- S2 M, _7 F# _ printk(KERN_INFO "LED unregister!\n");
+ r- W* i4 E* i, I4 H}
! C. Y# V; _& V7 Q! _
2 z' M, Q9 k, n% L8 B5 b+ cmodule_init(led_platform_init);
% J' q& k% ?# G; p8 e. e' lmodule_exit(led_platform_exit);
, k0 d/ _/ R' d( k% Z1 f& S1 J
MODULE_DESCRIPTION("Led platform driver");
+ M* g. _( K. [MODULE_AUTHOR("Tronlong");) j4 I; b. A9 D
MODULE_LICENSE("GPL");8 w9 G6 K1 N" L
; w) g6 M3 ?5 _, z! a |
|