|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
H8 Z, {" V/ @% ?. u& M) _#include <linux/init.h>
9 h/ B i& @( |7 s#include <linux/module.h>
" K% E7 V5 G9 Q" L+ b) E4 f3 J2 G#include <linux/kernel.h>( h/ k H- e4 R" R9 g5 Z" W
#include <linux/types.h>
. z) s: e. ?& i#include <linux/gpio.h>
) O, |" z/ Y, {1 \& b9 P#include <linux/leds.h>4 ~0 [' ^7 L5 M
#include <linux/platform_device.h>& u, E0 j" p: X( X) U) ^
: _# j8 }0 ~1 g4 p& U#include <asm/mach-types.h>
) q. r, H4 F* ], F2 ?% t#include <asm/mach/arch.h>
+ T/ w' `8 W% l3 K4 X+ s' y#include <mach/da8xx.h>) Q% m$ A6 ?6 {; u2 r
#include <mach/mux.h>3 _7 ]; Z; V& G- x
% x- t4 f: u2 X o3 K4 w. e
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0); I' K7 j+ f7 ~
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
7 p: M( z/ i% y) u# Y#define DA850_USER_LED2 GPIO_TO_PIN(0, 1) t7 l* c) K4 p. ~
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)6 o3 p6 D) t" ~' u" s1 K) G
0 L L/ C: G, k' `% d/* assign the tl som board LED-GPIOs*/
0 l6 S/ h R) _0 {$ Y# Q2 ^7 o Mstatic const short da850_evm_tl_user_led_pins[] = {( c- Y* G9 q8 _8 E
/* These pins are definition at <mach/mux.h> file */% H! Y& z& x* [# U9 k2 \% r, `7 H
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,7 q& w: T& _: V7 T
-1
% H. k8 D9 y" z* T; t2 E' m};
. y" D3 @( v. R$ u, A6 k
$ z K' \8 E: o2 [4 R, Z) F [static struct gpio_led da850_evm_tl_leds[] = {: n, P9 g- t+ i* [/ w
{3 y- j% i0 \/ i o
.active_low = 0,! p8 d h( F& \# K0 \& _9 w* i4 H
.gpio = DA850_USER_LED0,
) T8 p$ Q8 O$ ]! D .name = "user_led0",
( {! p H; O/ V( w8 V .default_trigger = "default-on",7 ]/ k* U" s9 H3 M" E4 i/ C
},
: A8 r/ U4 g+ K( G# x8 O" n {
2 q( l* @" {5 ]& J8 j! _: t$ H .active_low = 0,
, {/ Y8 @' }4 }( |. Q- a .gpio = DA850_USER_LED1,
# N) E# D! X! ~ .name = "user_led1",
* a# [" t8 ^ S9 ?8 C) X9 J3 S .default_trigger = "default-on",
0 Q5 o/ c* G; P8 H, O8 J' ? },
2 g/ z: `) t5 Y! g {
* i& v2 f7 [6 w, ] .active_low = 0,
: U) }) n5 F" @ .gpio = DA850_USER_LED2,' X6 T" Y* V7 b8 T! ~8 c
.name = "user_led2",
6 h, d8 @$ P4 p5 {! D* B .default_trigger = "default-on",% P3 M: |3 u! ^! M0 G8 ?" t5 S1 d
},# o+ w9 H# {# O! m5 t
{
0 {* y$ O' L# a4 U$ l .active_low = 0,
?9 F P7 X4 S7 x$ |4 f9 |* ?7 k .gpio = DA850_USER_LED3,* q1 ]- j- o ?' \8 V4 X2 v
.name = "user_led3",6 T1 d. \8 U6 G* [ k
.default_trigger = "default-on",8 n% Z3 F. u/ ^2 I! }7 J3 e
},% Z% O' {) P0 @! u. S j" y7 `
};
. M/ Z! s7 a; m w* ?! V- u
" l: S. n: `$ @+ M: Astatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
M! a7 e0 G& f9 `& V- ?* E% B .leds = da850_evm_tl_leds,, N/ D% H7 B$ H2 T0 G6 c' b& |/ N# t
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),2 w: z7 b0 f5 B4 m% x# |3 O
};0 Q; h7 d" z' g+ y8 H$ K& e t0 j' T
" c; E4 S$ K8 B, D! f
static void led_dev_release(struct device *dev)
/ ~: X5 K V& f0 q! f' {{+ B! w5 r3 {) @1 c' Q
};
& w& i( c' N" t( k0 r
5 M4 H' N- ]" b, xstatic struct platform_device da850_evm_tl_leds_device = {
& d( L. t B8 l. o+ g .name = "leds-gpio",- x! t8 i+ y) A2 x4 \, m' M6 _
.id = 1,
" [: |; x3 T2 |2 s5 k .dev = {
" a$ W) u/ F5 q+ P: A .platform_data = &da850_evm_tl_leds_pdata,
# ~0 ~) S" Q" R4 H. Y .release = led_dev_release,0 @+ u. |9 c) L; j
}$ M2 \7 v8 Z6 r" m3 d
};) `: a4 I6 I2 Y/ l
# Z; ?8 ^4 B% `, u$ h
static int __init led_platform_init(void), A" i' V* M2 E5 g7 q3 g
{
8 z# Q3 Y% {% F$ r int ret;8 P! F' [$ }. ?) b9 w
#if 0
3 u2 X8 H! x) T' g+ l- D" h, Y ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
7 B( D1 \( r" X. p if (ret): y9 E# @0 I! n5 I$ `+ H
pr_warning("da850_evm_tl_leds_init : User LED mux failed :") k9 d5 _/ K: ]( u
"%d\n", ret);3 B! m3 j' F. e/ q
#endif! ?* G$ k6 X' h8 Q6 U/ |$ W% v
ret = platform_device_register(&da850_evm_tl_leds_device);: T. y7 a! N4 E% [# g
if (ret)
9 p+ S) t3 \' S, R- _ pr_warning("Could not register som GPIO expander LEDS");
& f$ U4 l: _' V' `/ |/ h else6 @% g" s: n. n2 D0 D& \- [
printk(KERN_INFO "LED register sucessful!\n");9 H& _: E5 t6 @! V0 t
( ^' q, L3 W7 z1 z; F' r return ret;
1 H" y: B( h; c# U}# G. V+ n2 ~3 s9 L$ g! G' \8 Y
! f5 p$ P- c+ }: Ystatic void __exit led_platform_exit(void)- r7 V0 t# |1 o1 ]/ |$ }
{
$ k: J/ I# L. r: S: r" I platform_device_unregister(&da850_evm_tl_leds_device);
2 x* ], F6 Z6 d
* B0 f7 {# e4 j7 ?* H8 x printk(KERN_INFO "LED unregister!\n");; P3 y3 Y8 X' q5 j
}
. M4 v; n& \$ d2 K) u5 s' d4 a1 C" Z% T7 @
module_init(led_platform_init);
# J/ o0 A# l) Bmodule_exit(led_platform_exit);8 D! T1 U. O6 \! k0 j0 a0 u
6 A( F2 o' @9 |4 D0 J2 D6 QMODULE_DESCRIPTION("Led platform driver");
) f4 b% H; I; v' e* _MODULE_AUTHOR("Tronlong");
* c5 F- ? b" W; m/ _MODULE_LICENSE("GPL");
" q" j5 R4 h! l' s+ Y% {3 g# y4 _( z, }
|
|