|
|
求大神给下面的程序做注解,请稍详细些,谢谢。( W' Q5 M- O+ B. V% c- V) G/ O) U
#include <linux/init.h>
: f# {: \/ K+ b6 v1 h#include <linux/module.h>1 {: G: m" N+ s
#include <linux/kernel.h>$ J6 A# ^ | u' Z3 H+ ?
#include <linux/types.h>& S# x+ q7 ~; q3 v$ h
#include <linux/gpio.h>7 R7 e9 {/ V. t" i2 w; r$ @
#include <linux/leds.h>) I- E( \3 S' W$ O
#include <linux/platform_device.h>
: E: E/ u9 j2 [5 u/ E7 H7 i3 ^0 M y" V3 {$ e
#include <asm/mach-types.h>
4 a, | [8 P& T& _+ B#include <asm/mach/arch.h># w' A. |6 P8 r9 R0 K. u; W! T
#include <mach/da8xx.h>; k" @8 x i9 l5 @+ c# u
#include <mach/mux.h>8 }& X+ ~- t0 b0 k8 @
7 n" S5 w# r0 ^+ P% V& l#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
& U9 ^6 B% B9 `0 K5 P#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
1 L4 C3 U T3 w7 T. J#define DA850_USER_LED2 GPIO_TO_PIN(0, 1), K. b4 ~& Z7 d5 J' e+ v( N& M
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
0 g# k( U& Y# n4 P" G4 k
/ m) V( `9 s5 q5 Z: u/* assign the tl som board LED-GPIOs*/
i% O9 |6 r' q% X% ostatic const short da850_evm_tl_user_led_pins[] = {
6 g8 s6 l, `& P. }1 l /* These pins are definition at <mach/mux.h> file */
9 K/ T8 R. ]& ]! M/ X/ u, i; o DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
3 }0 B% S r" E. m) | -1
2 a- Y" `7 O& e# ]3 x0 X+ _- G};
2 i; N5 H/ W* J o$ q+ L1 b; |0 ~( P( r% h& ~! q; q( f1 R
static struct gpio_led da850_evm_tl_leds[] = {
5 m' |3 k# \8 |4 L3 b {
' t, O6 r; Q B8 |' l2 ? .active_low = 0,1 g5 R* M! E3 f5 y" }9 j+ J
.gpio = DA850_USER_LED0,
4 o" `+ z6 p# r5 U .name = "user_led0",
" P; g/ e8 ?$ x6 M5 w .default_trigger = "default-on",
: \0 w5 e6 n& r },
# y9 ^1 u$ Z2 K2 }5 X6 {5 ~( U3 J2 z: W { X) S* Q$ L/ ]& {+ ~* @. f
.active_low = 0,
! O7 Z/ q1 I% G: L. N .gpio = DA850_USER_LED1,8 l# A5 Y& s1 d: r4 P% _) d. F
.name = "user_led1",- h" Z0 X! K+ \, T& U- w8 r
.default_trigger = "default-on",- _& c% j% R* a! N2 A8 S/ n
},
: n% ]3 ^# q9 b8 o/ q% ]- m {
- f8 {' N# \ j; _6 A" q4 |/ P .active_low = 0,
6 X6 {# E1 i" d4 m4 H3 z8 R% g' T .gpio = DA850_USER_LED2,4 }+ I% T$ k6 @, X, a4 z# A) I8 o
.name = "user_led2",
0 i3 ], n4 e7 J$ a5 q* k .default_trigger = "default-on",0 M5 s" `- L' w
},
0 O, d& q) K( Q {; O2 {6 M9 e! }
.active_low = 0,$ ?- c4 E" W3 A- }" b1 b) V; ^
.gpio = DA850_USER_LED3,
; K" m1 G/ @/ n, D/ F' s .name = "user_led3",
0 A4 E7 t K# B# h" X- [ .default_trigger = "default-on",
/ W* w* U( M: g. @$ s, ?! y4 B },* d; m$ w6 d) n
};
" K2 E& R- x1 }9 A" p `9 ?3 Q' [+ [# t& ?
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {, J4 l9 i# N) n0 z8 h6 o
.leds = da850_evm_tl_leds,$ }6 @" p* f: ~. X, z) G
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),
, }1 }) i3 R8 c4 h1 D% T& ]};
0 ^ S7 D* y h3 W6 K. R' [/ \9 Z, j- W% V1 s8 G9 {% i" ]
static void led_dev_release(struct device *dev)
# H% d7 x5 v3 W$ X8 F; {" R{2 {. z! f: s/ I& k
};
+ ]% }. i2 N% D A7 h: U6 W- o! x
static struct platform_device da850_evm_tl_leds_device = {
' B$ n0 m$ a* o- ]0 q0 e .name = "leds-gpio",
* m3 Y F# K, M3 F4 F! @ } .id = 1,
& i' }1 n; V1 W4 ~- j8 P9 J .dev = {( o5 u+ p$ s, F2 F
.platform_data = &da850_evm_tl_leds_pdata,
, ?5 h% F8 B h7 N+ `7 x .release = led_dev_release,' N8 S i" k9 g! P& p8 ?
}
R' \$ d, ~) D' G3 V};
6 F2 g. k% F& H
0 z& ~- x# N! T/ J0 O0 `& Pstatic int __init led_platform_init(void)9 w) h* v1 J0 K0 C' p
{' g/ d5 a3 L$ \ _
int ret;
$ s. J2 D" H- {#if 05 A2 j; }+ C+ p' W& G
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);" a; G" Z+ T8 l m) U# t
if (ret)1 T6 `- ]9 X/ _) O
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"- T4 I; ~0 R2 @/ r/ x7 J( x
"%d\n", ret);7 _! Q- R9 h7 p% [& s
#endif
/ P( M* Z) P! g5 T1 Z5 J ret = platform_device_register(&da850_evm_tl_leds_device);
% p3 L! _8 r& P K3 m if (ret)' p' v+ d; R) C' b! z0 N! y
pr_warning("Could not register som GPIO expander LEDS");
4 z( b7 \' }, }# z! F; s else
* \( l6 C/ a0 p' a printk(KERN_INFO "LED register sucessful!\n");
& H+ |1 ?6 D& c, u; s* w8 u$ k* ^% d2 L) W+ [6 o
return ret;0 {( k8 n& f, e- z
}3 X7 I" r! \4 T$ ~
! t& D; R- ?1 }; ?static void __exit led_platform_exit(void)+ i5 t1 N, q0 p9 |! E8 k, N
{* o' s6 F5 i; W+ j
platform_device_unregister(&da850_evm_tl_leds_device);
6 b; p- H& v9 T8 _6 }0 p6 Q( ^/ v) z+ z$ B4 c0 r) C3 R
printk(KERN_INFO "LED unregister!\n");) `) _5 X- B! j x
}; H, [" ], P* `7 t& p( ?' h
% O3 o! w" Y5 s) E) o7 p9 \! Mmodule_init(led_platform_init);
3 g& [' e3 _- b+ l8 Q& smodule_exit(led_platform_exit);
/ [7 f/ Z/ O: p* r0 Q$ L" a' _# b+ E5 m" M# `8 p, ?
MODULE_DESCRIPTION("Led platform driver");
, y) |' `' a) ?7 h5 j/ A) }6 IMODULE_AUTHOR("Tronlong");
5 W: V- X& Z! b. ?, w9 T$ \MODULE_LICENSE("GPL");
8 t9 o, b( g: G1 h9 @7 |" K- R9 e& ^, ]
|
|