|
|
求大神给下面的程序做注解,请稍详细些,谢谢。2 w& [# E2 `# C
#include <linux/init.h>* o/ k5 E9 y$ v( I0 ^ S U+ O
#include <linux/module.h>
; ?2 P% D2 ~- H7 B; X$ B#include <linux/kernel.h>
3 w; p+ v. c; k- I3 G ^4 L#include <linux/types.h>
5 W6 g+ S" z' S7 H#include <linux/gpio.h>3 D2 M) g8 u7 E& e, C Z
#include <linux/leds.h>9 r& T2 D1 ]. S+ E
#include <linux/platform_device.h>
/ N) _0 ~0 d0 n y. N) o, G- r
/ l& l1 U7 F2 w, R2 z; N* L% D#include <asm/mach-types.h>- }$ r1 D6 }5 J1 \0 ^% K! }' g
#include <asm/mach/arch.h>
6 L/ P0 c; I4 u# y6 H#include <mach/da8xx.h>
5 v& l- P4 u N7 B9 [$ c( |#include <mach/mux.h>
, K( o" i/ {# E" o" M; s/ T
# C3 J+ u6 u! d; g$ o+ r& Y& ~#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
. _! n j5 O6 o& A2 c$ R; Z#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)5 F5 Q9 l, y5 S
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
' P! p* Q3 |9 p& b# i#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
1 V! Z \" I& G g8 I; w
8 W. }! Z7 Z4 L* h3 T! j, \/* assign the tl som board LED-GPIOs*/4 p' V( @7 m8 N5 M! [
static const short da850_evm_tl_user_led_pins[] = {4 c8 M, _! b e) r
/* These pins are definition at <mach/mux.h> file *// q3 ~/ m' o$ R- m% I( z V# o
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,, j9 J9 h; s1 Y; {/ C
-1 ^& g9 a' H9 P
};
1 Z, k k5 q' W% {* U! H
& B- z* h$ `7 b& s( Ostatic struct gpio_led da850_evm_tl_leds[] = {# c4 E3 I, a& u! ]
{
) _+ l3 U. \* G( B3 p' y .active_low = 0,9 v5 \5 x: B6 s6 c1 q
.gpio = DA850_USER_LED0,: \% h# a# L0 L- d
.name = "user_led0",; b; A4 y9 L, \0 J( z O
.default_trigger = "default-on",4 s! I4 \* H; }# r O
},9 l1 y/ h7 p6 x- G
{5 X! z ~1 j( x# Q
.active_low = 0,1 ]- _5 p0 p+ u4 l8 y" Q9 `
.gpio = DA850_USER_LED1,! Y* H1 p" K6 x3 D
.name = "user_led1",
( ^9 B) A" S; @. h$ D+ Y+ E; i& C .default_trigger = "default-on",6 d3 B# f/ s: s- D" H& E8 K
},! R. V: @& V* x( g# N/ }
{+ }! e) S" I2 q3 [
.active_low = 0,
6 X3 o& E, a2 ?, E/ R5 I! S. \ .gpio = DA850_USER_LED2,
8 }* c' p9 k3 P9 E0 M+ l% Y .name = "user_led2",
5 _* s# H/ b2 l- \4 v2 @ .default_trigger = "default-on",- i6 K/ C- I- ]9 A. J$ R; J9 `
},
A, a- d& d d4 t( d( W0 S; e {6 a- M+ k4 z9 s: _+ f0 U0 J
.active_low = 0,& S6 I$ M9 S; Z5 y: J
.gpio = DA850_USER_LED3,
) w3 q' v% r" p; h4 C9 \4 h: ` .name = "user_led3",6 M6 y1 v. T, {# n# x
.default_trigger = "default-on",
; R8 n s/ L9 p( @: ?1 W6 i9 [ },
; ^1 y, [6 u, f: p};, K4 g9 {3 y# Z6 z d p; E
: F/ D9 U: ^( z) t% I
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {6 _ ?: I# W C( n( ?. B
.leds = da850_evm_tl_leds,
9 N* B7 G7 u# W* {# o5 m .num_leds = ARRAY_SIZE(da850_evm_tl_leds),* g( U3 x; R5 K. _5 O# m
};; Q7 M @4 Z! P `
$ O1 C# m$ v$ M# L1 Q$ v
static void led_dev_release(struct device *dev)
2 _8 [7 O9 L8 n9 _" ^! Z{
% `3 o5 G `0 @* u. H};5 P& _) O5 f6 V" k
( _ D: I$ N) T1 q8 _; V5 Z
static struct platform_device da850_evm_tl_leds_device = {
% y+ f9 N* t. x6 n; a .name = "leds-gpio",
, [! [( I& }; }, ^7 d .id = 1,0 S9 u; a O" }1 L. h
.dev = {2 S8 w1 o' K! \/ j% y0 a0 s
.platform_data = &da850_evm_tl_leds_pdata,
$ P( V' K$ G& C) _4 \ .release = led_dev_release,
1 H# H/ x4 C- C8 j- L }. K6 g6 M* L( j% u2 {
};
: `, w9 k' [9 F% k# e- g8 X8 p, R1 {. y9 z8 H$ C
static int __init led_platform_init(void)2 X5 B" w6 [/ T% n6 y: S) m* B
{
/ f3 ]! A) a% d9 I int ret;% c/ o- O7 ]3 J1 v2 l
#if 0 E* C' w* z3 N4 n5 S; V6 d/ ^
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);- r: N# W4 W) J( L- A
if (ret)
. d2 c& `9 B9 `/ S pr_warning("da850_evm_tl_leds_init : User LED mux failed :"0 Z# Z7 C( j" N1 d( f! u
"%d\n", ret);5 i5 ~7 P) ?, T9 B9 ^) Q) F1 {
#endif
; o; @0 a7 R& s; s' w ret = platform_device_register(&da850_evm_tl_leds_device);% n0 v# g, Y# l G* K; a) g
if (ret)5 \1 L9 s8 J: d' w1 |/ l: g; i
pr_warning("Could not register som GPIO expander LEDS");
" Y2 h0 Y+ A# e' { else4 w$ s( r( J/ ^: _) u
printk(KERN_INFO "LED register sucessful!\n");) ?. @6 ]+ z* y. [4 x
7 V ~" c9 M! a0 _
return ret;
% V" @) p1 A8 A} }( g. P0 M( L9 {/ Y+ ?
9 t4 a* N! v1 A
static void __exit led_platform_exit(void)
3 _2 y6 H0 p# b& t# N; Z' A{
: A" s5 y3 T0 j platform_device_unregister(&da850_evm_tl_leds_device);2 ?; l! f W" T" _' j
. p" Z& @, S9 \% Z' F printk(KERN_INFO "LED unregister!\n");
% ]% x# o7 D! |) ?+ i* B7 E}+ B' e' K0 R" f1 x k' t) v4 _
( M' c( n. ?, E" G$ r& B
module_init(led_platform_init);# o0 h& z4 N7 i3 y! Y$ v1 `( C& b: }/ Q
module_exit(led_platform_exit);' M" K" m! m0 P* a2 S+ W0 y( n
, x0 W, H& h8 V0 m0 }& f$ rMODULE_DESCRIPTION("Led platform driver");
7 E R; S/ p' b: N! @MODULE_AUTHOR("Tronlong");4 S1 U! C3 i0 R& e& s+ z- G
MODULE_LICENSE("GPL");6 J2 p( n) @! e9 A
3 q+ j& W" Q6 l3 `8 Z; o |
|