|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
$ y y$ h% f1 M1 u#include <linux/init.h>) d' H9 W6 S1 n
#include <linux/module.h>! M( C5 _7 F7 d0 F% v
#include <linux/kernel.h>6 M: d( Z$ B( i& n) K
#include <linux/types.h>6 k1 W3 Y' J1 l2 P/ v
#include <linux/gpio.h> O) M, C0 }. s
#include <linux/leds.h>
/ L9 h2 P e O$ L2 y#include <linux/platform_device.h>! ~$ }- b5 x Q/ ^% M) v. g2 ~2 y
* g$ @& G0 ?2 ]; O: \; ^/ {#include <asm/mach-types.h>
5 t" i) E9 L1 i' ]4 z6 r#include <asm/mach/arch.h>7 _" L! A' ~/ V7 O0 B; f/ _
#include <mach/da8xx.h>
+ [) u2 Y' M9 m0 G; w9 R6 ]#include <mach/mux.h>7 E7 w6 G! Z1 |; @
+ w8 z \" b& [( |, a2 ]6 B#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
# A7 R4 c4 |( b#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)5 p; v+ `% b: M" S- k0 J
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
( G* B$ w, r5 i1 `8 V#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
2 r E+ K: I1 @5 l1 G, p
$ h0 @) Q0 ]! @/* assign the tl som board LED-GPIOs*/
/ P: m- Q% W- ~7 p0 H. v, x% g3 K; n( Istatic const short da850_evm_tl_user_led_pins[] = {
. e/ U& o" K' y, B0 F /* These pins are definition at <mach/mux.h> file */5 j" l* V6 a$ Y: J4 ]8 E+ ?
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
* b$ E/ D( x" U' t- o9 Q2 [ -1# h; ^5 V! L: ]/ Z+ @6 Q6 e
};
( D; \# @: J- ~9 s9 S3 ?6 h) D: u L9 {" Y& g g" E: H
static struct gpio_led da850_evm_tl_leds[] = {, |4 ~% i, H5 W8 w; X! N7 F
{) p7 q" d9 i" Y3 f7 ?6 |/ N! u* Z
.active_low = 0,
) e& k/ ^8 a2 a .gpio = DA850_USER_LED0,
% j$ n/ \8 F( k4 i& i( h7 l .name = "user_led0",
2 p u4 F+ Y3 P9 M7 a. [$ { .default_trigger = "default-on",
& U8 I- ?4 s4 K7 H, w8 |' N },: y3 m* x4 A0 u4 Q; L! S( ~
{
7 c& g! n6 {0 C9 Z .active_low = 0,. K3 Y) r3 v% v4 G p) ?0 a
.gpio = DA850_USER_LED1,
4 @2 g& Y b2 F$ }# [# P .name = "user_led1",
& a8 I c, r5 r% J. k) n .default_trigger = "default-on",! n" b% o) t" H; X) `& ~
},) k3 I. I4 f3 p, w c$ Q
{* v, O4 ~1 N4 g5 C* Q
.active_low = 0,
! u: n- t4 i% ?1 a; ? .gpio = DA850_USER_LED2,
3 t5 @0 o7 u5 C1 \7 U .name = "user_led2",4 a$ ^0 O: }$ ?$ d+ {
.default_trigger = "default-on",
1 O, P3 o3 I$ | },4 S5 g. ?6 N6 Z$ n' q3 g
{
! u* O3 R' d% R |3 j3 U .active_low = 0,
3 Z7 _5 [% P8 E8 c g" R .gpio = DA850_USER_LED3,
. d8 u! D& P6 N9 k .name = "user_led3",3 r! q! Y+ [: q, t: J2 }" X2 ]$ k
.default_trigger = "default-on",8 H5 j) h! _7 K, I
},% J' g+ W2 W, [, G3 }8 O
};
7 v" E, z# q5 e) M
7 G7 A" N; N( G, Ustatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {. J8 M% a% d6 b, g7 C# k6 X3 [
.leds = da850_evm_tl_leds,
; b9 @2 ~/ P, {2 F3 V0 g .num_leds = ARRAY_SIZE(da850_evm_tl_leds),7 O }, T* U& Q# m+ f/ I
};3 k- l, w" E1 F3 i1 E
# R2 D2 l4 f8 l, h- s3 m* N$ n
static void led_dev_release(struct device *dev)
4 c' Y2 X4 H0 r{! O% f, I1 r9 m7 f* |% U9 Y
};
# Q& W* P! Q4 ^; @
: h: V. O( W( p) E3 Mstatic struct platform_device da850_evm_tl_leds_device = {
( M; d" [. e7 ~; z, b2 W* J% ]9 N .name = "leds-gpio",
$ T4 [4 S2 F. V* S* }; h' X* @2 H .id = 1,
% m6 _! i4 K ]0 F0 E/ _ .dev = {
" A9 G, Q4 I1 y6 g+ e .platform_data = &da850_evm_tl_leds_pdata,3 ?4 |% P) N2 ~7 s" v. o# [
.release = led_dev_release,
. H! b. m# G ~4 B }/ {0 }" l' F+ ?
};# f5 \6 R1 J- s$ E! k$ K0 N
4 P- Q$ d& m; V! @
static int __init led_platform_init(void)& a+ l& W# R" O, ]
{8 V' q, _* `+ D( h& O8 t/ _
int ret; |$ X- H1 H5 _+ u/ A
#if 0
' z. s( s6 O; N5 j8 W9 D& P* F ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);% v/ P* j* z. i1 S
if (ret)
4 a z3 }; ] w& w1 O8 y pr_warning("da850_evm_tl_leds_init : User LED mux failed :"/ l* p, v w# d+ V% Q3 D8 z
"%d\n", ret);
" I* ^: G" ]3 J3 \, x- p- e. R#endif. D0 t! F s3 C& T5 o9 N
ret = platform_device_register(&da850_evm_tl_leds_device);5 C# Y; \" }; \" I4 G; v
if (ret)
0 P X1 C' ?) P) {$ B pr_warning("Could not register som GPIO expander LEDS");6 Q& L4 G* P% o
else
# N! d. X9 d. c% N8 y* L# X0 [ printk(KERN_INFO "LED register sucessful!\n");
9 C: d* M* x* G- |/ n$ j. x+ U! R, y6 w8 U' z! m
return ret;1 ]4 }/ t& f2 g
}
9 \$ s, {+ Z0 E8 [
& e( h2 H+ w0 ystatic void __exit led_platform_exit(void)
0 z6 j( b/ M8 g+ `9 ?9 `{
& e9 Y5 y6 e3 ~( W: |& O4 y/ u: ] platform_device_unregister(&da850_evm_tl_leds_device);
; H; O5 ?, A5 N4 ?2 ]" |6 ]
* F7 G1 T: C; p5 B1 G printk(KERN_INFO "LED unregister!\n");
( m/ H3 D# s0 E* I7 ?}" G9 q' [. E; q
" B* @' U. y0 F5 S7 [6 W) Cmodule_init(led_platform_init);
7 P! x6 d0 K7 {module_exit(led_platform_exit);3 Z# D ?- d6 d1 X& ~2 g
! R7 }* t# n1 L- x7 ]$ SMODULE_DESCRIPTION("Led platform driver");
, Q. z7 H* | y1 [0 VMODULE_AUTHOR("Tronlong");5 n, e/ P" M- d. l6 {. ?* r
MODULE_LICENSE("GPL");6 o n5 u6 l- o
6 K+ M1 u, @5 W: q5 q& ] |
|