|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
4 y6 m5 y' J4 j; ]#include <linux/init.h>
7 l f# q* ?& K#include <linux/module.h>% d5 A7 N$ e7 j3 E8 i
#include <linux/kernel.h>1 x" x _. l' {
#include <linux/types.h>
4 R5 j# Z( W' }5 P7 k3 q; V/ Q#include <linux/gpio.h>. G+ U; Y2 E2 R1 j1 ~$ D
#include <linux/leds.h>
0 I8 w' ^, F- S- d! _#include <linux/platform_device.h>
( n; c+ o; U: E% g. B! O) z
. b/ }7 t# E- H$ [8 b0 r#include <asm/mach-types.h>% Y) d- z# I, H( ]" d& R% o
#include <asm/mach/arch.h>1 t& Q( W, o o/ y3 t5 w
#include <mach/da8xx.h>
J6 Q" s$ A. P# t9 t, |+ z#include <mach/mux.h>
6 S- P. @, Z s! M9 Y( l
. D4 o. D# o6 ~/ w" U5 n- }# w#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
- x( ]- m% W- ]+ x. ?#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)2 v: X! A8 C" u V; y
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
3 l+ b, ]( m3 Q a" ]/ u4 J#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)1 E, W- w# k3 a; m/ k1 e
/ }, I, Q8 B/ B0 \/ U5 D/* assign the tl som board LED-GPIOs*/) Q7 H5 _! F$ H g4 `# n
static const short da850_evm_tl_user_led_pins[] = {
' [( C7 F, B1 b2 T /* These pins are definition at <mach/mux.h> file */
/ g& P- j& W: `" s/ m& F { DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
+ u$ S& _+ d2 z4 {8 r5 w -1
/ X. [# G2 X4 Z) h# N2 J) ?};% `7 [) ^8 r, t# {; ~! x8 q
1 F1 B3 K) s/ Z/ Z( h' D8 m* `' H
static struct gpio_led da850_evm_tl_leds[] = {' K' X8 _9 K7 L9 b% k) p& D9 N
{! @% y+ m3 I4 B/ A2 k" B, {/ `+ H
.active_low = 0,
- q) \ b5 [7 o$ T. q/ Q .gpio = DA850_USER_LED0,8 o# [* @$ c( r( v) J" J/ r
.name = "user_led0",
2 i7 Z6 Q* z# ^ ]9 _ .default_trigger = "default-on",& s+ v6 B* w3 L( \
},# a/ C( `, q0 V0 Q, r3 t; S: K$ c
{
5 K' h# b) b6 r5 \( O! l2 e( o# ~ .active_low = 0,6 f$ r" p; Y8 N( K& ]" O
.gpio = DA850_USER_LED1,
G) ^+ f3 m( V% |# ]0 O( p2 o .name = "user_led1",7 m" [6 Z" c1 n. Y8 F- T% V* Y* w7 w: P
.default_trigger = "default-on",4 y p1 d" w b! U1 P4 h
},0 U {) a) n7 \, m
{
3 z) v/ q0 Q" f( ] .active_low = 0,( J5 k4 S$ y: S W( m. W Y1 K
.gpio = DA850_USER_LED2,
* w# D$ x( C- G5 W( ~1 O0 ~$ i. j; h5 w& m7 a .name = "user_led2",+ i* e2 c/ l: R8 F1 k5 X# _. S
.default_trigger = "default-on",
2 r# [: j G: a+ r# u; l },& ?0 X" U' l. K3 u
{* u1 |9 w1 U( _
.active_low = 0,' A8 K: s! [1 c3 E' z- G
.gpio = DA850_USER_LED3,& f' y" K+ \6 k# L. m. @
.name = "user_led3",! M5 F, \2 V: X- F- k
.default_trigger = "default-on",# s' h2 b5 \- I3 {! r
},
8 C. `- _% w; W0 _7 j" v6 b% x};+ l2 w9 Q, A: Y$ W* _" N
. S6 c7 y: a" x }$ }7 A. }1 m3 zstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
1 E2 Z$ W: u- ~2 D6 K; }) x7 k! { .leds = da850_evm_tl_leds,
5 p7 A4 R; k" e% ^; L" a! C .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
2 B& G7 R7 l' f! ^};
0 n2 U& v5 Z2 d- h6 ~6 i
- e0 M9 n$ g! lstatic void led_dev_release(struct device *dev)
' q4 {. |% i4 q7 }) e' Q{& A: n; n) u: W- ?# U
};: K7 Y6 w" q( I
, G1 ^6 w4 M# R
static struct platform_device da850_evm_tl_leds_device = {
1 S, L5 d* J! b7 H( G$ j1 v .name = "leds-gpio",# g% n; Q" ~& K4 ^7 o! A; N/ b
.id = 1,! K: d3 `" B9 f+ c3 ?5 J' F) F* J: x
.dev = {6 _* s3 J% N& \* X5 X
.platform_data = &da850_evm_tl_leds_pdata,
4 Y3 [7 O$ T( q% V9 n I# w8 d T8 ~ .release = led_dev_release,
% l2 O; `0 [$ u5 J+ U, @5 Y0 R) F }
+ l6 X: n% p9 B2 ]};
7 [2 D1 L9 ~' }: b$ o" f, N$ w. L! n# `/ _' b1 w1 x1 G
static int __init led_platform_init(void)) d7 l) [ {7 Q! d g, z5 o. d, i5 f
{
5 a9 l% j7 J9 Z7 I int ret;
! m+ V$ g9 ^% H7 J7 V1 x#if 07 z! x! B* @6 L
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);# {+ ^- K; W* y# g5 u8 r! r
if (ret) C' H$ b. ?3 K- p$ ?2 p V6 S
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"% b9 Q# M! u3 U4 T G
"%d\n", ret);
& i6 v$ u9 n, I$ ?2 C0 x* o t* e#endif+ `, z; O% H5 n$ T; ?4 C8 C
ret = platform_device_register(&da850_evm_tl_leds_device);5 i3 R6 x5 v& S8 k
if (ret)+ o! ~7 f6 o( ]- p' `! U
pr_warning("Could not register som GPIO expander LEDS");( `" p* j8 G5 N; {6 _# o" R
else
( L4 y* {# L# j* {2 w% D printk(KERN_INFO "LED register sucessful!\n");
W( ?3 z2 C' f9 O% h% Y% A6 _8 F) A6 g2 r0 [
return ret;
% J6 o* [) Q4 p$ I" X2 V}9 q# q7 C |& g% X( C2 {+ x j
2 }/ \/ M6 {) v
static void __exit led_platform_exit(void)* m2 I9 V9 s: N# ?" ^5 k/ Z+ Y
{
" N- u2 b( Y2 {: @6 ?, r platform_device_unregister(&da850_evm_tl_leds_device);
- q, g4 q/ |% @& V: p
\. A A! X, ?; Q, k$ e printk(KERN_INFO "LED unregister!\n");: |* U- V5 w7 `9 K) @ j
}3 |) I$ T" ^. I5 d% B
8 q# `* P) ^% I
module_init(led_platform_init);
* L) M' |) k* {6 z7 G9 Ymodule_exit(led_platform_exit);
k6 F, q! B3 j# B$ O: {4 }8 Q* C! Q; p" H( L
MODULE_DESCRIPTION("Led platform driver");
: \$ m# I5 s$ T3 E, @" r# V! d# qMODULE_AUTHOR("Tronlong");( D& @0 `% |* G: d. o$ W
MODULE_LICENSE("GPL");8 ~5 @) _, g0 s: C/ a" I
( `; b& Z, y. G* W, w# b0 k: ]/ T |
|