|
|
求大神给下面的程序做注解,请稍详细些,谢谢。0 F; U5 G: [7 n
#include <linux/init.h>2 l5 E7 @; a5 w! C) C, }, Y
#include <linux/module.h>
4 U7 O( e; I4 n1 G0 [4 I) d) j#include <linux/kernel.h>! @5 b V: Z8 d% g6 A8 t4 b8 f$ `
#include <linux/types.h>9 l* G* E% T0 x% L" H8 l% _
#include <linux/gpio.h>" [4 E# R7 F# M6 w0 G
#include <linux/leds.h>4 d$ y1 `& s: w, \( V$ t0 l- w/ Q
#include <linux/platform_device.h>
+ m+ ` Q, u. L8 j- m H" D( m0 c) D! l& a5 S+ C
#include <asm/mach-types.h>
8 S; l# I6 R3 h+ m" P. M7 W#include <asm/mach/arch.h>+ J1 [$ ~. w8 a3 `/ \7 W: G
#include <mach/da8xx.h>
( ~8 M" `1 Y: F$ J" |0 J" ~# w#include <mach/mux.h>8 Y/ A# g% N; a% v
+ u) r4 l+ I1 A$ V _% a#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
$ `; V8 q9 K& ]! P( y) } G, A#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
0 c. }; J7 V1 j( G$ b: ~: D( D#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)7 o- E9 p* I( Y; u
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
) Q- z' J. h% i4 J$ s8 c
9 P( T+ S; L1 T0 A/* assign the tl som board LED-GPIOs*/2 A9 S, T' X( E( g: u# p' x; V) I
static const short da850_evm_tl_user_led_pins[] = {& g9 n. W% f* j) y
/* These pins are definition at <mach/mux.h> file */
3 k X5 ]* y9 g* ?' G DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,: i/ P) A9 h* U2 R4 X! J
-1
0 ?9 v) F- I1 L+ O9 D3 ?};. R/ p& X3 Z8 U% b
' p& G6 P K: A7 @
static struct gpio_led da850_evm_tl_leds[] = {
3 M* G6 C+ Q, Y! p; V2 T0 F {
6 h! w" v5 |( { Z .active_low = 0,2 j& b$ H1 ?$ G" p
.gpio = DA850_USER_LED0,
7 N- V! q: L, [# U. `3 n, X .name = "user_led0",0 U4 p1 A9 Q# j2 c
.default_trigger = "default-on",
. u( U9 y7 s4 ?. P' H7 D$ } },% q7 @- [) N w7 ?& h
{
( _1 j8 e1 C. Y' M$ j .active_low = 0,4 Y8 T8 t, `" B* W* j& E
.gpio = DA850_USER_LED1,
6 F5 D* t# U8 I. \* E- ?: \4 @ .name = "user_led1",
6 e0 o: K f# h2 k" ~ .default_trigger = "default-on",. S2 A, t+ G& r/ H
},& L N% z! G: H7 o+ B
{
* q; {" Y2 b+ H! J3 k8 y .active_low = 0,+ s0 |- N4 t' f. u$ z3 E- O
.gpio = DA850_USER_LED2,
# l& ]0 `$ U7 n* F& M .name = "user_led2", M& l' K3 ~4 P. ~
.default_trigger = "default-on",
+ f' O4 p6 {* A+ ~: \/ x },/ H( d( e8 ~. \' c
{: ]8 O. h! s' K4 o
.active_low = 0," _. F% Z% y7 j; Y
.gpio = DA850_USER_LED3,
9 Y/ Z5 ]/ P( E e6 ~8 I2 ~ .name = "user_led3",' ?7 a! k, @9 u3 }7 |
.default_trigger = "default-on",+ O0 Y) \. e) [
},
, b, H6 [ K- {$ u s! x};. D" M6 D! B( @" M& W1 K
2 O- d6 m$ h9 e4 {0 R4 f
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {" L g5 ^; r) I$ }
.leds = da850_evm_tl_leds,+ L. L; A9 v- g: K5 j
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),
: `: A: s4 w' m; I: ~0 Y |$ `};
0 L/ Z$ A6 ~4 {! i( x# u* W' i# ^3 c$ I- U* Q+ v1 D+ p
static void led_dev_release(struct device *dev)) n3 f- u0 i# |! ]$ @
{
" y, X8 E- r* t# v! `};
9 p8 q7 ? @- n0 }; \
2 h: U% S1 p2 t4 h9 {$ f$ kstatic struct platform_device da850_evm_tl_leds_device = {0 M. |% M$ C% ]! z0 i# O: S
.name = "leds-gpio",+ @/ I$ P) ^5 Q9 ~
.id = 1,# d3 ^# L* t9 g. q5 ~, |! F; w
.dev = {; K2 G6 u+ y# }% u& a& f
.platform_data = &da850_evm_tl_leds_pdata,
2 }! u, b a: G! i8 X. e) B .release = led_dev_release,
/ z1 X1 ~" l* x. Z4 b4 k }
" Z/ n) V: w5 x+ o' }};
' U+ [3 y! ~4 o# \; x' T8 M9 {# f9 M5 r# l5 M& @7 k! t: p% X6 Q9 t
static int __init led_platform_init(void)
4 N' a; T# ?( G7 U; k8 y$ Q{
5 S: P( Q4 {( V1 k9 ~" g$ b4 N5 @ int ret;
7 p* k1 m+ P& a/ j y3 J#if 0+ s$ S8 j" s- s* D' s
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);6 O, W; e) g# E! @. f$ M
if (ret)( O3 ^: G# N2 y& S
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
3 X% w$ g+ X0 O$ R$ u8 I. H "%d\n", ret);
5 e. d/ Y. D3 ]7 U, P#endif
$ |- E( x4 j, Z/ c ret = platform_device_register(&da850_evm_tl_leds_device);
0 ~4 {/ g& r* K- Q7 @% c# v! G if (ret)
' o7 |5 M1 ]3 y" ]0 g% Y pr_warning("Could not register som GPIO expander LEDS");- d2 u4 W1 c* z
else3 Y! X4 t5 ]9 f
printk(KERN_INFO "LED register sucessful!\n");
. P5 g7 b1 ~" Z! a9 ~2 i: G! b- W: }: g& @8 {) z, M$ C
return ret;) D$ ], X% K0 P% f9 l1 c6 X
}5 Q, D7 d! A0 b2 v8 K) u5 N
* \5 O$ g N+ `2 k2 r( H' ~- d1 q
static void __exit led_platform_exit(void)
, |( n& K* B7 m4 U0 Q{
; X! a+ S8 s+ m; I. K4 c platform_device_unregister(&da850_evm_tl_leds_device);1 F. u% @: @7 L+ b3 p1 ?
% l" b+ |7 d! H3 z+ ^5 Q6 c" h printk(KERN_INFO "LED unregister!\n");
* ?( o9 m4 p- f}
# O/ F/ P: j8 ~& ]( y3 X2 a! n; B5 L" x- W. y% S
module_init(led_platform_init);
1 O t, ^( O* Rmodule_exit(led_platform_exit);/ \/ X& ~5 l9 J' Y# [: R) W
Q! a; i. Y. W9 u5 V0 M
MODULE_DESCRIPTION("Led platform driver");
7 ~, g) _9 d% D! ~" Q9 x/ Y0 m# nMODULE_AUTHOR("Tronlong");% @% P1 q& }2 J& e( r- _
MODULE_LICENSE("GPL");
7 B" S5 L8 i) t$ [ n! B0 z' U/ f
|
|