|
|
求大神给下面的程序做注解,请稍详细些,谢谢。+ M1 E+ I4 t& \3 d3 E4 d3 m* O
#include <linux/init.h>: S; Y# t9 C( C; z3 W" d
#include <linux/module.h>
" {3 K; |; U/ B4 a#include <linux/kernel.h>
7 i4 q$ j* i& K" P0 }6 H, C2 F T#include <linux/types.h>
+ W5 f7 _2 K" _" A1 P7 g2 U6 p#include <linux/gpio.h>8 S5 n8 r: ^- ~: `9 c
#include <linux/leds.h># f/ }" [" N8 u4 G/ B! i
#include <linux/platform_device.h>
/ \+ X b9 h* {. x- f* g' @5 P& c8 O* V
#include <asm/mach-types.h>
# {; g) S, f/ \: Y! x2 W# h#include <asm/mach/arch.h>0 P1 i- l5 R5 P# }
#include <mach/da8xx.h>5 B4 b; V! i0 O$ C% c+ d, s$ f1 Y
#include <mach/mux.h>
# Y: b% k: |8 S' u7 j& a' L4 p% @. k$ e" U0 {6 a" N5 v5 @
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
?% _$ Q( }0 N#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
4 V r- Q$ w1 U#define DA850_USER_LED2 GPIO_TO_PIN(0, 1), u' f7 ~. B: V- ^- p# [
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)0 k! {" I! u3 k4 o% U0 k! Z
. _7 t& R) b, U5 K1 ^
/* assign the tl som board LED-GPIOs*/5 N; i2 C, n6 k: a, H& u& `7 n
static const short da850_evm_tl_user_led_pins[] = {
2 p) g5 i9 A/ y% l( j3 J+ f /* These pins are definition at <mach/mux.h> file */& I. A/ r0 }1 p9 I9 [3 w- ?) V
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,, o0 i+ X5 Y5 b/ S
-1! t3 H0 q$ U E9 D& i3 Y
};
1 B6 K' Q8 d% T! w3 V9 g+ h- s1 b* m; e+ V
static struct gpio_led da850_evm_tl_leds[] = {' o$ ?1 L4 H: ^& W: b
{
5 j. p/ b# z0 `8 q9 e* d3 B: n .active_low = 0,
. g& j. E/ @% d6 y4 _8 _' O( _ .gpio = DA850_USER_LED0,
* L0 c6 i }( j2 D n. Q" s .name = "user_led0",
" h4 Y; m* }9 _1 [6 D2 K .default_trigger = "default-on",
! Z# v! g8 @. r7 t+ @# C+ } },
1 R' W) J/ y1 L& w {
+ P6 i" n/ N; d1 T7 E7 _ .active_low = 0,
6 H& A* I) {1 w, H, c' X3 R7 u .gpio = DA850_USER_LED1,$ D1 Q4 m k- F) f4 V
.name = "user_led1",# l: Z8 ^$ L+ W# U
.default_trigger = "default-on",; i) f! M5 {3 j" T0 E" y/ Q9 o
},. h& ~. b8 H' a' q& g& d
{* m c9 ]8 V' G' m) e [" L6 \% M( a
.active_low = 0,; X7 K8 b0 \) w
.gpio = DA850_USER_LED2,
0 B# o/ p0 O( @# ]# _7 F .name = "user_led2",
0 F( }. H- t# D' _; ]$ s .default_trigger = "default-on",0 G1 y% _8 X; N9 C# H2 i' k
},( M) m6 h) a% Y/ |9 o
{
* X1 w. Y1 E6 y" f) l; w, W- s .active_low = 0,6 G+ ~$ F8 B- O$ Q; v1 G3 L: b
.gpio = DA850_USER_LED3,0 G8 K6 g0 i* b( T+ e, V
.name = "user_led3",
$ m9 N" a# M6 \/ {5 K .default_trigger = "default-on",/ c |; g5 {( ?3 R/ @- U0 ?" R7 J& t
},+ v8 H. A+ w7 G
};
1 Y i9 \" r6 U6 ~2 E) q8 s2 v
0 v: }$ J( ~ C, Q# f& j) c. R6 istatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {: h$ U. T. S% j' E- W
.leds = da850_evm_tl_leds,
6 N$ h9 e% w2 s( f5 w+ x .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
/ R. j+ R; H4 Q. d# p# m1 A3 h5 s* {};
. m7 ?. J9 L% F2 }! F
9 k2 F, @) j: mstatic void led_dev_release(struct device *dev)
3 ~0 Q `* a1 q% G, \1 Y+ Q{) a& h( d* H; B% z& q
};
8 r6 o$ }4 K/ C2 ^; j2 y: H; j# v: V5 G1 L
static struct platform_device da850_evm_tl_leds_device = {- ^( K6 K! R: |+ F2 }6 [
.name = "leds-gpio",* D: t) D$ A/ h. t3 ~
.id = 1,
! ]% f7 l U, m& T& }2 a6 M- d .dev = {
+ B e# q/ S6 @: J& W3 E .platform_data = &da850_evm_tl_leds_pdata,: b8 J7 l9 x. E" x/ ?% K7 D, a
.release = led_dev_release,1 X" R' B9 g3 A+ `. b3 i1 `; r$ Q
}
* ^" p. W/ E8 G, e+ P5 a5 B& _};
- X& K/ d- a; t
( x! o0 E- ^- p, W: W7 V, fstatic int __init led_platform_init(void)2 k1 x; g, i7 B7 a. C, A
{
" z. R: V3 K, d. o4 K1 g4 H int ret;/ Q% u1 q& L$ o, N8 ]: o
#if 0
8 g3 M. d/ e* e. T- X ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);( O' y; U4 p. X9 [% A0 _; l; J+ A
if (ret)
" W% B1 r/ _. S! n2 A2 b pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
8 i9 P) U9 o7 L "%d\n", ret);6 t: p; i7 p! B. k7 t6 @
#endif! f. V' P/ V7 o, e
ret = platform_device_register(&da850_evm_tl_leds_device);
: b7 [) h2 \7 S1 [5 o0 i# { if (ret)# @) h K7 L( Y! I
pr_warning("Could not register som GPIO expander LEDS");4 x& G: ^- H r) R
else" s- m' I& F8 h# M8 Y4 a& f" t
printk(KERN_INFO "LED register sucessful!\n");0 f5 ` q- n g- I5 U
5 z0 T# W* u) l
return ret;; I, M+ [2 X5 j5 |( {" s
}/ f9 }5 `- b6 W, ~7 @; O
9 N( T$ [) {7 e* [2 d: P+ M2 }static void __exit led_platform_exit(void)
9 {# g# h; _. d$ b8 G2 n- \$ G{$ J, C1 \* j. G5 W3 l
platform_device_unregister(&da850_evm_tl_leds_device);
4 e9 n" M( i; j6 j: T
. T+ [9 v0 v3 {. P8 E printk(KERN_INFO "LED unregister!\n");
+ F0 p- H8 W# w' j2 n* E# ]}
- @, _0 _* |4 c5 P; z6 [$ @+ D0 ?7 U7 B' L0 W1 E5 }
module_init(led_platform_init);) e! ~: {) m) r2 c
module_exit(led_platform_exit);0 V# B, ?# w% ^7 d! l' s O& k
1 n! Y2 B' F, m# }( v3 v
MODULE_DESCRIPTION("Led platform driver");
* ], ^0 n1 n hMODULE_AUTHOR("Tronlong");
: ? {! t3 o+ C- W, A% BMODULE_LICENSE("GPL");; K2 D6 ~* Y, W# V/ L4 E9 a
/ v' P, l. |) R4 s
|
|