|
|
求大神给下面的程序做注解,请稍详细些,谢谢。) p1 o& f1 H* S+ s
#include <linux/init.h>
: ]/ I5 t) M5 R#include <linux/module.h>
0 H$ i. _9 b9 P1 j! S3 b5 }#include <linux/kernel.h>
# y* ?0 [$ h* L7 X& F/ m0 E#include <linux/types.h>: ^ s* M' ^. q1 z4 W6 W% x
#include <linux/gpio.h>
, N0 D* K! e7 L2 I7 G( Y# j) c# @#include <linux/leds.h>0 S0 S/ p9 D) y6 _" E, v
#include <linux/platform_device.h>
@. ]% M$ o+ V4 t/ P, e$ M! l0 d X; w* }, R7 S c9 g4 e
#include <asm/mach-types.h>( ~+ q o h: ]# E6 |/ i: [
#include <asm/mach/arch.h>
: u n! M5 J* S+ g2 g- U#include <mach/da8xx.h>
) T8 {# ~ j& ?8 j#include <mach/mux.h>8 A& _1 k3 c& O( P" T1 y; u3 H
3 P! J8 g2 F2 u- L z2 {3 `9 R
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)) {. b& f6 a) g w% r5 L
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5); W& A; e8 C! M$ ]0 O% O) E
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
1 z3 ~/ z2 v% F9 l1 x- k. {#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)& q2 P/ b; o$ ?; ~, V
1 O, _% l1 H* R% a! \" E/* assign the tl som board LED-GPIOs*/
0 c6 P l0 U& }" F' ]" Fstatic const short da850_evm_tl_user_led_pins[] = {+ Y) i0 s3 |, Z
/* These pins are definition at <mach/mux.h> file */
6 K# j8 y5 h/ z+ I0 n8 V DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
/ i4 G0 x4 s1 I- E' y4 z, L& O -1; m& e0 ^8 S5 I+ ^% a* D- W- D
};
3 L z; J4 ]. D* b9 v
8 c- {' d+ \+ L, Xstatic struct gpio_led da850_evm_tl_leds[] = {
* O4 c- c) d9 w- g5 F {
( I' ~: k9 G; B( T- `, B .active_low = 0,
- r2 Y0 t4 r0 G0 H g .gpio = DA850_USER_LED0,
! |" R8 U( b9 R3 w: i6 f .name = "user_led0", J4 b$ Z" I! F2 Q9 H) ]3 W& b
.default_trigger = "default-on",$ b/ f3 W i7 H) }, z; s- I
},' k4 [8 c2 h. z7 H/ f
{: \3 z+ `2 l2 g( f( W
.active_low = 0,
' x+ f: v& r" n0 n .gpio = DA850_USER_LED1,' k7 `/ K, M: @' `9 B$ \/ b
.name = "user_led1",' D; [4 ?8 ], c& x! }. ~! D) y
.default_trigger = "default-on",4 S( X3 M0 F5 Z* l# i
},
5 p5 E! S1 O) Q d4 w& g {
3 P( P: W1 E8 e2 `! h# Z% e .active_low = 0,; j$ B7 J+ w* K$ J6 m, ]
.gpio = DA850_USER_LED2,1 e# m- x7 H; A
.name = "user_led2",! J% _- L; i: }4 m0 ?
.default_trigger = "default-on",5 b" G3 Y3 h1 t
},
; \- V( G2 I& _- t7 H& l! X {
" s" L/ A7 r# F* Z1 E: |) Z- l9 t1 m .active_low = 0,2 L( c8 P8 ] ^1 O5 F
.gpio = DA850_USER_LED3,0 |# j4 Y& c1 a3 Y z
.name = "user_led3",8 T' A8 \9 c5 W& H
.default_trigger = "default-on",
6 J6 R6 c- v' x- ]. l },8 N2 @- `5 K- b, |6 C& t
};" L( B+ l& b6 r
/ M3 |7 V1 K" U- |, Nstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {' y) W i" v7 q z! G) M
.leds = da850_evm_tl_leds,
) }+ q$ `4 ?! K ~" _$ D .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
) ?0 _1 H" L9 p, q% y};
' {& z/ e+ H3 Z- G, Z2 t( }; E0 R% U& Y E! W4 Q
static void led_dev_release(struct device *dev)
* ~# U+ Q! i/ Y* i6 v& K{3 {8 Y0 ~7 p3 H
};
. p0 \9 n, {8 x" o6 T6 y' e
1 M$ e- m& o2 y; ?$ }3 C5 {; ]static struct platform_device da850_evm_tl_leds_device = {; l8 J; h: C$ C0 H1 A0 K, ?; [4 a
.name = "leds-gpio",9 H( {+ e/ ~6 s: {" Y4 Q3 c; }
.id = 1,
9 }& m( x% e" { .dev = {
. ~( }+ p+ T& @8 q% v .platform_data = &da850_evm_tl_leds_pdata,7 s c; r% o: X9 C
.release = led_dev_release,
: h* h4 ~ M) U d( r }: c" A1 d; d( e6 E o9 Y8 N1 i) r
};) w( T( |! o6 B1 M, h' T
6 q3 n$ o* X# Z1 J/ L& Hstatic int __init led_platform_init(void)2 s+ ~9 ]: q6 C3 a
{1 L8 y, b* J8 X4 A, k+ g0 f
int ret;
, x2 c8 Y' ]5 N& E" c+ Z' f#if 0* @% @2 B, u/ V$ i
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
4 R5 V7 h+ X8 O I" J U; [ if (ret)! a, f+ p* l1 j s
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"( H5 e/ F8 n; v& x6 c1 J
"%d\n", ret);
c. {- m+ \' F. i4 c#endif
; a, E9 N7 K5 F* T# c* f ret = platform_device_register(&da850_evm_tl_leds_device);
; X' F$ h/ f3 W9 F; D+ F if (ret)
0 h/ \4 d Y0 p/ l1 n4 p7 M pr_warning("Could not register som GPIO expander LEDS");
! v7 {8 X# W* C0 M( } else
& ] N5 X) ^/ n H w* I" h printk(KERN_INFO "LED register sucessful!\n");
- h3 f1 r5 E) \+ f1 f& [+ h3 C K! w/ h" Q- s% E& F
return ret;7 O# ~; ]' D$ b) \7 H( b
}
4 N) h6 e/ d% p- T: Z0 L
$ c/ U$ c8 y5 l* o3 Bstatic void __exit led_platform_exit(void)
* [! }' ]2 i% T& j{
* o+ X7 d e9 Y+ Z) m, |0 O platform_device_unregister(&da850_evm_tl_leds_device);/ O; u: r7 O8 x8 u* L4 g
; N3 m5 F. G/ n& S" r% \ printk(KERN_INFO "LED unregister!\n");4 l' A% U: n# H- e/ b' O
}) y$ r! M7 d% E; i
9 y& Z& r0 {: ^; ?; _ ]+ h
module_init(led_platform_init);
* |* c1 Y( U- Hmodule_exit(led_platform_exit);( ]! c" [- \ T* w2 e. E' M7 c1 [
3 V% t* o$ U' }" j! S# `( a) D
MODULE_DESCRIPTION("Led platform driver");
% k ^, W( ]. j- H) \1 P7 V$ tMODULE_AUTHOR("Tronlong");2 `) s. G/ N( ~2 M
MODULE_LICENSE("GPL");; G% }- M( |: g. f4 i
7 P W/ B" X2 ^$ \6 Y0 J7 d7 M |
|