|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
8 P3 \) h4 A( r S! w/ f8 j#include <linux/init.h>
: c/ \/ T- r6 @5 P8 v3 y#include <linux/module.h>
" d/ f; e5 v, y" Y9 @/ K# l- P1 d#include <linux/kernel.h>1 s0 S6 _$ f0 h, D5 o
#include <linux/types.h>
j, X, b M" s M+ m#include <linux/gpio.h>
/ V& w H; _+ |- E, V g6 x: o#include <linux/leds.h>
8 |! {+ P' J, s6 V1 L1 K#include <linux/platform_device.h>6 D/ s4 E; M1 ]
' }( {( Z( F m5 I$ O. K
#include <asm/mach-types.h>) [$ C, _/ u. k0 C7 c
#include <asm/mach/arch.h>8 j! y$ B4 `: Z/ H; C; D9 R
#include <mach/da8xx.h>9 x( o' w$ ?5 _; H8 ~
#include <mach/mux.h>
+ z- T( c. W% c# E1 w0 i* d
% n; N! ^$ @; w; @' S#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
, S- K( w/ _, A5 C" p. g#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
& u9 L9 J) b- S& {" e$ S8 u9 e9 b#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
2 x3 h6 }* B/ t* F4 g! d: r. S#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
% B) t; B1 r4 x3 T3 Q" `
) E' v' r* _5 D; B0 G3 o9 w/* assign the tl som board LED-GPIOs*/
/ l! @. U. A( `, w4 sstatic const short da850_evm_tl_user_led_pins[] = {8 u$ R: q B% Q3 p3 k
/* These pins are definition at <mach/mux.h> file */" c1 {9 A) h% u9 _' `
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
: i. `6 n1 Q: N+ V5 X R# Y* N -1
% J0 S7 f$ E: _/ r};
* E2 |2 w. t: R) Z0 y& H u3 q1 }/ I. Y( n0 p( G7 d
static struct gpio_led da850_evm_tl_leds[] = {
9 q' ?- B0 i) O5 K6 a v {) ?6 q1 B' I6 L& x# H: M
.active_low = 0,
. c8 N- N" W( H .gpio = DA850_USER_LED0,
9 G6 D" K: ]6 y' i .name = "user_led0",
# h7 Y" s' Y( E .default_trigger = "default-on",
5 R/ e- \) O9 L' {+ C" b4 Q },
6 a4 K# Q E/ x( r! H/ O6 g/ b {
2 b' z: X1 `- u8 A- Q- n# A2 Y .active_low = 0,
. ]/ r9 v" F3 L2 z) y .gpio = DA850_USER_LED1,
% e4 g7 w6 \1 Z% G .name = "user_led1",
, ]3 \. G, G3 J) M7 G- T .default_trigger = "default-on",
; \' J) |; ^* v( q% T4 H },* F/ @ q; B3 I- k: l
{
1 G' W5 x2 s$ j .active_low = 0,
5 A( P# M& ]; B; D! d+ E$ X/ @# F/ A .gpio = DA850_USER_LED2," |* h m) H& O% R9 x9 k, w
.name = "user_led2",
, o# K' I3 c7 C1 G& m .default_trigger = "default-on",
5 N, g2 P' c0 _& [ G+ [2 T! d) I },7 Q& W0 F; c" |2 Y: z; ?
{6 u' {; r; V% z* a* h3 P
.active_low = 0,
& \7 |0 \2 P# ]% T- z .gpio = DA850_USER_LED3,) c" c8 w+ N; T5 R% I: E) D7 _6 r& O
.name = "user_led3",, S( n; C/ H) N$ d. Y
.default_trigger = "default-on",
; E" a7 ~. o$ F },2 z# p: D/ d q7 X+ H" R+ W0 k; x/ A
};
# U( P. m/ ?' g8 z* i
$ r$ z9 `& z9 ?/ sstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
& c3 k$ K+ q( x2 X .leds = da850_evm_tl_leds,! L; ^ F2 X) U. X7 i/ }: S" E
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),
+ k J* _6 E" P! L* p};+ }" ^$ z+ ?: i8 U2 `: q
8 y% c. Y- t9 N: @static void led_dev_release(struct device *dev)
+ t% a4 e. X) q% @1 \{
+ Y# e1 p" s9 o! c};9 J' L) I+ B3 g6 ?
$ |" s& G6 a0 R& h1 p: {static struct platform_device da850_evm_tl_leds_device = {
/ Z3 z8 g; s6 |( X8 j .name = "leds-gpio",3 B' ]* W1 l2 o& l7 N% T9 I, B7 i! e
.id = 1,$ o8 I# n0 u. P- e1 y
.dev = {
- r# L1 r( I) y8 W$ v* A5 k .platform_data = &da850_evm_tl_leds_pdata,3 z& q ~; t6 }* x, i4 Q' g5 f
.release = led_dev_release,% B4 `7 F4 F: P9 t
}$ i1 y6 M* _$ O/ ]$ e
};- f( ^1 D; z# T. |$ @5 U2 j
( X4 [: D3 e; Tstatic int __init led_platform_init(void), p/ e6 B/ m' w, C* f% w
{
0 a4 x; Z: u; e2 s! Y: [: ` f% L0 n# p int ret;
9 B# Y$ o# p! P _#if 0( O( x, [; n- D9 ^. U
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);. [& }. n; |9 S9 s( Q1 ~! P# P
if (ret)
( v7 }0 \: \* Z# P* c2 l! U- o pr_warning("da850_evm_tl_leds_init : User LED mux failed :" w' z9 b7 }* K( m5 ~, T; F
"%d\n", ret);& @8 [! B7 ?9 x0 i5 f
#endif+ [7 n4 {& S6 E# {/ q; y" W
ret = platform_device_register(&da850_evm_tl_leds_device);
3 l @$ G- P% E" A2 p; u if (ret)
- N4 e' }/ F+ g/ c pr_warning("Could not register som GPIO expander LEDS");2 p9 _/ |6 g1 T9 ~- g7 E" b: y& a
else/ U& D5 q& u* ?2 F% f
printk(KERN_INFO "LED register sucessful!\n");( i; ]3 I# ^3 C! a* x+ t1 ]+ |
) d! U ` V: f. u: H
return ret;$ n& Z& n4 Y. e% ~6 g4 K
}/ L4 s& P; N$ y, T
5 ~& Y7 L4 Z& ~& @& a9 Z4 Pstatic void __exit led_platform_exit(void)
8 s9 y" _2 w x{- ?% p; |& P m# z \+ a
platform_device_unregister(&da850_evm_tl_leds_device);
6 Q: m8 T' [+ }+ M C+ @
5 P4 L7 t# r" o, \ printk(KERN_INFO "LED unregister!\n");4 g+ d m1 G( x' A% {
}0 L5 _! o! ?7 \7 L; ]' o8 i& \
+ f$ `$ O3 Q; q5 `# Bmodule_init(led_platform_init);
7 L ]0 L Z6 |7 s, b8 Tmodule_exit(led_platform_exit);
. C7 a; X6 }5 y( o" g& b3 o1 ^4 I
6 z0 ?. | D7 WMODULE_DESCRIPTION("Led platform driver");
! E0 m) T, M/ L5 U9 } N2 W, ~/ kMODULE_AUTHOR("Tronlong");
4 d( t( i- Y& G2 T$ F8 v" {7 XMODULE_LICENSE("GPL");
& ?3 g8 m3 o }3 X6 P9 S9 o* o2 |
|
|