|
|
求大神给下面的程序做注解,请稍详细些,谢谢。# f/ r' n: I, u1 L! [
#include <linux/init.h>
2 Q. d% R8 b% A3 W& C% x) r' u#include <linux/module.h>
: L4 \& ?( R6 }3 X! d5 k#include <linux/kernel.h>5 v9 O9 x2 \# A
#include <linux/types.h># _6 _: ]& B) `, B: f& W% \
#include <linux/gpio.h>" L1 Z- X- B& q% v9 D
#include <linux/leds.h>4 ?. x# m7 T4 H; v! P) m
#include <linux/platform_device.h>3 u# \2 D4 i) y" L3 A! R
/ j E7 b# u- n* S
#include <asm/mach-types.h>
- p+ |4 H8 K$ ~#include <asm/mach/arch.h>' e2 Z4 t. [4 L" F, G" ~) E
#include <mach/da8xx.h>9 r. n8 e7 I2 d% F6 ]
#include <mach/mux.h>
5 b' y8 s8 f6 ]6 N( e# [# W9 m
" {; z4 W" {9 l/ S* ?5 B# d: s#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)- w1 Z+ k& G; w- G
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
! x9 r( o6 A+ v: K( k# H4 f) E#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)) w" {: S2 ?% V$ [9 a3 |
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)' d1 q/ g. B% y1 {% v1 j
& e9 b7 X5 u: i- A' @, K; ^% p. K/* assign the tl som board LED-GPIOs*/
! f. Z& q5 h- U Q4 e2 ystatic const short da850_evm_tl_user_led_pins[] = {
3 z' }2 r( x4 ^ r/ [ /* These pins are definition at <mach/mux.h> file */) y Y6 u4 X6 O- q
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,3 N& D# p2 e* n' d' a
-1
, n5 }; q; s( _! H9 ^4 K" B5 m};& t/ B2 v. N5 Y n+ P& d; |$ o
0 G* W1 X: Q( G7 W' `& D* g
static struct gpio_led da850_evm_tl_leds[] = {4 C+ }* ]3 B0 b7 u8 U6 L
{
; r7 V: K% c4 l; p/ z- r .active_low = 0,
5 }) Y6 Q5 Q9 D" Y .gpio = DA850_USER_LED0,
# X) R S0 U8 e8 L6 u .name = "user_led0",
/ J: k l; `1 c .default_trigger = "default-on",
% A& T6 E1 y/ @5 l: j5 a: h' r0 c },
; ^* R3 s7 @6 ^ {* |+ H8 T- v2 ^ p# i
.active_low = 0,- z; h V# Q' m& K9 \- N3 ]. \3 e# Y
.gpio = DA850_USER_LED1,; l" J0 `. f5 y* |8 T9 y
.name = "user_led1",0 r: ^6 T6 I3 G; i
.default_trigger = "default-on",1 }4 ?4 l8 x6 |3 @0 O) j
},
; z. }, x6 J% s" ^& D {; U2 j! [9 a! f6 s- q( Q- y" I
.active_low = 0,% \, }# e6 i+ i; @/ S4 b; C
.gpio = DA850_USER_LED2,
0 T! ` {* k5 r( | .name = "user_led2",
* [/ N0 D' `2 X+ n0 D [0 N .default_trigger = "default-on",: A, _3 O3 k" ]3 ~) F
},0 _: y! [, w7 C. S* ~. p
{
% t& ? f7 d4 C8 ^3 { .active_low = 0,
; k& G6 ~! n1 H& R: S9 } .gpio = DA850_USER_LED3,! v& Q" h+ ?% l8 m5 {3 R# z; l
.name = "user_led3",
8 o7 L/ ~ z0 c0 A6 l .default_trigger = "default-on",
) v1 H5 f7 t& C5 m7 _ },
t3 \7 T* A. M. s( Q4 ?8 l};
1 I4 g/ B. L) u0 t2 }
& m2 m) Y! R/ h9 p% `! x: V5 f! T( rstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
6 r! q$ l. L% {- y& I1 [ .leds = da850_evm_tl_leds,
& W. N- ^% z* k .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
0 i# O8 K% _, z6 n' d& V8 B};
+ c# ]. C+ T5 c' h y' J! |# }2 G* e' o/ a. o
static void led_dev_release(struct device *dev)
- m& H K, C% L2 L4 X9 I! H{1 B/ \4 q+ K+ _* S
};: K( T# g5 o- E1 i. J% L7 Z. T7 A/ v
7 J4 s8 N0 D9 \# _6 l9 o- B4 N
static struct platform_device da850_evm_tl_leds_device = {8 ~! Z$ J v% Q9 e- h. k- r1 r7 {
.name = "leds-gpio",
- q1 F4 {7 g U, Z% Q, t/ k5 M .id = 1,
" T- x+ z6 `. }6 M .dev = {% q, T/ D' J; D& f9 M9 S
.platform_data = &da850_evm_tl_leds_pdata,
7 u" c1 x3 K" L& L9 b9 H .release = led_dev_release,6 B5 q7 y& W( o. I( e' D
}6 N8 a% k/ |* E9 Z2 E0 T
};! n. z; K' a; S# ]2 Y7 V
Z* [, ~5 Y0 h
static int __init led_platform_init(void)7 h3 J$ i7 w& S
{: ~) q: `1 i, j: `3 w
int ret;
9 U3 W6 f7 N8 Q+ ]' {#if 0
_" l8 g: r: i- \ e ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);5 F! ] {4 ~# K- U0 p( |% q2 N4 v
if (ret)
+ O. [2 |+ ~! q2 _: h% L5 ?3 B pr_warning("da850_evm_tl_leds_init : User LED mux failed :"4 Y8 p# [. E: A# q
"%d\n", ret);8 u5 |. w0 X$ a: U& Y: B E
#endif
. d* F% ?* Y. \& E. ? ret = platform_device_register(&da850_evm_tl_leds_device);
; v3 i3 Q/ z/ X8 k ~7 y! G+ q if (ret)8 a4 Q- r) s# r* Y3 U
pr_warning("Could not register som GPIO expander LEDS");
! h% m: |7 E5 C- j else9 Z3 [' D! i/ u' d6 j3 ]
printk(KERN_INFO "LED register sucessful!\n");( u& K3 P) O1 m2 {8 I
" Q' _4 |8 G' ]3 K8 u* |' s& ?6 g
return ret;. z T# M4 @! M% Y) `' H$ i8 o
}
3 w) N" [, \2 x5 r7 u% F. ~1 e2 f9 o2 o9 S4 f# X* P, P
static void __exit led_platform_exit(void)
, U+ ]( I% [/ E0 J5 C) r{- K+ h0 y% b& x* \0 Z- d' V
platform_device_unregister(&da850_evm_tl_leds_device);
, j" x' v) i- m$ {% m, |. r% X- N6 X1 b6 z
printk(KERN_INFO "LED unregister!\n");
* G8 e$ Q3 }" u/ r0 _& }- K' V}9 U3 _+ l: }# C; |6 C
: p0 _ R& ^5 ~" t3 G$ e
module_init(led_platform_init);
- ~0 Y w; x9 Tmodule_exit(led_platform_exit);
% r. Q8 b* ~8 m$ u! v. m4 U: J( Q4 ?1 [8 C8 d I
MODULE_DESCRIPTION("Led platform driver");* r6 @4 g% f9 f* K1 h1 Q) W
MODULE_AUTHOR("Tronlong");
1 S# \3 b3 |; _' J LMODULE_LICENSE("GPL");
9 d* S4 |) `# A p" P+ b4 F9 U) C
|
|