|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
6 a. R: X5 o0 x- U8 N+ M h#include <linux/init.h>2 A) y$ V7 `8 \( ?
#include <linux/module.h>7 b* P- w2 d# E& X& f
#include <linux/kernel.h>
- S; U9 ~' ]/ i! i) {3 X$ `#include <linux/types.h>6 j( q4 h: a& C* R0 T5 Y
#include <linux/gpio.h>( l/ i0 `: i9 w( ~9 ~
#include <linux/leds.h>
( @! h* C6 D* W; o4 O, r! |#include <linux/platform_device.h> s' K/ k: H# O4 t& @
9 V) J D2 p2 L4 v* M" R* L/ }
#include <asm/mach-types.h>( Z$ g g) Z' Q! ]
#include <asm/mach/arch.h>! Z7 D5 ?! O' ]( M' @
#include <mach/da8xx.h>
# C/ Y, f V% s9 P#include <mach/mux.h>
' W0 Z. ]% [4 [4 s! V+ o
" ^+ u ?. n i: n4 Z#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
. V6 }4 v+ l. Z' Q#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)9 h% i$ F+ F$ P* d) W2 c# I( c3 T
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
0 `! S1 c# x, a2 R: _* N3 l7 c#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
# ?4 S" l- s( w' U% e0 Z2 I! z
/ t0 B0 Q5 e, _* A# c0 Z/* assign the tl som board LED-GPIOs*/
1 P6 N/ X+ B# [static const short da850_evm_tl_user_led_pins[] = {
; ?: s4 z& F& d3 X( T /* These pins are definition at <mach/mux.h> file */
5 |: r Y+ Y2 z4 Y DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
1 r* T% h% T! {1 B3 v -1
6 D% X7 D1 K, c* R( v};
; |! O" I) z' v* R8 m1 t, w# @8 Z- `4 \: R5 b3 W
static struct gpio_led da850_evm_tl_leds[] = {
G! g, M1 I, A4 S, g) d {
3 Z4 ^: D y7 N. C+ { .active_low = 0,: K1 g! _6 {7 B4 G. K, W
.gpio = DA850_USER_LED0,# h( c! k6 {$ ~+ {- _! ~+ d
.name = "user_led0",0 i8 \8 W* N! k3 V# X
.default_trigger = "default-on",
2 j. ]; O1 `. P! S% s$ q },
2 K. A" M* F4 o( H: V4 @ {! z K7 o' u3 F* V
.active_low = 0,, ^) |2 A# r2 f" @7 J
.gpio = DA850_USER_LED1,% N& Y# L* Q1 T: P6 g7 I5 W
.name = "user_led1",
& T/ f/ k6 U! n9 Y) n) Y" Y1 _ .default_trigger = "default-on",
. f b: [9 F, H: p! O6 o, H },
3 }1 N+ @# `) Q) C! k v {1 n3 U3 q0 H* K& m
.active_low = 0,9 w( Q! _8 }: ?. I
.gpio = DA850_USER_LED2,
8 E/ C5 n' J ]* Z .name = "user_led2",0 x! K0 x( w3 d5 q/ D
.default_trigger = "default-on",
. Z7 R) _$ R& |, i$ d' T# T) l9 B },
[* E. o" [9 j) P6 } {
" u8 @8 l7 u$ H# P; X, \* F4 k .active_low = 0,4 v% s1 {! {$ N8 \# T6 w2 _
.gpio = DA850_USER_LED3,: h Q; d: d r _7 B
.name = "user_led3",( |" ~, D* [6 F: m Y! Q/ J
.default_trigger = "default-on",
5 ~5 b' Q: U% |/ [ H- W6 ^4 V' L },% L" j, K E" U+ u2 `7 W
};
8 S5 _/ ?5 ? ^+ y& d* y& j9 ~5 b8 B5 ?$ x' L5 G
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {- A; n9 I' Q: @; f3 `4 W
.leds = da850_evm_tl_leds,
, u' O3 Z8 B6 O) E* @ .num_leds = ARRAY_SIZE(da850_evm_tl_leds),1 b; u* T5 P# _6 C
};
7 G# b0 U p$ q$ h, V3 i1 B+ z
* X9 w' R/ k" L, ~" C1 s. Y* [static void led_dev_release(struct device *dev)
5 [& H9 s/ d+ S# o. L: @{. M9 x- N% v% y' f1 P
};: e8 Y. I+ C, E D0 s
5 x! Q {$ K; B
static struct platform_device da850_evm_tl_leds_device = {# e1 k# s j9 L. V* O1 G- A
.name = "leds-gpio",
- G! R9 ^1 { N) L .id = 1,
; }7 |3 W( T& d S- ~( }) D .dev = {# I+ @3 W! e$ m T$ Y
.platform_data = &da850_evm_tl_leds_pdata, _* g# O# ?0 K7 v" R
.release = led_dev_release,! P% p5 n; V7 ]" p2 P$ E' j5 C6 G
}4 A4 y$ [8 O3 Z, d+ L. s: G
}; M: s5 w1 ~+ U- Y
2 n) @: p) p* z3 G' S& X7 @/ T6 F
static int __init led_platform_init(void)
, _$ D V" a8 @5 Z) Y+ |{
& t7 Q! e( G0 I* E int ret;
! k0 A4 Z7 j' d#if 0
: q, x3 l) ~2 G$ Z: I/ K$ v ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
0 D9 B/ h. @. w6 ~% r if (ret)
( |6 e' w, _5 J: ?3 y9 f pr_warning("da850_evm_tl_leds_init : User LED mux failed :"# B( C _' A. h. Y @0 T3 j
"%d\n", ret);- v! e' C( J% Y2 e
#endif4 y$ Q3 {2 z: r. _/ j' ]3 r9 w
ret = platform_device_register(&da850_evm_tl_leds_device);$ V# I4 z6 f! G
if (ret)# D `9 J! c3 ^$ k
pr_warning("Could not register som GPIO expander LEDS");( X; I! s8 b: _6 u) c) ]& T
else
A0 N2 T2 i. b" D& P printk(KERN_INFO "LED register sucessful!\n");* N8 h( w L! e; n2 [
$ B" k- B/ Q- Y& v return ret;: H# n& D3 e$ }( A9 a2 M- R1 T5 R" s
}9 Z, \( a# {) A5 ` F, ^
) d7 y8 F* A* P- O4 Ystatic void __exit led_platform_exit(void)1 e! q; o+ n6 Z _( _- ] j: J% V( ? V5 I
{7 |. t; a) _6 l, q
platform_device_unregister(&da850_evm_tl_leds_device);
- Q' {" ~$ R7 |: u. |$ F8 Z6 v# [9 H% c8 z W) x; b: C3 H8 ]
printk(KERN_INFO "LED unregister!\n");3 i$ S6 m7 E: l4 F6 r( D
}
3 w t2 d& P8 m2 a( t$ s! L" m! v1 |1 ^" f: f4 q
module_init(led_platform_init);4 [# Z* O" E' }' o
module_exit(led_platform_exit);
3 F0 f7 a" x( A- F
7 t5 u! a7 ^ o- L: L4 HMODULE_DESCRIPTION("Led platform driver");
+ N6 K/ h% {* ^+ i8 |5 |1 `6 nMODULE_AUTHOR("Tronlong");) X, H: @+ M6 u# X
MODULE_LICENSE("GPL");
9 R* o, V1 } }) a" Y* c( h4 ~6 U& {1 B: M
|
|