|
|
求大神给下面的程序做注解,请稍详细些,谢谢。1 [0 h# \: M& l
#include <linux/init.h>
/ X. ~4 f K5 b, ~( {. S#include <linux/module.h>
, I/ d# ?- t. ]( ]+ g#include <linux/kernel.h>0 a9 r* L2 h3 T% K$ Q
#include <linux/types.h>: Q J. ~1 V2 K: k4 P! v
#include <linux/gpio.h> J0 m, X% b. b% a( T
#include <linux/leds.h>
6 @6 L* z9 f! ?#include <linux/platform_device.h>
5 h0 g8 V" U! i0 u: q
, s$ B& f) {, }/ M#include <asm/mach-types.h>
' l2 e6 }- v' q+ V& k2 k2 t#include <asm/mach/arch.h>$ z0 \1 T2 f: v( J( f3 F$ u3 `6 i4 ~3 g
#include <mach/da8xx.h>
$ O5 U7 _0 ]& f: _+ w#include <mach/mux.h>) }# P$ \' f v: ]$ V
. c8 a2 O. f* ^: H& Z
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)* ]* z5 B m% H* W/ |
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
* }* C9 J' F& v! J K. @6 ]#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
5 C" V. `0 ?1 i% I' v q3 Q6 ^. F7 J#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)8 O" [3 W0 t& \ h# q: F- ]2 T
* }1 G' K! X( r) U# }9 y2 [
/* assign the tl som board LED-GPIOs*/
8 G+ d5 |- H( q- ustatic const short da850_evm_tl_user_led_pins[] = {
& W; L, _6 q9 F* J; l, b) c /* These pins are definition at <mach/mux.h> file */3 @" L y- {) l5 u d$ }4 F
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
! M0 J* T2 u) H" ~ -1$ h) X+ W6 {- r8 K/ q4 M8 J& B
};
. x0 q0 ^+ p# Y# h# I+ U; |6 |+ X6 o" y9 e
static struct gpio_led da850_evm_tl_leds[] = {+ o G7 D" U9 O/ r1 j' A
{( [7 ]7 t- W( j* j" S% N
.active_low = 0,
, q+ V7 C, Y" B .gpio = DA850_USER_LED0,
& Q J. q& R/ f! c .name = "user_led0",
1 w, b. L/ i+ i% ^: [ .default_trigger = "default-on",6 ` S( f: J0 v8 \ q0 {. v
},% _6 A7 R$ l- k& X, x& u
{, o/ [+ N: c- R, l! n
.active_low = 0,- `! J* g& d6 b- _/ z# a
.gpio = DA850_USER_LED1,
2 h3 `7 D: i1 |; M .name = "user_led1",
. i2 M; a4 z3 _5 B9 h$ m .default_trigger = "default-on",
! W% S; A: `+ x) N1 y },5 S$ @0 [' G: E7 t+ W k7 V
{
8 D6 \; f& }9 V. L; R& m .active_low = 0,* Q" b1 w9 V8 j ]$ {9 F
.gpio = DA850_USER_LED2,' i; f7 |: \ E3 i6 W# L
.name = "user_led2",: c* x1 C! S( j/ _% v
.default_trigger = "default-on",
1 ~0 \3 D. [" ^1 j" j },
1 Q: R5 D& i6 Q3 c/ P0 F( R {
5 i! q7 a0 X7 X9 ]6 O* J' V .active_low = 0,7 w3 ^. N' @7 {; y, z
.gpio = DA850_USER_LED3,
6 u* a `* T& u# w* H .name = "user_led3",
% Y0 p; e, |( k. c .default_trigger = "default-on",
0 c8 V, F; t, E; V e },
2 Y8 \, s) W! c' C1 @, m8 g};
. H6 U% K/ J( J* P! v2 D+ A6 l* q$ z( h6 {! u7 C F1 z
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
$ }3 K3 z( N9 }+ O .leds = da850_evm_tl_leds,7 ?3 A; j* ]+ o$ A" F; u1 M5 o
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),
; K# r" y$ A4 `. T9 b};% M. C5 A+ F! |. V/ C* c. z% P/ O
% T9 ?0 a) {0 j1 u! S
static void led_dev_release(struct device *dev)
: d1 F& B% { x+ _5 t{2 V9 R, x( n8 y5 f1 e
};7 D2 [& a9 ]: |! a2 n" J
5 ?7 e% `- U" h" D. o
static struct platform_device da850_evm_tl_leds_device = {
" {, n0 H F1 A7 e4 \! |7 L9 B .name = "leds-gpio",- V5 i+ I: j/ }/ e- a( L
.id = 1,
8 q6 V5 U1 K5 E! m: k# ~ .dev = {
( `2 J; }( ^; ? r/ x) x4 c/ ] .platform_data = &da850_evm_tl_leds_pdata,7 v2 w7 O+ }! Y( o. h
.release = led_dev_release,
]2 y6 b9 r( j& R/ E }
8 d& O) x7 H4 \* _};/ L8 B {, D( ]8 s: ~$ M1 T
; T4 [% v4 N% O) cstatic int __init led_platform_init(void)
, o- B- S% I5 x* m) c. |" b{
, U0 G. N9 R: ^5 J int ret;. U3 u& m5 r3 C
#if 0
; t# c/ H' d/ \, m: |& n7 n/ h+ _# M0 K ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);* m* y+ V# Y0 @- e
if (ret)/ N( P" t4 d I) `, Y( N
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
- P( I/ k1 J3 E6 x$ ] "%d\n", ret);
6 _8 P5 E2 M5 C% S#endif
; `: y/ b2 T5 X" p% C" s) H6 M ret = platform_device_register(&da850_evm_tl_leds_device);
- J! X5 q% r9 ]$ B if (ret), M! C: g! r2 g3 m3 T1 i0 h
pr_warning("Could not register som GPIO expander LEDS");
* Z8 K1 P9 g7 d* s else% X6 U: d, \ U$ u6 _$ V( j
printk(KERN_INFO "LED register sucessful!\n");
9 a" W& X9 B' b' j
" f8 t3 }6 a: _" P$ y. d return ret;" ^; l6 q4 F! T9 A( f, s
}7 W) O6 O& b# }( ~( j) a5 a
/ D/ U; w- L$ X, P4 m* C
static void __exit led_platform_exit(void)5 {6 |# P$ j3 L0 b9 J" L7 e4 q; H. E+ u
{
0 p9 p9 w% j1 r: @5 p: U( ?$ A platform_device_unregister(&da850_evm_tl_leds_device);
7 e$ @0 D9 a6 C* V5 R- ~# t
, m7 k2 d* A6 N& L7 l E printk(KERN_INFO "LED unregister!\n");0 {4 a4 i/ e, ^4 M A
}3 t9 c1 o/ W& A2 J$ l9 r2 h8 d
Y/ E) c7 Y/ r: j$ s# o2 K L
module_init(led_platform_init);6 Y" v6 [1 n) v
module_exit(led_platform_exit);
, T. A5 o/ {. V" S) @- @! b5 K" k* y
/ A; q, J9 W6 O+ {MODULE_DESCRIPTION("Led platform driver");5 q( d2 e& o9 u0 t' U9 G, V0 o
MODULE_AUTHOR("Tronlong");
/ V/ N, y" X& _$ M9 ?0 yMODULE_LICENSE("GPL");: J8 y: A9 X7 i d* _! i
6 ?( C! \& Z8 @$ P+ X0 s9 Z |
|