|
|
求大神给下面的程序做注解,请稍详细些,谢谢。; ^- X f4 z& M* `, m
#include <linux/init.h>! g- T! r* |) ~3 X( {+ G
#include <linux/module.h>. Y6 d* g( a5 I6 }
#include <linux/kernel.h>+ J) \! S! n1 q
#include <linux/types.h>
4 _0 {1 `+ U x$ A: {#include <linux/gpio.h>" x: q! {+ x y! M: Z8 u
#include <linux/leds.h>
" D5 r0 z: Y/ ^#include <linux/platform_device.h>
5 Z2 A# M! _ J/ n$ d7 g4 {6 \
* X' @7 @3 R0 Z9 H#include <asm/mach-types.h># O3 ?* E; u. G
#include <asm/mach/arch.h># Y; x2 ~$ e. e+ u8 e/ \
#include <mach/da8xx.h>
+ Y( e2 t9 S, Z/ i4 M. `+ F#include <mach/mux.h># T6 ~, Q; R% U! V% |
8 ^& ?) S8 L3 S/ Q M
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
9 ?; l, N% P7 s" I2 }/ h, `& z#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
# |7 @+ T( |) i1 z. G#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)! I! Q) O! y" p6 }: f' s7 }
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2). N8 Z& q1 Y. m2 b
# N! n5 L8 `- s5 g
/* assign the tl som board LED-GPIOs*/$ y; O8 Z# c( o6 w) e& V, U; F* y4 |
static const short da850_evm_tl_user_led_pins[] = {) ~4 R7 g* u+ [% D) v
/* These pins are definition at <mach/mux.h> file */ K5 P Y( n& a( q- J+ V. w9 E# @
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5," u- M X5 t7 T/ Y. `8 m
-1
4 N! n0 a" g( o4 g};
6 j: t- p* g0 T) e) S3 P5 Q9 j' H3 D9 M1 Z" Z
static struct gpio_led da850_evm_tl_leds[] = {
6 [" b- x$ a, n$ w } {% X# A# L; o5 d. E
.active_low = 0,' V5 @# A6 T3 R. K* M& n$ e
.gpio = DA850_USER_LED0,
. j1 L# X( ?. r, `: A .name = "user_led0",9 ~, o! P! ]/ \3 V1 p6 s4 u
.default_trigger = "default-on",
' K- j3 l7 x2 Q( w* i }," i4 w2 e' S5 I( N, @+ J* T; p- s% q3 s
{
8 x; x* i [% T6 |+ d5 ?" D .active_low = 0,
4 ?' z( e* C( b9 E$ o- g .gpio = DA850_USER_LED1,5 j3 F7 e. w7 m6 H9 E
.name = "user_led1",% Q& ~5 T1 y/ e6 T1 |% z/ R3 e6 N
.default_trigger = "default-on",* ~3 a& ]5 O6 j+ W7 m; f0 Z2 D% b3 i
},
. u2 t3 j9 s# T# d i9 a% M {, d6 n/ s/ D( {9 |( J( ^8 ^
.active_low = 0,
4 I' c5 L. C8 R. B .gpio = DA850_USER_LED2,! _5 F# @$ d% M9 ~, W" @3 A
.name = "user_led2",, R0 V! q M' W9 E& F# d% W4 D! C' M$ F
.default_trigger = "default-on",
! ^" n8 ^/ C# N {+ ^ x },
9 b9 P8 y' p0 b! a {
, l$ m8 e/ }. Q; N* h+ r' v2 C' B- n .active_low = 0,
: B2 |2 F) q9 S8 [8 r .gpio = DA850_USER_LED3,. G: R* @. n/ j0 ]
.name = "user_led3",
. \3 r! P( c* o; Z9 g4 A .default_trigger = "default-on",2 O R; Z' m3 O/ E* \ T5 I/ y0 o5 _
},
$ F0 a9 j1 [* z) ]9 k T) u};
7 h$ @& S! R- R2 }5 F$ e" x
# O7 R' r) Y# `% E+ ?9 ~static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
# _0 E! y- T; R) C .leds = da850_evm_tl_leds,
; ~8 u7 ]& c# F5 Z* I .num_leds = ARRAY_SIZE(da850_evm_tl_leds),6 ^8 E5 S" h" N8 `" D
};
) H3 S" i8 |0 p2 N' f% o5 K, R& ]% `5 p& D9 y
static void led_dev_release(struct device *dev)8 k6 v' G! p: B( k1 k( g8 p
{4 R% }8 Y5 w; {5 x" G7 h0 t
};! h5 e$ i {8 i* c! X: T% e, U
1 i, H# q" S8 E0 r6 t& a
static struct platform_device da850_evm_tl_leds_device = {8 X v3 w$ x& r! ~! x8 E/ g- n
.name = "leds-gpio",
2 P$ b O3 o: H$ k" Z0 A6 ] .id = 1,
b+ q& F" l" k: `% o |4 d# h' _ .dev = {
$ x/ c5 z$ w+ S* I# R! m1 M/ W .platform_data = &da850_evm_tl_leds_pdata,
# _) C9 Z2 _* r .release = led_dev_release,* E1 _ y6 P" e/ v/ C
} m- v* B7 q- z: U2 D) G& M
};
- W* P, K4 Y) y/ g" k* s
) ^. Z! I8 Q9 D+ x3 |* fstatic int __init led_platform_init(void)
$ _& n& `; `( `{
5 G0 T* p* A, t2 I s int ret;2 `/ ?! [/ ]# `) {( |$ b) h% f2 a3 v
#if 0
/ ~$ T. N+ Z& R5 P2 ?- z5 O; w ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
0 X6 n* o+ G0 B: r( b. T+ y9 E if (ret)/ S, `# c3 _- T: R
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"' o1 a5 l8 I8 h9 v1 R+ z
"%d\n", ret);6 ]5 g$ ^, s$ ]# X8 L& |
#endif: k. V" a6 y; I% `, i& t
ret = platform_device_register(&da850_evm_tl_leds_device);- A t8 r) j L. V' y
if (ret)
; \% n( K, T. O/ L$ P6 h pr_warning("Could not register som GPIO expander LEDS");
7 }2 w+ H: w$ U! [1 A! ~' q2 D else
4 ^9 Z( ? m; p6 f7 ?: h! ^ printk(KERN_INFO "LED register sucessful!\n");
" _0 H( _: V4 Z# ^8 O$ H+ J# Z5 [) v
return ret;
) E% e7 p# ?* @5 q& e: {}
9 G3 q& _% G6 ^7 A& U5 ~8 N& {4 e t; A/ m. k' `
static void __exit led_platform_exit(void)- q' G( i, l( C( {: L
{9 C0 m' X. A0 A0 P
platform_device_unregister(&da850_evm_tl_leds_device);- U7 Z9 z, Q5 ]4 j; O
+ S$ h" o1 c S. q) {4 v% { printk(KERN_INFO "LED unregister!\n");0 V; E/ z1 ]" B9 ~7 S* X- O( K
}. l! {$ l# A% `) M
, M. ~! [0 Y4 G4 k8 f# v X
module_init(led_platform_init);
* n& M0 ], @$ c% l: c' i0 I/ A9 imodule_exit(led_platform_exit);2 W6 V; x0 q- L8 e. B: ^* ^- Y
( M; a' W! c( W: w/ \7 IMODULE_DESCRIPTION("Led platform driver");
9 o( e9 j- t5 O1 [, `: iMODULE_AUTHOR("Tronlong");
6 s6 Y8 M: D/ y; L' i9 c8 HMODULE_LICENSE("GPL");
, y' v* j* \! g5 b3 C" Q6 E: c i% ]. t6 ?; v" g- m
|
|