|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
+ U$ D4 u O% c( Y9 p. ^#include <linux/init.h>
7 h, L, d# p E' R/ ]#include <linux/module.h>2 R* } ?4 R& Q: n! L6 B
#include <linux/kernel.h>& V2 h7 b4 K6 y+ L. t& T4 r1 r- {
#include <linux/types.h>+ ~% w/ D" c" j' F+ e" b% T
#include <linux/gpio.h>" u" E# h+ k9 k+ ~# f' I9 v. I/ v
#include <linux/leds.h>9 x( x* i2 H+ O: ^" s5 {' S
#include <linux/platform_device.h>
% u( u& w2 _% W5 R8 y" f2 ~/ A5 Q8 p& {
#include <asm/mach-types.h>
: A" K" s5 V1 ?#include <asm/mach/arch.h>1 P: o6 t+ r7 W* k
#include <mach/da8xx.h>
- m2 V# c7 F# Q' l. h#include <mach/mux.h>* O t0 T! I4 ~# p
2 I+ Q6 H/ {' i5 S
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)$ [$ \ S6 z% Z. h% ^
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
3 z0 g* [2 `- [: Z#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
7 E8 t% G6 _7 ]& y9 q8 ~. }; L; r#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)( J$ G0 A' @: E9 N V; [* p( r2 B
9 H5 M. ^ X; M" V
/* assign the tl som board LED-GPIOs*/+ i k" d( ?1 L9 ~& F, I" f5 A0 z
static const short da850_evm_tl_user_led_pins[] = {
' {( m# ^( E V) r/ B /* These pins are definition at <mach/mux.h> file */
! `& j5 y2 Q; |' k( y% Z/ z DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
: Y% ^7 V7 ]3 l1 x1 ]. F& A, e# x -1
, t% w7 ]3 m( W# g& O8 d) x};
4 D0 ?& c4 s/ n* F8 |
1 E8 d% I% v _: Zstatic struct gpio_led da850_evm_tl_leds[] = {
0 L6 ]) f$ G$ X3 F2 d0 Z" s( ? {( I, s _- v/ E& Q$ t2 T& A
.active_low = 0,
( @ E0 A) K: X' z .gpio = DA850_USER_LED0,
7 l I' D3 J4 S& z: W .name = "user_led0",: k+ L4 W' B* r8 L
.default_trigger = "default-on",
; C$ p; J$ a" e* F* a" C },
: P( _* W! V( ~" y {" N0 ~6 B0 Z& u% ^- d
.active_low = 0,
8 M: ]5 K8 L; [! Y. Y: m .gpio = DA850_USER_LED1,
3 \* _$ u& L, b( R .name = "user_led1",5 G! Y; \9 N: a! N# J7 j
.default_trigger = "default-on",
3 t2 G! E* }, [$ b5 l },9 x* I2 f( R) j( S9 H+ P
{
+ d& i; w2 A* _ .active_low = 0,
. K1 j3 ]2 D3 J .gpio = DA850_USER_LED2,6 K$ T' t3 i% O7 h7 B$ J6 b% F9 A
.name = "user_led2",$ {% H" f5 ^3 `# _% J0 W/ }0 _
.default_trigger = "default-on",2 w5 P# a L0 ?* m8 ]2 H
},
2 M" }, i* {" _4 u/ } {: k! r O* u* |" h6 _! r& o
.active_low = 0,3 e3 v; l/ w0 r2 ]
.gpio = DA850_USER_LED3,
" y( f1 a4 i0 F8 k: y% ` .name = "user_led3",: D# H& |8 b2 [1 g" T, f
.default_trigger = "default-on",
3 C% [- T+ A0 l( h) w7 E }," R# _; n# j3 P% g h* q( F
};
+ x9 W3 u5 I1 k: O3 M, t% \
, B, w$ \! I* S- ~; ?static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
, J G- o7 a, M( W; [ .leds = da850_evm_tl_leds,
6 l9 ? N% O$ c) ] .num_leds = ARRAY_SIZE(da850_evm_tl_leds),6 k# P1 {5 E$ z
};) u/ ~ P, c0 W1 {. V
) @7 a+ Y4 u* u1 k1 M0 Z6 W; `/ P
static void led_dev_release(struct device *dev)
) F4 ^6 o# G! @; `, `/ f$ @# d{
/ j) k% ^0 C+ {; |$ W$ a2 L) t1 H8 E: @};! ?3 A3 j/ j0 `9 Q6 n
& ^& H; |" L3 M( k, B8 [/ v) ?static struct platform_device da850_evm_tl_leds_device = {
# j$ \: A Q/ S. Z( m .name = "leds-gpio",5 e- V; y: U1 B; F- y
.id = 1,
% M7 f* V& z# ?2 f .dev = {
) u8 M- \2 k$ { .platform_data = &da850_evm_tl_leds_pdata,+ d0 i# W: r5 X1 l
.release = led_dev_release,; }. p5 I3 o8 K( S
}# X# Z6 F# Z) I. {/ `) e R
};9 {! D' t8 Q/ \/ y) t
( e7 U0 c. ]" J0 m% I' }static int __init led_platform_init(void)
4 R) m: T; R% z6 t8 E{
" T+ `& j+ k: W* F int ret;7 N" C! E! T2 a- c# O6 {. x% Z
#if 0
+ a2 ]$ A( P$ u3 J ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);+ x' ?/ T( e, J$ m$ w3 v
if (ret)8 r; w% g5 |& B6 E. N( ^ w) e w* Y i+ x
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"8 n3 [. l! M; ?; N4 q2 `
"%d\n", ret);
! [: _; C( x& E' K! C#endif. o% S8 n9 J. U
ret = platform_device_register(&da850_evm_tl_leds_device);9 n' Q# f' ]) H7 q$ n7 ^6 D
if (ret)0 M4 l7 w% ^. p/ r$ o" B6 k y6 X
pr_warning("Could not register som GPIO expander LEDS");
6 O$ r5 f' q6 ] \$ ^ W else
2 |4 c* B7 Z! q( c. j printk(KERN_INFO "LED register sucessful!\n");: a; N+ }4 t5 v! _8 C" H% N
! u1 T: T( U7 Q$ \2 {+ v8 G9 Q return ret;
7 Y; k0 j+ L o% _8 u: s}$ U- |% D9 P# r& _
' b* Q6 Z+ S7 S8 ~7 n, estatic void __exit led_platform_exit(void)$ \- }# F2 L; O, d" H
{: P( |2 K D. b4 Z3 S! P0 o2 y: F
platform_device_unregister(&da850_evm_tl_leds_device);
# @- u4 a1 }- Y, c8 j; ~, h! v! {0 `3 E( e" d& R% k4 n
printk(KERN_INFO "LED unregister!\n");
# W2 M9 Y2 n% B5 j6 R}/ @2 Y3 y8 ^0 H4 a# y
7 G! n+ N2 D9 e6 ~0 j
module_init(led_platform_init);, D5 d! m2 }& |- `1 y( z+ d
module_exit(led_platform_exit);; ?4 D3 y2 l. J& I
/ |+ Q& R7 g( I9 DMODULE_DESCRIPTION("Led platform driver");
& v" ~0 s4 _2 n' }) W2 K1 wMODULE_AUTHOR("Tronlong");$ B- E4 o) c% }8 b$ w4 L, a
MODULE_LICENSE("GPL");
: @' v( P. d7 G: l) X0 |+ H& ^5 w! r# @) N \, m7 \
|
|