|
|
求大神给下面的程序做注解,请稍详细些,谢谢。0 s: e$ h, _! Y; J, Z
#include <linux/init.h>
6 J+ G$ Z5 b8 X3 K4 D) \3 J; g#include <linux/module.h>
4 C2 `6 Y) O0 o% s3 H#include <linux/kernel.h>- q3 T/ [6 l5 |
#include <linux/types.h>. `9 D# }" v2 `: n5 P' T4 B" ~
#include <linux/gpio.h>
0 ^" Q# |2 O9 D* k& X#include <linux/leds.h>" x9 W4 c7 G: V$ C% P7 S! |! K
#include <linux/platform_device.h>
; S* K! ~; Q, a7 h0 q$ q( @ g2 a3 |8 [
#include <asm/mach-types.h>
! x8 T6 D/ g: k% G/ T% _#include <asm/mach/arch.h>' X; N8 [- S+ c6 J- l3 y; t
#include <mach/da8xx.h>
. }% a, O' m" I6 ~( f' N- `! E! K#include <mach/mux.h>! V2 N" Z4 y: U" W+ O8 d; y
" g. j: i2 m N- f9 a3 d. Z9 z
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0): r. A& h2 F1 w( \
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)+ @0 Y% w/ V. z ^) q
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)# c- [' ], b/ {+ z
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
0 w% x* s! m+ U8 [5 C3 G6 g' E% M0 l+ c* l( [
/* assign the tl som board LED-GPIOs*/7 Y. D a, p" p
static const short da850_evm_tl_user_led_pins[] = {
* {+ T1 i* S; U4 {1 v /* These pins are definition at <mach/mux.h> file */, O+ p3 l2 j+ a- g
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
) o/ B; v+ z. R. f6 P2 t -1
/ i: G5 l Y/ ?1 ]! w& n};2 K9 m, s/ B! Y8 y4 O8 s: g
8 k- t' {. h* p5 r# h
static struct gpio_led da850_evm_tl_leds[] = {
- x$ z; ~& H7 j4 A4 M; ^% @ r3 y {
1 A5 X I* @3 ]4 X/ \ .active_low = 0,' P% y, [' s4 |% }
.gpio = DA850_USER_LED0,
/ C+ V3 [, v% F .name = "user_led0",( c [! j3 B8 t2 m- _! @
.default_trigger = "default-on",
+ G( @/ g7 w0 C0 O. h* z },
) x" I9 W1 W7 \( S2 m2 n3 G2 ~ {' F2 u; @# i) u0 } j# @# O
.active_low = 0,6 w6 J/ {( @4 V
.gpio = DA850_USER_LED1,
$ E/ A P0 R4 H1 k m! W4 T/ y .name = "user_led1",3 r/ @. Z3 L' w: z E
.default_trigger = "default-on",
6 ^ V+ ~3 v2 Q/ Z {" @ },
/ `; w7 G3 e6 M) R6 `$ o {
" r6 j e$ x. h/ s .active_low = 0,
9 m b# u) ^# R; O .gpio = DA850_USER_LED2,
8 c) ~3 I% k, T5 z; f7 { .name = "user_led2",
; ]1 Z' Z* Y% W .default_trigger = "default-on",
0 k2 D! Q( e0 Z },
3 w8 S: M B4 x9 o! h {# \; [2 |+ r) `! Z
.active_low = 0,
! J+ A) R7 b, G% z+ ]: h .gpio = DA850_USER_LED3,( p5 Y" F8 Y+ U) {" [
.name = "user_led3",
: C- B# ~ ^$ c; L; X* t .default_trigger = "default-on",
! A2 w! u+ C/ X R },
; ^- Z$ Y9 p* l1 [ n};
$ F/ U: k. e' j% o5 v* }* L8 N! P |# ]- O4 |
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
q4 B3 N& ^6 y) S( p( h( ` .leds = da850_evm_tl_leds,, G( O5 I% ]+ E& L: ^0 T" t
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),/ Y+ n7 P: r; j! ~5 l0 X
};$ B0 M* |; V8 s
+ E" E4 I o* t3 d K, g2 U5 r
static void led_dev_release(struct device *dev)6 y/ U% g: w" J' L
{ N |* I8 C: ]1 ~1 k& I
};1 S2 j' ^6 M: k9 P n# _# \
8 ~8 M$ K9 A9 M. \) l& o) C
static struct platform_device da850_evm_tl_leds_device = {
4 \8 c$ e$ ^1 H' ? .name = "leds-gpio",3 W# c4 h; x. ]9 B9 O! `
.id = 1,
( N$ P6 j3 H$ I5 c4 Q: L8 ` .dev = {
; X- }; W) O4 P# |$ a/ d, h3 r .platform_data = &da850_evm_tl_leds_pdata,0 E! X+ [6 y6 A2 \5 ?
.release = led_dev_release,
, e7 G( n/ h8 F$ o4 _ }
% d( k6 d) f# `' T};
/ v5 V; \* P P* G$ L1 g, }7 B2 W9 E
static int __init led_platform_init(void)
. b% `* D2 v0 T# p9 u9 j' G0 _{ n- L, A# S3 e. G' N7 h
int ret;
) e) q, d% C9 N' E2 L- c#if 03 |4 P. c! y! h" J& U# e
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
9 S2 m' U3 {8 [ if (ret)
7 g/ J6 z) N* D pr_warning("da850_evm_tl_leds_init : User LED mux failed :"* l0 x- c$ Y4 i m# w3 ^" l" \- e
"%d\n", ret);
A' A2 c/ V8 w* k#endif* U" c! ^, x* q8 G. m
ret = platform_device_register(&da850_evm_tl_leds_device);
8 V5 j6 E: \' w: N if (ret); `9 u8 ]9 H5 J2 K3 U
pr_warning("Could not register som GPIO expander LEDS");
# Y, K& r) y9 F9 X else
7 }# `% N# a2 _, y7 B9 b. e printk(KERN_INFO "LED register sucessful!\n");: w' K9 W3 l( p5 |9 R- C8 |' h$ }% e
! M. S+ H9 k2 J. M" u return ret;
2 m( L/ L0 `% i. k. z}
% Y: @4 W, m* z3 P7 g) H; X/ |5 Q" U) G2 l4 t+ N- q
static void __exit led_platform_exit(void)% P* ?8 A$ y7 t" b' ^9 k3 C0 O
{0 l$ z" @0 _* Y1 K
platform_device_unregister(&da850_evm_tl_leds_device);+ e: F" { b/ Z; J
' w, R9 S( I4 Y% r* S printk(KERN_INFO "LED unregister!\n");# J ]; ] l3 h9 e9 D
}
1 v0 V( ?# j+ s2 \* X+ @
& [7 P$ t0 |3 V/ ^" vmodule_init(led_platform_init);, U7 E/ _& G& G5 A; W- j
module_exit(led_platform_exit);
4 m. P$ L: z( c4 V) \
3 b: h0 A9 i/ t9 @MODULE_DESCRIPTION("Led platform driver");
$ r: h* n9 a2 x/ W$ x+ s3 rMODULE_AUTHOR("Tronlong");
6 E: s$ P- _) v" C- L5 N: w6 CMODULE_LICENSE("GPL");
3 U9 c# S" H/ l$ s& j3 H" P7 d4 `2 r
|
|