|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
8 ]7 |" K+ H8 }; ^8 q#include <linux/init.h>
2 ?+ j. |, O, D2 L8 a* [#include <linux/module.h>
/ D3 w! Z: @) T' I$ l2 D2 z# D+ q#include <linux/kernel.h>, A$ h9 f, m. ]- s5 Q6 C1 ]
#include <linux/types.h>: c4 L! p. c4 E
#include <linux/gpio.h>
' I/ g) u. w+ u: s- v- _8 J#include <linux/leds.h>! H b8 M! C" O- s9 I/ o1 ?) h8 g
#include <linux/platform_device.h>$ g5 i5 h5 x3 l, |! D
6 V5 K, ]* u* i0 k, r: {#include <asm/mach-types.h>, H! C8 p# X! ?& `
#include <asm/mach/arch.h>
/ y7 D" t# n! t8 X8 {#include <mach/da8xx.h>
% C6 g6 ^" }5 B& w2 b#include <mach/mux.h>
3 Q7 T4 ?3 O( m5 J4 N4 t2 H
6 ~. q. V" W0 M#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)1 u+ P5 r1 P" `1 ?% |
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)# @, e, v |+ }
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)& M% }5 r8 m+ t7 u
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)4 X% b2 A$ O9 l4 \$ }" l
4 L6 `; K# V( b# n* N
/* assign the tl som board LED-GPIOs*/
* D# n- Y! g/ ~, b& P+ mstatic const short da850_evm_tl_user_led_pins[] = {7 L! \2 a4 f1 G
/* These pins are definition at <mach/mux.h> file */
# T+ R5 H4 R% ^5 m- \ DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5," D# [7 q$ U1 |' P6 @4 ?8 g
-1
W: e) ?: I/ A' _1 R5 J/ s};3 R3 a1 C, e1 R0 N
2 h' e/ n2 G% e. u( A" C
static struct gpio_led da850_evm_tl_leds[] = {
; Q& |+ ~4 L* {- R6 q {
- Z& E; I) P3 f6 B7 u: _ .active_low = 0,
% l4 W. M" j4 f& { g .gpio = DA850_USER_LED0,9 e) ~5 X/ E, V! J8 @
.name = "user_led0",
7 @' C* \7 }1 n) m* S9 ~$ T" G* x7 b .default_trigger = "default-on",9 e t8 R: k: q; w; M. ]! y
},
$ d d9 T" _& i3 H {# Y! n7 M: y& W+ `& L9 _; q, F
.active_low = 0,) n0 [) I3 u, `) W: s0 m
.gpio = DA850_USER_LED1,; y, n2 t0 q1 e0 q" R2 K2 f
.name = "user_led1",
( p/ m+ }2 s0 z( N .default_trigger = "default-on",1 R5 N3 V F: ~* z* G$ n |+ Y: B9 ]* f
},1 T: Q1 n2 J( u/ S- g
{$ m. S% |: N/ _/ r; d, U2 e
.active_low = 0,; a" j5 A8 c' w
.gpio = DA850_USER_LED2,: m, `, R% l# S2 k1 O8 w
.name = "user_led2",2 r- u/ j: T0 V
.default_trigger = "default-on",$ ~0 j! r' G$ ^/ E+ D) T
},
: {) k4 i s7 b6 ] {; o) T8 S% s+ [- P& G8 y' ?1 B& L
.active_low = 0,
, ~# {) P Y) g1 R .gpio = DA850_USER_LED3,
. t* r$ L0 n0 l& n# G .name = "user_led3",' z5 C+ ]0 K! `1 \
.default_trigger = "default-on",! ]$ `/ A- C6 E8 K! v
},
, p/ Y4 ]6 h! E$ \: e4 x};+ m: Y0 l, I' U |/ y
. H& p3 R. p% c L+ t( }/ b4 g" E8 {static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
! C& q/ R; Q( \8 |5 d9 r( C .leds = da850_evm_tl_leds,4 n3 Q+ h. e3 B+ @0 m) P
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),
8 C! O1 J, u# G" }7 C};4 l) u$ {# `- w
4 F- [7 q$ A! L* m
static void led_dev_release(struct device *dev)' y9 q! T% T, h+ H$ q
{+ Y% J+ b4 l8 V6 x( ~; v: L \
};" l, |1 F: [! g' q, u" [1 r5 w
" e' E. C5 ] bstatic struct platform_device da850_evm_tl_leds_device = {
4 C% ]3 B% q( I1 W: O# w .name = "leds-gpio"," A% w* y. ]2 {) p: h! v' s
.id = 1,3 O( |6 M. ?: x+ J' q4 P# R5 g
.dev = {
; [5 x) d+ R% H# I ?1 v2 L5 S .platform_data = &da850_evm_tl_leds_pdata,
" S1 H9 N! _+ {( P+ I .release = led_dev_release,
6 A9 w/ P9 U$ \$ i/ n9 c0 d6 P }6 O- g) a) S3 {! y5 B/ N: r( k) }
};( R5 R7 ?& L5 v7 M# w& t$ n. v
( { _* p# O j0 }9 y: r- r( ?
static int __init led_platform_init(void)
0 x/ z1 U/ J$ a! y! w. S{
2 ?; r3 |, i- d/ k+ J) f5 Y) e& j3 W int ret;
8 |7 s" z* I$ r D3 b#if 0
: k1 n4 D; {# Q9 c O8 g. y ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
Z. a) Q% S8 ^- g# c if (ret)
% b9 Y/ T2 K( m# I$ E pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
1 x. n" K: o" p" f1 C3 w2 i "%d\n", ret);& R1 X; S5 |' H7 e3 b8 ~1 T$ R5 j
#endif1 g; b' \4 o+ I! z' C g, }
ret = platform_device_register(&da850_evm_tl_leds_device);
! R L0 E+ f) r) \+ f+ K if (ret)
8 V" Y* V/ M# F7 U: S4 C6 G, H pr_warning("Could not register som GPIO expander LEDS");
! Q* y2 c% X" p: M/ L7 g* K( n/ Q2 s- h else
$ x Q) h* ~# O. p" c printk(KERN_INFO "LED register sucessful!\n");
, j0 N4 t' b: P. D9 ]& q& c4 h5 p |
return ret;" ]8 U2 F- S. Z F( D, u& H
}
5 w; v. _1 Z# T; i r
" c: J8 ^/ H$ G% l. u$ Qstatic void __exit led_platform_exit(void)3 v+ g) u. _# v# H# w* x( D( }$ y
{3 J# z/ b+ V3 e# |9 W
platform_device_unregister(&da850_evm_tl_leds_device);8 U" ?% q6 n& u
7 e L' D3 }6 m/ T
printk(KERN_INFO "LED unregister!\n");. @6 {2 U3 f7 J
}) x, H: _7 m- h& j
% x! l# t2 ?: _- N; V8 k/ ?module_init(led_platform_init);
% F4 D. W% R( K$ tmodule_exit(led_platform_exit);
+ h" t4 Z6 d/ @% w
. C, {1 m4 P9 f, B; c+ SMODULE_DESCRIPTION("Led platform driver");
3 P! {2 q% c6 ?2 s7 L! EMODULE_AUTHOR("Tronlong");; E6 ?) E- G3 W( Q" B4 S2 \, L
MODULE_LICENSE("GPL");
% G/ E' N* q. \; ~ R- j$ k
% E; e. m& S4 O4 H U$ b# n' W |
|