|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
9 n* @4 p5 U+ p$ `, |. l#include <linux/init.h>$ V0 x3 C' D6 y u
#include <linux/module.h>
0 k5 V2 w( `$ y4 Q# A/ s$ U#include <linux/kernel.h>
4 P4 B* a; [! c& N! F& D6 L#include <linux/types.h>
/ D; s. Y" g- ]( Q* }( {#include <linux/gpio.h>$ D' w: e& r% l0 y. ~0 i
#include <linux/leds.h>
# i% E9 B6 I+ b+ F#include <linux/platform_device.h>9 f3 A$ x2 s1 b; `
( s) h: l+ I- E0 A#include <asm/mach-types.h>- f X5 d& U3 }/ O3 u
#include <asm/mach/arch.h>
. D8 H8 S0 Z% G) w% \8 v W#include <mach/da8xx.h>
+ G4 l" c, n. n( e; w; O4 f#include <mach/mux.h>2 Z' a, j% @0 R
8 R' |7 e! R8 @% u2 V3 L; D
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)$ T" i% k; f- e8 }2 i
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)# H. B; m) W9 m, Z/ \
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)2 |6 }. B+ Q& }. t0 m' t
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2): `( h6 e p, ]' @( A0 S
9 y: L, i8 n. T* L: o2 a# r0 f- g
/* assign the tl som board LED-GPIOs*/
4 i. ^0 A5 S+ p9 \' q* \' k: ^3 s: zstatic const short da850_evm_tl_user_led_pins[] = {
$ k! @( H7 Z/ d* u; V1 y /* These pins are definition at <mach/mux.h> file */
# [2 P% V; N& T9 E+ ~" Z DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
7 x# X; I& D n -12 H* y' P# g% Q8 r' }6 [
};6 C& K9 ]2 I' ^# p0 d; V* P
* E: q3 ?6 D p) Q6 K
static struct gpio_led da850_evm_tl_leds[] = {' S! j. v1 A3 f4 S; w
{
' q- M! \1 y( O .active_low = 0,9 n# W+ P! `) S
.gpio = DA850_USER_LED0,
# F* @; ?) b) z7 M2 ^ .name = "user_led0",7 I' q- T4 X0 q+ N8 W6 p
.default_trigger = "default-on",
; ~5 }, z0 b ^* ~. } },# e2 \6 j$ b6 j6 Z
{
, ]1 J& o9 s( R) l% U$ ~6 H .active_low = 0,
0 O! [7 p9 I# Y3 r* o: ^' I6 H .gpio = DA850_USER_LED1,
/ m+ L; {5 i- w! m8 l .name = "user_led1",
( w6 {+ T3 w2 e .default_trigger = "default-on",
2 \& A' p( ?! d/ ^ Q# Y. N },
: V7 y1 w3 _$ G! F {0 F+ ^% E1 ]* ^5 g% s3 d% M
.active_low = 0,
: q! e. Q- C: R& c2 Q* J .gpio = DA850_USER_LED2,
! v8 ^2 N0 x* N- Y/ U .name = "user_led2",- ^6 N/ u# A" D C$ }
.default_trigger = "default-on",
8 }; [, F: J- f5 m- f1 b' Q1 o },
3 U$ f, A6 Q. [0 y1 I9 v# i; ?, ] {6 Z$ X/ b1 {% q+ Y. h& M0 m; U
.active_low = 0,
+ d) q# _7 [# }4 c( o .gpio = DA850_USER_LED3,) \. S8 I+ H, ~( @# W1 E6 q
.name = "user_led3",1 Y* O5 x9 a9 r
.default_trigger = "default-on",
& B9 V: N3 d2 o$ G# F% s% | },6 J5 Y; b, {9 Q; r+ |
};: a0 L4 J w9 c' S8 L
0 S6 [. y( I# [static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {5 k. J" H3 j# E4 @& F9 D3 x
.leds = da850_evm_tl_leds,
, {: c, k, S8 }+ _* `8 c, t .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
- Y) ]! }3 |/ |};; o( f1 u( G B+ }. A1 C' p0 o( A
6 X, ~1 y5 d1 r: ^5 r: D8 |static void led_dev_release(struct device *dev)
3 |3 Y( n' y/ ^9 a0 M{% \# g; Z8 H$ m* `& j. k5 g& E
};+ w' U1 h# X' [" l
& M* H% @* k0 a* {& Y5 f1 X$ }static struct platform_device da850_evm_tl_leds_device = {$ q3 v0 b+ q' V. Q) V# l- N
.name = "leds-gpio",
' T/ S, _* O) X+ U .id = 1,& n( P5 f, E' B* K8 b
.dev = {, E E1 Q. b9 m6 x* {4 k ^; Q
.platform_data = &da850_evm_tl_leds_pdata,
; z+ y( R9 {0 ?# L- \ B! a7 [9 e .release = led_dev_release,
h; L7 ` W! Z' _- I& S9 u, X }, z4 D6 u/ Z% ]$ x& ?% n$ \4 L/ X
};
2 h8 h R }0 }
' o4 i" x* v+ a' b4 o* ostatic int __init led_platform_init(void)
2 G, ^- k' ?2 a{- @! W4 X* q* c7 Y! u
int ret;
) |+ c1 {% l! l, _3 Y, T- s#if 06 o# f- I$ i1 S) p& D: K& E
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
2 b; ]5 J- P% y" N% F3 v% t if (ret)
8 G) ^8 M8 h. ^0 ^! ~ pr_warning("da850_evm_tl_leds_init : User LED mux failed :"6 G$ @, o1 X) V* k) `, e1 H
"%d\n", ret);
- u; u6 I3 `9 T( a* w#endif
, i6 ~: |8 ~! o9 q% D- ] ret = platform_device_register(&da850_evm_tl_leds_device);' z; E# R, c; k
if (ret)$ @. }0 }" j& u( t9 _" Z; c: U
pr_warning("Could not register som GPIO expander LEDS");0 [+ ~* @* z! W i- w
else
4 a5 O! y; h6 C# s; y printk(KERN_INFO "LED register sucessful!\n");: Q3 y m% o* f
7 H4 L# L" W( r6 c* G* @
return ret;; y* P( ~5 |# }
}
- O5 m% E3 G% b: j u; |/ E" _) U" R q9 r2 X& S, A) F) H4 t
static void __exit led_platform_exit(void)) F( V! G- d" C6 O5 W
{
; U6 z j7 f% F2 l1 B platform_device_unregister(&da850_evm_tl_leds_device);
4 s. F6 U ~$ a$ ]6 Z$ x' S z9 K; J. [1 D
printk(KERN_INFO "LED unregister!\n");
4 d% E) m1 ]+ ~5 G" O}% G: v+ ]) f+ @& H; G- e7 D; r
; ` S$ i" U: i! X# }. t0 lmodule_init(led_platform_init);5 G; r2 Q: r9 }4 g! d$ H; f" b
module_exit(led_platform_exit);
1 g' [, @6 l: ^$ j- i# @5 `! t
! A0 j3 F8 c: g$ _9 u9 I0 xMODULE_DESCRIPTION("Led platform driver");$ W, [! A0 H8 Q' L
MODULE_AUTHOR("Tronlong");
) @; e( Q7 F0 z$ d$ F, z5 rMODULE_LICENSE("GPL");
: @/ u7 E( ?' L9 Q2 N7 a$ ~) Y5 B
" Q$ t$ g: S- X x) F |
|