|
|
求大神给下面的程序做注解,请稍详细些,谢谢。4 ]: p* z4 u8 W J4 `
#include <linux/init.h>
# N4 G; z Q6 l* L. x2 G#include <linux/module.h>
8 a& j, [0 a7 g8 H8 M: `#include <linux/kernel.h>
9 A0 M( L' m& H# d#include <linux/types.h>
$ s$ u0 p+ L Q9 Z% x' e#include <linux/gpio.h>8 s% L4 _( M' {+ |3 P. u ~
#include <linux/leds.h>
; ?* Z. {- h* ?- `6 [' e8 l/ o, U. f' T! h#include <linux/platform_device.h>) s" `) `$ B6 B% m) U1 _; C
0 D7 X% D4 L, R& T) J; d#include <asm/mach-types.h>
' b% u) f9 X0 a# s9 e7 i8 C#include <asm/mach/arch.h>
- m, _/ |8 g5 r& l, {* X#include <mach/da8xx.h>
/ S2 z% A" Z* _#include <mach/mux.h>$ M. }/ u" g, D/ l+ G" B. i
4 c7 Z! R+ I9 _0 q#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)2 ?4 z" ]- g- k0 W3 |2 z
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)' |& q% r r0 r9 `5 a. V
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)8 |, ], t1 T( v0 S* Y5 [2 c& n+ x
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)# P; w! w/ u3 ^% _# n; V. h4 t
8 u6 ~! `; l4 f4 `' n/* assign the tl som board LED-GPIOs*/; t- q g! H* u/ v: n
static const short da850_evm_tl_user_led_pins[] = {1 O' J6 x. v, H( O
/* These pins are definition at <mach/mux.h> file */
3 c( v k' m" R- m DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,/ n" f, |5 a" u
-1* p( l. X) [8 P; R6 H1 D- r. K% f6 ~
};# W/ b9 o; _% J& r+ R- |$ R' i
8 Z: V5 d1 n$ ^. t8 l# n" H) nstatic struct gpio_led da850_evm_tl_leds[] = {
1 V, X2 V" t; u {
' M4 C5 o% E: d7 ?# [ .active_low = 0, e% q0 a5 S4 _* P/ `* z
.gpio = DA850_USER_LED0,/ O0 g1 i. {; C6 a3 s0 O/ e
.name = "user_led0",8 q$ U1 M( g$ X: ?# f7 y$ ]' i
.default_trigger = "default-on",1 }2 L9 u' l4 P5 N/ U) @
},
/ ]3 ~1 k9 g8 q% V o. O {
' {- w: e( O9 ?4 D' _2 f- J .active_low = 0,
) Z. J1 ^4 `6 e# X .gpio = DA850_USER_LED1,
& y C, i/ C4 _7 e6 n# a2 K) G .name = "user_led1",! [7 Y9 C( r9 @# a% U
.default_trigger = "default-on",
3 u/ J! b; U- h- ]; h },6 f2 }- Z2 |& t0 f- r! Z; m0 C
{
/ C6 W5 A, E! L' M5 R* s: e, f+ J' E .active_low = 0,
" S/ K+ n7 U& ?" m .gpio = DA850_USER_LED2,
0 b' K$ p! r* `" W; J .name = "user_led2",) b t- E: j: n% Y+ D8 ~3 t
.default_trigger = "default-on",
' K0 W* |: N! o' M },
2 c2 R! {& L& g! E6 b0 t" S% }" u3 C! L# j {
( Q+ z* P; ]2 Q( Q& H .active_low = 0,
+ A o0 d' ?) M0 T .gpio = DA850_USER_LED3,1 O* X* m+ ^8 L2 X! l
.name = "user_led3",0 `) t% w9 H4 N& t2 d
.default_trigger = "default-on",: P4 `4 d# `: O, a: S1 \" c$ Y
},2 c) x( J* x2 \) {
};
4 o4 t( O% h4 q3 t, [8 h- N% K9 g8 m1 M! _ U
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
* S( _7 V& Q$ j0 i7 f9 j& Z .leds = da850_evm_tl_leds,4 ?/ U* U1 W2 j7 Z: R
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),
k% t. e9 F5 k$ S+ h/ P, P8 M! c};* T6 x# u$ G w1 x+ c
0 y5 D4 [* `: L/ @$ h$ P" Cstatic void led_dev_release(struct device *dev)
, }( Y% M( q$ |# G0 k{3 g2 ?! {6 o H/ K
};# u8 X9 b& b6 ?
/ O! _" _7 G( f$ r% t7 [static struct platform_device da850_evm_tl_leds_device = {
' a! j: q) M2 m) M* ~! P$ ]! ? .name = "leds-gpio",
) s; E4 R3 ^) l `" L; L$ Y3 e .id = 1,; J) f% D, }& B1 [4 e8 e- T F
.dev = {
, E! S) r5 ~3 N- x5 C .platform_data = &da850_evm_tl_leds_pdata,6 I( |% r" d+ L1 p0 A9 Y
.release = led_dev_release,
. ]. i0 h( b# N- g% | }
' C) p) V# U# G; W! R};8 Z6 @/ |; I6 `; F
; C7 S8 {1 m! Y6 h; t
static int __init led_platform_init(void)
0 X! a3 g' c5 r9 G2 `, J{; d& o0 V' z5 i& a
int ret;
0 R l( n F3 ~# \7 a: w3 p; c#if 0
5 y" E: I: J+ A# \ ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);5 a) p2 k# A( K) @2 h/ l
if (ret)
0 c4 B- O# C+ n2 r* H9 o& ? pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
k: k3 D) P. H+ M1 M- A1 K "%d\n", ret);/ _1 W! u6 u# _5 t5 y$ Z
#endif! g! a+ P0 P- G$ Q
ret = platform_device_register(&da850_evm_tl_leds_device);
4 {! E9 c4 R! m& E if (ret)
* N! `' _& x1 w) o pr_warning("Could not register som GPIO expander LEDS"); z" s( h. L% e
else
1 C! U1 k" A# m9 [8 P printk(KERN_INFO "LED register sucessful!\n");
) E% g$ {" a4 A+ P2 q; Q @- V0 b. s/ G3 H. V! E/ ?
return ret;9 v u' S! s F" m
}: Y/ T9 U9 P7 ~( P7 s3 ]/ X
8 s r8 k% W1 ~1 t1 u' c! r p2 Y
static void __exit led_platform_exit(void)
4 ], [8 |, b; `& R; V{9 n M! }3 {9 \" ?; X
platform_device_unregister(&da850_evm_tl_leds_device);4 R$ p4 `' p; l3 P& I" Q; E, E
$ `8 J" d; ^% A% w) |2 ?$ K2 }. C printk(KERN_INFO "LED unregister!\n");
# R0 u- W0 S; |}
$ M' a) M' A! @
9 m# v+ [' D( B4 I2 ]& Zmodule_init(led_platform_init);
) A2 Y L9 r6 F3 |. smodule_exit(led_platform_exit);
. S) u6 c& ^3 f1 w1 h* O8 o. g( I7 c5 [2 \) T
MODULE_DESCRIPTION("Led platform driver");
: ?/ m/ B3 l y2 T$ A. X9 aMODULE_AUTHOR("Tronlong");
: J; E. o/ T0 N; V. {) y* iMODULE_LICENSE("GPL");1 |3 b9 T) K2 v% J- D
& o$ y! |3 A+ ^3 @, g4 k1 B" q/ Z$ e
|
|