|
|
求大神给下面的程序做注解,请稍详细些,谢谢。. F; h8 ^" ^' {6 N, i8 P
#include <linux/init.h>2 I4 |. P# u9 \5 J+ @* u7 ?. L
#include <linux/module.h>, q- }) L, T# \! {6 r
#include <linux/kernel.h>( d ~% z2 Q6 W$ _2 S
#include <linux/types.h>
1 y3 d9 e- z' ^, m#include <linux/gpio.h>
* n. e( M! q4 y# P C#include <linux/leds.h>
5 w: p$ B9 Y- W6 h0 D, g. M- y#include <linux/platform_device.h>+ r9 r* H. k1 }5 ]6 m7 M
$ @, ~4 ]- P, O
#include <asm/mach-types.h>
9 Z, k& J8 ~" p4 j#include <asm/mach/arch.h>
2 }8 ? @& J" y#include <mach/da8xx.h>" R* N. q6 z& {8 T5 C+ L5 T3 {# g4 ~* {
#include <mach/mux.h>
4 C) @1 I5 u3 P, m
( {. L# y8 @2 u: @) c#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
7 w6 I* Z, V. U. p( v4 w#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)& N5 m4 j. o# _3 ]" b; q+ @
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)% N0 a9 t1 ^( j5 C% g9 y
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
/ S+ Y0 A! n- g3 H5 O7 m7 F3 v$ b( |0 h5 Y: ]
/* assign the tl som board LED-GPIOs*/
; W( S5 l, U. S9 z6 {' ]; Dstatic const short da850_evm_tl_user_led_pins[] = {# s. R5 d' }3 O3 p( I$ Q* k* Q
/* These pins are definition at <mach/mux.h> file */
) o o3 n/ L. A, a* @- R DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,) \. {/ w. V8 Y4 b9 l
-1
) f9 q% Q! K8 g$ Y+ ^};
) G# b* ^2 H) C6 F! x ~& M$ n
% d6 i6 d+ T) r, Ystatic struct gpio_led da850_evm_tl_leds[] = {/ D2 w0 M5 c8 q, n i7 f4 E) v
{# ^& i$ P7 w5 G
.active_low = 0,
( y7 `! y, V; W/ [# P8 H .gpio = DA850_USER_LED0,
7 j( z! ^0 F& r/ @2 H .name = "user_led0",) K: ~0 \) {: K% ~ [5 j# F9 y
.default_trigger = "default-on"," g2 p6 w) X( G3 Y' ?
},* F1 l. X8 `: B
{
2 U k% b+ L6 l7 F# d. H .active_low = 0,
" c- v& e9 m7 ~" c d6 d .gpio = DA850_USER_LED1,0 X8 [6 J$ n0 L+ m3 A
.name = "user_led1",
" {- ]" z" O* J" r0 L( G" h .default_trigger = "default-on",
4 P% P5 E9 v; y },
2 k! k3 M8 u( [! E: d {
1 L0 f l0 ~1 r+ d! i/ C .active_low = 0,+ o2 z8 B4 C; S' W( r
.gpio = DA850_USER_LED2,
* `5 F. R$ o" K: @1 B5 w' b1 ^ .name = "user_led2",
`' q9 Y* v z# d5 t5 _' I0 o .default_trigger = "default-on",
# R7 v3 q2 a4 V) @# A8 U },+ E8 n( G' b" t3 y. ^& y; d
{
M3 J( v1 N! ~5 ^2 G .active_low = 0,
7 D+ d( b8 n( x% O4 R .gpio = DA850_USER_LED3,
4 ]" z( S* O) v9 P, C* I/ r: ] .name = "user_led3",! n( v$ [8 q$ F: G3 N
.default_trigger = "default-on",
9 t/ Y5 [# o& Q7 J# B* p4 j },
. ]; H# u: l* q) g- P" F};
: L3 \' x# f u7 s1 j0 a7 t/ u4 t! e0 E2 X0 t k4 x
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {- K8 F, N) J* b; B+ M
.leds = da850_evm_tl_leds,+ K) a5 F8 a+ |* r5 Y+ i' I4 K
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),
7 B% g- i4 N% O- A0 N( e- i};
) X A' w4 h- C) h, ?& B v/ Y! `2 s, j& n# e3 D" D U
static void led_dev_release(struct device *dev)
; |% k3 u- l2 K5 F2 A& V# [5 M{" B& {+ F, q+ w- W8 S( H2 r0 z8 B
};( L7 I8 e; g' V$ I! O
: g# Q8 h L; i& mstatic struct platform_device da850_evm_tl_leds_device = {
8 ^$ N o2 r1 s' Q( x) m4 \ .name = "leds-gpio",
8 k1 M1 }4 |* n* H+ @+ F .id = 1,
]& W( ^+ r5 x4 O .dev = {5 A3 O. q7 V }' o
.platform_data = &da850_evm_tl_leds_pdata,
( M* ~, ?5 t2 T9 u- j$ O% I" l+ U .release = led_dev_release,5 ^* O! _& M% T8 ^9 D* g
}; s% A# m0 j& T. k; ^
};! x% K, i: ~+ a0 u
2 I3 o+ `+ c9 M# @4 h
static int __init led_platform_init(void)
* X' v3 _( } v' j" a* x. ?8 J2 |5 X{
9 E" n- \$ e! ?8 H! N* a9 y9 F int ret;
* z* V1 S& d3 o/ `1 q) r- k#if 0
# p0 b/ }" z* g6 S; Y ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
( h( c& r7 I9 S' @; R if (ret)& F. e# V0 B) A% ?
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
% T0 Y- s: q T* ~ "%d\n", ret);
% m/ I! B' o; d) `! b: N: ?#endif
- p& M, T2 ]7 l% `; `) k$ u& d ret = platform_device_register(&da850_evm_tl_leds_device);; |/ W4 v$ h, w$ p3 I8 Z
if (ret)# N0 H: L: P G: D+ N3 i; C
pr_warning("Could not register som GPIO expander LEDS");- q0 _. i) ]7 }5 _
else
" d0 S: |( w& o printk(KERN_INFO "LED register sucessful!\n");1 | j% m% {5 t* _$ \& A
$ [% U# e; |# s4 D6 e* L" y
return ret;$ O( d' [" ]6 p' L2 [) o
}
2 O3 X; W! { F& K k% ~6 C* ]( R+ X T
static void __exit led_platform_exit(void)+ y* f1 h6 M* J9 P9 ^, v& C, z
{- V8 w# `& z' i- p- g+ L3 [
platform_device_unregister(&da850_evm_tl_leds_device);
% b' j/ n4 w& m$ v% c& G1 i7 \& W5 n& h% c9 t. l* @
printk(KERN_INFO "LED unregister!\n");
$ i+ C9 m/ K) U3 ^9 o4 ~3 k' H}: S: k! o2 R' F+ @" w
! K( [: Y% A3 e. |# m# @module_init(led_platform_init);( {- o. z }8 f4 z0 {
module_exit(led_platform_exit);) x/ c/ R$ G1 e
( |% F, G2 w5 T/ |
MODULE_DESCRIPTION("Led platform driver");+ V0 w& K5 ]2 s+ @7 `
MODULE_AUTHOR("Tronlong");
+ P7 a5 u* F$ u4 ?MODULE_LICENSE("GPL");0 S& U: l F/ Z" o- }. \
: w+ }! Y$ L6 a8 O/ h
|
|