|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
3 A, O& e5 G) s$ [8 f r7 \ S2 h#include <linux/init.h>
, B; _$ |( g2 @#include <linux/module.h>+ ^2 c r3 Z' }- v- l
#include <linux/kernel.h>3 V' j' s. M% [" S: |1 Q
#include <linux/types.h>
7 I& e" O9 J# r#include <linux/gpio.h>
' G- s* V; l5 M6 F1 t#include <linux/leds.h> u- r- ~) K3 u, {- b& k/ g
#include <linux/platform_device.h>
( n j1 y$ q7 z! s% b# M) a- k. A$ g+ q
#include <asm/mach-types.h>
& g3 F: v- G: q& h7 v3 B6 |( P5 P#include <asm/mach/arch.h>
' g2 f$ D6 ` K" n#include <mach/da8xx.h>4 |8 c# p& ~% B5 H/ @. p3 H
#include <mach/mux.h>
' d% Q. o2 _1 F, G) Y {% w- T) T
5 k; S; r9 k% U" I, q+ t7 Y#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
0 o) p8 [7 w' d& a5 F! ?. X#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
* {. f! N+ I, D#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
0 W5 U' x1 \2 Q `( L' ~& k#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
/ }+ e* x1 x+ p0 G. L8 J- p- d6 K/ ^
2 O; [+ ?5 h( d- N/* assign the tl som board LED-GPIOs*/
$ Q1 g. Q3 {2 i: t0 h: y5 U9 ostatic const short da850_evm_tl_user_led_pins[] = {. \8 \3 S% R9 L! {9 {
/* These pins are definition at <mach/mux.h> file */) G" z ^+ K7 ~
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
8 k) h9 Y5 \$ L Y n2 f -15 k* O6 _- t! I' z9 B
};3 n5 ]" \' L8 g x1 F' R
* [6 _1 i. c, L- vstatic struct gpio_led da850_evm_tl_leds[] = {0 K2 H9 X6 g$ t
{
0 G6 C% q5 `0 s2 Q+ O .active_low = 0,
' t) Q8 e' Z/ Q+ _: Z/ d .gpio = DA850_USER_LED0,- t) P2 H4 x, ~$ x' l! \
.name = "user_led0",
h# G& \3 `" }! ? .default_trigger = "default-on",+ h8 c( x" w/ P3 L9 l0 f: m+ r
},
/ a/ V5 E7 a% u {: i) Z/ N; y* y3 ?$ U% K) m% S9 W
.active_low = 0,. }; W: T2 q: E
.gpio = DA850_USER_LED1,
$ t V! {3 H- e7 t' d" l" N .name = "user_led1",* [/ v8 y4 O' F* ?# A i1 c
.default_trigger = "default-on",+ r% O& I8 T) f, o7 F
},
* Z: D6 M8 ~! F/ E {
: Z4 _6 b, [: D1 k .active_low = 0, u M8 i' ]0 I, J* B" {( g1 m) H* @
.gpio = DA850_USER_LED2,
5 Q( d O6 Y8 \) j1 x. O2 _ .name = "user_led2",
% ]3 p! ^& O' T8 Z .default_trigger = "default-on",, G/ ] k6 `3 r( J4 j9 _
},* u5 R) a& R, x
{
3 ?1 B0 |, Z8 x. v .active_low = 0,0 ]9 S! I0 ?* i S* x
.gpio = DA850_USER_LED3,
* ?# Q6 {# u% M2 { .name = "user_led3",
2 ^$ G+ v4 k4 e" H: n& x .default_trigger = "default-on",
& k- u' {; C( ]/ I9 m9 u8 @ },8 l$ v2 |3 J. g0 t
};( R6 ?9 G0 n5 z5 s2 g2 ^8 k1 ]
/ z& o1 r# l( ^3 j& mstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
2 ~0 w7 ?6 m5 k5 D) q3 W8 r2 B .leds = da850_evm_tl_leds,
* q0 e& D Z0 u- `0 i .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
) n/ T& T1 Z& G4 G* Y8 ?8 D9 g/ x};' t: w: R2 l5 \# c/ E1 O& p7 v
' U( g- B+ o( O- n2 w
static void led_dev_release(struct device *dev)4 D; N+ K, @: G8 r: o
{
" w9 I) i$ C# } c5 A* H$ U};
, R4 O; D. C4 Z* B: x& T+ q0 ~. ^+ Z3 t4 }& V z% c
static struct platform_device da850_evm_tl_leds_device = {
! X1 V2 R3 M( [7 k% K7 k# o% [% m0 r .name = "leds-gpio",
% _" w. [$ @( b- C" h' u# B .id = 1,4 s9 S) t5 y4 e# O5 j5 E
.dev = {
+ `4 _5 w. e. b- ]9 x7 n .platform_data = &da850_evm_tl_leds_pdata,0 m8 g1 t" s i5 Q! d: m- A
.release = led_dev_release,
5 `6 R& h1 x5 i) d; u3 | }. w2 b4 c& p$ Z
};' T" ~1 |$ j2 W& x9 ^( W
- \4 i8 P" I# \- f& J
static int __init led_platform_init(void)
3 l' K( s* S D8 R{
) r: c! V% C+ n3 x9 q: K. f& y int ret;( D+ o$ S! C. a1 V) D
#if 0$ J( p( t) B% A+ i
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
" d6 y) V0 x1 j- |' ]+ O6 T if (ret)+ ^, X2 i- T- R8 w9 |# l
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
2 @, x' ?6 d9 w, T8 V" p" B- z "%d\n", ret);
- t! t u( K6 _# d5 a, u- @#endif
4 ]3 n/ J' N+ \( d& r ret = platform_device_register(&da850_evm_tl_leds_device);
$ R. R1 m) V% X6 d9 o6 T0 \7 c, ] if (ret)3 k" o6 P( a- S z) E; w2 \7 r& i
pr_warning("Could not register som GPIO expander LEDS");: j7 }. g5 c- Y4 E
else2 I& i( s" X6 M! I+ C/ K% O* A
printk(KERN_INFO "LED register sucessful!\n");* {. j. w- y T% X- _% v9 `6 b5 ~* g
- y1 G# B: Y( ]( M$ [, Z0 y. b# T
return ret;2 @% L1 I7 Y: U' s( {. S+ a c- P
}, ^) e, n9 c; H3 b+ j
) @& B' A9 v' G) {" O7 f
static void __exit led_platform_exit(void)
* P- I% d/ g" r: J: x{# \' y; X, c3 {8 T4 q- |6 e
platform_device_unregister(&da850_evm_tl_leds_device);1 K8 o9 _* }. R9 q% ~
2 P J$ ^ p+ A* `2 Q9 }$ J
printk(KERN_INFO "LED unregister!\n");
6 F3 w, `* R) K6 o8 |}
( m5 \" ]% |$ d: Z/ [; k) P/ x6 D$ M, h: x: V
module_init(led_platform_init);2 }# U! B. A* }7 i& I, S8 N& X
module_exit(led_platform_exit);: G9 I: @. I1 P/ l2 D- D
[1 M* H3 t! A* c5 u3 ]
MODULE_DESCRIPTION("Led platform driver");" q1 A: `: j; @& G
MODULE_AUTHOR("Tronlong");- M$ \' O, y7 A6 N
MODULE_LICENSE("GPL");
0 w U/ d _4 ^- ]# z/ G& F" x, U; `2 b; z. J: H
|
|