|
|
求大神给下面的程序做注解,请稍详细些,谢谢。' V8 `' C6 u% k5 A' L% l$ s) Y
#include <linux/init.h>
6 I7 K5 {. V# K. Q# L6 |3 l#include <linux/module.h>9 |1 m; r. L' q
#include <linux/kernel.h>) y; X3 H/ ?) c& M
#include <linux/types.h>
* o( V. x% r: ?#include <linux/gpio.h>% t% R4 F6 Q: ^+ i
#include <linux/leds.h>
0 E& C G" @: ] |: m( s#include <linux/platform_device.h>
$ t; P I8 b8 |2 D5 Z1 C {" z1 |( r. l; x- U2 U. Q7 q; `
#include <asm/mach-types.h>! K, K0 ~) K1 j3 k2 W5 j6 z
#include <asm/mach/arch.h>
+ {- U. {& K) a. H7 |) s0 @#include <mach/da8xx.h>; ^2 \9 A5 C a9 R& l
#include <mach/mux.h>
5 d6 Z$ q. j; u- I1 B: G9 n2 f0 g! \
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)9 U& l: {5 X/ q. h w
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
- d! Y/ a! s$ t( @: A5 Z#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)% d5 G7 d+ h: p: x3 B" D6 Z5 r, ^
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)+ ?6 ~2 \0 \8 m* h7 t( D
3 y& q) J5 f+ q/* assign the tl som board LED-GPIOs*/
% X, N! I$ N! Kstatic const short da850_evm_tl_user_led_pins[] = {
Z/ r$ ?; f2 ~, I /* These pins are definition at <mach/mux.h> file */
" m+ K1 i5 ]. \2 e$ h1 K2 e- P9 [ DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,7 S0 s8 V3 T. R; N- e0 |
-1
; {8 p8 ^! C5 ?};. z+ v. @/ Y/ o; I+ \+ C0 w
2 G. x5 H$ g. W+ U0 S$ |, V
static struct gpio_led da850_evm_tl_leds[] = {
9 C- k# f/ i& g- C( _ {& h( J1 b' o% u) w9 g* P
.active_low = 0,% _+ n; L( h4 k) @2 `
.gpio = DA850_USER_LED0,
% a" b- e a, h' z1 r .name = "user_led0",
2 `; F1 l6 r" H/ m9 z; h" ~' \ .default_trigger = "default-on",
- s( w6 [/ N: x: t },4 `% N+ x! k9 N" J: Q3 b
{# c& n& W1 V' n/ W; ]4 y
.active_low = 0,
' s6 E, o5 F% X! k( {, h0 u* f .gpio = DA850_USER_LED1,
3 M9 b( ], f0 D* E+ a+ J7 N7 ?, o .name = "user_led1",
" q: U' C6 @$ Q3 k) d .default_trigger = "default-on",
; X" Z0 K% ~! V# ]% w8 z5 m+ L7 N3 f },4 e3 ^& V& T. w; p* {
{0 s0 E. J$ p# b, K
.active_low = 0,
: y$ i, a' o8 B8 o9 s9 n4 E1 ] .gpio = DA850_USER_LED2,; }! y- U4 I' D9 E! v) K4 n z
.name = "user_led2",
: k0 V) n" D/ S2 h0 e+ J# w .default_trigger = "default-on",
# l+ s7 p( u* |7 j* ?, g& P },
* a/ Y, M4 m& h! |. U: u' O! `- k3 Y {- Z& `. G/ T. P( U! W; O
.active_low = 0,+ Z# }; ~' m5 I
.gpio = DA850_USER_LED3,* T9 W) B) h+ P- ]8 Z# C3 X- i
.name = "user_led3",
9 {: ?5 D, q- n2 Y g .default_trigger = "default-on",
+ L, G2 V; _1 a# Z+ O) N },
( Y8 ?7 D9 q+ O" Z4 r};
0 C2 j# e& o, u" C7 X5 {2 v6 T& u/ j' ^8 v4 H' y2 n) F
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {# q( _& e8 i5 [: W5 Z) n
.leds = da850_evm_tl_leds,: g' H9 ~0 d3 _$ A: ?6 r, i
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),$ Q8 A7 n2 m7 k& F( V$ h
};
/ u& H/ Q- W/ l+ T# v( v' P( d7 Q6 [' y8 j* Q0 ]7 M/ c/ x. e
static void led_dev_release(struct device *dev)- u4 a) y1 G8 T Z! B$ k0 D7 d
{
+ q6 @: C( l7 k' j: p0 ~2 z6 W. h};
/ G3 W" q) ]* k8 {
3 C0 x, f5 c" lstatic struct platform_device da850_evm_tl_leds_device = {
. ]$ B4 ~6 A4 A/ R/ B7 ~ .name = "leds-gpio",
1 X/ f' X5 s. n4 b, X! @ .id = 1,
0 q, G& o: ]# V .dev = {
) o( ^+ F* W9 `+ b% U( V5 A .platform_data = &da850_evm_tl_leds_pdata,
, n! k" d# l7 @. P J; T4 s, | .release = led_dev_release, F7 Q5 k3 ~. l0 H( |: Y% ~
}& v9 b' Z1 |4 | F8 H
};: ?( B( l5 W- f5 w
6 |# j- e0 G% vstatic int __init led_platform_init(void)
% `4 ^2 i5 Z$ f- Y! u! {7 b: }{- I" n @3 { u+ V, E! p9 T x
int ret;
$ A+ I- R; Y. J0 ?7 D0 {+ t#if 0
4 t. R, ~: _ i7 @) Z& o% b' Q2 I2 L S ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
9 l* L) J; c2 T' W if (ret)5 Z( R, G, S* V: q7 ~% L' F
pr_warning("da850_evm_tl_leds_init : User LED mux failed :". z1 X( u2 C K: ?6 I2 d/ G
"%d\n", ret);
5 U& h" V* R' d; g Q- W#endif/ } y6 o( }; Z4 J3 U; p% k: D
ret = platform_device_register(&da850_evm_tl_leds_device);- ]# h( V( B( g* g, W- Q6 \, P% m
if (ret)& c: D' H1 c$ a3 @1 |( y( h9 B2 H" \
pr_warning("Could not register som GPIO expander LEDS");' C# e8 \, u/ K
else
) Z# H4 F; O" d- @3 m* u" ] printk(KERN_INFO "LED register sucessful!\n");
; Q# \: R7 z- U7 h9 J; T3 K) `2 \6 @7 t0 l( e3 i% g' v) v/ l$ x
return ret;
' u* U8 U7 S( d# ~4 c1 Z}
]3 v( ~2 X) l; \* K8 Q
) n/ q/ f$ \5 K8 sstatic void __exit led_platform_exit(void)
3 e: H4 B; O6 s0 J{
; e8 U; Z$ S9 J- ]& z- M8 m platform_device_unregister(&da850_evm_tl_leds_device);6 w! s2 p+ H4 p+ f. o
( G2 b3 P6 v8 A; Y
printk(KERN_INFO "LED unregister!\n");
9 M% o; R& }% F9 Y}/ J) U ]2 b/ R) y9 j" m) S) G/ m$ U
7 ]% y0 C$ Q* y! A& a% l& wmodule_init(led_platform_init);
3 [: J; H0 A% o, c2 {& amodule_exit(led_platform_exit);
9 |6 q7 e. Y! n+ N7 T/ y# k C/ a& T- b1 T& X9 `* h. i& ? u8 U
MODULE_DESCRIPTION("Led platform driver");6 ?8 M% u6 p2 R8 z$ \ f" T
MODULE_AUTHOR("Tronlong");
; G( F* [8 C, V+ `$ g4 G3 \MODULE_LICENSE("GPL");
- W/ m0 c }4 p' F. U0 D( y9 a$ |5 U. F; d# e5 k
|
|