|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
) E: m0 V3 r; \7 [* ~/ P#include <linux/init.h>' q, ~- W% u* x* L
#include <linux/module.h>& f$ \, c5 l) f
#include <linux/kernel.h>
4 @# e" O2 U( `0 w! y) r6 ^, e- a/ q; u#include <linux/types.h>
0 k6 p, ?: z6 @( i0 w# W; X#include <linux/gpio.h>
0 z( A# m% h; U, T# f4 K4 E/ p, s#include <linux/leds.h>. N9 x6 n+ c# e" r4 V
#include <linux/platform_device.h>% w7 x7 Q/ e: }1 A
6 G& O' E5 [! ?! A1 N* _$ m* Q#include <asm/mach-types.h>& v6 c; y& Q, U5 u9 n6 j
#include <asm/mach/arch.h>
$ E/ q. z2 t, _: C5 q" ]$ A% H1 p#include <mach/da8xx.h>0 J4 h: X& D S7 g; o. X& u
#include <mach/mux.h>
- X( e' A" o; N' j5 ?1 E
% t( C N6 F" [8 s/ g5 ^7 `#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
, Y* y' z2 W1 W5 u! u#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
; J) J6 n7 M& C# n2 D i. _* K#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)1 _9 t6 v1 G3 Q3 U
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
0 i e7 F: m, ^0 @( D% ~% l8 r& J4 D6 d* ~! N) J
/* assign the tl som board LED-GPIOs*/
* |/ T, ^6 F! L2 P2 d* ]* M4 n; Y9 Gstatic const short da850_evm_tl_user_led_pins[] = {
. T( X+ E! j: r8 T) ? /* These pins are definition at <mach/mux.h> file */6 S( W4 Y* { T5 Q5 p0 t" A
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
, V. Y; c# `& _2 ] T; y -1
4 E, H) k; |+ U6 w" u};8 t' B' W9 ]" J9 k( K; x1 ?4 s
( W5 j; B- t6 J9 u9 I
static struct gpio_led da850_evm_tl_leds[] = {
! ^, O4 C6 ]0 Z+ `, B {
/ D/ m& a* v/ } .active_low = 0,
1 j6 ~# [+ ?5 O x .gpio = DA850_USER_LED0,
8 a- ^& t! w. ~# ?. Q .name = "user_led0",, ^6 P) `! X: S
.default_trigger = "default-on",
7 p ?! x/ ~# g0 U; [ },% }+ w) C- V6 x; E( b7 C1 a
{5 w& m4 R5 s8 J# c% D, o2 [
.active_low = 0,
L' [. L. b: e! ~' F ]. O .gpio = DA850_USER_LED1, x! r# \) L; N: N; k8 Q
.name = "user_led1"," @4 {# g" m% I( P t8 m' c7 [
.default_trigger = "default-on",+ a1 ]* \) N1 |) T
},& L6 Q) o5 B0 H
{
9 c/ u% b$ s a2 c- N .active_low = 0,
V5 I. i% _3 e# |4 M; B9 ?( t .gpio = DA850_USER_LED2,
4 y, j5 N/ U, v: d; |% @ .name = "user_led2",
# L# a( ~6 P" H3 s .default_trigger = "default-on",0 `% s% `; o; f
},
8 z2 T/ c! F3 g" K1 X {
( N' ?; Y2 k: \5 v) s% P& J# p" c .active_low = 0,+ ]4 o8 o, F/ q, K
.gpio = DA850_USER_LED3,4 q, Y2 m: O: }% }% w8 n
.name = "user_led3",+ m* j: I4 c. _, D
.default_trigger = "default-on",$ n; P1 p! [2 k* X1 ]' p: }7 F3 r
},
2 @. D0 w, z2 B4 J/ U g& I};/ E( R# C2 C1 _% _5 v8 M
; x- g7 l/ k3 C3 u6 Y9 [1 Z) }- gstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
5 Z3 T' n7 @) a5 N/ F .leds = da850_evm_tl_leds,+ G! O7 D/ G& e7 \8 {) t; g
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),
) k, W2 ? x8 V};
' s }! _) W1 N, o) e& T. P) f1 ~/ K2 f# Z; A4 F
static void led_dev_release(struct device *dev)
) s) [& i7 d, p7 {7 P0 h3 b( C{; T& s/ U# _) }5 @
};
! J5 r; T9 b- U; p# ~6 }4 B# H. R7 l, q2 F6 }8 p* A
static struct platform_device da850_evm_tl_leds_device = {
1 J5 {1 M8 a& @+ y9 U. ~ .name = "leds-gpio",3 d' r D' A) v: A7 c& B
.id = 1,$ ^9 E8 J) Z' U0 x+ C
.dev = {
$ v+ `0 @# \* F/ a! C' ? .platform_data = &da850_evm_tl_leds_pdata,1 G9 V' V. [+ ~- X- a3 f8 B
.release = led_dev_release,& ~: u. H3 \! {( G5 |2 b
}
) q% i$ c2 a+ M% ]$ `};
8 \% ~/ v* s; [. i
1 L5 a: c O) H& S) f3 z3 w ustatic int __init led_platform_init(void)
+ o% k5 a7 Z& K6 S3 V/ I6 d{
% o8 i% z( q( h2 }" s J int ret;
! x6 `+ S4 E! m$ Z8 M6 e6 w#if 0
8 o* B/ c& C. }, M3 D5 | ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);3 A! [6 J. D1 D0 E$ B) e
if (ret)
) T1 l3 G3 \+ v6 r; ` pr_warning("da850_evm_tl_leds_init : User LED mux failed :"0 a5 V( I! R* b2 @, [/ R; t
"%d\n", ret);
( N, k- M& c5 H# C, }( h#endif
& K2 J, e- i3 K" F" E h ret = platform_device_register(&da850_evm_tl_leds_device);7 `7 I# r! B$ K# W7 [
if (ret)
4 E1 G4 G, @" `; F0 q: [$ [5 r. C pr_warning("Could not register som GPIO expander LEDS");
9 X7 L! _) r" B! W$ }* U! J else& g- Q; F9 v' Q0 w& p
printk(KERN_INFO "LED register sucessful!\n");
! ~/ [ V; ~% r5 \
$ L6 J) E2 X/ L! Q return ret;
) K U% w" P. c/ R6 I}
: r1 U7 n: p% M$ g% ^$ @8 N$ \, {- Y/ b9 j
static void __exit led_platform_exit(void)& y& h2 r/ Y/ [' i4 p) ~! }/ @1 E5 y
{$ o2 ?: D; |+ J) [: U4 \
platform_device_unregister(&da850_evm_tl_leds_device);
- n; q: _8 J P" U M
0 @% ]) X7 ^/ [% H: ^ printk(KERN_INFO "LED unregister!\n");/ m" B6 S5 C8 V5 j$ y+ o
}
: q* V! h' [6 F' F
2 o; o" F. a) Bmodule_init(led_platform_init);
+ J- x, w* G6 W, p" pmodule_exit(led_platform_exit);3 m8 C9 G+ x; E" V$ d! j ]" K5 g
8 T5 v5 J% n) X& @; R" {0 xMODULE_DESCRIPTION("Led platform driver");
0 R1 O; m5 p6 N: E$ ~; |7 zMODULE_AUTHOR("Tronlong");6 Z7 m. ?! S& p5 k3 n! G
MODULE_LICENSE("GPL");
- T: m; D5 B2 X: E, {$ m& m. J! C5 Y# y. A; B9 x
|
|