|
|
求大神给下面的程序做注解,请稍详细些,谢谢。, s1 `% i& h7 p% f3 f4 b) h9 d
#include <linux/init.h>
; D7 k& f0 x( w Z#include <linux/module.h>. ?- j9 I- Z$ z; m' N' g# e
#include <linux/kernel.h>
+ [. ?( }9 A& y2 ?4 q" C' j- a" o- n#include <linux/types.h>
L8 w7 q6 G! Y& K) h#include <linux/gpio.h>
2 M0 J* _4 O: o* ]6 d* `#include <linux/leds.h>
7 B( f/ Z2 Z- |& S#include <linux/platform_device.h>1 K4 A5 q) ?/ X, f( I2 X e6 {
' ]; |( e" |% _4 {#include <asm/mach-types.h>, i9 f: w# \: j9 X* s! `3 W% d' X
#include <asm/mach/arch.h>7 B5 [! _6 I0 x- A6 T
#include <mach/da8xx.h># q' \1 a5 x- t5 c! X# g
#include <mach/mux.h>; n( @4 n% c1 D* Q9 Y
y7 D8 |& S' Z/ N- i% i#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)8 I. a' h: W6 f! g8 V, p$ d4 T
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
. h( d2 b& _& C5 [- z, K( G. {% H#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
9 M; O5 m8 P4 R% k6 U8 c#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
L+ W1 V( F5 g, k6 ?3 y( |+ G- e/ q' ]* O/ D b' x1 R
/* assign the tl som board LED-GPIOs*/! B5 Z+ x& e: Z9 ?; j; a
static const short da850_evm_tl_user_led_pins[] = {8 V1 f' K$ z9 W3 u8 ~1 A$ k
/* These pins are definition at <mach/mux.h> file */* d; k9 C+ n$ ~ h/ X
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
' q0 Q% p5 W& E8 M -1
5 L: z# \6 a' y' [2 I I; y};6 P* s3 }" l* t% M$ H
' q8 k8 L d8 G1 Z* b1 Rstatic struct gpio_led da850_evm_tl_leds[] = {# W$ }* Q- H" _0 d. C5 l
{# A+ G0 R# F$ q2 [4 H' F C
.active_low = 0,
! Q% U$ @8 j( C6 l; `! L( Q; N2 g .gpio = DA850_USER_LED0,
7 ~$ @! E* V8 q3 t5 D& S3 Y .name = "user_led0",; T7 p' J9 x4 c1 {- Q
.default_trigger = "default-on",
. z. e4 `5 O" C/ ]5 W },
+ I! g% U `- y1 s {
, z. r) n# n5 N5 o* \1 `9 j3 P" H# \2 o .active_low = 0,% }! v! {6 ?6 X* b, \* M
.gpio = DA850_USER_LED1,; ~( f$ y# j$ d9 D3 h, f U) L8 }
.name = "user_led1",
2 c) O+ G* g5 t3 e% { e .default_trigger = "default-on",
( v$ n W! V4 F. p1 ? },4 L ~7 g# X! B
{: m. ]" |9 }7 K/ E
.active_low = 0,$ `* B8 H/ ~, V
.gpio = DA850_USER_LED2,
% ]& t3 C+ D z3 Y .name = "user_led2",- x6 B2 }" r9 z. h- s. V5 F5 u* s
.default_trigger = "default-on",# p8 u, y" ~% P; Z+ [, c: @
}," p: w1 ?5 S. J3 }
{
# t+ h( [4 B( D* ^6 t w% [5 p .active_low = 0,* ^% u' n9 Y5 k; ^# V }4 ~
.gpio = DA850_USER_LED3,- ~, D, t9 L# P% o a6 f
.name = "user_led3",+ e4 K- E' D: D# o$ k7 k
.default_trigger = "default-on",
' x4 w, P( o2 v: R7 H },& y$ D5 S9 Z( E
};. A/ ?! |0 @3 C9 s
3 l# w) N9 A+ ]: a
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
/ L9 ]- j! r/ z0 R% t, ^1 j- k .leds = da850_evm_tl_leds,# e+ ^, x3 Q! e( e3 W1 C: ]
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),% _: n: m" N* O6 K! ^7 n$ ~" L' }2 u
};/ X- j1 S1 w2 t! g
b1 ]1 ?) T4 [" q
static void led_dev_release(struct device *dev)8 U e( P; D$ \6 T% d! [
{" x! g, U+ r. z( m4 A# y
};
% q" T5 J2 K. h$ B" {' \9 d' t+ X. J2 W5 Y
static struct platform_device da850_evm_tl_leds_device = {" g# z! V6 C6 d; _' ^+ l
.name = "leds-gpio",
5 M' c7 k( m; C0 \ .id = 1,& q5 k$ ]+ I" d. @1 b% X
.dev = {
0 |/ f8 L4 D. \0 l1 J9 s8 l8 [ .platform_data = &da850_evm_tl_leds_pdata,
5 z3 K1 z- _7 b" X; q" ^% e .release = led_dev_release,, ]4 N0 O- F2 \ |* R( Z
}0 e' v: t& Z# Y( e1 ]
};
' Z% n7 X2 [( I
0 g. _4 z9 D; s; u6 @static int __init led_platform_init(void)/ o, c! D9 q; n8 A0 F7 I- q. ?
{/ F& C7 [: M' u1 {# B& `
int ret;
5 u: \) }6 Y& g3 r1 n5 v#if 02 U2 c/ Z: H8 Z. C
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);" B+ I+ C; t9 x2 w
if (ret)
$ i. @& R) X) ^1 n: k" W7 \ pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
S a4 e q$ ~2 Y% I "%d\n", ret);
7 _0 G/ i# R `#endif
! h( X# a) `) N. T3 X, a ret = platform_device_register(&da850_evm_tl_leds_device);
C9 ?; |/ k1 z if (ret)* V L5 j, a1 b1 i/ Y/ l# e
pr_warning("Could not register som GPIO expander LEDS");5 L4 E4 q, q! [
else
' q- u+ g% i9 u4 _$ H( t5 A printk(KERN_INFO "LED register sucessful!\n");
4 l2 M: @& d2 G1 U# V+ E
& u W' K9 h+ k9 E% I return ret; K* L' n$ ^+ `0 R$ l/ O
}
) t' I& @! Q" V" t' n3 S9 D6 E+ D( h( F
static void __exit led_platform_exit(void)
! m/ n& F ]' |2 k& q2 }$ T) P{- H. U1 N/ k0 }8 O8 f: O* A, o4 |
platform_device_unregister(&da850_evm_tl_leds_device);
/ k+ Q8 Q% i" v6 c; Q/ x' V& X* q1 H2 P4 `: {# ]
printk(KERN_INFO "LED unregister!\n");6 [& x6 a' k3 o/ J* I
}
' G7 c( g G$ \6 ~# M3 j# N9 F6 ]' D1 R P+ K6 f+ ]
module_init(led_platform_init);/ |6 W$ f0 `3 X* e; v5 k2 ~
module_exit(led_platform_exit);) h L0 W0 q0 u- b' x3 {! P0 k* t+ e
9 d8 Q' q% G6 s' A& J# w& vMODULE_DESCRIPTION("Led platform driver");
. a x2 }3 K% P2 |MODULE_AUTHOR("Tronlong");
( q% V# E) M& l( E3 Q; hMODULE_LICENSE("GPL");
8 N; n/ @$ f1 \* U0 w: y
1 t* Q# s |; y |
|