|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
' z# b p- t& q/ W0 S, J: Z5 j#include <linux/init.h>+ c R1 _ J! \- k2 K( F
#include <linux/module.h>% L2 ~% L( E. v- `2 I! j
#include <linux/kernel.h>' L1 b9 C- E, L$ h# S% @/ g q
#include <linux/types.h># H7 r2 ~; d0 o5 {! C
#include <linux/gpio.h>
$ W3 r5 c! w/ e) D: N4 Q, g#include <linux/leds.h>) K; ^& |5 a$ d/ E2 ^. a8 K
#include <linux/platform_device.h>
8 H- v$ l4 ~- ~- Z; N# c: p
5 x) V! @; d0 q& H6 |#include <asm/mach-types.h>
* [ X; k. |2 z' e5 d#include <asm/mach/arch.h>- y, Y' j9 r: v$ u4 c
#include <mach/da8xx.h>
# G" `% p% f" T5 {8 _#include <mach/mux.h>
. V0 y( Y5 b( V
* j/ w7 o5 Q, W#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
! {, `+ o. B8 c8 l# u* \: O9 R#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)4 Q+ F& z3 f# J
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1); F4 B& `: g i
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
) F6 N) p- b/ y% \- l) ~9 }3 q% [! b7 G7 f( R
/* assign the tl som board LED-GPIOs*/
6 z" B2 l0 f6 u* u; sstatic const short da850_evm_tl_user_led_pins[] = {" c# ?$ p: S+ b3 j4 f S- A" ~
/* These pins are definition at <mach/mux.h> file */; B8 |1 v- l$ R8 p1 y
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5," i* |8 E- h6 D, z4 x7 k/ c! a
-1; h% q0 s; e" W0 O3 w' m- ~
};
, a4 l5 ~' b) o5 L& ^9 a
! g$ e ^2 g. V7 U9 X" \static struct gpio_led da850_evm_tl_leds[] = {
( ]( H% k' w2 W6 F1 ~2 r4 l% p {1 L# F; P0 r8 [3 l' r
.active_low = 0,' K t, B' \( d' [* O6 F
.gpio = DA850_USER_LED0," i$ X" {5 ]6 w5 f2 L9 x: f& R' o
.name = "user_led0",) F' K/ l& ]1 ?9 W# M" D" l, x
.default_trigger = "default-on",* l3 K1 L3 q# Q% L, R' i
}, h* N& N+ v2 H5 }
{( a# C0 x6 d. d1 S5 z/ g/ d8 _
.active_low = 0,9 N. O$ n5 A+ g& r
.gpio = DA850_USER_LED1,2 m' @9 _! l' C$ j
.name = "user_led1",
" W& V. x3 @; {! W+ G% C0 e .default_trigger = "default-on",
; |# K0 p$ S) F* }( B },
5 h6 }. Z( D, w3 r/ G. F {4 @9 [3 T% H; O
.active_low = 0,+ f$ S* \) A @# r- G
.gpio = DA850_USER_LED2,+ {. D6 I U; i: k: O$ V% K7 n7 v
.name = "user_led2",8 D S! ]! |; X3 J% ]5 I
.default_trigger = "default-on",
k# t! r3 w/ d# K/ u/ O4 g/ N },
) }! o- [! E' `& T3 W- { {
4 T6 D7 ^6 X. h1 T8 o% V .active_low = 0,
& N8 j' U; r% M .gpio = DA850_USER_LED3,
. | B, ^! S- `4 C2 B/ J8 n; X .name = "user_led3",
; g4 H" l8 a+ ]# Z" i .default_trigger = "default-on",
$ B/ Z! P9 l5 }8 \6 `3 \! Z9 G },
% X- e2 f d/ g0 _- i" ~ o};% X( h) K& @% B
5 E0 E! d# O9 wstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
" n7 O! Q* D1 L% ]# I' h7 Y6 q5 j .leds = da850_evm_tl_leds,+ ^2 c9 u- E) Z6 E& L* z" u
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),/ D; b( A k; \7 k2 b
};
. \6 r5 Y0 }; U& W$ L' `( n3 T7 E/ @& S8 p/ G5 O
static void led_dev_release(struct device *dev)
6 }8 g5 M( ~8 c1 Z) T{: H2 I* N, u0 t* ]; V" }8 F; }
};
. B( O" d# T* X2 Y" l
9 [' v& N$ \0 M; Wstatic struct platform_device da850_evm_tl_leds_device = {
2 ^) M2 @+ @ B( V5 [ .name = "leds-gpio",
: v3 @6 Y# g6 X- R: x$ S+ m5 M .id = 1,8 t Y5 }4 s" ~3 Y' u* Z1 F- |+ Y
.dev = {6 M/ j& ^+ D' ^( f' g
.platform_data = &da850_evm_tl_leds_pdata,' a- n8 f1 `+ o: U
.release = led_dev_release,5 o" s. d9 Q+ b1 k) r/ m; L
}
# f4 X8 {/ u9 d5 G+ Y: i};4 A3 O$ I, n7 |/ i, J- s% q6 `, h
5 n, o6 f+ m- T& c# Q H
static int __init led_platform_init(void). j4 J1 A6 F9 J: t9 }- `6 X o
{" T& q8 i6 f9 t; J: x! U
int ret;) Y7 g3 p8 R6 p4 v- U
#if 0
{9 O, L: A5 v ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);# Z5 O! i# |6 d( H/ D( A
if (ret)
: A- A. L! I8 Q6 u# | pr_warning("da850_evm_tl_leds_init : User LED mux failed :", X5 d6 }& o( x1 V0 `. S! t
"%d\n", ret);
# }, b9 D$ }4 z- b _$ x6 y#endif6 A7 p- o+ S" T$ w' [) ~3 f
ret = platform_device_register(&da850_evm_tl_leds_device);! g* j6 a) j( v% R; A
if (ret)* |- w4 O, F9 B2 h, Z
pr_warning("Could not register som GPIO expander LEDS");4 Q* J; X: G3 v$ {3 F3 k, i
else
: r2 f+ m7 t1 H$ ]2 Q/ D3 Y' Y printk(KERN_INFO "LED register sucessful!\n");
6 M* j3 `7 h* g; n6 F: t2 C& d; Q- ~. w/ K+ b' k+ S! s
return ret;
: d5 w+ J4 Q V9 a3 P% w! B}
4 I% a2 l; Q3 O& E% [3 {; i. q8 p$ y6 L# m
static void __exit led_platform_exit(void)6 x' x7 {: I, S3 S
{
- k1 G' X! z3 S( z$ Z2 P2 J platform_device_unregister(&da850_evm_tl_leds_device);
0 `0 B# s3 R) i/ ^7 K
% `4 f# u' x. ^' }# x# i printk(KERN_INFO "LED unregister!\n");
+ C' u3 y' `( i, }+ N+ `}' h( |4 O8 O, g
; w$ d- M2 Q% O$ K, smodule_init(led_platform_init);( f3 P' m* q& K8 m m6 u! r
module_exit(led_platform_exit);
" L9 s! I# l6 B8 J# ^4 h) s h4 U5 {) K! a. b; k, B, f: g0 P! @
MODULE_DESCRIPTION("Led platform driver");+ Z3 L& p5 u# E) A+ x; ~- E0 b4 c
MODULE_AUTHOR("Tronlong");8 _3 y C! }) p) O3 _
MODULE_LICENSE("GPL");/ b9 V8 T1 I" N% n) \ Q$ b: I
% x; V: s2 W/ j9 {# m+ v |
|