|
|
求大神给下面的程序做注解,请稍详细些,谢谢。! D# e2 b2 W( @2 b. F
#include <linux/init.h>& a7 a' h, f& z' ^
#include <linux/module.h>+ M7 u: {0 x6 R7 H' ~# n4 P
#include <linux/kernel.h>) M- T4 W7 Z# R; U/ m6 W
#include <linux/types.h>; S8 S1 I" ?& h. `6 W1 H% Y
#include <linux/gpio.h>
9 t) f% T( L& j- l#include <linux/leds.h>
( N8 p: n5 v# m#include <linux/platform_device.h>
9 C4 J# x% d, v. U$ @; z8 I! N# u5 w# B- D. X4 X! d
#include <asm/mach-types.h>- J; P8 x. U+ i3 r) s
#include <asm/mach/arch.h>
- {" l! x9 |; t$ p#include <mach/da8xx.h>9 \, F2 d2 ] X4 m/ r
#include <mach/mux.h>
3 u2 }; O2 ^9 e+ H1 V) w/ P
$ D! b/ u2 n( v' K; z! c#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
( P- g; y$ P2 L3 W+ ?- @9 V#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)+ G) H A8 d' ^5 w f
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
7 X$ D$ E4 w, o7 I' s#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)' d) J @7 m6 c
8 L# ?: u) Q9 M4 g- l8 J4 T/* assign the tl som board LED-GPIOs*/
- @: j( V) s I/ S$ i O4 \* fstatic const short da850_evm_tl_user_led_pins[] = {8 _5 L4 @+ G: O1 b" n
/* These pins are definition at <mach/mux.h> file */1 L; e. V- d' l8 f/ Z d8 j
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,, J+ t; X3 H2 V# E' I
-1# e& x$ E8 {$ F e7 o# L
};( S& x% t: v0 P! D3 ?* [3 _+ G5 R. l
& R9 G3 g7 U( B
static struct gpio_led da850_evm_tl_leds[] = {( i/ x# F, y# y
{$ c! a9 b& Z3 J: e9 {8 E
.active_low = 0,* A5 h, ~1 w4 t1 x2 }* ~
.gpio = DA850_USER_LED0,, a# Z# Q# \' i' z& x2 g/ {( B
.name = "user_led0",) x H) N3 l4 D
.default_trigger = "default-on",
# P8 M% n; z0 d) N' T& [- v( C },7 k6 F$ I1 j& E2 | s
{
; N4 [( B y. W& q .active_low = 0,9 E0 K" T/ D. X' A
.gpio = DA850_USER_LED1,1 q/ J8 U/ U, G$ o# J
.name = "user_led1",
' {2 K: h' \" R. g3 `! P7 o+ T& l .default_trigger = "default-on"," ]1 p+ S# ]6 e U
},2 c" c$ x* @; g/ E3 h
{
f9 r2 [; z' K .active_low = 0,
+ n; [4 O) i; n; [2 T .gpio = DA850_USER_LED2,
9 S6 I0 @8 ] z# R7 C- y .name = "user_led2",' M: P9 ?8 Y0 F n' Y" V* ^
.default_trigger = "default-on",
2 q% d! Z+ Q1 c },
( l1 n8 j3 t1 j7 F i+ w+ b {4 P" ~2 P7 s# s; \; y6 P) g
.active_low = 0,
! x0 O, U3 K5 e .gpio = DA850_USER_LED3,# R/ D3 q" A" i3 q
.name = "user_led3",! C( D2 U7 J; x5 H# U
.default_trigger = "default-on", @6 T; N, i. j& y! L. _* y
},/ \1 P5 L6 D' z: D* U1 C$ Q
};0 L- V& u9 U# Q: ~' k/ A% t
3 t1 W: |7 {# B% ?* {* u( l
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
( G( a, @9 t4 [' m0 m .leds = da850_evm_tl_leds,& {: a/ t1 n5 P" F, ]1 ]; m. f
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),
+ J, P3 g+ R( R) h};; ` z5 K" b# [" v
& Q/ ]0 a1 U9 T; dstatic void led_dev_release(struct device *dev)
$ ?% C7 X' x2 e: Q{# S9 \ f9 E% F% }0 x
};/ H. J, t r% M6 V* j
$ k9 P9 n. Y: \$ U3 l) zstatic struct platform_device da850_evm_tl_leds_device = {4 h" x: k; s' M$ W3 m1 |: G2 @6 K7 c
.name = "leds-gpio",8 v% o) z3 z) G1 o7 G1 p" M# i5 U
.id = 1,
- M5 x- W- O. W. v" S1 f: b .dev = {
% ~" Q' }' a# Z8 o" }/ m9 T# z: t .platform_data = &da850_evm_tl_leds_pdata,
9 y3 Z/ w8 a/ s/ l .release = led_dev_release,) s: F# O5 k6 S% G# E: y" y* {
}8 p% N* U' _* b m' u2 S5 a
};- a2 f# b6 [( v: H
; i& h- j5 _1 ?2 z+ u( T! G
static int __init led_platform_init(void)2 T& p$ v) b% n: U% e, ]8 [% X
{, U+ b/ B! m; \2 h5 s! S+ ]& `
int ret;- B1 w+ c$ H# }. y
#if 0! b# s: c' H) a- c) k
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
3 V( f& q3 j, t/ b if (ret)
/ x6 I, x* R/ H; a* r; L pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
) K0 f, e# \! a6 a0 C "%d\n", ret);5 x7 k& B) F* `. _
#endif
7 E# b( @* n k- j+ J9 `* H ret = platform_device_register(&da850_evm_tl_leds_device);
* v& b& a/ L! e0 i4 K0 s( O if (ret)
0 a8 f) u7 @( X* h0 j& g pr_warning("Could not register som GPIO expander LEDS");! \/ A$ a/ [* m$ q. g
else# N6 k' N1 q4 S' K; L$ t
printk(KERN_INFO "LED register sucessful!\n");( H% y2 e( D( ]# j/ L7 F
7 C' r+ N. A1 x9 J' J3 A return ret;
) F" o, B5 ?2 k6 }: G4 B' [}" h$ n Y3 Y1 f
3 }0 |8 I2 E* c# _! J* X$ ~- W
static void __exit led_platform_exit(void)
: w( r6 m3 F8 U6 W{) R5 g$ ~* T2 R+ Z' L: j
platform_device_unregister(&da850_evm_tl_leds_device);
: J+ u* @; ?) `* v: S+ E# T; N. B( v- I% G& M; a
printk(KERN_INFO "LED unregister!\n");, Q+ C* Y# y$ J0 g3 [8 P6 ]$ H
}5 g0 i/ x: K7 }" x. Y
( Y c! o0 v% y' \8 k6 S5 qmodule_init(led_platform_init);% z, \; R, e, D% t) y! a( F
module_exit(led_platform_exit);
; U0 k0 ^3 r: o( L1 w: ^ Y) b" {% N7 X; O5 c8 r+ L4 z( [
MODULE_DESCRIPTION("Led platform driver");
/ |2 T0 z8 K d) F0 |9 [MODULE_AUTHOR("Tronlong");4 N" C6 C/ m/ e3 S7 {8 q2 X
MODULE_LICENSE("GPL");
6 F1 I. s8 p3 `% g) ~7 x" i
" P% ^; j2 q" G0 x |
|