|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
- x% Y" ]% r* P( h+ Y; f% v% y& O: R#include <linux/init.h>( y k- \$ k A% |/ l0 k
#include <linux/module.h>
9 ]: g2 i4 r/ `2 K6 E! _#include <linux/kernel.h>
1 W& m0 w. @" ]& a#include <linux/types.h>
9 s* @0 S8 O6 n2 r) v8 k* v8 }#include <linux/gpio.h>
+ e9 x3 k8 U, g#include <linux/leds.h>
" R% {7 }) x: y4 l#include <linux/platform_device.h>
" E+ C+ F" r- } `: g9 L7 g2 I- e, [" m) v l
#include <asm/mach-types.h># G: M& J) B5 V( x9 o
#include <asm/mach/arch.h>5 q$ V( K+ f$ c* v: k! Z- N, p( }
#include <mach/da8xx.h>% a0 e. L+ _* z9 h
#include <mach/mux.h>
9 h: H7 M+ m/ V# p. F' D' c( S6 g' Q+ e. L% P W
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)# N6 x# A1 |+ I+ W
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)$ E, C. g% l- s4 q1 q
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)7 N) ]& O/ I1 p' m8 q& C' _
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
0 ?$ W7 `' P+ X l+ ^- r. v- D$ }
2 b% H5 J$ n" ]2 K1 H; S/* assign the tl som board LED-GPIOs*/
1 E/ n$ r$ ~6 ystatic const short da850_evm_tl_user_led_pins[] = {; c8 ~% {9 r7 }) f+ h
/* These pins are definition at <mach/mux.h> file */
9 r- W8 ~5 J" y* | DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,$ @! `2 J2 x6 d4 ?, h1 x
-1* W( @0 ?: B0 E. ~. M# C% I, U% o+ N1 n
};3 |7 ]5 [8 w& \& B6 Z4 T6 s' w# e$ B# e
+ `# F: J& R0 ?! n C: l
static struct gpio_led da850_evm_tl_leds[] = {; x( z' Q) p8 y6 B K) t+ J$ V
{
9 Z, h9 Q9 S9 ]9 S; L9 s# ~ .active_low = 0,
1 X# h* |5 D/ R9 J .gpio = DA850_USER_LED0,0 y+ `4 e: E. v/ F- A" j9 u
.name = "user_led0",
* y" @# M0 \1 r% A( h .default_trigger = "default-on",
8 K+ `1 y5 U. G2 s },& Q* t; l: k; c& m1 U7 g; S
{ c' L) y1 f7 {
.active_low = 0,
L5 K0 @- x6 |% S0 j# a .gpio = DA850_USER_LED1,
! w5 I9 K( n1 x g. e) n" f+ o .name = "user_led1",8 R% q6 g3 [3 Y% E* j* P
.default_trigger = "default-on"," G* r) B0 f+ q/ n1 @8 A6 F
},, C; T5 M+ n( H3 f
{, m9 G3 r, r$ I0 X
.active_low = 0,3 t" p7 \1 [2 C) v: v( u
.gpio = DA850_USER_LED2,0 o- e; ^5 L% I# U4 l
.name = "user_led2",& d* C5 Z2 y5 ]+ }7 n! |
.default_trigger = "default-on",
. t( Y" \* f- n- x1 ]# S/ ] },! \' F+ k) }* T' d6 p- _
{- D2 ^$ [' d9 i$ c
.active_low = 0,
% l! x: Q+ E, G) e; u .gpio = DA850_USER_LED3,, S. R, C C( V$ M5 g- t/ d6 _
.name = "user_led3",
; h3 w; T+ _) r( U D9 Y .default_trigger = "default-on",
1 }$ U7 Q+ E1 t },
/ ]$ _0 I! z8 j. o};
: j% U! m2 r9 w
1 Q d3 x7 O. x" istatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {: u# T# t! K5 ?0 y# d& k" c3 S9 B
.leds = da850_evm_tl_leds,- v% W) ?) C/ F4 U( Y7 J5 H
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),
1 q0 D! `' Y- y7 r# R& E};+ E# m+ y0 C1 J$ e. E+ ^; b
, g+ d: x1 ~" y, S) M1 Fstatic void led_dev_release(struct device *dev)$ s4 b# r( }, k' n6 p; P# m
{0 f( @* ^0 @: J$ K6 H J& U4 o
};
B# u, e* S9 ^- {' X& ~1 h. Z8 D ~4 e" m9 s3 i4 X7 U+ Z- X
static struct platform_device da850_evm_tl_leds_device = {
! f$ f8 }# w& C* _/ k1 H9 M' r .name = "leds-gpio",& W$ G! k4 _* X
.id = 1,* @' A+ a0 q8 R, O3 `
.dev = {
: U: |+ {$ d; a$ H: ^7 O .platform_data = &da850_evm_tl_leds_pdata,) n4 @/ y8 i- h1 U2 S. @5 B+ D
.release = led_dev_release,
: }( `5 X- J5 L. g7 S- G1 J }
- Y8 k" z( [& F+ d8 j};
p) D, p2 t7 A- f9 K" [, ]
# y* k$ N( ?4 g- T! m1 |static int __init led_platform_init(void)3 H- |& r, R5 M) e
{: P) o6 k9 B1 \; u8 i6 k6 T: Y
int ret;
8 ]+ h/ w3 e" x8 S6 |# N- d3 ]#if 0
3 \3 e; j) \# V" S7 r8 ` ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
% z: s! I/ \+ ~+ | if (ret)$ H+ _: a. G7 \: R
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"1 k5 S2 w' X( s2 v* ~
"%d\n", ret);
8 X5 R$ G8 h3 H: \. C/ @% ~/ P9 @#endif
0 m! K# z6 l5 L% |' k ret = platform_device_register(&da850_evm_tl_leds_device);0 p- r9 I8 p6 R2 X+ e
if (ret)
. K% |5 u% |' J4 o8 u pr_warning("Could not register som GPIO expander LEDS");, n0 g7 S3 a0 M: T& G$ _+ n
else! m9 X* G' m& Q( ]& g
printk(KERN_INFO "LED register sucessful!\n");
5 Z0 g1 D- F6 d' J% W' F2 R8 p ?0 G+ R$ R
return ret;) ~2 \' ^$ }4 J: k: D+ B, D
}
* `) H% d. X6 P V7 B+ B: r# j C n. `4 d
static void __exit led_platform_exit(void)7 Z* d% Z- ?0 p# k
{
1 ^& \8 R( A7 {* J: y0 h# S% M3 I# v platform_device_unregister(&da850_evm_tl_leds_device);
/ U& a$ ^8 k; @5 h0 B% r A+ F. O# A) ?# u7 F2 D" K2 J/ A
printk(KERN_INFO "LED unregister!\n");
: R0 `6 i/ F9 U) X( K% n' s- s! t}
( ~9 q1 [7 K" H8 S, {! c0 ?* t
" U, I! r& l) y/ z+ Mmodule_init(led_platform_init);
9 W& M- g( i* ?$ c& a( m% ]. @module_exit(led_platform_exit);( _ l: C, U9 v1 d* g
( e+ M: g: h- r) W* V! Z5 k4 u
MODULE_DESCRIPTION("Led platform driver");
3 B' |4 I7 N" XMODULE_AUTHOR("Tronlong");
4 e. u7 H; n: W+ @. h' ]* m% OMODULE_LICENSE("GPL");% X- \$ d3 \* `1 {3 F; m. ^
: N' r f' ^9 G3 G$ p, W
|
|