|
|
求大神给下面的程序做注解,请稍详细些,谢谢。$ J6 q" U* G- Z0 |4 y
#include <linux/init.h>, x* D% Y) I' I( b
#include <linux/module.h>* U2 Y- ]$ v6 ]% ]: X. y, u! _
#include <linux/kernel.h>
5 U2 b0 T; z1 H& z& U#include <linux/types.h>9 B R+ I1 b/ L5 S
#include <linux/gpio.h>) |6 M4 Q4 M0 O
#include <linux/leds.h>/ k3 ~! q2 L, e6 ^! n
#include <linux/platform_device.h>9 P, c7 @; e) W8 o) q( a# m: Q
0 {$ s6 f0 I; ?5 ^+ H#include <asm/mach-types.h>. I. l5 }6 {5 w( m4 e# T
#include <asm/mach/arch.h>' S( }, F, g$ L, d8 D, S
#include <mach/da8xx.h>' M+ c! ] U$ q7 n$ d- t0 D B3 a* x
#include <mach/mux.h>. b8 @ _8 a* p/ m3 p, f# p
8 c3 M* X* {/ c7 A1 [#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
+ y7 x; w5 R& V" E! B#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)1 a1 ?* K2 Y4 k% r4 e" U5 t% V
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
, c) X2 u) g7 T) {. b#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)0 K8 T# Q& F/ H5 z( ~* X3 M
- W% R9 c1 u5 {6 |& k4 N6 f" A/* assign the tl som board LED-GPIOs*/
3 x5 a- Q: t K/ E- ~static const short da850_evm_tl_user_led_pins[] = {
2 p; X0 K. f' B. I /* These pins are definition at <mach/mux.h> file */7 r0 T) W* |2 X; P
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,4 C1 ]1 l( r4 R+ |" o; }
-18 A/ L7 Y$ Q! B
};+ Q, k! [$ o7 p Q
3 N& b! N* S' O5 E! j% W# Zstatic struct gpio_led da850_evm_tl_leds[] = {2 b) d, Y+ T! O
{
$ S! S( ?, J2 Q; w- \* w7 Y .active_low = 0,$ q/ o# i: X" x' `
.gpio = DA850_USER_LED0,, U, T% g* w# |, F G0 w
.name = "user_led0",! m+ l) N; ]* ~0 `& f/ m4 v$ J
.default_trigger = "default-on",
. [& O) k' j Z },
' N; l6 A! o3 M! t! z {
1 s& G3 N5 [* {2 J( m& D) l .active_low = 0,2 F) F! L# Y, r: b3 T
.gpio = DA850_USER_LED1,
1 E2 z u7 k5 H .name = "user_led1",
8 Z& S# b \, ~, l .default_trigger = "default-on",/ Y M8 r" ~+ M4 h% X5 ~9 ?2 S# @
},+ i" a2 C+ ~1 T, L- h1 W
{- r! \1 ^9 a5 N2 Q
.active_low = 0,
( S2 p v1 t1 [ .gpio = DA850_USER_LED2,; u' K. H4 U' S- _5 |% Q
.name = "user_led2",- e. P4 |% ?5 E# S. k% b2 L( K
.default_trigger = "default-on",( x" `3 Q4 T" j
},$ k" B" ?9 x- N: u; r! ?, Z7 H
{% d& h a. j0 D6 ?+ F
.active_low = 0,, n$ y" W: ~7 n7 l
.gpio = DA850_USER_LED3,. G1 b8 }+ y4 L3 j
.name = "user_led3",. d7 Q. U& d4 J: [- j5 {
.default_trigger = "default-on",
6 X0 ?4 K8 D$ V },+ @& j4 k3 V$ ^, d
};# x: V* `9 L( a
t4 `' p8 c( ?, G4 I* h8 x) s
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
$ ]" D6 l& `) ~1 E1 x. n .leds = da850_evm_tl_leds,
( l' W1 ^( a& Q. z .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
9 m5 E9 g; L2 `2 n};
# d9 E* y. `; U8 Y- M! ]/ |$ u8 N" J0 d
static void led_dev_release(struct device *dev)5 c0 F x5 [: T# r% U& v& x
{
+ z1 y: K7 r8 g};9 K' T! c: M, R' |/ F' p+ B
. t; J9 W9 c7 H& g# S1 g' n4 \
static struct platform_device da850_evm_tl_leds_device = {
, U& `7 }3 _) o( i! s3 S8 j .name = "leds-gpio",
; F0 s9 s% ^7 I$ z5 e! ` .id = 1,
7 S8 J' G) q; ]7 }. { .dev = {
/ i5 f% i5 O v- X. o8 Z .platform_data = &da850_evm_tl_leds_pdata,6 W# I" q3 z) [) E
.release = led_dev_release,
2 @, Z* t8 G. q }9 @( \3 L' e$ `4 F. e
};& z" \' b1 }' y- ~1 o1 B2 u
4 g7 v5 O0 t. @+ Astatic int __init led_platform_init(void)9 H( I1 u/ b( Z- s) ~9 s
{
% O- j* y5 F' j int ret;2 N0 N6 S6 b9 j# l% d
#if 03 R3 K5 E, r+ {$ J6 U' O) X7 Z8 S
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);5 I6 C) W" p+ ]8 c
if (ret)
* W& b% L g- z! Y) `7 ~% ` pr_warning("da850_evm_tl_leds_init : User LED mux failed :"1 L$ o7 r f* y- [- t
"%d\n", ret);/ g; e* q+ ]7 O1 Y# \5 B9 M Q3 s
#endif
" @ Y$ E1 c0 w& b' i7 s ret = platform_device_register(&da850_evm_tl_leds_device);3 G2 T2 J: q3 U- {% Z
if (ret): g! Q' L; O5 q$ l) c
pr_warning("Could not register som GPIO expander LEDS");4 }# s9 x0 [# X3 C. e+ d9 X) U
else) Y+ `0 }0 `# p6 R) j
printk(KERN_INFO "LED register sucessful!\n");7 S! a: X7 Q* O5 V1 l
8 C0 p$ g+ l3 d9 @
return ret;5 z- j! Z0 @ P& M7 R
}
~8 o6 r& r% G2 b: I. b
/ w) s5 X; T4 t) M, e6 zstatic void __exit led_platform_exit(void)
7 T' v3 W9 O! E* p- y8 p# U" T- S. E{
, J$ X7 A c& j/ j9 f, Q2 Q2 C1 R platform_device_unregister(&da850_evm_tl_leds_device);7 M! m3 c% \5 k* `8 M8 W
8 @' N% X9 E2 c- ` printk(KERN_INFO "LED unregister!\n");0 [8 G: J- L/ h" B% Q
}! b- g6 ~+ H: o/ R! R( I1 N7 g! o5 V
' _/ V/ L- Q% V t' c9 ~
module_init(led_platform_init);/ G0 b! t0 o9 [9 a! R \- E& X
module_exit(led_platform_exit);
2 w$ T; a: Y' P. F W/ i4 A8 c( r+ q
0 B8 n% }+ |3 E+ w2 U$ rMODULE_DESCRIPTION("Led platform driver");
- _: z$ `* e" K2 z: K5 n5 aMODULE_AUTHOR("Tronlong");
, f$ o5 p, Y- yMODULE_LICENSE("GPL");
. k/ J& N5 ~: [3 P/ f- L: @ e9 U5 B& T# I
|
|