|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
% R; N0 l* _" z8 @* M' n#include <linux/init.h>
: ]0 i1 n/ [2 W- k& @$ S, H: b' B% y#include <linux/module.h>
- R W1 d0 k$ h#include <linux/kernel.h>
8 R9 X& [9 Z! m1 _: O* _4 g8 a#include <linux/types.h>
" R" W2 f! [9 `( I1 D#include <linux/gpio.h>
3 L* f8 x' J: }* B5 Q2 {3 I#include <linux/leds.h>
. W/ V' i. Q' f7 d#include <linux/platform_device.h>: c7 C5 j8 S' S: j; |
2 J" v& ?! q6 `#include <asm/mach-types.h>- W! z$ }- I) @9 }
#include <asm/mach/arch.h>
! q& V L+ l! q3 s#include <mach/da8xx.h>5 y: a. C& b/ g$ \* H. P0 l
#include <mach/mux.h>
0 f4 m6 z0 F, n
( b1 F, D& W+ `1 m! Y' F" @4 ^#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)! ]+ b& q) \" k7 k$ H
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
# a9 u) l* o0 j: w# Z#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
2 m) E7 ^8 n3 z#define DA850_USER_LED3 GPIO_TO_PIN(0, 2): m2 X* y+ b$ e% O) @ K& J
& g3 y m# S0 b8 [5 T+ P* I
/* assign the tl som board LED-GPIOs*/( U7 G6 Q3 R% l
static const short da850_evm_tl_user_led_pins[] = {% v* x- b+ S& k' E2 |
/* These pins are definition at <mach/mux.h> file */2 U% ^5 T* b, W! d, R
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
- M& X8 ?2 f: A% x3 M1 k -17 F2 d' F4 y) I1 ]! e
};% m) T. D/ j( P W
9 ~" [: R& s3 s% u) Q. N
static struct gpio_led da850_evm_tl_leds[] = {4 r# Z! F; n& i/ N2 G p
{
1 `% U( g( f! w: u .active_low = 0,
! S+ m( K1 z5 S9 r .gpio = DA850_USER_LED0,
* y6 X: [' ~7 k# l7 ` .name = "user_led0",/ O+ T6 f* w' n5 ^
.default_trigger = "default-on",; n& i+ |% s% H5 i9 }; S
},
" t. p) w0 \. I {/ E& n2 F, O/ E/ D! a0 V6 p
.active_low = 0,
q! O T7 t; Y2 w. p .gpio = DA850_USER_LED1,
d2 {' o* v$ W .name = "user_led1",
! ^- ?3 e6 E9 S& `7 v .default_trigger = "default-on",
6 V6 `: T0 p2 S) p: X% D },/ z2 q) m8 o. A: z4 f& P/ l
{
/ U3 P0 Q( l$ Z" _' F+ J# }% z .active_low = 0,
6 A( o6 L; y* q$ Y, r+ E" A .gpio = DA850_USER_LED2,5 a! Y" Y4 }% n+ H. a$ I
.name = "user_led2",
6 I- v2 d$ {) B7 x: g .default_trigger = "default-on",( \* i" L8 b _ b% m7 U$ y
},
+ u( D! Q F5 }4 T1 B6 z1 j+ O {
, g8 J+ j v K8 f$ Z .active_low = 0,
/ M9 t; {6 \6 ?) W# x8 v% g: A .gpio = DA850_USER_LED3,, J9 I! Y9 T; ?% w4 l
.name = "user_led3",
& \7 H6 O* |" u5 N8 u' T; E .default_trigger = "default-on",
9 j% u& K" {' M9 P( H },
0 x* I. j# K0 G- z/ M8 S};
& ~ _9 ^+ ?/ t& z" y3 s, `( l, v% J& z7 z
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
% ^* ^7 z& l$ \' g. ?1 q9 Q- y3 O .leds = da850_evm_tl_leds,
7 |2 v/ t4 H# [. ?5 n) E9 t .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
@3 J- ~' r7 ~; f' Y};
' _# G/ D/ D. X+ C* h4 [( G8 ^7 ~) x
: `2 ], W5 r1 R: X/ ^static void led_dev_release(struct device *dev)
6 B1 b2 W8 }, g+ R+ m+ z( b# G{
1 p/ }4 S# m( I8 N, R- c* N0 B};/ P# d0 s: w# F$ U* T
4 E3 L8 S1 p0 _7 U4 H5 i; C4 H
static struct platform_device da850_evm_tl_leds_device = {% l R |1 C% B" l7 U3 u0 N, X u
.name = "leds-gpio",
8 a$ W. X0 r4 i$ D9 s) ~: ?& T2 j .id = 1,7 @/ L( `: P) N, U
.dev = {0 q+ J/ r$ _: x' K
.platform_data = &da850_evm_tl_leds_pdata,
8 F. |$ |% \5 u7 ]6 B .release = led_dev_release, S" L) f" g& q* _3 d& s) {3 d8 Z
}
$ v6 U% u9 H, a' Z+ i};% A, [) m* f" [! o4 v
1 Y3 ~) K$ S- u( B* n, U$ Astatic int __init led_platform_init(void)
4 Y6 W& d5 f6 c0 P1 u2 x{
" F& m1 w1 P t. {4 v1 C% p int ret;' G# o! b0 e/ r8 S
#if 0% b; K3 {) ]' r
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);. `! H- r4 S& c7 q' V- q
if (ret)
" R H) }0 S! a- |/ J pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
" a2 F( P5 S/ A, J/ ? "%d\n", ret);8 ^: o8 p0 c( _# a- r0 |
#endif* V$ x7 K2 X* @* A2 x- O6 t
ret = platform_device_register(&da850_evm_tl_leds_device);
, T8 [( K1 x- l3 ^# [ if (ret)
& \2 k4 x8 G, @/ `. y- L7 g pr_warning("Could not register som GPIO expander LEDS");
9 v* e/ q1 D, P. F2 W8 b else& W9 Q7 x# ]+ H7 U# R8 m
printk(KERN_INFO "LED register sucessful!\n");
0 W, i7 @1 r8 P* [9 w/ ]$ S6 l& l9 b6 p" O
return ret;
) T$ o. M! u( T; F}
) I4 {6 |+ e$ I. A% z5 l8 M. X/ b
g" O0 H' _" `. }% ystatic void __exit led_platform_exit(void)
/ F- t# K' }+ Z& n: L2 t{
, N- ]; T: L; n: `" ~! e# ~ platform_device_unregister(&da850_evm_tl_leds_device);
- g# Q7 t0 J' S% G2 c3 M
: O9 w T+ ?6 e# E5 D; Z: G5 I9 o printk(KERN_INFO "LED unregister!\n");
) B! B2 M3 y Z& v# H$ F2 L}
R) Q! e% k4 `$ K; _- J; w
3 m, g, W9 [- _9 U0 omodule_init(led_platform_init);
+ B# F. A! q' L% ?; D* U) `4 f2 }0 j' Umodule_exit(led_platform_exit);
( U+ ]9 `; j6 r( P5 q: S' R7 m% R- q0 i/ b7 Q: f9 {" }6 y7 N6 h
MODULE_DESCRIPTION("Led platform driver");0 S; W# @" j/ h4 E$ ~
MODULE_AUTHOR("Tronlong");
2 T7 y- z% T. t. A+ L* ^MODULE_LICENSE("GPL");9 ~/ U7 @# | C" \. c% Q
6 K" s- y: y. n! Q- t$ Z* x0 r
|
|