|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
& _2 f7 w- j0 ]7 j( s; ? |#include <linux/init.h>
7 F0 t9 l0 s# S( R2 Y#include <linux/module.h>; H. I& g9 K2 W1 w6 {& y
#include <linux/kernel.h>- K/ c6 }. [' |& L- y' l- u' b" \
#include <linux/types.h>+ m8 u- b! I, } o' y6 a5 B1 k
#include <linux/gpio.h>
6 A. _9 l# O: g% y9 d5 U#include <linux/leds.h>
1 I! q9 N2 {4 x#include <linux/platform_device.h>- k/ _8 @! [5 {3 f) o' y
. i/ p, B* K6 Y; ^5 x* O#include <asm/mach-types.h>
& L1 l+ {8 g" U8 Q#include <asm/mach/arch.h>
5 o6 a3 Y$ x8 G% ~#include <mach/da8xx.h>
1 {) j6 S; Q) G* O9 |$ u#include <mach/mux.h>
. {+ f7 O. T, O8 M4 _5 {: c# N# s9 l7 l
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
+ I; J) p3 l' P2 U#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
5 n/ z. P/ [( ~; Q+ A#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)) p( W9 j4 ?9 D2 y3 ~
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)/ {* N: ^0 O7 p' l9 y
2 W/ J7 x+ o3 H0 y+ Z3 C
/* assign the tl som board LED-GPIOs*/2 a" n; i5 a5 C0 u, P; Z, N
static const short da850_evm_tl_user_led_pins[] = {2 m( i1 R9 a Y, M, `" v
/* These pins are definition at <mach/mux.h> file */, B7 t- ^. o9 W
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,' d# ~5 f( L! {0 l8 L
-1; E$ J/ c1 P g, b" d S! g2 T6 y
};
+ B; P2 C. i# P9 |* M( Y: v" f5 t; g- p6 u: G" Y2 w
static struct gpio_led da850_evm_tl_leds[] = {" `3 A2 z- a+ t; X
{& F2 d. d4 D N0 }) R, ?3 n" B
.active_low = 0,
* |% j4 K2 Y ` .gpio = DA850_USER_LED0,
9 U+ p) ^ O( C& [3 ~/ p4 j: a .name = "user_led0",
" ]+ Z9 X% {. i5 v, ^* O .default_trigger = "default-on"," F- N. E: H" p
},8 [; _# t' ^# p3 G) B( d3 Y
{
& Y7 U# N; w- k' l9 g1 Y3 P .active_low = 0,
4 P0 \+ d q1 C! O% e6 g* o+ n0 s .gpio = DA850_USER_LED1,
% H2 I2 x' Y% E" b5 f$ P# X .name = "user_led1",
# e7 \! @6 R0 V! F- m .default_trigger = "default-on",
' l9 T" f' ^& x! _% G! A },1 t0 ?+ F5 Q% B
{3 o' w+ t* v' ]1 [" X
.active_low = 0,# U/ V. J9 Z4 f9 [3 [3 G! W
.gpio = DA850_USER_LED2,
! W: p2 E' h; i8 c7 s6 |3 q' K .name = "user_led2",$ |# c& t. C9 b$ X3 j' [5 f
.default_trigger = "default-on",: ~1 X4 y D/ P# [7 N/ J6 J
},
" W4 O' N$ x" W5 v {
6 n' [! x4 n, j; s .active_low = 0,7 k/ z( T% ^4 I
.gpio = DA850_USER_LED3,
# N4 n2 d7 l( i6 R# Z .name = "user_led3",
' T9 t5 ?" F+ B$ o$ s .default_trigger = "default-on",, }; u, y" `4 o z9 r4 Q
},% v. U+ Z" z4 h. J& y$ \% k
};
7 }8 t3 S( e1 g( q
& M! \6 f' @+ O; {static struct gpio_led_platform_data da850_evm_tl_leds_pdata = { q6 e: h9 d! U, c+ S# T4 c
.leds = da850_evm_tl_leds,
4 r9 i8 t+ K3 W. J( Y .num_leds = ARRAY_SIZE(da850_evm_tl_leds),6 k0 H$ r7 A$ g% N3 e
};
0 e3 r( `2 L! l# J8 N' @- w. ~4 x' @( c& g- s+ ]
static void led_dev_release(struct device *dev)
7 w. X% g9 d2 f; m0 k{# w9 a6 y' r, `3 X/ b
};
9 D: `+ j$ b# w1 d) G- i. k
2 `* E) o( Q$ |2 u" Mstatic struct platform_device da850_evm_tl_leds_device = {
+ C5 o8 d- q* E3 T+ k) D' ? .name = "leds-gpio",
1 D; O8 G8 k# C% D; S .id = 1,
]1 d: w0 O8 f. Y5 L, F. h .dev = {7 B5 @6 |, R6 J r
.platform_data = &da850_evm_tl_leds_pdata,
5 g9 k: U1 d6 K! ~1 N" R7 W% g! c .release = led_dev_release,
( X; `3 |9 w. d' f. _+ @. K* b }
$ Q6 d" V1 J+ \3 v7 O+ J};
4 m& Q5 a) e/ x! F' x0 n+ h6 X' N& ~9 h* C" w* |' i. {
static int __init led_platform_init(void)
- u( G5 t. Z, l$ s5 D( `{) P/ K% v/ Q2 o
int ret;
/ b0 o- r0 z2 ?: R; Z7 @; B#if 0, z+ h# g# D- S8 U6 ~) x
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
7 [- \$ ]3 q; c5 U/ h& d4 u+ S if (ret)9 {6 Y# x0 i; l3 U; |/ y
pr_warning("da850_evm_tl_leds_init : User LED mux failed :" ]9 u" j, ~# m& W& n
"%d\n", ret);
- k3 W7 ~2 f- n6 @#endif
" _" s8 D3 r, ~3 \* R+ a: T ret = platform_device_register(&da850_evm_tl_leds_device);8 h& S- w7 ^8 f4 G9 j7 h6 i. c9 \
if (ret)/ d& b1 ^/ D: X. h+ j: n8 c4 P
pr_warning("Could not register som GPIO expander LEDS");0 ^; z$ |0 I/ Q0 Q1 S1 b4 n% T( Q
else
; t1 k4 k; ~2 {/ }" G: z \5 i printk(KERN_INFO "LED register sucessful!\n");4 Y% L; g$ G+ G; ?: _0 M# q$ M6 V( p
( m& d& X5 T) N7 y% E+ k. I6 d/ i return ret;/ m& u3 I' O- H, E0 @; G% B
}
0 k; c: k0 s+ t# B8 Q* H
6 N# a9 `+ p J% _' l% l# Wstatic void __exit led_platform_exit(void)
" l$ f8 h8 r1 Y{& D6 M- O8 x' D. V
platform_device_unregister(&da850_evm_tl_leds_device);
+ A' x% `2 M& _+ O
0 g6 _9 Q3 k- [4 e) \: D( Q- p printk(KERN_INFO "LED unregister!\n");
& G) J' H7 @' C3 c; e}
! y2 I8 K/ u! E& z9 v1 r$ g0 C6 _- {) e- N
module_init(led_platform_init);
* Q4 B8 \) k5 @- E# X+ m. Pmodule_exit(led_platform_exit);5 s; U: t4 l/ V" B5 z9 S
# |" v$ T9 A9 ^+ oMODULE_DESCRIPTION("Led platform driver");- g5 Z' D4 S% A
MODULE_AUTHOR("Tronlong");$ L3 w3 a$ S8 S4 ]5 x* `9 Z6 f
MODULE_LICENSE("GPL");
" Q* Z# b! x, I; \) e
: O, e6 m) V F1 G! x" v5 i |
|