|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
8 }+ p. F5 s' c9 u#include <linux/init.h>5 o5 f' `& ^1 Y
#include <linux/module.h>
4 G5 n! S6 I6 ~; H) Q#include <linux/kernel.h>
: D- x0 K6 p0 A4 X7 p#include <linux/types.h> j. H$ |0 ^- w; h4 m0 y
#include <linux/gpio.h>3 N) H' ~9 O: R' D
#include <linux/leds.h>
6 R( K" o+ D. E( F+ g#include <linux/platform_device.h>
. k$ |( j* M; g% |3 v) n
* S; F w' P) R& q' y9 w" N& m#include <asm/mach-types.h>, L: x5 ~% t& n4 o# i+ ?! `0 Y0 A
#include <asm/mach/arch.h>
5 y6 c6 r$ a: o+ E9 k1 I& n4 x#include <mach/da8xx.h>
( h; Z' U8 {0 V1 P$ C3 z; u0 |#include <mach/mux.h>, `' T; }# `' q" I+ l
3 n2 M5 q. C( D+ Q/ ^/ v4 @
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)9 O, C0 \3 E/ V7 `( v
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
: N2 a; e3 ]$ W#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
^" r* { ^; g8 p- M: f& {#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)' @) a2 s5 G0 u$ Z
" n( D- ?! u$ g( I1 O% K5 O
/* assign the tl som board LED-GPIOs*/$ F* u! I+ s& q
static const short da850_evm_tl_user_led_pins[] = {$ L2 F8 s8 o# i2 u" n' r. d+ C' b- C
/* These pins are definition at <mach/mux.h> file */" F ~1 I' R4 ]+ M" h; j
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,! ^& |6 Y' M) ]& b
-1
$ E. y- A" i ?0 L M9 r4 U; j};
$ T7 }4 M& L5 a. X1 D6 \ w) g9 S
1 P, w# ]$ A+ o( Tstatic struct gpio_led da850_evm_tl_leds[] = {
9 p" p$ b- J ?& k3 W% B' u y8 i {4 _$ n: J0 F! J" S- q
.active_low = 0," ` w) g" ^* G1 J, w* m/ [
.gpio = DA850_USER_LED0,; f" P, T- v) _. {2 ~" R
.name = "user_led0",* I! s% d5 U3 I% F9 g
.default_trigger = "default-on",
' j: I' b$ b: E; | },
% q1 y3 w4 s7 {. M2 B. f {
+ ?6 S. [; h2 _. j! b1 ] .active_low = 0,
3 Y* a* U- Y1 b- F: c .gpio = DA850_USER_LED1,
- U- g+ X. D A0 ~, U I .name = "user_led1",
0 M8 U- H l* k& n0 }6 Y .default_trigger = "default-on"," _% }: n0 e4 A3 a- v
},: D0 _. Q" }* m6 b9 i' s% i, s
{ E% R% o+ n7 _& w1 E
.active_low = 0,
& [8 n* E: ^- k .gpio = DA850_USER_LED2,/ `- F$ I' T* m" R' L5 J" q
.name = "user_led2",
! h9 J! n7 t0 ?7 R% H" l% V .default_trigger = "default-on",
( P- Z! l, B' B) ^, ?3 A: t },) h! U8 H1 @- d
{
7 b! t2 }. H% c }6 f7 P .active_low = 0,
% U2 u' a1 W0 l1 e$ P .gpio = DA850_USER_LED3, y8 Q9 \' _* X' W( C
.name = "user_led3",4 [ g8 K4 j* h+ L
.default_trigger = "default-on",9 W: P6 Y! z0 p" D. |5 |
},
$ v7 I: L+ R4 h, v};7 }6 |* E, B7 `) i
- _% V$ H1 ^0 B' J% l3 c1 S8 F" [
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
8 C' a2 c# m" F0 H/ Z .leds = da850_evm_tl_leds,0 z- S1 {- E5 c' f m$ m$ d+ i- I
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),
! t' [% n: s/ G8 q, ]3 u0 f2 C};
4 z( l$ s+ `8 a/ s: w# a# X* ^, g
static void led_dev_release(struct device *dev)
/ C2 `0 u4 F. E, j{/ Z0 N2 Y8 B9 a# z* W; g" s
};* Q$ `* I* H5 h/ ?
/ @0 M. [/ j* K: I$ X# Z" Estatic struct platform_device da850_evm_tl_leds_device = {- x' W1 f' s; M, ^7 {) M6 \ h: \
.name = "leds-gpio",6 z7 S* \- m% _- V1 _& B
.id = 1,
4 }; Z2 U0 H- X L9 ]4 h. L) \ .dev = {; T' x" W$ R" q% g. N* v
.platform_data = &da850_evm_tl_leds_pdata,: {3 o Q# W; t5 O% G) D$ E- h
.release = led_dev_release,$ g" S4 r+ S5 g/ i
}( m" J3 H1 u- X2 `( J
};% i) X" E$ L2 v* c
# m1 g' f2 Y) k. a5 V6 w% x, _static int __init led_platform_init(void)
8 V# a' i& s5 @5 P{, G1 o2 o g) P9 L/ J& }
int ret;
! k) [' G' `$ j/ G#if 0
9 h) q4 O9 V$ a+ ]" K' I- G ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);( J& p* A, a5 P4 F" F
if (ret)
* D! X1 X. T/ y, H8 Q pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
8 ?6 _3 j; C5 @. }% b6 [8 G "%d\n", ret);
r* n4 s' {* O u7 o#endif
: ?5 ]: H2 p5 l3 d J5 D ret = platform_device_register(&da850_evm_tl_leds_device);6 p$ X# K; d0 L9 v
if (ret)4 }3 l9 |5 s2 y, v5 X: p2 S' }) y
pr_warning("Could not register som GPIO expander LEDS");
; ?( R5 {- D: h, G: V; }0 G( b9 k else* H* U v' |) _2 V# K
printk(KERN_INFO "LED register sucessful!\n");* g- N1 S. n$ N/ q
1 w6 G1 ?& O7 b2 C return ret;
. r0 F' X4 e Q) q) e" @8 M}0 |; a4 V3 b3 d+ Q. \# [' T
% Q) _+ }( I4 L! Y2 v3 v7 g
static void __exit led_platform_exit(void)
2 Q2 V$ w; L' @% U: K$ `& h{% k$ ~) R6 E: r; @( r2 z4 M% X
platform_device_unregister(&da850_evm_tl_leds_device);+ S/ ]8 s N& x# S! t$ n" W. j2 P
4 M$ g) u; w- L) V* i8 o9 T printk(KERN_INFO "LED unregister!\n");8 N. C& c! a5 J" t
}
; g1 X6 z0 S3 ^& u) L( S# _/ |
* S" c6 a/ E) I0 f ~* |: T$ Lmodule_init(led_platform_init);
1 Y) r! s# u6 A9 d0 nmodule_exit(led_platform_exit);4 V+ }+ i' I/ g( m: C
# G0 U( f7 F9 ~3 S! i4 z; \MODULE_DESCRIPTION("Led platform driver");& T( j& ~6 E1 _: W" M* b: f
MODULE_AUTHOR("Tronlong");1 I3 `+ H/ K: S% y: v/ l* K" K2 w3 o
MODULE_LICENSE("GPL");/ d+ s6 p) O& j6 x( ~! B5 Z
! G* b" F! O. p6 Y4 p5 f# | |
|