|
|
求大神给下面的程序做注解,请稍详细些,谢谢。' z8 g) } M/ e# }( q+ o
#include <linux/init.h>! J& y# P/ {! G- a# R# v- ^
#include <linux/module.h>' X$ H" r, k4 O$ u+ f
#include <linux/kernel.h>
6 t5 d) e( ~; `: E/ A) w#include <linux/types.h>1 W+ s# n0 [1 T2 g
#include <linux/gpio.h>
/ ~ z4 K, i1 i" q9 b#include <linux/leds.h>. p7 g \, y% ]; y7 U* a9 w2 L/ [
#include <linux/platform_device.h>
" t- _9 j% ^3 H) \7 e6 V2 R" Q) {7 a; H
#include <asm/mach-types.h>; u. q4 w! D( t7 W9 n8 g( N# `2 M, g7 m7 l
#include <asm/mach/arch.h>
2 e% a* Z9 l# u- P7 f' e#include <mach/da8xx.h>% m. g- |# S$ s& h& y
#include <mach/mux.h>3 t& z- }: Y3 A2 L: w* Q
* R* e9 k3 h0 F: A* B: ~/ s2 g
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0); e5 w' V/ S& G& u- ?" |* O" V6 b7 R
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
$ \% G8 s: T% x9 R5 K3 ^#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)7 G4 B$ {9 [! G2 ^
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
( v5 W0 |9 l$ }0 L6 ^, D5 Z/ Y: A8 r& c% [, D
/* assign the tl som board LED-GPIOs*/7 J3 s, A5 `$ ^) G/ Q) ^2 g0 ?5 `
static const short da850_evm_tl_user_led_pins[] = { x; V% t) }& G
/* These pins are definition at <mach/mux.h> file */
5 k( n- u7 G- W. U! W DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
0 v4 v1 t% n' i$ Q4 H5 c3 J. M -1
; P# t, t& I1 Z! r ~};
2 Z7 A6 W7 f* ^+ S
- `: J( p6 F# `8 T u, fstatic struct gpio_led da850_evm_tl_leds[] = {: E' N4 w: e- N4 ^9 Y5 s
{
' j0 c$ h7 }/ t5 I1 ?: p .active_low = 0,
. V. k- a" @: ?" H .gpio = DA850_USER_LED0,9 K4 v& T6 V9 t4 _% t* O. Q
.name = "user_led0",/ Z" \0 O' \$ u+ o9 D) p$ G$ X
.default_trigger = "default-on",' _! u3 K0 P. k
},
9 ^0 R$ J7 Y6 y7 F& k4 S# z {
' O( @* {% g' _ .active_low = 0,
4 L) O+ T/ L- b P# `) S0 [ .gpio = DA850_USER_LED1,( ~/ J# `3 q! x
.name = "user_led1", ]( X& ^( L. a5 j" c* l& E
.default_trigger = "default-on",
! {0 H( @1 Q0 Q) B0 q7 N$ F9 g/ h3 a" u },
( i* J1 F$ m. c9 {; ?. { {
+ X# F% I: U5 ]* `7 k: i .active_low = 0,9 M+ u+ s3 i* ~
.gpio = DA850_USER_LED2,$ ?" T4 E4 m* K( M& _4 G
.name = "user_led2",! P. A6 m' V! M: K
.default_trigger = "default-on",( B$ L7 J w& A7 b0 t
},4 C$ L+ o* `- r; |4 q" P7 `9 p0 U' {
{
/ m( m1 {! L. `) @3 q# R/ [+ r .active_low = 0,
9 Y: f7 t+ {$ q' v .gpio = DA850_USER_LED3,
0 W4 h( \) n8 E3 {) d1 f) } .name = "user_led3",# s1 w, K1 p$ x, X+ f9 e
.default_trigger = "default-on",5 u& e9 V0 r1 d! E% T5 }- ?' O3 I
},# X- N6 p8 a( J2 }
};
7 j5 k2 D% a; c. I$ f; a: q9 X8 f% i0 s9 a8 C' C& E2 {: v" v
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
6 d7 m; N' E( d( r [ .leds = da850_evm_tl_leds,/ Q: E1 _/ v* A" }; R8 z: }
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),
# Y# c0 \9 {+ n! a3 y% T};( [; x0 W" F2 n+ h
7 t, I0 w; _8 ^) O2 E( P; d0 v
static void led_dev_release(struct device *dev)
' P/ F. Z! r. ]{* L9 B& m; l% {& ]% Z, t. p
};
9 q5 X& w% T* G+ X: b4 ^- X
* O9 \+ H7 @+ C7 Y* qstatic struct platform_device da850_evm_tl_leds_device = {
8 t4 V7 r: e6 Y; \7 J/ D .name = "leds-gpio",
e* b" Y" \4 [ .id = 1,) S; _( c6 ]. w9 R; Y
.dev = {& G5 ?- T) O4 k; W& W
.platform_data = &da850_evm_tl_leds_pdata,2 U3 Y/ Y: z- t
.release = led_dev_release,
1 a# L: a1 g4 {% X; b }
9 r. h H- g( m( L3 ]+ q7 S};) b( a) G6 m& R4 Y: ]
' R7 ^0 |. b8 c$ Z: U* _static int __init led_platform_init(void)
1 X: ]. l, h m7 ^& s' N{
+ N! N% v0 p: Q' j+ s9 K" k int ret;; [! p8 h* ^5 x
#if 08 B% G2 c2 L: a5 _' Y' N/ t6 p% @
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
& r* \; a( x7 a6 W/ B if (ret)0 D9 Z# o' R* X& Q% L" R/ j
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
! g4 N- e% E* |- Q5 x. |3 e7 i# ] "%d\n", ret);* d) F/ _0 [- [4 S
#endif2 z Y; ]: V# X% b9 X
ret = platform_device_register(&da850_evm_tl_leds_device);+ |$ e" E( S( H2 r- k+ Y8 \
if (ret)
/ ~) S( {" B6 P5 z+ l pr_warning("Could not register som GPIO expander LEDS");# D2 Y1 D4 p/ L$ D* C* N/ O
else
4 w1 K1 d9 E J: U ~$ T( J$ i4 P printk(KERN_INFO "LED register sucessful!\n");
3 {8 b- x* {5 E; l) V) Z1 H
7 y. E" [( K" f$ f) @ K& b$ p: { return ret;
* X/ v; n4 y/ p}& ^5 s8 [5 K# {* R0 r, A2 h0 ]
* `/ z3 T( m4 M' P; Z, kstatic void __exit led_platform_exit(void)
/ A: j9 P. D0 w1 T{
1 r E2 B) ^% p platform_device_unregister(&da850_evm_tl_leds_device);2 y4 s/ f2 e, c- t% ~& O
/ k5 c$ A, H3 b, i- V
printk(KERN_INFO "LED unregister!\n");: M/ Q# j$ t& t9 D0 I
}
% J8 o$ P! s5 ]$ q8 x# S; _
, t9 W- v/ X; g xmodule_init(led_platform_init);& {& `0 }% Q% ?) j R6 ?
module_exit(led_platform_exit);
( D5 e8 j k, @0 X' n) }( V$ O% @& e: z, ]/ D$ I x) g
MODULE_DESCRIPTION("Led platform driver");
0 s, c B! j7 h+ XMODULE_AUTHOR("Tronlong");
1 j X$ I6 r$ U$ x1 wMODULE_LICENSE("GPL");! t- y, `( e: }2 T
7 |& s8 c( D+ t& `2 w, @- } |
|