|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
- H2 ~7 ]8 e& u& r) a#include <linux/init.h>5 e$ u+ ]! w$ h3 x, H, b& l1 ~0 U/ ~% m
#include <linux/module.h>
n9 [. y- N, _2 T# z#include <linux/kernel.h>% R% i. C$ l/ F; r- M
#include <linux/types.h>
- D" T$ m" M6 Q& H9 |4 m/ ^#include <linux/gpio.h>
: J+ r. I$ C) T& y2 R9 q#include <linux/leds.h>- x% z0 F. W- {* N! }
#include <linux/platform_device.h>
' p' U8 `6 D. j3 o5 S8 Y: Z4 N/ `2 `9 a, M- ?4 K
#include <asm/mach-types.h>
5 f8 ? I: Z- K: k# O0 L#include <asm/mach/arch.h>$ u! D1 h2 Z _5 T& i: Z
#include <mach/da8xx.h>
. Q/ @8 u% `! { `* `) W. _#include <mach/mux.h>- C( Y( M4 E2 T- o: s! j7 U
. ^& R' o4 e x1 v#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)8 {& {! p5 j" ]8 B. }, d( `) U+ R$ i
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5). d1 H1 F+ G* D4 n9 f5 `
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)9 h+ i, L1 s1 e( u
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
* d% U) a \9 T! |
; c2 h6 i- B5 {( N9 L8 ^" U/* assign the tl som board LED-GPIOs*/
9 Y$ |/ l4 ^1 G+ w, q Zstatic const short da850_evm_tl_user_led_pins[] = {
& h7 V3 f% y2 f+ u /* These pins are definition at <mach/mux.h> file */
. f0 Z3 F; W2 S* i6 Y: v4 s" y! Q DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,: z% X$ u, ]+ _" y. }( K/ d/ j2 L
-1
& R ]& v* K' P* o6 D, z7 v5 H};
( H3 w, b/ I( `/ Q+ V. m6 S. S: k$ a/ j
static struct gpio_led da850_evm_tl_leds[] = {
0 V4 @$ O+ [/ B! ^# n {5 _4 R0 N5 g4 n- E! `# a
.active_low = 0,
. N* s6 F: c0 b& P4 }- q' Y+ A .gpio = DA850_USER_LED0,3 Y# F: \) J$ b: [: b
.name = "user_led0",
( [" H( M* m8 I$ T2 p" R) {3 Q .default_trigger = "default-on",
0 N$ G1 L6 l- R7 g },
8 M" l" g$ _4 u& B# Y) J" e/ \ {
/ ~; R, B( `& D7 w) \$ r .active_low = 0,( @1 m+ [4 r& ^! B( b( \4 l# g
.gpio = DA850_USER_LED1,% @; P+ Y; g; j( }, y' v' Z7 B
.name = "user_led1",
; M/ a0 `; }1 c/ A6 h8 U- S8 k .default_trigger = "default-on",5 @& S2 o$ k1 m3 d) M d
},
7 W" h$ P6 _) Y9 e7 U {
, h& R8 j" |0 B" S# L .active_low = 0,; N/ Z4 p1 J" y: ]5 C% Q p
.gpio = DA850_USER_LED2,
& m0 G8 f3 @1 z2 l6 O* s6 Q# Q .name = "user_led2",
* {9 X8 c; h+ s% G .default_trigger = "default-on",; X! e7 a2 q* G" G- b- ]8 v
},: x9 m4 A9 V3 o2 e) o# O% y
{4 P d6 V. ?, I/ F5 a% G4 H9 A- }
.active_low = 0,
* I) j; S8 m$ \- E' {, r0 k) w .gpio = DA850_USER_LED3,7 l# l- Y+ B3 \( y% N5 E7 N, |
.name = "user_led3",5 A {* l/ k" O5 @
.default_trigger = "default-on",
* q; q' l4 f" u3 C" E },
* d: B7 ]0 O8 F3 h8 X+ f7 j};
" T' x. n( }# ~/ `/ A7 ?/ b$ u( J0 k8 S+ a2 g4 l$ J/ Y
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
0 t% s$ I1 |* O" ^* }2 f6 J- ? .leds = da850_evm_tl_leds,
) i" \2 w8 M) X* W .num_leds = ARRAY_SIZE(da850_evm_tl_leds),# `9 s8 ?7 e+ k, L+ I0 U/ }; Z
};
6 ?: m% t3 O$ E& B! t
8 y/ m& `0 t8 _6 hstatic void led_dev_release(struct device *dev)& {, Q0 u+ L; r8 M; m8 d! k' K
{
* ^" ^! l3 B; B6 U. `};4 x3 l) m5 { }- r9 k
( q) ]9 u/ L1 [' ^static struct platform_device da850_evm_tl_leds_device = {+ N- W$ Q% O& a5 A% o0 n; ?1 b
.name = "leds-gpio",: o# e. k: ]" }2 e
.id = 1,
$ D) C0 a4 y# T- l2 o! p .dev = {1 K# N- C' ?9 S; U3 g3 {
.platform_data = &da850_evm_tl_leds_pdata,
5 x. Q* B4 @. q9 Q+ f# h) @5 | .release = led_dev_release,
7 R' W& {2 L+ a8 ?) W0 ~ }2 ]* Z, o; v+ C9 z8 Q' U7 c
};" R1 N& s0 P8 I! T7 t+ ?
- O6 U5 L/ u8 B3 f# G' T
static int __init led_platform_init(void)2 q: Y k M% I4 ], e0 y) p
{
2 V; }" {. T7 C! a int ret;% r6 ?$ i* _0 [+ H0 J
#if 0, K, |5 ]" N6 e: [; Q: \: n. z
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);5 a! x. z- \# D* Z& {# K
if (ret): J$ |& p9 R) D/ s
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
: V2 \7 ]/ R( z "%d\n", ret);0 a& P R! m P" O' P
#endif
: Z- k, \$ e+ L) E' t) ~4 i, C ret = platform_device_register(&da850_evm_tl_leds_device);
& z4 y3 u7 I( x% `8 A if (ret)$ R7 ~/ X0 f$ H: A: W( H
pr_warning("Could not register som GPIO expander LEDS");4 e. _0 S( T7 s
else
) [3 n- u4 m! L& D# T printk(KERN_INFO "LED register sucessful!\n");
3 m5 _& V. v$ f3 }$ z( F
: J' T7 k6 F; E7 O! |, a- z return ret;
& x: a G8 ~( C: g" _}
# b; h! Z0 h) J2 m
9 ^7 v6 |/ J7 B' P8 o+ l' {' |static void __exit led_platform_exit(void)
* k$ j4 v/ X' U7 ^- m{
8 [3 M9 P# h# P$ P. C0 X platform_device_unregister(&da850_evm_tl_leds_device);! E9 C, S) H/ N& L7 C
& ]$ u, f t) x" {- n
printk(KERN_INFO "LED unregister!\n");/ S3 T) P# e. [' \( O
}
( `# E1 R% H8 B) p; b7 Q$ _% T5 ?* v9 [* }% S3 J6 c( [
module_init(led_platform_init);: x" M; b) e! N. q/ o1 F
module_exit(led_platform_exit);
8 y; ~( x; H* h1 n y2 ]0 R2 k8 S4 X9 q9 c
MODULE_DESCRIPTION("Led platform driver");
4 T* J' W7 j* s3 P# iMODULE_AUTHOR("Tronlong");9 n3 W7 e1 U' m) [
MODULE_LICENSE("GPL");
; C; J+ o0 s! k% H- c
* `! t$ Y$ j/ K/ V |
|