|
|
求大神给下面的程序做注解,请稍详细些,谢谢。7 C. p, G% ?. ^4 G& A! p: `
#include <linux/init.h>- _# Q, X/ {# S5 N2 c
#include <linux/module.h>
$ @# g( C, O0 y* ]5 W#include <linux/kernel.h>% I H( |1 K9 r! e9 a7 k
#include <linux/types.h>8 G' x5 g9 U+ D
#include <linux/gpio.h>
' A T3 p6 P& m. f#include <linux/leds.h>7 T" l8 D! v7 p' c& o5 W5 W
#include <linux/platform_device.h>
% W# h! X- z+ O" y: H: K! G- o, z9 n: f. |
#include <asm/mach-types.h>
" y; s2 P3 E, R' P#include <asm/mach/arch.h>" f/ y- C2 Q( n6 r
#include <mach/da8xx.h>" M5 P0 Q: z! X+ _" @
#include <mach/mux.h>9 e; n1 J" j2 ^( a; L( P& u7 a; t
; X3 A# v7 z; M6 t4 [
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
5 D" K s' F3 q7 i#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)4 V- n$ W# Y( a. D
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1): a; J# o8 J) A* j9 q8 m7 P
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)" \% z0 V0 Z5 [; C" ?
9 Q7 r3 u) ~3 G$ Y* i# z4 H
/* assign the tl som board LED-GPIOs*/
& G. o/ O% \+ W" [+ u; f% b3 bstatic const short da850_evm_tl_user_led_pins[] = {: g! }8 V. A8 C0 _$ n
/* These pins are definition at <mach/mux.h> file */
- `" T# u2 d l9 d6 t- U% U$ e g DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
. t, c1 a8 Q- j- l5 ^5 ?" J) | -1 c4 K! Z z. w
};
_ o }0 m1 W9 x9 e
0 j) |/ M# x X- P8 qstatic struct gpio_led da850_evm_tl_leds[] = {, D5 G* }4 y/ j$ e' t0 x
{; W2 I0 F) S3 N* Z( `( c1 \: [
.active_low = 0,
: u/ U( ^7 u( f& Z' M/ t- o( i. w .gpio = DA850_USER_LED0,
8 g, X9 Y/ L, o0 M .name = "user_led0",1 N L h g* R; M3 ]( W% f
.default_trigger = "default-on",9 ]1 B% M) X1 n2 x
},, t- b1 A. a1 N+ V5 c6 V7 T3 a. Y
{
& G) b% l2 d, n6 d7 e .active_low = 0,
' N( X9 ]1 r/ l .gpio = DA850_USER_LED1,
. Z1 E& [' ~8 v. I8 Z) s. D! y) I .name = "user_led1",& {" R6 _3 L' i% H0 i x) `/ F8 _
.default_trigger = "default-on",. x# f) g" N. d& a1 d8 G, v
},: d3 v6 u4 v1 V; x( y* g2 p
{/ T* Q- f$ U6 ?# ~1 Q
.active_low = 0,
8 {+ e9 i/ {0 g* G# R+ f .gpio = DA850_USER_LED2,
$ \* d0 @% ?8 @ .name = "user_led2",8 Z$ U- l$ D: A h( }
.default_trigger = "default-on",- I( n: t7 D! {( u: u# c4 @( L
},
8 i/ O! `. {( ` {
; C' M% U+ t; J .active_low = 0,
' \, \& |- p! H! R- ?9 k% O .gpio = DA850_USER_LED3,8 i, p4 j+ L! m/ V ^( @6 H
.name = "user_led3",
" L3 q! v' A* w& V# B8 i( w" U/ Y .default_trigger = "default-on",; c4 H" j& W' c
},
P- T* L" x9 j};* {' x0 T& @' ?9 d, q$ ~
: @, L" ~& u9 |- v, |0 _$ ^static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
2 s9 w! T0 f" l) o) A& c# Z .leds = da850_evm_tl_leds,4 A( I% F: f( H4 g" K6 X+ d
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),
! G3 h, J& e1 A, p- }2 i};
: M& y8 A/ o5 A) v+ {
- f9 o$ U- d8 \5 Z O" Y" Istatic void led_dev_release(struct device *dev)
% _4 F2 `! |2 p{' d: I1 H, S( l% }5 ]. A1 R
};# O8 f# p9 u% q# ~; c9 S
8 E! u) ~& N6 _0 j7 tstatic struct platform_device da850_evm_tl_leds_device = {9 Z4 t; f+ o( ~; E) {/ ]
.name = "leds-gpio",1 ^9 c) T' a1 o! \3 I8 E
.id = 1,- G/ j/ F4 n0 y- b5 ^ t& t: D8 u
.dev = {
' \ J& I2 N' I6 V( R* _ .platform_data = &da850_evm_tl_leds_pdata,$ Z8 x9 |8 i& |( [
.release = led_dev_release,' f* i4 [# Q; f R2 Z+ q8 z
}
2 c G9 k' T; b( [" B0 h; W. ^4 \};
' }/ Q/ A% ^8 |; A2 R
+ l9 r9 e3 K6 R8 j- ` Fstatic int __init led_platform_init(void)3 j; `! U& e+ h9 } o
{, e) H1 M6 \7 g6 n# g! F
int ret;
# h; T6 p% [9 @- E) C8 F4 K#if 0
! T. v* m" ]* J$ M( @0 N' ` ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
4 n- N) }7 c5 H( ^9 @ if (ret)
' u h7 k+ S# Z+ { pr_warning("da850_evm_tl_leds_init : User LED mux failed :") M( N. V! B; G! n5 W
"%d\n", ret);1 M1 s/ o0 C% G0 O' \5 j; ~# s
#endif
- |. k' |" U T& z. j, ` ret = platform_device_register(&da850_evm_tl_leds_device);
8 i% V7 J- d# o( ^5 C" W0 I6 s if (ret)
) j! R$ |" Z% D3 ]& |. ^ pr_warning("Could not register som GPIO expander LEDS");
* I0 a4 Q( j, A7 B9 H else
' d" b. U, {+ {3 U* h printk(KERN_INFO "LED register sucessful!\n");
$ ~- x4 R: P. f$ _5 u# U
+ J/ w+ Z7 d& o. n return ret;
9 @$ W+ M/ W# Z}; F- \6 L! l8 l, r1 r* K9 d! e; z
$ N$ L+ m2 ^% Kstatic void __exit led_platform_exit(void)
4 V! X$ F+ X. \! D3 |7 w6 @- p4 o/ O{
; L" y& W, E8 U. E+ E# N/ \3 I2 H platform_device_unregister(&da850_evm_tl_leds_device);( p1 i( R5 T G- l
6 ^( K/ L) Q2 ?# E1 s$ t6 k: Z printk(KERN_INFO "LED unregister!\n");4 K) ?2 P, O% u, N7 A: G
}8 Q* S* Z; U9 r
! y8 F, M, d( l( Z' E% i* |
module_init(led_platform_init);# n, {! ?0 x" }' ^$ Z
module_exit(led_platform_exit);
; ]2 ^9 H y9 g) y- ?' {9 ]9 W; r# @- n" f2 t- ^* Y1 m3 J8 p
MODULE_DESCRIPTION("Led platform driver");
1 X+ J) X8 C" R4 {MODULE_AUTHOR("Tronlong");
2 c5 i% R2 K" G, T s4 z% o( }MODULE_LICENSE("GPL");, Q7 R& g. c0 U) U: b% O3 y
6 Y- g+ G3 K$ d$ D$ I
|
|