|
|
求大神给下面的程序做注解,请稍详细些,谢谢。; X% U" H( A2 q1 U4 }: T
#include <linux/init.h>
$ {. Q, e1 F( g. H#include <linux/module.h>
2 q1 U1 d7 J4 ], X#include <linux/kernel.h>4 r- `$ u+ ~1 U5 R& e8 p+ ]' t
#include <linux/types.h>
M5 C* o2 R$ F" l5 |5 {0 C8 b% \#include <linux/gpio.h>
9 ?$ ~% N6 w, A#include <linux/leds.h>6 A( g+ k( b' y) Z$ ]' C! p, Q1 H
#include <linux/platform_device.h>
8 Q2 Q7 D- [' O/ b$ w
; Y& K, q% K7 X" I* B0 T#include <asm/mach-types.h>
; E. A g9 I! m8 I8 V#include <asm/mach/arch.h>! D& r4 u$ j$ N' ?1 I8 I# m
#include <mach/da8xx.h>
& o+ ~$ S/ K0 h3 G#include <mach/mux.h>
7 l- U* c# S; L/ C4 J4 g; K& x
B. N! G0 }& D% N: l#define DA850_USER_LED0 GPIO_TO_PIN(0, 0). u0 F( b6 K! p( ?' X; m
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)4 }) W% x+ m6 f$ c
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
! @7 a; V7 P' ~& s; F#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)* r# t$ Q! u& Z2 o' u9 V
' A. @. T' j1 }( @6 x1 q/* assign the tl som board LED-GPIOs*/
$ t+ S7 K" }6 N; A# Wstatic const short da850_evm_tl_user_led_pins[] = {
& z& F2 d, }+ P8 e /* These pins are definition at <mach/mux.h> file */* u& y+ s$ E3 `
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,( U, C* O7 \% U
-1
! J* x% a3 P( h$ N! d _};8 w) y6 v& u+ {2 x
. U9 \' E0 K& }; r+ Q/ f
static struct gpio_led da850_evm_tl_leds[] = {
/ W5 I' C& y; s- p; |. ?+ w: _5 J {
- {' z3 X; Q: E- W/ _: [ .active_low = 0,
4 e: D9 b: O, t .gpio = DA850_USER_LED0,: T; ~& t* F, i8 S8 C6 g: H3 Z
.name = "user_led0",
0 J/ m( X) V: K7 }) M .default_trigger = "default-on",
7 ?+ I! d) ]8 F3 D+ Q0 z) w! A },$ j+ R; r& R6 t- i1 |
{
3 _# \) f! W$ L .active_low = 0,
/ t4 L( T" H6 ]& l; e) ? .gpio = DA850_USER_LED1,
6 J6 ?* e# Z/ O. K1 O0 d! {& y* B7 q .name = "user_led1"," D1 {7 T: _1 M0 V; y- G, p
.default_trigger = "default-on",/ r/ k) U! v4 K. P
},
8 k6 ?8 ?: |0 k/ W7 x {4 {; ^; M4 C$ Z! E( B( g
.active_low = 0,' l: ]! I3 k! P$ ^. r- s4 j
.gpio = DA850_USER_LED2,4 W- U" u5 o0 v( x% O d9 `
.name = "user_led2",. g& c5 g+ W7 f% K! n8 p4 I8 u7 a9 L
.default_trigger = "default-on"," G3 O: x. l- `
},
9 `& t4 ^; T7 E: E- b, B {
8 i8 M5 M# H$ `, {6 ^ .active_low = 0,' C4 c, |9 n$ g) @/ T+ R( x6 e0 f
.gpio = DA850_USER_LED3,
+ L9 k+ F: q. _& w& |3 e. D .name = "user_led3",
: s7 D' `% `6 H6 \) |, p .default_trigger = "default-on",) ]6 {1 j/ ~' K% ]6 B
},3 J$ N1 G' ^& d9 u- {1 X
};3 k0 M0 s* i$ p9 a# _. J- b% V0 h
& _9 e7 N& j9 G/ Ystatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
$ n+ c N- w( @) p( D .leds = da850_evm_tl_leds,. Y2 J! G [$ i4 Y" l; q
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),
& w/ e; U' q" U0 z0 k) }; T};
/ ? [& z# ?9 z9 Y" [$ F( t* T
; i2 K3 x$ s/ |/ j+ w' xstatic void led_dev_release(struct device *dev)
' X1 A+ q1 L. w3 L1 m1 m9 ~! g{
( c% x8 \2 @% S2 ?};
- k; u4 `$ t# G
* l8 R" C. \( `+ Ostatic struct platform_device da850_evm_tl_leds_device = {
) \: I. C C& b .name = "leds-gpio",
+ X1 a" l4 _- n6 D# i2 |: e6 C .id = 1,
1 m& p7 d7 N# u9 J .dev = {
. m W, t1 f" _: N$ n' B7 I .platform_data = &da850_evm_tl_leds_pdata,4 o* w9 ]2 _: V& L0 [( \: j
.release = led_dev_release,
/ u5 t( M( O5 |' ` }# r' }* j2 z+ @0 H
};
h F) s. ^" @8 Z; `# K- p- n3 ~! h# z, G8 N7 I
static int __init led_platform_init(void)4 ^% t8 y7 j+ J+ G* a g
{
1 [1 T; c0 ?, n2 X! X" [6 l* Y int ret;/ L' X! l. L7 n6 J9 l
#if 03 a" h i7 C' Y4 l4 u
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
! f$ I% |7 L' N5 }+ D+ H$ [( u; S if (ret). Q5 `7 c- S0 Z0 e
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"' J2 @; x' e" q3 ~" U( y% f
"%d\n", ret);
/ e: K5 c, D; l# A5 b#endif
/ |1 H1 O6 N: _ v ret = platform_device_register(&da850_evm_tl_leds_device);* K; X& k2 `# o+ l# |# k
if (ret)7 W% H4 G$ G2 `, }. ]6 j% [$ _
pr_warning("Could not register som GPIO expander LEDS");2 s, D# ?) u* T& a( C
else
- G) I' E3 ^ | printk(KERN_INFO "LED register sucessful!\n");
* D& I) N5 ^! I# Q2 w. W5 F8 u4 i8 K2 p; Z, x+ n0 ~8 P/ C( f6 G
return ret;
9 y. M' ?) h2 e a& g}
0 @5 T2 d8 J! N3 t7 n3 n% B/ x
! Y9 j- y; I0 F9 i/ `static void __exit led_platform_exit(void)
' g2 h! ], E6 Z( W/ l+ Z3 H+ f4 O{+ J) O) A. e# {# T, E/ M
platform_device_unregister(&da850_evm_tl_leds_device);1 p; z5 L" s) i) J4 T" P
/ F) Q. ^4 N2 [7 \6 G printk(KERN_INFO "LED unregister!\n");
8 ]& l; i3 t' D) `2 r1 _% p}3 ]9 O- T9 `1 q r0 `; `0 p
! f! y4 y- v% p' ]module_init(led_platform_init);0 g) G! K2 G1 m
module_exit(led_platform_exit);; d7 [. a2 o. O, {0 s
, k! C( n+ e" |& i5 J, q! Y: TMODULE_DESCRIPTION("Led platform driver");8 A4 d7 Y2 Q+ Q& {
MODULE_AUTHOR("Tronlong");+ U. Y" K: Y# A4 \! f# E
MODULE_LICENSE("GPL");
2 C! U/ |* e) m1 \* T n4 W# T7 @4 r2 b8 y5 J, x/ m h) h. \
|
|