|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
4 ^2 x o& L$ q. a#include <linux/init.h>3 r7 {. i8 d3 K4 P5 Q. f; r
#include <linux/module.h>
I* {5 j5 E7 h z1 J0 j5 f5 D#include <linux/kernel.h>
, S1 F- a, u- g& l- c. X#include <linux/types.h> r1 M& v0 C5 ?6 v9 F; s
#include <linux/gpio.h>2 R P+ k$ @5 ]% w- m1 U
#include <linux/leds.h>+ C) T" y% y$ N
#include <linux/platform_device.h>
( K4 A- E: t3 m# Y/ E A: B9 K, [' U& {! i; `- ]
#include <asm/mach-types.h>1 {+ N+ h6 c' l. x; b2 K( {; a, \
#include <asm/mach/arch.h>$ f3 Q$ T# C* A- q
#include <mach/da8xx.h>" F( q0 @- N% i" m
#include <mach/mux.h>
* J& I; H: j5 W2 J; }, k9 h/ q3 ~
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
: ^+ r" o% }- q; r. Z% H#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
* @& m/ _" U4 L" d5 ^# `#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)9 ~9 W- W- o# p! t' {6 b
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
; D- z5 e: H5 p% y
/ M) Q% o# B1 {& z2 y; g/* assign the tl som board LED-GPIOs*/1 h9 h+ A! N+ P4 ^+ q$ a
static const short da850_evm_tl_user_led_pins[] = {
. {. o5 W7 P0 Y: ^ /* These pins are definition at <mach/mux.h> file */; |2 v- H. |6 c( A- |
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
1 _5 o" n- f3 Q7 ^ h -1- z1 k) I% M. z' r/ T, y
};, y, v) ?3 K1 Z' S( Z7 f. I
. D/ ~' i' B- y1 T+ }static struct gpio_led da850_evm_tl_leds[] = {
/ m# g0 N& L3 [. B( P& O {
+ T. }4 b; ?$ w) ] .active_low = 0,% w* R! h# e0 w: J
.gpio = DA850_USER_LED0,
( ?" u; u, x# s# R7 Q, J .name = "user_led0",8 I& R7 W# X" l- \* T
.default_trigger = "default-on",+ W; g& H4 K' v1 O6 g
},
* [+ M/ l$ ?2 y {
; y. Q0 Y3 M" X .active_low = 0,. V+ i: y" C& ] n* M
.gpio = DA850_USER_LED1,2 y1 W% U- M7 H( ~& n" j
.name = "user_led1",$ }) J9 q+ x) t0 |# Q6 T* E$ d
.default_trigger = "default-on",9 }& H' |+ }+ q' z! v2 }
}, w9 w8 ?4 I4 {/ f9 p
{% R. W$ a3 `! b; I5 U/ s4 D1 ~
.active_low = 0,- U* p4 I3 H7 c. x/ v4 b& r
.gpio = DA850_USER_LED2,; O7 W* `6 U* J! \" u- N/ M
.name = "user_led2",
8 i, l# v; B+ S. }; O. G* \& C! t .default_trigger = "default-on",
% K( `2 N8 S/ Z j# w( C6 r },
( l. }7 C1 Q2 H D) r' N {. R7 g% r% D3 I; Z; _1 X
.active_low = 0,
6 f' b, s/ c7 x2 a .gpio = DA850_USER_LED3,6 M" _' P$ n# s& Q
.name = "user_led3",! C! W8 ~5 ?+ O# T! m- X6 h" }
.default_trigger = "default-on",
. [1 v$ v! c( ]2 M, e4 t },
! V1 ?. q$ k2 |- c7 h! k0 Q# s};, n- P6 S: I0 z
/ B+ @; w7 l8 c: t/ dstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {) O) ?' e1 a8 P( q
.leds = da850_evm_tl_leds,- G: X8 I" |2 i5 G6 e
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),% i$ }% V6 Y/ ?. e$ v
};( F' h9 u8 ]: B: w# M# Z
% r% @4 | K3 T5 f' H5 a
static void led_dev_release(struct device *dev)! s- Z' ?' a' G) P8 K4 S% s
{
- q' v( Y- L# o* R3 y2 G9 K& x};0 w5 i4 `" v1 B: e
4 w) C: D: b% n* i' b: V
static struct platform_device da850_evm_tl_leds_device = { L8 _4 t4 J# A- c; P# T2 x% n" k
.name = "leds-gpio",
, y& F. R' f4 W9 g+ P; W5 L .id = 1,
3 ]) b7 ^# @+ i+ b) \ .dev = {) I; R' g& R7 _( l9 V1 ]
.platform_data = &da850_evm_tl_leds_pdata,
/ M+ Y) c& G4 }( o8 [. C+ n: G .release = led_dev_release,
/ q$ B7 \, G$ d$ _' E }5 `* S E& u9 b9 \
};
7 h0 ^- T$ a+ B, V
( z. n/ ^9 I9 ]5 O' p* p Kstatic int __init led_platform_init(void)+ ~! T; `* ?, ~$ _' d8 t" f
{7 v1 t7 S; S+ g( Y0 Y. g2 p- H
int ret;6 ? C7 V1 h- z- N; E! m- J" K" g, T5 u
#if 0" d; M2 w5 d! S% L" h0 e& ?/ U
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
N; ~6 U% G( b1 l4 N if (ret)% K- p5 R) P# `
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
$ {* v: ^# H( x4 W6 F "%d\n", ret);
# R9 U) Z2 B8 u- }3 m/ p# ]#endif
2 x. u5 w I7 |$ }8 N. n* \" i: ^4 K ret = platform_device_register(&da850_evm_tl_leds_device);
# j- V3 p0 s; A if (ret)" W) |7 W5 V2 I* A! w. `9 p- L6 v
pr_warning("Could not register som GPIO expander LEDS");4 |) C' _0 ` `% X7 ]8 L
else
- z, h% D: @9 {0 Q# ]: i printk(KERN_INFO "LED register sucessful!\n");
]1 p: M2 B( |' `( E- F: Z8 A$ O6 Y2 c! i- X
return ret;
8 @+ a- }7 R. u4 T' i6 g( M}
+ c) O7 k4 B7 n: S0 q
/ Q& i5 B3 v" ostatic void __exit led_platform_exit(void)
: l! @' s. K, l4 _' k2 y7 _{$ D' p/ C) R1 b/ @
platform_device_unregister(&da850_evm_tl_leds_device);
: ]7 I: L: _( X5 }8 M7 D i- z# v" d! [% i+ |/ p! ~% ?; d
printk(KERN_INFO "LED unregister!\n");
, w0 Z# l+ ^' R) V5 M- F3 C}" n4 r1 R' R# x( S% x% m X# `
0 x4 h9 \% Z! fmodule_init(led_platform_init);
6 U7 ?0 O( B% M6 e4 D! V, I" i: smodule_exit(led_platform_exit);
3 L7 p! R5 V$ U$ o$ P; u( I1 N) G( `
MODULE_DESCRIPTION("Led platform driver");
) ` |$ B/ \; C* |- s" Z- ~1 yMODULE_AUTHOR("Tronlong");8 u; o( X5 p* j
MODULE_LICENSE("GPL");/ S( q/ e4 q9 X, v
' r% r& x" z/ o, G7 N) {7 z |
|