|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
6 R4 o7 H. U) G* q2 R#include <linux/init.h>; }! z" ~2 m# f3 {) W0 P5 g1 |
#include <linux/module.h># ^7 `5 \+ P5 d, B5 S
#include <linux/kernel.h>
& N o [. s h: m: V* Y& F _( S#include <linux/types.h>
; i$ @. f) D. ^5 `: s: c#include <linux/gpio.h>5 }, c8 F" O, V6 q* j; K' Z; T
#include <linux/leds.h>
( z2 t& ?4 T- M4 `#include <linux/platform_device.h>8 N, i+ m/ [; i) f/ j
: K) K _' L, A/ j7 [
#include <asm/mach-types.h>" @; M$ B* p0 E/ k0 B5 {6 Q. y* s
#include <asm/mach/arch.h>
3 J' Q, ]4 U2 F( L7 M1 s4 A- t#include <mach/da8xx.h>% y6 r# \5 t$ [- e
#include <mach/mux.h>/ }7 |! M- M4 d# ]9 F0 h
, V4 U4 j0 w0 S' K: w#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
{ Q: k w; Q5 s r#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
- V# V: U7 S3 r# A- J% g. ~#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)0 A" O3 s2 t& i! E
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)# W% B" ~3 G7 v4 h4 g7 Y
& I1 Y! Y7 o, O. h& |4 R
/* assign the tl som board LED-GPIOs*/
3 W, s$ E" W( Tstatic const short da850_evm_tl_user_led_pins[] = {& `" I" ~5 [. m0 ~; Q
/* These pins are definition at <mach/mux.h> file */5 d8 M! i* G" `
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,0 s* L5 S8 ^+ H8 B5 T# b
-1! b% K0 W* S7 c2 P( w
};. Q y8 V; N# a" ^ Q
. I* B. p- c8 l. z' g" ystatic struct gpio_led da850_evm_tl_leds[] = {
' j5 b, x* H t+ G2 X {& B$ ?) z8 m. P
.active_low = 0,9 H/ h3 f" [" w* h! t! V7 r8 U' G
.gpio = DA850_USER_LED0,
/ b. u4 l k( i# J9 ]0 i .name = "user_led0",5 ?/ |) o- g& M+ q: i- n y
.default_trigger = "default-on",0 J9 p. J. Z5 q' U1 t
},
& w0 E& d/ f1 q' [# {1 _6 x {* x' q6 z5 p) T! ]$ {$ H3 h6 }8 L+ a
.active_low = 0,6 I" i, ]& G6 x$ S* D! c
.gpio = DA850_USER_LED1,: y- z3 Q9 x( U- r! j, i
.name = "user_led1",$ T F( W- \& V3 L/ J- A
.default_trigger = "default-on",
1 l! A$ U# E, T9 X },2 c/ @- H* Y6 r; J' X+ v$ ~# G% f4 W
{
& H# o9 I) ?0 b .active_low = 0,
6 w) m! o% A- @7 R .gpio = DA850_USER_LED2,9 x1 W, m* w" _# _, N: X
.name = "user_led2",
& m; E7 M9 S( U4 N- E .default_trigger = "default-on",! U# x* j w g8 s }
},9 C, @8 Q" E* L% d6 ]3 i
{
- I/ i! S' V. I+ t. L1 j4 R, P .active_low = 0,
! m4 R7 y* V$ x4 Z& p( @! } .gpio = DA850_USER_LED3,
9 i3 T$ @8 |( N3 k+ h' j .name = "user_led3",6 k0 F8 ?* B( g9 }! q" l
.default_trigger = "default-on", j8 P4 A: n' z$ R: d
},
# N4 ^# m) E" e3 N};
2 d8 H' R- u2 X1 ]5 F7 n! O/ f2 T Q3 x+ O+ v
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {5 E; R- B, [2 X) y* p
.leds = da850_evm_tl_leds,
& }9 z: e) g, F- }# Z1 u/ a" B .num_leds = ARRAY_SIZE(da850_evm_tl_leds),$ _* R o" d2 Z+ [
};
4 m6 _9 f# P: o$ L0 d4 K, b! V, q0 P/ {, x: X, [
static void led_dev_release(struct device *dev)
Q# Z& e1 P; ]. R$ G{
( r; p- {8 C" I4 }% E}; e# s4 `$ g3 J; x e' s
+ g2 {; T' r) y. \3 C& V4 p' Estatic struct platform_device da850_evm_tl_leds_device = {! ~8 Z" I+ ]4 v1 H4 P
.name = "leds-gpio",
) c4 [2 l7 q; g {# l0 v2 Q .id = 1,7 S# ~/ ?5 j+ U
.dev = {
& g0 F% T6 S) b .platform_data = &da850_evm_tl_leds_pdata,
2 c. |, s% N* b& ^ .release = led_dev_release,
: r6 j. X9 E" {2 N8 E }
1 y/ k2 w, H: b# X ^};. n# R7 m- n) a3 l
9 N: [: b3 S4 {5 h& M6 N7 |
static int __init led_platform_init(void)
# B' k: o6 k) U( z. U ]{& F5 ~6 @/ ^ Q* @, E
int ret;
% Q9 a& w3 @! S, N) G9 ]' m#if 0
6 j0 n0 Y4 g: s# [ ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);% J7 u9 A. n- R7 w( o
if (ret)
9 r( }" m$ H+ c pr_warning("da850_evm_tl_leds_init : User LED mux failed :"3 ~0 @- E5 i6 m" a9 `4 [' }
"%d\n", ret);
0 a# J# M# H2 U2 b3 \5 a% L#endif8 ], w+ L1 d3 q: ?" L1 k1 L% ?
ret = platform_device_register(&da850_evm_tl_leds_device);
0 @ g: U) E) q$ w9 s1 e if (ret). `+ \, {/ D2 C: U
pr_warning("Could not register som GPIO expander LEDS");
4 Q6 W0 x' a9 I ]* l$ g: f& u else
1 p3 ]& |5 @- W+ t5 C printk(KERN_INFO "LED register sucessful!\n");) {. i) H" I# V# a& B D9 V: A
6 b4 V0 P. k9 [
return ret;; Y r: D1 ` e
}! x9 L$ _! M, H( q/ I
# w; E& o' z6 L* }9 ~+ f
static void __exit led_platform_exit(void)
$ z% W. s8 u& @{, Q h! C4 Q0 ~2 W9 c9 V
platform_device_unregister(&da850_evm_tl_leds_device);+ V) h2 d$ z/ h$ f, h0 {8 |3 b3 Z
$ R& y5 A( H7 A/ `+ I printk(KERN_INFO "LED unregister!\n");
, \' q8 o, e1 f( b5 J}# p# Y: `1 u1 T% p: }; q
, Y% i" O- G- l$ o/ wmodule_init(led_platform_init);
- \; E6 s& v$ j- imodule_exit(led_platform_exit);
3 D+ `: |1 G R$ J. t
& X9 o% W' y* ` uMODULE_DESCRIPTION("Led platform driver");
- O* t5 s0 a; H7 G' V" @2 _MODULE_AUTHOR("Tronlong");
0 n7 v9 O+ }, M/ X! f/ `- F8 H8 pMODULE_LICENSE("GPL");
% ?# p- `; B( r9 t( b* p4 Q) y8 z
|
|