|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
9 k' F Q9 N$ q: X: H/ u: f4 M#include <linux/init.h>
3 t X* u+ J$ l7 P#include <linux/module.h>
+ c, u( ]7 p6 k* W& A8 ]* s#include <linux/kernel.h>
* J- t& U% p& h/ q+ B! ?+ k4 \#include <linux/types.h>
6 x8 p- H: @/ }6 J9 j; H* L#include <linux/gpio.h>
% r$ E: M& g! x, N4 r#include <linux/leds.h>
) N2 n9 M& Y4 ^5 p; F#include <linux/platform_device.h>9 Z" k' F8 U2 X0 V* k( c
& W3 Q. b4 ?& h# F0 s/ p
#include <asm/mach-types.h>
`" H* w! B3 v: ]" O9 V/ Y- c#include <asm/mach/arch.h>
9 v u4 J, y; @5 ~: g7 C, c9 k#include <mach/da8xx.h>
6 Y1 X4 b# M/ E- V x1 A# g4 g6 z#include <mach/mux.h>
- P3 {: r# o7 H9 R( w: n9 N3 h1 V/ n, l
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
- E; S6 w- V8 m8 m4 \#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)0 f8 ^7 H. I1 p
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1) X( M" w$ r& s' n' Y
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
$ E. a$ K7 I0 U! F' K6 |
7 f- n& q7 }' b& W/* assign the tl som board LED-GPIOs*/
, U* e& l' j8 [; B, U; u- Cstatic const short da850_evm_tl_user_led_pins[] = {
; g! R( A/ z! M, Y /* These pins are definition at <mach/mux.h> file */. @+ J0 _) p' q w7 k
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,. P7 I& w0 I; H$ E4 L+ c; _
-1* L+ ^+ S9 w$ a: M" |) _
};4 X5 {+ j8 `9 V; x# g/ _4 A) P. V
2 m$ `1 T0 S% v4 y! a3 _; Y& B1 v& t. Xstatic struct gpio_led da850_evm_tl_leds[] = {% I! Z) t% r) L
{3 d( A2 }; H3 g- D
.active_low = 0,& W V; [! O3 T7 Q9 X7 ^
.gpio = DA850_USER_LED0,
0 d9 Q9 q. M' M+ C# T: Q p .name = "user_led0",7 {, U0 T# [3 I/ ^6 ], l: O
.default_trigger = "default-on",1 g* o* D& ^& ^( p8 W
},
( c" C$ j& r4 {0 W" J {
m2 Q, x2 p# B. J) h) J5 D .active_low = 0,1 T5 i3 U1 Z. a. G
.gpio = DA850_USER_LED1,
' A0 ~' A/ t8 y1 H .name = "user_led1",
% i6 j" M8 A! l3 s" u( M; W .default_trigger = "default-on",- m9 B9 Y5 b8 `! f6 A
},$ P, C" c% l% k+ |5 C; F
{
, w5 e. i# K x- x' ^( e .active_low = 0,1 C. e3 Y: m3 s( T' i6 X9 X
.gpio = DA850_USER_LED2,1 O8 \, F* G& @
.name = "user_led2",. p0 l4 L' @& d) Y9 F7 N, [; ^% ~
.default_trigger = "default-on",
" V' R0 A" r% q },
2 n7 D# h ^# w2 x- } T& } {
, l! Q5 D/ n; \3 [! h .active_low = 0,
# y) F2 `/ R1 b& [! c .gpio = DA850_USER_LED3,
. n! k' m$ L' _$ c5 B .name = "user_led3",
O1 K0 ^& }/ N& w .default_trigger = "default-on",
, M/ J1 v9 W/ R1 d. k; d0 u },
+ A: o: r; |$ e2 B/ g( K$ U6 f( [};9 q3 o9 U" S% F
: I0 G+ Z& y) P0 I# ^9 ustatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {* @( {5 O7 d4 Y- p
.leds = da850_evm_tl_leds,% E* k. [, E8 U9 D# F
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),
. Y" k s. b. x) x& c};
+ q7 J) R) g0 y8 |9 |0 I5 g# u, r. A2 X3 w
static void led_dev_release(struct device *dev)' {4 [& l. y4 p, Q
{
" Q2 f$ n1 ^/ f! i/ G2 o) m' c};
( U* B, x9 u2 I. T) E1 u. N% D4 C
static struct platform_device da850_evm_tl_leds_device = {
% R. F& M* Y$ p" ]6 G .name = "leds-gpio",
1 W8 q/ t! W& E. O, H6 t .id = 1,* m l; U4 }8 g- U
.dev = {
' G* }! m7 Q5 Y7 m/ } .platform_data = &da850_evm_tl_leds_pdata,. G* m3 Q/ P' |( |
.release = led_dev_release,
$ [! C( F' p" p1 h3 M% u }* d# J1 z6 M! |* r
};
/ I9 \; Y$ _$ B8 }% N# f* P' _, F% O+ x7 v) N& H9 z p
static int __init led_platform_init(void)' r* x8 W. `2 A+ M9 x7 [
{
; n9 i X7 V2 K int ret;& s) e3 c6 c4 \4 ]7 }. B& Y
#if 0, |$ m; K2 p8 F- S+ C5 T: c+ m
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);' l6 l5 W% U: V
if (ret)
5 l! w' V( Y0 F; u! ~' U: G4 Q pr_warning("da850_evm_tl_leds_init : User LED mux failed :"0 @( N3 O& n& A6 Q
"%d\n", ret);+ P! w) q1 F$ |9 @
#endif1 }6 @' D: y6 ~4 F1 }9 g
ret = platform_device_register(&da850_evm_tl_leds_device);
( O& |# U8 F) ?& G! \0 e w6 V2 v2 G if (ret)
# f6 A; o. h$ Z9 K" ^4 Z) M& o pr_warning("Could not register som GPIO expander LEDS");
" E- x+ e4 K' f( r } else
3 w9 s0 }2 S9 e' J B printk(KERN_INFO "LED register sucessful!\n");' E& G4 ^: h: W/ G4 `# G, L
6 `* H. Y2 H% O8 _ return ret;4 q! y0 i: l/ _* C4 j$ p
}6 x" l& x9 c5 Y, T- n. h
* V# C1 e* Y( |, g* i- Z
static void __exit led_platform_exit(void)% q s1 l$ ~9 g' c, d" `
{
$ k9 R# L" k, @: x3 v platform_device_unregister(&da850_evm_tl_leds_device);/ ]8 M* \7 y8 f- m2 k2 [. Q
9 L6 {8 y1 e2 k+ I% g
printk(KERN_INFO "LED unregister!\n");, E6 ~& c6 B R/ w
}
r' J' \* p4 s1 U+ z. `' c+ e5 h
" \$ v: p s7 n# n$ gmodule_init(led_platform_init);
- u3 n2 F( | |5 d/ R; X+ omodule_exit(led_platform_exit);
7 T1 G/ W! R7 M
( G# W1 M' [% A% h/ g9 `MODULE_DESCRIPTION("Led platform driver");
% U0 E2 `& N8 c' H7 i2 J/ rMODULE_AUTHOR("Tronlong");2 o/ h6 }7 z! R$ B! z- l
MODULE_LICENSE("GPL");
; z' X0 R0 f% o U/ d. U3 T! M, u" E4 H6 X I
|
|