|
|
求大神给下面的程序做注解,请稍详细些,谢谢。& o9 u- ~: X3 _& `
#include <linux/init.h>
; L) @/ G" b. e& T#include <linux/module.h>
( M7 ^& O" e+ B: E#include <linux/kernel.h>" ^2 |# r1 o' D3 B
#include <linux/types.h>
+ y, {5 {- h( g. \; a. |#include <linux/gpio.h>
8 {, L6 Z, \, n4 Z( e7 T#include <linux/leds.h>: T$ }/ W6 Z d: w3 e$ z* z9 Y
#include <linux/platform_device.h>
; g' X& @9 w! n7 m9 b( s# x2 D& D
#include <asm/mach-types.h>
: r' S2 S- m5 t, W#include <asm/mach/arch.h>
. ^6 s' e1 U2 f2 O2 r3 n D3 [! W#include <mach/da8xx.h>& e, a$ X! ]0 u( Q2 V
#include <mach/mux.h>
6 N5 \2 t! L# L: [8 C" h
- K( n* p1 J2 t#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)$ i( o& ?" m X- i1 Q
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
% V' A1 \; B/ U4 o#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)* G M5 |1 j9 Y. S m3 @
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
: O! f, A4 U5 M
* G5 H5 A# Y7 p9 }, Q/* assign the tl som board LED-GPIOs*/2 ^8 ?4 D+ g+ g2 |' r
static const short da850_evm_tl_user_led_pins[] = {, D! Z1 `; q" O- @1 Z
/* These pins are definition at <mach/mux.h> file */5 z! c3 ^3 [5 U4 T9 C9 e6 m- A
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,- e8 N& Z2 g0 L- O" k
-1
7 ~ O# |8 ^4 a$ P5 I};
/ w0 l) T! d8 P: r. U$ M- I4 O1 l& V3 I0 X# ~
static struct gpio_led da850_evm_tl_leds[] = {! k) c. H! s1 M" i9 t: \
{ h# [4 I/ s1 t$ N
.active_low = 0,) B; n& c6 V; T* R# B. ~
.gpio = DA850_USER_LED0,
& o+ i A3 t0 e0 b' f .name = "user_led0",
; R% x" _: o Z, H5 [ .default_trigger = "default-on",
2 a& z4 n6 R0 s3 `, [ },8 S: o0 c; T) `; V6 ~) a0 h
{! {6 U5 D3 a3 Q& j, X
.active_low = 0,
$ F9 s7 \0 Z! W' B7 A' K .gpio = DA850_USER_LED1,
1 w- @; i5 j5 s8 X" M9 J .name = "user_led1",3 e; x6 R9 ?8 C) c6 w F& w
.default_trigger = "default-on",. Q; z. y4 m4 d
},6 S+ p3 O! R" r* t4 T {
{
% V; j" ]8 _5 k9 U. ?3 M% v .active_low = 0,3 E' t8 F$ _8 a0 g
.gpio = DA850_USER_LED2,; C0 L2 }6 C, f/ u, ?& O
.name = "user_led2",
5 J* t0 V# P$ J6 z1 n6 c .default_trigger = "default-on",
# ?. D. v, c, G3 \$ I, ]1 T },
/ K ~8 ^) F" ^+ s2 h; F {
( c! r4 z5 `9 l$ H1 n- ] .active_low = 0,
a$ I* X0 F' _ .gpio = DA850_USER_LED3,+ j6 R+ A& ^) V" _
.name = "user_led3",1 j2 C* K' m3 n5 L8 J
.default_trigger = "default-on",
1 K1 d) n/ r7 [ },
$ ^6 v; E7 N; R- k};& M. i- X1 E. a5 U7 _5 p' G6 A2 z
, a C7 |; q; p4 X( f, ?7 f
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
% ?1 t1 }4 p) @, I .leds = da850_evm_tl_leds,- s0 E* q; y* _" M! P
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),. ~4 y7 I7 N% M" \
};
) K# @' _4 m% q5 C% _6 l
' g; y! `0 w6 S" S1 w Qstatic void led_dev_release(struct device *dev)
U, {! V* o. M( d0 R6 \& k{
- e" a0 q& U4 W# a2 O3 h$ I};
' y9 ~# G2 c( v' \# }7 U" d# r- l9 c9 H& E/ G! b
static struct platform_device da850_evm_tl_leds_device = {* J G+ v3 \% p- Q y7 A* n) N ~, Z
.name = "leds-gpio",
/ ~& B; c" R; E8 F2 L+ f .id = 1,% P1 ]) U q# \
.dev = {
5 q" ]4 o6 u4 e4 H& I9 B* H& p .platform_data = &da850_evm_tl_leds_pdata,
. _+ T2 Q& J1 E4 E .release = led_dev_release,
" d; x' w- u( O0 Q2 O: _9 j }
9 L9 x; Y0 y3 A3 _/ p7 d# J* w};
5 J* a j V" l" f+ l# ?# k' U$ T. l2 ~$ s/ N/ u# z
static int __init led_platform_init(void)1 c; M1 }6 q3 l- H! F! D- t0 Y
{! V, ~6 B( d( b* M, ?. Q9 M7 o
int ret;
2 G3 }1 J t, T! d#if 08 r, H, x) M/ _& \$ n
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
' r0 x6 F% W1 b if (ret)6 u, d6 U) S) I2 C
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"/ @ E8 l" `/ d# Q( m4 z- |6 |
"%d\n", ret);
7 Y( V0 M+ G e9 x#endif
1 u" z3 D3 W' G) N$ ] ret = platform_device_register(&da850_evm_tl_leds_device);
2 R' N& w1 i- y if (ret)
6 w/ ?" ~" s+ B! q7 l pr_warning("Could not register som GPIO expander LEDS");* S9 ?( j Y, k8 ?0 ]5 J" J1 P1 O
else/ F$ x1 l) D( m0 T
printk(KERN_INFO "LED register sucessful!\n");, c/ Y2 c1 X# X% n+ M
( M% c. [/ g# M7 k5 { return ret;% R, W, B8 f5 F) h
}9 K- {$ o3 t( x n, }( h: D
$ e0 R! a. @- o+ o5 Wstatic void __exit led_platform_exit(void)( {( ~3 O2 e$ \! i* Q) b
{
- }" D8 g. o9 w platform_device_unregister(&da850_evm_tl_leds_device);, ?) A, G" t0 n# h! U1 P8 \& x
/ Q- F: ] X b/ N* z0 m# y
printk(KERN_INFO "LED unregister!\n");
/ D5 v/ M' H6 h4 M}
6 X& S4 J* x0 Q+ L6 @" d0 `+ S8 E, Q, t, C; G: \3 w( r I; D
module_init(led_platform_init);
' t: p( O" F% j3 cmodule_exit(led_platform_exit);% m8 _" C- C: K& f
8 A: L! q4 }. a& c, T; i
MODULE_DESCRIPTION("Led platform driver");
# u9 N" P6 U' ~. T$ z7 N E: iMODULE_AUTHOR("Tronlong");
0 _$ B8 `+ z( ~) s. A F- q3 dMODULE_LICENSE("GPL");5 S/ a( E3 u4 n2 N$ ^# E7 N
3 Y# A# I# E4 z |
|