|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
# L6 v. J8 T: L% E' i* r2 n#include <linux/init.h>
4 k9 Z S& ^ C4 |+ i& D#include <linux/module.h>* X; h$ F* N- O8 L Q- |
#include <linux/kernel.h>4 ^$ {/ y5 c- d. p
#include <linux/types.h>* o8 y5 \& E/ j* I8 M* L
#include <linux/gpio.h>
# Y. P5 p6 ]- m#include <linux/leds.h>
4 q9 t9 A1 }: y. B6 V; g: }2 k#include <linux/platform_device.h>
# |8 s+ A/ m6 f1 y# w( F3 D" c; Z* T' l
#include <asm/mach-types.h>2 z+ P0 E( \9 p9 D; }! {: m1 o, w- q7 \
#include <asm/mach/arch.h>
& @6 t/ q" f4 n' x/ \; L#include <mach/da8xx.h>
/ N, o( K; t f0 P& p# m' A2 |+ \9 H#include <mach/mux.h>; y; e U) Q" U& ~
5 k- w! f$ k) E2 u. e# {- m6 ~#define DA850_USER_LED0 GPIO_TO_PIN(0, 0): a. k5 j5 r" ?. L
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)7 Q) L; g. E4 @& t$ r
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)+ M! b1 D: m, Q* a# d- S
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2), |/ c* h$ u( }2 ^& r8 f
9 r* O) T" M" u# h/* assign the tl som board LED-GPIOs*/( D5 ~3 M* g$ P. K% o' M) [
static const short da850_evm_tl_user_led_pins[] = {
! b, u& Q9 U s+ `4 i /* These pins are definition at <mach/mux.h> file */
# ^8 M$ _! J' Q _ DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,4 S. t. P! w5 D9 _; W
-1
5 {# z, r: c3 E+ N# j}; F6 R+ Z4 w; `0 }5 C
& P9 a- m% ]( m9 N1 T
static struct gpio_led da850_evm_tl_leds[] = {
( e% B$ V9 k; [0 M6 W9 e6 [5 Q {" w P) m& w. E: D& W. n3 Y
.active_low = 0,4 ^5 t# L; e# ^( p% d6 z9 v2 k
.gpio = DA850_USER_LED0,% B( U/ _: N) }, N& |
.name = "user_led0",/ g* K d/ v# S8 q0 y h
.default_trigger = "default-on",8 Q, H8 i: J r4 O
},
{4 Q3 r- U9 w# P# e {
5 x+ O& C! O, P/ f1 K .active_low = 0,7 N! D8 g9 ~! a# ^6 ?! d+ ]6 P
.gpio = DA850_USER_LED1,! ~ n o8 J) p4 S+ V
.name = "user_led1",
& q$ h8 v Y3 S% h .default_trigger = "default-on",* o) j3 S2 u8 a( j
},
+ W i$ E3 a. ~8 M5 u# b {1 N6 W+ K% j% w! G b
.active_low = 0,% t# l- P+ D! C' h3 A7 D% k1 P, s4 f
.gpio = DA850_USER_LED2,
+ x( y1 b- o8 ^4 x .name = "user_led2",
! e& P; x) J1 n$ z .default_trigger = "default-on",2 D3 M7 n' e/ I
},
6 W0 L+ w+ ?! e t. t4 t {0 |! o9 ~( Z: m7 E" P/ [0 Z
.active_low = 0,
3 S0 g2 U2 ^0 ~ y8 I9 u .gpio = DA850_USER_LED3,
+ B, X" e3 Z/ @ .name = "user_led3",
1 ]( f6 g: N m/ J! t .default_trigger = "default-on",# O- L A2 V! n& P M- q- M/ S0 |
},
. A5 w, t1 R {$ C8 e};
" v. X( o# z) j4 s% [ `4 i. r+ y
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
$ m7 k3 a% L4 E .leds = da850_evm_tl_leds,8 y- P" v4 w0 r ^
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),
: O3 o0 i3 E e) Y& f2 R};, H0 V" d) T: X/ M) V: m0 x- r
, F% l9 S# k: _( P- n* |( U1 w: Zstatic void led_dev_release(struct device *dev). j& F- e) Q6 v8 V& [
{, }9 k3 W" ?" U5 d* ]5 D
};
7 A# Q! ]9 c. }9 f6 f9 P; d" ^" O; n+ _( r7 I+ O
static struct platform_device da850_evm_tl_leds_device = {
0 k' D& ]9 P; C2 x) [$ `* y .name = "leds-gpio",
7 N2 R" K+ i9 l% ^% H# [$ W" F .id = 1,: h* ~0 ?3 I1 X; N" P( P
.dev = {
, G6 w5 O& F2 B$ \ .platform_data = &da850_evm_tl_leds_pdata,- P! P* s) y9 i O% E/ s q% _" A+ a
.release = led_dev_release,
9 X5 g" K: m/ m+ b }
/ w) P+ d% k @8 R% ]/ N6 z};
1 Q- Y* A" H5 C, H! N; Q+ O" l- j6 }) {; {: L: C7 m: I
static int __init led_platform_init(void)
( v' _/ `, Q: ?' `' p8 Q{6 N0 h- O. s, @5 z# b$ i
int ret;
1 L5 u+ W! @5 _& m$ T' x3 C#if 05 i- f h5 ?! l8 ]9 G
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
6 t0 ^; u8 d, C9 i- Y {2 x- T V if (ret)4 }+ t a: a; z6 w' z+ `4 L
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
, D7 F9 c* X: o: y: u "%d\n", ret);4 Z& ?/ R; d! x! e9 Q( W
#endif, i6 a2 `8 M. G& g% p; n
ret = platform_device_register(&da850_evm_tl_leds_device);) X$ q1 F+ |( \( ~' Y
if (ret)3 }1 c; J) B6 S/ \" ]: e6 x/ ~$ u5 \
pr_warning("Could not register som GPIO expander LEDS");
! C: x1 n- @, Y else3 ~6 e. o/ O# V: V: I
printk(KERN_INFO "LED register sucessful!\n");
( r" v" }7 p: Z* r0 |$ _* D" H6 k, t
) m( }) Q; Z, e9 f" ?5 G% {3 m return ret;
8 X2 a6 {5 G$ _" s0 n$ ~1 P3 D}
4 b! _3 t' l4 P2 J5 s+ a7 Y( k" J5 V2 I0 {* T2 Q6 p2 Q
static void __exit led_platform_exit(void)8 G7 Z) b" ?. ]6 u, n; S# M! `, J% B
{* a I; i2 S9 r: e8 V
platform_device_unregister(&da850_evm_tl_leds_device);
0 \7 Y% {! ?) O$ U7 ^; J7 a9 t9 Y& a- m! y& S3 \" Y( G
printk(KERN_INFO "LED unregister!\n");9 ]' f3 d2 c! d5 O& u+ p
}% h# w7 v0 U: @3 W( Q
, t' z9 l& @' e2 t3 S" Vmodule_init(led_platform_init);
" g6 }' g1 W" u+ omodule_exit(led_platform_exit);
1 @5 W: Q5 f, r/ d0 i/ k& r" ~, ~
MODULE_DESCRIPTION("Led platform driver");
& {; F/ l+ L6 c3 W% lMODULE_AUTHOR("Tronlong");0 ^1 }: i3 x4 ^1 L; u# |5 l5 v
MODULE_LICENSE("GPL");# [7 d3 B4 S. f# W" F- n' X+ n1 A
9 `! Q% A8 ~$ P4 T3 k1 [
|
|