|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
) c5 X8 ]. `% W, P* T5 A6 Y#include <linux/init.h>* s0 f( b* m5 U/ y1 t
#include <linux/module.h>
5 T3 s1 C8 e* C' D: S#include <linux/kernel.h>
) t' g& `' d" z, }2 u' ]# ]#include <linux/types.h>) r1 @* p! w. E7 z/ Q
#include <linux/gpio.h>
4 y, [* ?9 U0 _5 \8 ?( f) ^+ u#include <linux/leds.h> b8 e* k* z: G) v- J
#include <linux/platform_device.h>
" A8 J5 P! K, z& A# C0 H9 ^0 f& ^: h
#include <asm/mach-types.h>
( P1 e% A' ^$ \. w5 o#include <asm/mach/arch.h>
( ~. s7 X( \& E) V2 Z#include <mach/da8xx.h>: t% t' N, o6 c3 J5 L t$ h
#include <mach/mux.h>; T8 l- o% _+ e1 k6 b9 l; f
/ u) J& Z" Y/ o1 Y9 w#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)' y( x& ~$ D m2 h/ j2 W u, r
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
6 C4 X, K$ A4 f4 P5 N( `1 ?#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)# F3 s' q! L. h/ q
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
/ W- j; s3 G1 a/ `1 B+ K6 v \# O" l& L/ o
/* assign the tl som board LED-GPIOs*/6 p5 Z+ f, n* |
static const short da850_evm_tl_user_led_pins[] = {7 Q9 ?( ^+ D' q3 O1 R6 K9 x
/* These pins are definition at <mach/mux.h> file */( h' o5 T, p+ a0 D1 u8 Z7 v4 y
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,6 \! g0 R6 T7 R6 ]* D
-1
' F( T: c# d3 I4 C" }2 x$ M( I# g};2 z6 [& o7 u! f/ C6 W; i( [4 H
5 Y1 `3 g, _ n- n% O: \, m
static struct gpio_led da850_evm_tl_leds[] = {3 c4 z, C; p( {8 j& Z
{
* y" ~6 Z5 l) ?$ k .active_low = 0,# D: C6 a3 M: Q/ z! ~9 L. T
.gpio = DA850_USER_LED0,
* {: |3 e. ~% |6 O .name = "user_led0",
& t6 f5 _7 T2 N" B .default_trigger = "default-on",
* b# T! k' e' t9 x! S },
. a; i9 V& B# M0 _ {
1 O* i- `3 t& D; N; f7 } .active_low = 0,. x+ |) d/ O7 o/ C" w$ Z% c
.gpio = DA850_USER_LED1,7 ~7 n `. B4 ^; T6 T* w1 V
.name = "user_led1",; Y5 c' w7 E0 \( k2 L
.default_trigger = "default-on",4 {5 e; {, C! _* v) B+ O. P% Z
},6 \2 N9 e% t! c. M2 t) q7 M
{
! a1 c7 U B$ N, ?# p .active_low = 0,
! \ `- j s; C .gpio = DA850_USER_LED2,2 O' E- _4 G ^+ ^2 n
.name = "user_led2",, Q0 p% G) b% B; V7 w+ s
.default_trigger = "default-on",
, S0 w3 t* v1 [1 g },) b* P7 p0 m0 Y% ?' d
{" Z: Q4 r# N, c G0 s
.active_low = 0,5 V' b! f5 x: ^$ u. U. R
.gpio = DA850_USER_LED3,
* \9 i/ x2 B9 v5 l% J! E .name = "user_led3",
: N$ }3 P7 w* \+ a6 C. k .default_trigger = "default-on",% z& z( A2 {! r/ o" v1 P' f% _0 a
},# I$ S0 \# T: C; F
};
0 Z, Q d* a, r1 |9 G4 V9 M
9 A% t; q* P2 {# o; ?9 j. b, b& Pstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {& R4 l% r; n( T3 ~! X1 I
.leds = da850_evm_tl_leds,
, t* \- s* n& `+ x: Z- ~3 Z4 Q .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
& }- i7 y9 X0 a1 B! W};
4 s6 q: D, G' ~, ]' Y" \+ v, W
; q1 P# j+ e, b. `0 z$ q% d2 n* N; ~static void led_dev_release(struct device *dev)$ j A+ W/ V) t' T3 p3 M
{
( _3 p5 e |* |! u4 t};
! g, C7 P. S7 O
+ B% w. W, W+ q' ]static struct platform_device da850_evm_tl_leds_device = {$ E0 j) g" x% P! C& k2 k
.name = "leds-gpio",0 @ Y7 R# U- r% y. t5 m6 K H5 e
.id = 1,
+ x5 d3 J+ X" Y/ N1 E# k7 f# i .dev = {
! `; f L. E3 I* N. J5 f2 l8 U" U .platform_data = &da850_evm_tl_leds_pdata,
: O$ G, Z$ ^8 O7 c% P .release = led_dev_release,$ @3 X" o5 W y, L. G
}
- @( [/ g* A! `4 @6 \};
2 c) D" b. J5 y4 r' E$ U3 ?, S8 v, T7 Z t. }
static int __init led_platform_init(void): d& h) t0 Z! i/ N5 y1 p
{( T; s3 v' @2 s T+ C1 h
int ret;
3 [& ^5 Y. L( y# m#if 0+ M w) X8 o2 m( N5 z. P v& w
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);2 R- J" c$ j: i3 ]0 l
if (ret)
( t% H) O% G! ] pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
, P3 p: T G* C8 {0 l "%d\n", ret);
* s# F5 S4 M! O- c8 Q7 u#endif
* i: b9 e' S5 l5 `. J ret = platform_device_register(&da850_evm_tl_leds_device); i& @# u1 K6 \7 G# n7 ?
if (ret)
+ R* M* v2 }* h: K' u' C pr_warning("Could not register som GPIO expander LEDS");$ n+ Q+ Q! Y2 s/ j& N: }
else H% L7 l* m6 u3 u6 C+ S
printk(KERN_INFO "LED register sucessful!\n");
( N, U8 ]7 y7 F
1 h$ N, i* o9 A" d, Q1 k return ret;
6 e- x( |6 [4 D' |7 t) s}; V" d% d" D5 t: x) t
. [- Q0 z" }7 V H
static void __exit led_platform_exit(void)
0 Q2 h' j6 `. M1 N{; w6 b, U0 A9 x- r' n
platform_device_unregister(&da850_evm_tl_leds_device);& i: D5 E3 G* k: l2 b! ?; s
) X8 I3 \! {: {/ b w7 K( y$ | printk(KERN_INFO "LED unregister!\n"); q7 B( j7 B$ j: I! b
}
( O0 K6 c- w" Z; b5 v' Z
1 z+ w f4 m- F5 F- pmodule_init(led_platform_init);0 M; D: L0 }$ Q' B- ] S
module_exit(led_platform_exit);
. s# X6 y2 D4 J- [4 H+ w8 j9 @: g z6 d5 m& O* R7 r. D/ n
MODULE_DESCRIPTION("Led platform driver");, E- Z$ s- @$ X) t- n
MODULE_AUTHOR("Tronlong");/ ]8 C% J" }$ R3 ?
MODULE_LICENSE("GPL");
L( w+ N3 V4 u; ^5 {9 j- B
7 f* k6 s _, F2 r' b: g! } |
|