|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
5 P& y1 O' H. m8 ^. j7 ^4 n, n#include <linux/init.h>
- l# H! j2 X/ ?: K7 p( H6 H#include <linux/module.h>
A6 L4 }6 O; F#include <linux/kernel.h>. r7 {7 q! z2 h. B
#include <linux/types.h>
, T- Q# D; k8 D1 h& O#include <linux/gpio.h>1 J+ @ G( W7 r0 ^0 X: f5 r
#include <linux/leds.h>9 _; T' ~8 ?5 K; _; {1 I% A
#include <linux/platform_device.h> o- ?: N+ y3 K& ]& I
# `( l; e4 G5 m M/ h9 T. w% a& M
#include <asm/mach-types.h>
- I. ~- P* M1 X( J5 Z1 \9 R#include <asm/mach/arch.h>
- u/ m2 t8 F& T1 i% I; K! M#include <mach/da8xx.h>
5 D& V9 h; F9 [" |#include <mach/mux.h>
/ ~2 ^& m, [; }
+ J) S& p$ s# L7 E#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
) o# X0 ?4 m. S+ e' \) Z; w8 g: A0 b( {#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)* S3 w8 h+ Y; `! | r' Y( n! X8 _0 F
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
4 [$ `; Q$ ^+ m# P" W8 Q#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)& z7 q& ?) N9 |& ^& n2 D- ~
# X1 a V6 D( k3 x; l/* assign the tl som board LED-GPIOs*/! ?' Y% k# T3 [: Y
static const short da850_evm_tl_user_led_pins[] = {
: X8 y0 c) }" [9 @ ` /* These pins are definition at <mach/mux.h> file */1 M# d, p5 x% }
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,* V( W5 @* q9 B" ]& x
-1. V& T: B# l2 ?( i
};
! p" K1 r4 x4 X1 ?7 R! P# ^
2 g8 t! ?. z5 v( u8 mstatic struct gpio_led da850_evm_tl_leds[] = {
w* B* C: Z. D" f0 E. @% u {. E X8 F' e: u( h
.active_low = 0,
4 {' B& P# O* Y& U+ K$ D& h .gpio = DA850_USER_LED0,
; o2 X4 M2 g# n, k; ~" B .name = "user_led0",
e) k0 F& h+ y .default_trigger = "default-on",8 D: N+ W2 J {) t/ R: C
},. @+ o- O% |% _# @' Q9 j+ G
{' K( g9 m% u/ h" o9 t1 u0 d
.active_low = 0,
F0 ^$ l3 u/ t2 q) o .gpio = DA850_USER_LED1,
& C- v# d4 j- a; R$ ?% I2 n .name = "user_led1",
1 h# A: ^/ O" {1 V5 `, e: | .default_trigger = "default-on",# J1 {3 F/ X6 ~4 M N0 X# j
},
% F: j; S( s9 n8 [9 t9 k# O {
; @5 m; E. u) i: p/ J W .active_low = 0,
7 ~1 B% J# L% g: Q0 h8 X .gpio = DA850_USER_LED2,
3 e- @4 i. |( @- A3 T8 e: |* F .name = "user_led2",) w& v; l* E6 X; A" Z
.default_trigger = "default-on",; T' L' D3 m) A" o5 |- x: x* }- F6 N9 X
},
. t8 A% y/ j) r6 L3 ^+ [4 B) K% ^/ Z; z {
3 t$ ?, b/ B d8 ?% C .active_low = 0,& x" U1 n$ T# s; t
.gpio = DA850_USER_LED3,- O7 |6 }4 b* I, ]. P/ C7 ^- N
.name = "user_led3",% V, r$ _7 w, C( J$ N- N1 N7 ?- |
.default_trigger = "default-on",3 ~ H4 V" M" s1 s) y
},! i* i0 e5 ^1 x- C4 _$ X6 x" r1 I
};. n; ]5 Z5 U) U; `% _7 C* [6 y2 G5 N
# }- O8 H0 c( \3 P5 g& Z% s# T2 t" l$ `static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
* _) d1 X9 O4 l .leds = da850_evm_tl_leds,
9 f; l* X3 h) ^' ~) l .num_leds = ARRAY_SIZE(da850_evm_tl_leds),6 c; k5 x# Z6 ^. U8 |
};1 K V0 o8 d6 q9 J
1 L8 n! p: t! T& E% N G' u' u* estatic void led_dev_release(struct device *dev) `3 w/ g6 a9 ?+ i
{; [ @# r0 e3 b ~# g+ [1 ~% P. p; J
};# i) J% c: [" _6 C ^: N
3 @0 e/ l$ X. [" D) R, r( Ystatic struct platform_device da850_evm_tl_leds_device = {
A% o" ~4 y5 F& t! v .name = "leds-gpio",
. o8 v: K1 R& ` .id = 1,7 f7 X; \+ w! m* |7 M0 j- o
.dev = {' W6 Q; q. Q& l( c6 d5 T$ G
.platform_data = &da850_evm_tl_leds_pdata,
+ l6 m) F' e3 @ .release = led_dev_release,
+ Z1 F+ R* Q6 r' [7 l) M1 O }* T" b8 W, ]% k `4 T+ L! }# ^& |
};( V* E6 `7 K. e; k/ o+ @: w
: V, d9 l) r1 l
static int __init led_platform_init(void), E' v* d7 i% M- ~
{
) k6 U+ m4 T& Z int ret;
8 ?7 N4 q5 W7 I- F4 b$ X6 n#if 0
7 b+ B4 t, Z% u8 X$ c8 O: r1 Z ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);9 x& P8 \2 v1 V# ~% J
if (ret)- @+ v' R0 i$ K6 ^: Z
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"" m' [. H, W/ t' @
"%d\n", ret);
o% v2 X0 q/ y8 U, G% T$ u4 M#endif
' V6 D# H5 Y7 { _* h ret = platform_device_register(&da850_evm_tl_leds_device);. u) |% [" E2 I- ?$ i* @
if (ret)/ |. g4 r+ u' u5 s' `& F) {
pr_warning("Could not register som GPIO expander LEDS");
" R; Z2 o1 ~0 E" ^" p3 a( R else
. U1 f& J* o9 {2 G9 J2 @ printk(KERN_INFO "LED register sucessful!\n");
1 G, u% k0 b' Z/ ]
$ M- I5 L/ T3 p3 k* \" ]6 D: F! i1 p return ret;
+ V5 T; B# n# d}0 E$ b$ m$ R/ g c
' e% e* a4 U$ m8 v, Estatic void __exit led_platform_exit(void)4 h+ c: Y7 h i T. r$ c
{ X( y$ P/ g" K5 }. G
platform_device_unregister(&da850_evm_tl_leds_device); R' x* Z4 l! R- P- f9 L9 f$ i
/ V6 a, k+ Y- W( a$ c( C printk(KERN_INFO "LED unregister!\n");' ^2 I- W9 i5 r: ~6 h9 ~8 }
}# L* E' f$ @/ y S+ \$ P
( G9 ^! X8 v. Ymodule_init(led_platform_init);7 @) x8 X! K! m7 f
module_exit(led_platform_exit);5 J1 H/ u) v$ B% d' r( I# Q
/ ?. I' t6 S4 \! S1 K
MODULE_DESCRIPTION("Led platform driver");
, F4 p$ @- [* F2 \MODULE_AUTHOR("Tronlong");
5 B9 _4 v x6 V6 p3 P3 K* [. TMODULE_LICENSE("GPL");- Q& r. L1 }. e7 R9 n! c8 J; t
0 {' l& \9 z8 S0 Q |
|