|
|
求大神给下面的程序做注解,请稍详细些,谢谢。9 q6 w) d" Q6 A1 Q- [
#include <linux/init.h>
2 O( X5 x3 w5 B/ [#include <linux/module.h>
M0 |/ _, q" K9 N#include <linux/kernel.h>; G% X, s0 j+ _9 V2 l+ A
#include <linux/types.h>8 G8 V( h* g+ t1 B+ e
#include <linux/gpio.h>
/ v$ x7 t1 a, G7 u- ?, z( j8 Z+ Q! f! |#include <linux/leds.h>
( q x7 M# m0 h: K4 N0 @( b; h#include <linux/platform_device.h>
: z. e# f& h3 q: ~" T3 g" D+ i$ I. ~0 T4 p ]+ ?
#include <asm/mach-types.h>& E+ Q, ^. v3 q
#include <asm/mach/arch.h>
' q0 r+ c" w' s9 J, K. R$ ^#include <mach/da8xx.h>; g: [1 @' V" H! M t6 P7 Q
#include <mach/mux.h>
# w+ F8 g- N7 O/ I
7 q' F& S7 G' w4 b4 O: v7 ~#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)1 u' p! U; l3 k) n
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
$ _5 A/ r7 ]; ~2 a. Q- t#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
. @" L* @1 ~2 V' M& ?, P: W) S4 x#define DA850_USER_LED3 GPIO_TO_PIN(0, 2), _- h1 x9 ^& j
( M$ A4 ^$ g7 F
/* assign the tl som board LED-GPIOs*/
& w/ v3 z# h, @$ v( G4 C4 rstatic const short da850_evm_tl_user_led_pins[] = {
4 e' u+ V1 p% K2 P /* These pins are definition at <mach/mux.h> file */0 {: W7 d2 V4 q
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
, F7 s1 r- y! N% m; V$ o6 i -1
6 y1 Q, ^# X1 c/ `};2 f1 I+ K7 t* L t
4 f1 _% R1 N; Y5 w. R" P) I: q
static struct gpio_led da850_evm_tl_leds[] = {
# E( Y- z* ]) y, e' U* | {* z3 Q2 H. V* T3 s) C
.active_low = 0,
, k7 m* Q# Q7 m' q .gpio = DA850_USER_LED0, c0 N3 _) y6 a3 i2 d" a- U8 u
.name = "user_led0",
$ r) s" | Z% U: N* c6 z .default_trigger = "default-on",
2 ]; E9 H; a" k/ i4 K },6 W% {2 J( Y8 s$ G4 O% k1 k: S B c
{
3 l, L/ S0 b. Y5 T9 q* V4 ` .active_low = 0,+ y; Y" |5 O. A$ B) E
.gpio = DA850_USER_LED1,& h1 o6 l" ^5 C( T7 M- ^. c$ A8 H
.name = "user_led1",
9 i# ?0 e! z6 I# h3 a# Y .default_trigger = "default-on",
! m. \+ [$ B0 r a },
. W3 U2 Z, i3 T1 O6 ]2 i+ q" f' l, j" G {
1 w2 Q2 F6 f( t7 O .active_low = 0,
; N. o( j$ p! J2 W .gpio = DA850_USER_LED2,
# r4 `& r# _/ k, U: z8 N- N$ w .name = "user_led2",2 [* P7 k) ?; V6 ~% t& l) E; |
.default_trigger = "default-on",
c. \3 G7 W3 o j7 F0 A0 L9 \9 W },
. Q \: ~( H1 Z- h$ ? {
: ~6 D: |% E% B6 M .active_low = 0,
* w) R6 ]6 C( d1 V# ~1 g .gpio = DA850_USER_LED3,
5 S5 a8 p& Y$ m0 M .name = "user_led3",+ J; c& W% w [. y! [6 t
.default_trigger = "default-on",
+ D3 G' a7 g' I% `% Q6 p6 x },4 L: n+ x6 I+ S, _1 H5 Y+ a8 n
};
& R+ A8 i* Q8 R6 |# F9 z) M4 x* r; H$ q2 t3 o; U' \/ y- ?. w/ n' o, c! O
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
: _3 V, p# j/ H6 v; w( R6 ~ .leds = da850_evm_tl_leds,1 ?, N+ z7 c7 K
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),8 D$ e! c5 q& u2 n
};- r# X0 f# e* ?, E$ M
" [- i) y r, A6 ?
static void led_dev_release(struct device *dev)
, w( b0 w! E0 v, Q{$ D( F# l! k* R6 x. _1 W
};* P8 b$ C- g8 |5 K H
( [8 h( M. B" g/ F: O3 C3 I4 Z6 Y$ qstatic struct platform_device da850_evm_tl_leds_device = {
7 J6 I; b* U- {& y) P! x- |! A* T% B .name = "leds-gpio",
3 o1 I9 ~' x4 J: ?/ v .id = 1,
$ m+ h# S, n1 ], X$ Q# ` .dev = {
) g, g2 d, t2 `% c$ D/ ?9 B .platform_data = &da850_evm_tl_leds_pdata,9 y5 W6 g7 h& j- N8 v, |$ G
.release = led_dev_release,
0 h6 X4 i6 I, C$ P+ y& M }, b- p% a5 F: ?/ f0 d
};
) M ~' C& X9 Q( N& u
; L0 Y F9 j* X% M/ Ustatic int __init led_platform_init(void)0 Z6 e1 g" _3 H8 W/ B
{
" d b$ [ k; s$ R int ret;" _4 q! ]$ V6 D
#if 0/ p4 h* N% x; U; i5 p7 w, H
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
8 _3 e; Q% Z) O* f$ |3 M i if (ret)
# w. l" r7 r' A- Z. ]7 h: P pr_warning("da850_evm_tl_leds_init : User LED mux failed :" [; t! R# F* A; F' D
"%d\n", ret);9 q, }: h I5 l: x3 o/ _
#endif+ X+ g$ O" C+ e" {) N
ret = platform_device_register(&da850_evm_tl_leds_device);8 {% s* G3 v% Q0 f
if (ret)6 s. j: x* [) |# c
pr_warning("Could not register som GPIO expander LEDS");) i% v, z& T" @% ], M2 }) M S
else
. E* C. r. ]" f' v0 t# p' ]& o printk(KERN_INFO "LED register sucessful!\n");0 k$ A) ^) }: {
8 h) ]* w* E9 w, J. L% f9 i return ret;
4 a: ^0 _. J2 L0 S# O8 G7 ^}# Q0 V: D' Q# b2 x
5 C3 D1 P8 U5 A8 z! ?" w9 `
static void __exit led_platform_exit(void), C2 \( z$ e! N# H
{
/ S% y- f/ J0 s9 ?) l platform_device_unregister(&da850_evm_tl_leds_device);% E4 W/ b ^5 Z/ i" y, v, U) ?1 ?
- y2 S# m5 r: b3 b. g3 d
printk(KERN_INFO "LED unregister!\n");
( E9 N8 z- ?' l5 N}2 ^9 o8 I0 x9 h
: w6 y. s9 ?' W9 f3 n% k5 i( ]module_init(led_platform_init);
/ T6 y8 f# Y1 M w5 A. ~0 ]module_exit(led_platform_exit);8 p: f) [6 Z5 G4 T
3 _+ [. \. W0 d# r% A) ^4 @: F4 AMODULE_DESCRIPTION("Led platform driver");+ @8 b! U' Y* R0 Z2 ?. o( S
MODULE_AUTHOR("Tronlong");
2 ]8 [6 G4 p, X+ I. p% B$ i. _) ZMODULE_LICENSE("GPL");# ?! A O' Y7 P
: Z4 R8 ?, N6 z, B1 C L
|
|