|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
& T7 ^6 P+ N' {) G0 G1 l#include <linux/init.h># F! E# E9 M3 w8 o# ], T
#include <linux/module.h>; M6 S0 t: J" l* K& p! x
#include <linux/kernel.h>/ A! P: q) q @1 U
#include <linux/types.h>
" ~8 ], l1 u1 z) j/ Y#include <linux/gpio.h>: d8 @& z; T5 ] V) T9 r
#include <linux/leds.h>
1 l/ E4 O, a! p) e#include <linux/platform_device.h>
- ~# u2 v/ N# V% \ W# h- H
v& m0 `! ?/ e1 D/ x, P6 u l#include <asm/mach-types.h>
/ [0 l M7 v0 \8 p" T+ A0 F#include <asm/mach/arch.h> J$ H) ]' g5 q; _0 `# q
#include <mach/da8xx.h>4 ?& c- H$ _. s9 a- C8 Y; a" X5 U' Z
#include <mach/mux.h>! |- t6 m# e2 j9 o: P6 e
) i# P; H- b, u: `7 N9 y7 _#define DA850_USER_LED0 GPIO_TO_PIN(0, 0); f$ d* }! C8 s- `
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
4 a$ p9 }& g) |- @! H7 _+ c#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
' d. D4 C5 o7 }+ n/ L$ w c# Y4 c#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
4 `& h( c7 _( \: a4 m+ z' ?/ V; }2 @4 S
/* assign the tl som board LED-GPIOs*/
$ o% {' G" ~, n1 fstatic const short da850_evm_tl_user_led_pins[] = {" k. a) E+ g, `/ M" }
/* These pins are definition at <mach/mux.h> file */
% I/ r# a: \( O. ^6 [ DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
+ x& i. S/ x7 [ Z9 z -1
* Y4 M( H) W. w& @};; Z( Z* y. L& Z7 A
) A3 G' B" S6 Istatic struct gpio_led da850_evm_tl_leds[] = {
; P2 C9 y! k1 g) S! Z# y {
4 T1 X ?7 @# e7 i2 Z2 ?& w. u" c& C .active_low = 0,0 h$ M$ ^+ t/ F
.gpio = DA850_USER_LED0,% c4 y; H- q, l. S1 [
.name = "user_led0",
L( V3 N( \: u& w- c" y3 h .default_trigger = "default-on",! Z% a" X9 [$ S6 |' C0 R7 L
},
/ ^) e: D" o: D0 n! C: T @ n {6 h* {; s0 W9 d6 b+ l
.active_low = 0,# x% K% _: I8 Z& i% h" g5 L
.gpio = DA850_USER_LED1,
, {0 O8 m8 t' R) O1 g* X .name = "user_led1",
* l7 J6 u& [2 g, ^; Y Q .default_trigger = "default-on",
& K1 Y- |$ F! g# K+ f) Z$ W3 S },
% I, Y! h1 t$ @; t0 H" U; X {
| q( t% I, C; e/ [9 |$ u# |/ A: w .active_low = 0,
" ^& }! P1 J9 i3 E( o6 C/ } .gpio = DA850_USER_LED2,
" o% y% M) r8 o- t( R8 z( M/ O# W .name = "user_led2",
6 k1 l# V+ J- H( Z/ p0 @! O. O' Y .default_trigger = "default-on",& ^! j/ w" V9 C% H! c
},: w0 M$ E3 N& f& h" Q& H+ o
{
2 o) `; _2 p* M: T$ E0 o8 w& P4 v .active_low = 0,
9 P; F% C2 F2 B+ `" F* w .gpio = DA850_USER_LED3,
; J C9 W: M4 A .name = "user_led3",! e4 ]8 \5 o. `# R) X* q, {9 U
.default_trigger = "default-on",
; P5 e3 [; F+ O },$ B# H3 W" h/ j- s
};$ L' _8 ?; R, c2 }
+ K) Q! V6 {1 L' y, G1 q; ^- Hstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {4 w! H* A) W N$ _3 X4 o
.leds = da850_evm_tl_leds,
# z1 U0 x5 n. X8 p( K .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
/ E( k; y! ^+ R+ o2 n};
V. k% D- d) x! e X
; Y8 P: y N$ ~" Dstatic void led_dev_release(struct device *dev)' R5 S- Z) c" D* f# b7 v: G& a
{
( F5 [3 j' G7 A6 f! b};0 I3 W2 L6 G; v* O3 P' ^
5 t" b; |5 ?6 P3 M
static struct platform_device da850_evm_tl_leds_device = {! T9 G6 y. D7 Z W$ G" l) _# g) n
.name = "leds-gpio",
: ~8 u3 C! |! }: I$ g; o" M .id = 1,
+ S: f6 ?8 y: V7 F0 K$ h) A .dev = {
7 t5 I( ~/ a* T3 W$ C$ Y .platform_data = &da850_evm_tl_leds_pdata,
/ U2 _* K1 Z3 a$ {+ Q3 k6 R8 h .release = led_dev_release,
3 N% B2 S! {' U; V3 @5 H3 S }
; F- X# n% Q5 m) p};8 H$ Y7 ~) D5 L% f, A6 c
$ q* W2 L% A* zstatic int __init led_platform_init(void)
, [8 S: I* c& D, P p{
8 L' P5 E+ G2 K$ N+ \) E) V int ret;
# ^5 @% u3 m9 v8 g7 F! k1 m" B; J#if 0
! j @7 q7 F/ @: ^ ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);( u! A. {% j. |6 a. ~! k0 R
if (ret)
: R1 ^1 v& u# f+ ]* V pr_warning("da850_evm_tl_leds_init : User LED mux failed :"1 F% L* \/ i! `8 c p' c" z9 N
"%d\n", ret);2 F7 V/ k9 s' k9 K! c% F! s
#endif
1 @- E% b$ ] E1 ]9 c6 X% a3 V ret = platform_device_register(&da850_evm_tl_leds_device);! S+ g7 U" I% x# F$ B" x" P
if (ret)0 J) f( B/ p/ u1 T: }1 w8 r1 u: l/ K
pr_warning("Could not register som GPIO expander LEDS"); S4 Y6 A# S+ i$ H/ y5 C2 q. O
else
5 J9 ]& G. ]: l- O- Q3 ~ printk(KERN_INFO "LED register sucessful!\n");2 S' N9 K0 o1 x) H! Z2 o" D# N
- q( u5 N! C6 ^* w2 t% | return ret;* x$ A# f9 j d0 w' r" G" ~
}# O' d% ~" Y$ o1 q: z' W% q
; W) k+ O" y& Q3 N. B* b
static void __exit led_platform_exit(void)
. q, V6 O3 E/ ~{
T ]* @/ [4 K7 z4 l, { platform_device_unregister(&da850_evm_tl_leds_device);
% P. U/ k8 _8 | c# e1 [+ b5 A2 E" o6 V4 L% ]& i
printk(KERN_INFO "LED unregister!\n");
/ f2 q% h) g) J2 ~}
1 O! K" v& s7 }" _# t: {; ~3 p, s) S
module_init(led_platform_init);
4 O. V K1 P5 V4 p4 q5 \module_exit(led_platform_exit);
; y$ V1 p! k/ _* I
8 s3 A' F7 ?7 v# ^7 yMODULE_DESCRIPTION("Led platform driver");
& n" A S" P- V' ~" t+ x6 \- jMODULE_AUTHOR("Tronlong");+ Q) b% }: h) r4 x5 M) h
MODULE_LICENSE("GPL");
3 n7 X" J- w& [ B: t, D6 B5 v: o5 w$ J) s/ @ @
|
|