|
|
求大神给下面的程序做注解,请稍详细些,谢谢。1 V( |4 H. y- p- f, j7 {/ a
#include <linux/init.h>
7 |' m7 V9 y9 Q" \$ x+ ^+ Y! u#include <linux/module.h>
# A& z( |# a" \& F#include <linux/kernel.h>6 j0 c6 T, J+ s
#include <linux/types.h>3 ~5 Z- q! Y0 }9 }0 U! o
#include <linux/gpio.h>. c* F6 j4 o! n, ?$ H9 j/ T1 y
#include <linux/leds.h>
: Z6 Z2 A- [. f+ O6 g0 D9 V7 f#include <linux/platform_device.h>3 }, Y4 x% s9 c& b* r
. l) c1 |" y+ s4 ]# q+ S#include <asm/mach-types.h>
9 s9 ~6 h7 b# c* x+ Y! l/ Y#include <asm/mach/arch.h>- v* S M6 P3 Y1 g! Z$ d% T7 ~
#include <mach/da8xx.h>
' W4 C4 N6 ? `#include <mach/mux.h>; Y7 ]; g# F, p1 U
, P5 k/ z- J2 _7 L#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
: c- K* D% y* h' R* B+ @#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)7 [+ t1 O( K8 C3 B
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
6 h0 C; \/ [' I3 N4 H5 D5 @#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)4 K: f4 S4 n! W: g% Z
+ N2 Y! n' n4 v/ }/ ?4 H/* assign the tl som board LED-GPIOs*/
8 {3 ^/ V& x" J) J3 Y5 l7 |$ D0 r, bstatic const short da850_evm_tl_user_led_pins[] = {
; I" s2 \6 S# G6 C; P# a9 L /* These pins are definition at <mach/mux.h> file */
& i1 m& D0 ?0 o7 V9 R/ x; b DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
& Y' o2 [/ V0 T- P2 q0 J. b -1* X& U! V: Y4 F: m* [: P
};+ a" O+ m5 T- @) l! \& c0 u
! b( h4 Y1 a) b) s7 b& Z8 w7 Tstatic struct gpio_led da850_evm_tl_leds[] = {- ^: Y9 L- F9 ?! x" f; P6 H, {" o
{! R& H3 w( v$ }, f9 ]) r
.active_low = 0,
1 U% Z' J6 S {9 Z4 d+ Y$ Z .gpio = DA850_USER_LED0,
& o) ]* s- e7 a) R; w .name = "user_led0",% p8 L. o w) r% P- p
.default_trigger = "default-on",
( Q; d/ D4 m2 t. C/ R },
+ W0 x- {* K( l% n; y8 ? {+ k8 k3 O9 W% o, ?& j0 ^
.active_low = 0,
0 b% e$ V4 y' p. w6 Y& Q .gpio = DA850_USER_LED1,
2 q' P; _8 i: J4 J8 u% }- T .name = "user_led1",
4 Y8 ^2 R: J. N3 o .default_trigger = "default-on",, e |' X9 h5 G+ Y
},
7 W2 _! V5 a, N3 u7 o& Z3 F {
3 d) g1 O d/ ]- F: ] s9 D% U4 I .active_low = 0,) E: O7 ^/ G7 ]% j5 H2 k9 @
.gpio = DA850_USER_LED2,# m: u+ B* v3 }# ? f; n3 H5 x
.name = "user_led2",- h. E7 j5 V" a" r& t. N, u. T' t
.default_trigger = "default-on",
. X5 [ P9 K+ j0 F },5 {1 |9 B' _$ {" C+ Y5 E: r
{7 i3 h7 g `& P# F- x
.active_low = 0,7 Y9 V" n. ~3 U- p: @
.gpio = DA850_USER_LED3,
2 e/ k' {- {9 j0 B7 G3 q. _2 e .name = "user_led3",
6 p2 D$ Q5 `8 ?& r ] n- b( o .default_trigger = "default-on",3 g1 u: X& \6 Y' J: I8 J- i
},/ m6 d' V# e5 k) j: n3 {
};4 v8 A1 ~ U& i3 |& z$ P
* U. ?; ^5 `: T( u0 `7 u! K
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
2 J! \8 Y3 D+ Z d+ M7 \; f .leds = da850_evm_tl_leds,
Q6 w- Y' J! M, q .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
' s* d) a6 W) p8 s$ [9 J" c8 Q7 ~# P};) ]2 Y3 n8 T |. }( l
% L2 X2 z% I) Y1 xstatic void led_dev_release(struct device *dev)$ g0 U. l) b0 F
{
4 ^9 `$ Y. ?, p% j/ Q6 ^0 p) |};
( i! L5 b; _' ?7 o! }. C" i0 J2 S {1 i8 U
static struct platform_device da850_evm_tl_leds_device = {
8 G' u; w1 A9 v K9 f .name = "leds-gpio",% u* e; t" s! ]7 F) j
.id = 1,
9 G$ F' |9 A& c+ ^& [, y .dev = {
) F' C, R& o2 K+ m1 }! J .platform_data = &da850_evm_tl_leds_pdata,
% s7 g! A* M# e .release = led_dev_release,! A* _" u* J# x" ?
}0 s/ F9 _+ I/ r
};: p* V: x! l* @/ e5 E. v" h
% I; z7 j6 X2 P+ V& \3 Q
static int __init led_platform_init(void)
" f- M& A* z' v{+ G! w5 \7 e P$ }$ @
int ret;
" n3 X7 J" E2 m#if 0' ?, Q% O, S. \! g& F1 C; k1 A2 p2 b
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);- w! T4 P* N/ H6 P9 b& n9 p
if (ret)( K0 Z7 A- U/ T/ N* C& |8 J
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
! D+ @7 T D( S9 j6 _4 c6 G "%d\n", ret);
7 M+ u! X0 u; R1 ~0 ?+ J#endif! e$ i/ p4 ~6 `4 n3 g
ret = platform_device_register(&da850_evm_tl_leds_device);
- X8 B" L- R- Y( G6 c4 E if (ret)
6 ~% M& x# n( E) v$ A$ \$ @ pr_warning("Could not register som GPIO expander LEDS");& q `% g: Z* ?3 V/ \1 N
else% w/ ?5 s" H6 q3 @6 p( P
printk(KERN_INFO "LED register sucessful!\n");" P9 F- b# C, ~
( T7 v/ [% D: t, F
return ret;
$ M$ o: P/ F7 F& h! Z3 F}2 b4 @ S. y! n) U
2 i. K4 v$ b- Q- t5 \& f* s$ Z0 b, fstatic void __exit led_platform_exit(void)1 H' E% x0 w! m( \+ G* Q! I
{. a$ {8 {2 d7 k4 v# O
platform_device_unregister(&da850_evm_tl_leds_device);) g& O6 j( c4 ]3 i/ q9 l4 G0 |0 c( S0 M
3 _7 {$ g! r* g1 z5 v, Q2 W9 @ printk(KERN_INFO "LED unregister!\n");' B6 u* J5 a. |3 \6 J+ E: f# k* \% ^
}4 L) D5 o. R0 l
0 v3 y7 c: K4 S- N! Imodule_init(led_platform_init);# g1 Q: F) O* s$ U! M8 ^0 `' z
module_exit(led_platform_exit);
5 F- L; s4 B/ ]( F; J4 `4 V' v M
* @+ h f# R$ t4 _5 Z. M4 z; \MODULE_DESCRIPTION("Led platform driver");
# v8 _. j- S6 F F& D; t: MMODULE_AUTHOR("Tronlong");
9 r+ Z4 g4 P+ P' @9 \MODULE_LICENSE("GPL");
7 B* H- q( u* T6 ]7 l/ Z
: F7 H; c8 C! n |
|