|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
" N. {4 U# @1 q; Z1 h3 D#include <linux/init.h>
# Z" a) @1 |; }3 D#include <linux/module.h>
* Z! R& B4 G0 U#include <linux/kernel.h>, B9 P9 Q/ O. w3 r2 |) G$ \! H
#include <linux/types.h>
" e0 F8 W8 X% Z- R7 `#include <linux/gpio.h>+ h) A% m, E4 e. b* a! f& F* d+ q
#include <linux/leds.h>3 i8 l1 v" b8 f3 r/ j# h/ D
#include <linux/platform_device.h>, i' f# o9 D- ]# `" r& A
5 k1 e; F5 u' C% [0 i8 W#include <asm/mach-types.h>( m7 \# b6 w; w# l
#include <asm/mach/arch.h>0 j y" u, |7 z& z/ g
#include <mach/da8xx.h>1 H$ x l0 `4 L; B$ {% d x5 \
#include <mach/mux.h>8 ~( _ z9 F7 Z$ P5 P% e" f1 x
% ]! f1 [+ U& D" N( M$ @" d#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
6 l* `& v9 X+ s {! d1 u6 H4 D: C#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)* h3 ?* R- c3 k# G9 U1 y# M
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
8 Z& I2 Y1 l+ Y7 H m9 {9 T$ A#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)& x; K8 V4 v ~+ f! _: R' l
( E+ ?/ I* I9 j, S! Y# \/* assign the tl som board LED-GPIOs*/
: b1 \# A2 c8 t. y' Q1 y- e/ Dstatic const short da850_evm_tl_user_led_pins[] = {9 o( x: o) N7 H$ ?1 l+ D
/* These pins are definition at <mach/mux.h> file */
( A& g7 @, F* z: \" g D* h9 _0 ^ DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
0 y, L0 N3 E: s% C/ P -13 y' j1 a. j) u$ C
};9 Z3 z' w3 ~% H, T; ]7 N
3 Y3 N+ e: c) g9 o* _static struct gpio_led da850_evm_tl_leds[] = {
, |0 P7 j1 @, d5 H" Q {. U& j$ S* Z: a w9 j' s
.active_low = 0,% o7 e' a9 u7 z: s# b' T0 `
.gpio = DA850_USER_LED0,
5 b% e; p7 J. u .name = "user_led0",
# Q: w, z$ U3 K* w5 o .default_trigger = "default-on",
) w; |0 o1 Z: E/ m7 g* W/ ? },/ c( @; V, k8 H `5 F. I, w
{* k+ v! o& ^ r! v4 ]! T& J+ |& Q
.active_low = 0,
3 w- Y* P- y, `( v .gpio = DA850_USER_LED1,2 ~- m; `( k5 V$ u5 ~8 P7 _
.name = "user_led1",
4 J# V- `4 n+ h3 h+ q .default_trigger = "default-on",
- w4 |4 u9 D7 m6 b" _! v$ u },, c) i ?& P0 ]6 G8 }
{6 Y, |) c0 X& y' H) Y
.active_low = 0,. \4 F7 N- Y7 p1 |' }1 b U
.gpio = DA850_USER_LED2,6 b6 d* g6 x2 a) K; P% n/ M/ H$ ?$ E
.name = "user_led2",
3 k: j }. Z' ~* n5 U .default_trigger = "default-on",* r9 ]0 m0 v0 i3 w( S2 {6 t
},) b2 z5 H# z: R
{
4 h1 Q. w3 Y" [- B4 X .active_low = 0,
0 l& Z4 w9 c3 \" ?3 R' ^/ h# }; s .gpio = DA850_USER_LED3,# y$ R- R% [$ p6 f! Q
.name = "user_led3",
9 R( f8 Y2 v( \! A" ? .default_trigger = "default-on",
5 M( L- d# q: C/ B/ T y7 D# x, X },2 z ?; Z6 F4 ]9 N1 y$ h% I
};
1 ^5 b# V, d( o* n% z d& J
" U% m+ x# ?6 q! {/ n' g2 rstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {" u* z; P/ u8 Y5 l! L, U
.leds = da850_evm_tl_leds,6 T R1 s% T$ S" w" n
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),* @0 L: b0 F8 ]: c- ~( {. }
};4 `3 \' _7 o4 T
! x5 L1 e% s' K. Q
static void led_dev_release(struct device *dev)
' O/ v; N+ B. t4 g( {{
" |0 o) P# r" y5 k5 m: X};" L# i( a X3 i$ F' B: e: B# ]! U$ K
/ @- Z' Z4 G8 A: t1 }static struct platform_device da850_evm_tl_leds_device = {
, @# E& B! o9 _# }2 q7 Q& L. k) u .name = "leds-gpio",6 l4 J; H3 v6 v# a
.id = 1,
! A7 a- p3 s( V. G7 Y! @: a .dev = {
! N- N2 z O, _" v3 K* e8 L; j1 I .platform_data = &da850_evm_tl_leds_pdata,
8 c/ X" M, y9 c/ X .release = led_dev_release,
% m% G" h3 S+ d: G6 y1 b3 F }/ L9 B% y2 x( ^( x6 R. L
};
6 V3 C8 i- T' w/ z6 H* z6 Y- w
* ~$ [- s0 H3 ?( @8 lstatic int __init led_platform_init(void)
. }- z9 o7 h* x; x{2 |- ~) ] P- Y; L
int ret;; Y1 {4 W L0 |
#if 0
5 j' W8 G& ^$ d: l ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
" ]* A& [( Z. K. N9 u" @ if (ret)
7 i( ?3 U0 n8 x& f4 p pr_warning("da850_evm_tl_leds_init : User LED mux failed :"( i/ y* V, x9 }0 Y8 y+ s* U" w* n
"%d\n", ret);- _$ }' @8 A. o/ W! y
#endif
6 N# C) y" x- }+ M5 Y! L, m W+ X ret = platform_device_register(&da850_evm_tl_leds_device);2 Q" E+ r9 q+ F) Z
if (ret)
9 g1 G n# g5 O3 s pr_warning("Could not register som GPIO expander LEDS");
9 M$ |, K/ P' L& ^; M5 x else) ~! ~! m: |5 G. I r
printk(KERN_INFO "LED register sucessful!\n");
) {$ d3 p, u0 M/ D) \6 A K& R# E
return ret;
" C. r- `: ^" c7 ]. `}8 E$ O: {, T/ {& k- Z. _- R
) I \+ G2 X* c Y0 w3 ustatic void __exit led_platform_exit(void) L B ]: l; c3 X4 Y& K
{- A; ^6 e6 }+ K" A) ^+ b; I! ]( Z
platform_device_unregister(&da850_evm_tl_leds_device);
6 o0 l* m( r1 y* ]3 d5 i. P8 k3 b' _' O. ]% v; t. s! [) P
printk(KERN_INFO "LED unregister!\n");4 U6 s1 J8 \3 y2 \2 w/ R% b5 x
}
1 h" I+ T. p" I3 @( S# a" b
- f2 _) v. ^# w1 v' e8 jmodule_init(led_platform_init);
2 u6 V7 x( |! Y+ e6 ?3 U/ lmodule_exit(led_platform_exit);9 a, J) |9 V* _4 A# L
& U D( D# c% ]6 J: YMODULE_DESCRIPTION("Led platform driver");
$ j* P9 S# k2 i7 y2 EMODULE_AUTHOR("Tronlong");6 W5 R( S: J3 C6 x5 h& D
MODULE_LICENSE("GPL");
" P; K, U/ P' \: y- D$ b
7 N, A% n9 p7 q. H3 h |
|