|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
) Y8 ]" ]+ f$ {% k8 F#include <linux/init.h> L8 T1 g2 S' f" ~. m+ a( ?
#include <linux/module.h>
9 s& E1 L1 }* t, ], ]8 Y9 \#include <linux/kernel.h>9 w t% C4 `/ T f
#include <linux/types.h>5 \: r! a! V' M% E/ \. A6 e h1 X! h
#include <linux/gpio.h>
. j6 m/ j8 \; @9 A; k* q+ b#include <linux/leds.h>+ V/ N9 r* | o5 C+ D9 b
#include <linux/platform_device.h>3 t G. r! Y: T$ ^7 U$ d( i
* Y7 O# ^5 W8 Q! U' W#include <asm/mach-types.h>, `7 R/ N, d# D" v7 }
#include <asm/mach/arch.h>
. V8 |6 n4 _9 H1 }9 G5 F$ T#include <mach/da8xx.h>/ A, r% G. F+ x! m: w
#include <mach/mux.h>: `$ i7 ^! ^+ O# o- E( i
: M" z X+ n' k+ w! [2 H& B( _#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
1 m+ E* U& Z ~#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)& v7 E# q* v! C' j
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)/ d+ ^0 B' r; X
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
6 x k* H) e+ U N1 J+ f' q! Z5 t/ J3 ?3 I& I- H* s+ l
/* assign the tl som board LED-GPIOs*/$ d$ }+ J7 {$ f
static const short da850_evm_tl_user_led_pins[] = {
; C# c+ C" z8 h( [+ d; M2 N /* These pins are definition at <mach/mux.h> file */9 Q' c' b# w) v& F [/ \: s
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,# O4 y0 d5 C; {& K0 p
-1
6 M5 A N5 P$ M& k" _) _8 ?- X};
' S0 Q$ h/ t7 k/ y' y
4 e2 q, k+ e {7 Bstatic struct gpio_led da850_evm_tl_leds[] = {# s- w' z# R3 }# C
{; }, U. V" ]" M% ~ t/ z4 p" V
.active_low = 0,. u3 F1 h, u" f" {, }( L& \5 K
.gpio = DA850_USER_LED0,
0 r' L `3 { ?6 J9 N .name = "user_led0",
. m8 Y; ?) e W1 L4 Q- Q% |# U .default_trigger = "default-on",' @% P# C+ O( X" ]2 s
},
: W& y6 Q8 w* R( s1 g$ l { E! D, m9 q0 @" I8 p% S) y
.active_low = 0,
/ B' h4 J1 P1 ?( T8 c. A9 w! g .gpio = DA850_USER_LED1,) J4 g! K5 p Z7 l* q
.name = "user_led1",
4 h0 j9 [* j" ?9 F- C4 f: u .default_trigger = "default-on",
& r4 i/ I, j2 J }," i# V0 `% S0 s% a% l
{" H# X1 H) g8 G Y
.active_low = 0,9 p2 V) o3 r$ W9 u" y
.gpio = DA850_USER_LED2,
5 I# e; J# l* e4 Q& E3 n .name = "user_led2",
7 @: c" }/ G" O& v. m+ G1 P .default_trigger = "default-on",
" b5 _6 @7 s& ?9 h9 A },3 {2 x/ Y1 s9 Q3 B$ i. K
{
& M& {7 w& h4 F7 @( i& J5 R .active_low = 0,# T" \( t; Z! W! K/ X; ^. B
.gpio = DA850_USER_LED3,
1 W* m4 ~) K/ e C" L .name = "user_led3",
% Q1 w7 F3 P0 f .default_trigger = "default-on",
0 H, P- r* h/ e4 Z! ^' O },: d! T9 z" h1 i2 b( { S; C: N
};9 f# A9 S8 m$ N1 e2 Q8 t7 A
2 y j0 E) ~% `, g
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
5 E4 A$ a: J8 V: w3 c5 m6 p .leds = da850_evm_tl_leds,# S) p' `6 D6 Y# W
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),
* I& M! {9 f0 w ?};0 O9 q9 N- x& s0 C
% q" P( w5 |! d$ w3 ostatic void led_dev_release(struct device *dev)
" X* \7 _1 u4 R6 x2 }{
1 \- K+ f j* z3 T" [! U$ ^# X: d};5 |: A/ n: x2 w( A$ H$ f
. _0 F' g. A4 F. n' ]1 ^
static struct platform_device da850_evm_tl_leds_device = {
. I: u* `5 I4 y: J# H6 A9 } .name = "leds-gpio",' Q7 ^5 O: y( q! [& Q7 B) j3 {9 a( s
.id = 1,* H7 I- K2 B# _
.dev = {
3 \6 o8 n/ V: x* Y. Z- G8 `5 A6 f+ T .platform_data = &da850_evm_tl_leds_pdata,) V0 p- m7 a+ S- i9 C) A, U: E. l
.release = led_dev_release," e5 u5 I6 h1 c- E
}- w9 ?9 W+ D1 H- J. i! p% |2 [
};
( }! U0 M0 t6 I' l" h* _$ `, |, }6 M/ D, J5 n0 _" d5 q+ I
static int __init led_platform_init(void)
* l4 k" a' N) s! |{8 Y7 G* h. K" }
int ret;
+ R( Q9 T8 Q3 z" D2 b& M+ ], k r6 @#if 0* b+ j$ @& B- I1 d# [# Q0 E
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);6 h; k# @3 f0 {( d4 Z
if (ret)
$ f$ Y3 \% m" b& |9 f, v. m pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
" E7 }9 Q5 Q- @: ] "%d\n", ret);6 R5 X8 Z* Q/ T" D% [1 U( K5 a
#endif
. G! x7 ]# A9 |8 K( m7 x9 W ret = platform_device_register(&da850_evm_tl_leds_device); Z9 }9 m) S7 U, A
if (ret)6 X; O, {! S$ W/ Y5 H
pr_warning("Could not register som GPIO expander LEDS");
5 O7 k3 ]2 w6 t7 |7 P* n else9 a2 p' v3 B/ k4 L6 b: x y
printk(KERN_INFO "LED register sucessful!\n");
+ P& ?2 Z* H' s4 J$ A$ [7 |' t$ |8 Q
return ret;( j! B& [/ s B' {9 z
}
9 L1 H* g$ x( U0 @/ C5 ^( s m) }$ [8 q% \
static void __exit led_platform_exit(void)" m) |3 d' s' @1 l( T; _& h
{7 p e+ ?$ D0 P
platform_device_unregister(&da850_evm_tl_leds_device);
# e4 d- v) Z" y( y/ { \
+ d4 G. W' P' G- I printk(KERN_INFO "LED unregister!\n");
' q& t+ d0 p+ q" |2 D# |/ _$ s1 h}
2 N3 \; L/ {! Z; y8 {* |% c
( }0 g8 G2 P# X' ]2 Cmodule_init(led_platform_init);! z5 M- y A: {5 X! q
module_exit(led_platform_exit);
' x2 J1 b# o5 G4 x4 r" f) u; ]( _# N q+ M7 c! A
MODULE_DESCRIPTION("Led platform driver");
7 m# q7 W7 I' `5 w- N3 [4 Z0 }, F& NMODULE_AUTHOR("Tronlong");
$ m0 H, f8 g" h. |$ e8 jMODULE_LICENSE("GPL");
" V8 }- k' E) y3 Y% B4 `
2 B- m- m. s. s4 ~% X |
|