|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
+ O4 ~( m( Z8 T. V* t5 g, M/ O7 n#include <linux/init.h>* J$ W( v1 k) p* V; q
#include <linux/module.h>
( x+ s" c, A7 N4 C m#include <linux/kernel.h>" {1 u5 `9 s! F8 j% T. W0 i
#include <linux/types.h>8 M. G( f1 c* F+ Q" C
#include <linux/gpio.h>
- h- C* f& r% h" V3 w( J" |#include <linux/leds.h>! Z7 N& y' ^& m! a- e+ f4 [; Z
#include <linux/platform_device.h>
2 d# u" J7 ?! [
$ i! w! @ r, Y' |3 G#include <asm/mach-types.h>
8 h+ H6 w$ b. X' R: F- y$ u) e#include <asm/mach/arch.h>
1 R1 H: T' b7 v" _#include <mach/da8xx.h>& |/ U5 P j6 a
#include <mach/mux.h>9 P+ h- j; \3 m: {2 F
$ @. f; V+ B4 V#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)( W" o+ o: w9 @( _
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
- ^2 M7 }% d8 H9 b$ Y8 B#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)8 ~$ J5 x! r; H
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
; {/ S7 l# b5 W& Z" c
' k. r! s# ~5 ?' H/* assign the tl som board LED-GPIOs*/- S7 w: l8 C* h! n1 J
static const short da850_evm_tl_user_led_pins[] = {
Q) K9 |8 M7 U6 ]1 p /* These pins are definition at <mach/mux.h> file */: o; H a' t2 S. z
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
2 n# p; O6 V( W -1
/ M5 _, \6 ^' V% g3 s, e7 a6 r* I};
8 J0 W1 M& M( w0 S1 i. X1 h) V
* m6 l! a3 [. F9 C5 J. W% [static struct gpio_led da850_evm_tl_leds[] = {! ^7 s _: p2 d8 M4 A
{
6 L* f1 z# z) n( d. v/ Z2 X .active_low = 0,7 P7 h0 o/ S+ [. }/ }. i
.gpio = DA850_USER_LED0,
5 ?! i' K+ T0 O0 W# r .name = "user_led0",
) ^: j7 v6 S7 ]$ W8 J .default_trigger = "default-on",
" ^& U5 D( w0 B. j( L% h9 d },
2 }9 E$ t3 o; k* Y1 a+ { {
- f& p$ v* w; d$ S .active_low = 0,
) `' @8 Q% D- r# t- b+ I .gpio = DA850_USER_LED1,: n* M1 n i) h/ ?. k2 Y) l
.name = "user_led1",3 C( B% y8 q0 C2 _5 |) N: d, \% G
.default_trigger = "default-on",) F% w, E" D- n8 i
},$ H& L% m- G9 @
{8 s l* }1 N: R9 C
.active_low = 0,
& s3 M* l$ a1 _ .gpio = DA850_USER_LED2,
* I, j) ~; ~9 w .name = "user_led2", m; ]$ w) Y+ J( _! t6 H- K
.default_trigger = "default-on",* Y( H: G P9 p/ M, k0 x
},5 a/ y H6 k) z
{. N+ z/ K {6 z1 b7 L1 t+ K7 x
.active_low = 0,
9 r, q3 U- w7 K* J. s7 B, Y .gpio = DA850_USER_LED3,
' E/ ?, P4 N& p3 S1 ~- F .name = "user_led3",$ [7 _* B6 w, B: T4 k3 r
.default_trigger = "default-on",! {0 D8 t) ^" f4 y) N! M, c
},
3 k, Y1 O; B) m5 t- Y8 S};9 J+ p4 R3 @. R9 g
6 I6 F8 i5 }" ^0 X
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {& U( _7 ?2 c0 j6 k( s4 A) K! y
.leds = da850_evm_tl_leds,
) E/ i) U$ L& y+ Y" R$ R# E .num_leds = ARRAY_SIZE(da850_evm_tl_leds),5 k" v" _1 N& l
};
# a8 w' n/ X9 j1 [" j3 ]( J. O0 b
static void led_dev_release(struct device *dev)
' j6 n: H H+ |{
; V- J- ~+ u6 j# e9 N1 A1 }, Q5 M};
% A2 b- I+ U5 |9 u
) Q& ^0 G D7 t$ |# Estatic struct platform_device da850_evm_tl_leds_device = {
; r: P9 |1 I+ O# O# z& c .name = "leds-gpio", ~* m$ \3 C6 L/ N: K! ]
.id = 1,
: y" K2 Y* j' R4 {4 b$ a/ f .dev = {$ M; f& B; ^' Z* l' U+ K7 K# R
.platform_data = &da850_evm_tl_leds_pdata,) P2 d* M. B# U: n- Z) H- O# _
.release = led_dev_release,
6 Z! _6 H( i4 ~; b3 r }8 t3 z- ]: i6 a, m$ r" x( Y) _6 ^
};
; |( t# [; @) _" H1 G& h: I1 [3 P" B0 J* r9 b# `
static int __init led_platform_init(void)& C0 X' M1 q; C. d6 Z# k& h
{& S6 v' f7 K* |9 s a5 N
int ret;
2 S) p4 H: R' [# i5 O4 d#if 0 ?/ N, A R2 \. N
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
% w( m& ]: h0 d if (ret)
! ^2 Z) Q# b) k/ O) w2 E6 F3 Z pr_warning("da850_evm_tl_leds_init : User LED mux failed :". J) ^3 ? r h* t V
"%d\n", ret);
8 x' p, E; R/ R& C0 t8 g' {3 g#endif
, \+ s" G$ I) d3 g5 t+ W ret = platform_device_register(&da850_evm_tl_leds_device);
: e1 @0 F: _7 z% s) |: b5 [ if (ret)
1 }# l7 B( A& s: m/ u pr_warning("Could not register som GPIO expander LEDS");" h9 V ?2 A& |3 S
else
2 z- C4 V- L* f/ L0 t& z2 { printk(KERN_INFO "LED register sucessful!\n");
, s$ V6 B3 l2 F( ]6 j6 n9 P
: |5 d X% K4 L' s- B& \+ i return ret;# {, q4 ~- q8 o' z: _" n: U: _5 J
}% M5 Y2 e5 R7 ]% v1 G) Y
3 l5 f$ h* H% y! s0 p0 ostatic void __exit led_platform_exit(void)
! i$ j1 c6 Y# `% Q+ e9 K{
; x6 B m2 @' k' n7 G: K platform_device_unregister(&da850_evm_tl_leds_device);
- X2 g6 @; `* K7 r& ]* D& f* ?8 D! [) B. P" E; [/ Y+ ^
printk(KERN_INFO "LED unregister!\n");& S; S" U9 J) g2 B( P
}
% r' D3 P7 _9 X c% ?( I3 s3 H- _6 S
( a) y/ v$ |( F4 }module_init(led_platform_init);
3 q K) s* Y$ c, ~module_exit(led_platform_exit);( U+ R, U) p( w% z, N6 i3 n
( p8 m+ }9 Q1 R7 O8 Z7 `- i$ Y
MODULE_DESCRIPTION("Led platform driver");6 h5 A# i K% ^4 P0 r0 ^/ m
MODULE_AUTHOR("Tronlong");
/ u' Z. l0 W( B$ G3 O d7 ~ v. M6 iMODULE_LICENSE("GPL");
' `; s" C q5 k4 ~1 o, f* |- T/ z
2 F% g; x( n& M# A! f5 B7 r% @- c |
|