|
|
求大神给下面的程序做注解,请稍详细些,谢谢。: K- c# Y. }& y5 p& w# ]* m" c
#include <linux/init.h>( N- D/ u+ I. ]
#include <linux/module.h> ^" u, M& h; A! D' W6 g- K) \
#include <linux/kernel.h>
! O. x" h. o1 b, Y( \. }) p# i#include <linux/types.h>
5 N9 W; {% q! g% ], p% m, b#include <linux/gpio.h>+ C( j* ~; i- h4 H9 K6 L
#include <linux/leds.h>" ]9 t/ U. K. i" k
#include <linux/platform_device.h>! o1 o5 Y& O5 n, L1 z( `4 G
, Z1 W, Y4 r/ W* T#include <asm/mach-types.h>4 w/ z) [5 i( Z7 N3 F1 d6 V. `
#include <asm/mach/arch.h>
' q: o" @- e1 T' P. E- B#include <mach/da8xx.h>) c- E1 q0 k8 \8 U# Z8 Z
#include <mach/mux.h>2 g8 @+ J0 d2 U( t
% _6 Z/ Z: g- L9 A F, {#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)% b/ Y+ x$ R7 Y5 Q5 X8 e
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
3 f2 G3 I f. x& k4 K#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)0 v* U* ~5 t5 v E% J4 o* f4 E
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
% ~) q8 S4 K N$ R" P) \$ J9 z" y9 Q9 I# W7 [& Z5 \8 D
/* assign the tl som board LED-GPIOs*/
( |) n# ~+ ` [" U6 Lstatic const short da850_evm_tl_user_led_pins[] = {
6 ?. d. n& ?. _! c0 l8 {4 | /* These pins are definition at <mach/mux.h> file */
# o; K, l. W# q; R* f2 r5 a/ ~6 Z( } z" R DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,% n2 L+ {. f1 r H+ w
-1! o- H+ w' }; K1 j
};
4 K" f$ R" v: ?: t
0 V2 Z" ]* D$ {/ I+ }static struct gpio_led da850_evm_tl_leds[] = {4 a1 w! w& o) D+ V
{
! K$ s6 ^1 B4 ~- M1 z+ ]* l .active_low = 0,: Q" `8 m: @8 q Q( v
.gpio = DA850_USER_LED0,
7 L, N, C' v% q& n .name = "user_led0",. e6 f# u5 t$ p& o- n
.default_trigger = "default-on",4 H1 R; B9 ~2 B# D% y5 i1 V8 c
},
* l' _( K4 q( u2 k {+ G/ z) ?% c1 w
.active_low = 0,
% L0 W& P. x0 b% @9 } .gpio = DA850_USER_LED1,
' U( I/ ~5 A x5 K% r .name = "user_led1", ?9 w3 |1 r* Y* t' \- g- T
.default_trigger = "default-on",, U+ b% c2 \* X- S
},
! E# u; M; { c% ?. d5 J# T {' b0 L% Q V, Q3 f. J
.active_low = 0,
/ o, N; C7 E3 Z! ~$ `# c .gpio = DA850_USER_LED2,* B) b& ?0 _% v j
.name = "user_led2",
5 N) r5 h- ^" f3 }6 h* m+ B .default_trigger = "default-on",7 i h- P0 f* R1 ?
},0 [$ b: h$ c8 Y: {- ]$ v6 y" i, G
{- L9 h3 J Q. B/ R2 p/ ?
.active_low = 0,& R2 q( {+ P2 h6 r
.gpio = DA850_USER_LED3,! S. v" d8 s W* C
.name = "user_led3",/ {2 L9 e: d; W6 |9 j% K
.default_trigger = "default-on",
0 H- R/ }% g& H6 J' w0 H6 a },
$ E( n/ [7 h- _};* ^5 D4 v9 x5 U2 r
& }! h( h) G& @: v0 c3 {* _+ Astatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {: i- L5 f- N* G* y' K
.leds = da850_evm_tl_leds,: _5 R% s4 z. Q- _$ S
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),( t+ S! R( S' m' I. S/ G0 p% C
};( P' q" r7 w/ _- ~" B
! r% n! y& _. I/ ^7 H+ O
static void led_dev_release(struct device *dev)0 d z5 a& r. k
{1 v& y8 K7 T' z& C/ D
};
( C$ Q+ [- y# N$ Z
& s; R3 s0 T6 O* r' dstatic struct platform_device da850_evm_tl_leds_device = {/ @, j, L. L$ X2 z! M# x
.name = "leds-gpio",( G. o5 n; `, b. z
.id = 1,0 b5 o# w- J u" r0 @. Z' b8 H
.dev = {
9 H8 ]! W! [1 p% }- `" v) F .platform_data = &da850_evm_tl_leds_pdata,
. h( f+ j& _2 _: A7 V5 ~ .release = led_dev_release,
3 l; ^' E% k* u4 b. H* s }' R* `& b7 i; Q/ U! i
};
' {2 B( ]3 ~, L. c1 I' k; q8 k: ?1 |$ g' \7 A) p o" U
static int __init led_platform_init(void)
" F4 x8 Z0 F h. g! E0 \3 u{
( v& V' A) h. e8 O int ret;. S' k0 u6 o: |* R. t3 ^
#if 0
2 g: t5 j4 ~( `/ F6 a ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);1 Y% q/ b) G6 \# o4 D8 ~8 ^8 J
if (ret)4 g3 R3 r' S2 |
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"7 N/ G* n- Y+ Y% w5 g
"%d\n", ret);6 m& D- P$ q$ y6 H
#endif
* A- p; }2 p/ y* K* ], `5 ~ ret = platform_device_register(&da850_evm_tl_leds_device);
1 b; z6 d0 B2 n9 q1 r5 d if (ret)% W- I: D# O* s
pr_warning("Could not register som GPIO expander LEDS");+ e# @+ |' O0 H, F: c' d
else
2 D) ~* k% K6 F% j0 a printk(KERN_INFO "LED register sucessful!\n");
( J) M/ H" ^' `6 V4 g1 q3 h2 \6 r# M0 S! `
return ret;
# Z" E/ t( c$ x6 E- i# I}
; u% @! W, i! ]3 h- R" h& o1 @7 m% l! L
static void __exit led_platform_exit(void)
0 Y4 ~ J0 x) C% Z5 ?1 B{
' w' J; `( c. R& n: ^$ O t platform_device_unregister(&da850_evm_tl_leds_device);
. x# ]" m( L" s# R7 ~+ H* e& U' z2 f* U0 Z. t
printk(KERN_INFO "LED unregister!\n");
8 i. N2 m* a {}3 m- ^, s6 v" u. n
* ?8 q/ L* @, r# N" I% a
module_init(led_platform_init);* z+ Y$ ?# ?3 Q, l: Z; f
module_exit(led_platform_exit);4 n' J( ^/ c3 P8 p7 d
- T8 `( }3 o% n4 \4 c4 j4 R
MODULE_DESCRIPTION("Led platform driver");3 e- ^6 P, @1 s
MODULE_AUTHOR("Tronlong");2 }& i4 ~1 V5 x0 r6 \6 |
MODULE_LICENSE("GPL");0 I" ^; h8 X+ i, Y" o! Z
A ?# P- `# k4 A( [0 h* ` |
|