|
求大神给下面的程序做注解,请稍详细些,谢谢。: {( u& } u n
#include <linux/init.h>
- }" h3 A: G) o& W7 m! J#include <linux/module.h>
# d1 @1 I3 C+ F( V; Q6 P#include <linux/kernel.h>$ S p8 \4 f: Q7 p
#include <linux/types.h>! t5 P' |. p i9 a; y# k. j
#include <linux/gpio.h>
+ H7 A- |8 l: i5 x8 D3 f% Q; S#include <linux/leds.h>
! u& R) g% T, M- C' |; {#include <linux/platform_device.h>
& Z0 h) G- i8 ^, X% R) O( w3 E+ O+ E9 ]+ K7 r
#include <asm/mach-types.h>( s Y! o2 ~3 m+ x
#include <asm/mach/arch.h>, J$ l) y3 D8 y- p
#include <mach/da8xx.h>
/ ~/ z4 V/ S# R% F1 w1 V#include <mach/mux.h>% P, r' B: a" h: @
4 p) s$ V$ Y P6 s6 Q, L( o#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
$ [& f: B1 V. \8 m#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)4 r, M" X! w% @1 B
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)* l! Z1 J1 Y) S3 r6 z* ~
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)2 |4 J; k3 F) j5 s% R3 u
: w2 w6 `! {9 S3 K" i" v1 K% v/* assign the tl som board LED-GPIOs*/# m& ~% D! c% s5 C1 c
static const short da850_evm_tl_user_led_pins[] = {
. o* k2 }5 o8 n! v% e /* These pins are definition at <mach/mux.h> file */
" M* v6 ]4 R0 D! t9 _$ j' Q0 c DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
+ W5 n |9 s6 Q* S -1
! P/ x* {; O* `( o* c7 X9 k* X};" m( }. q; e7 ?
. n- @/ W5 {. X5 O! m4 Jstatic struct gpio_led da850_evm_tl_leds[] = {- a4 E1 x! `. l" |
{
( c. G0 e. z7 v4 k .active_low = 0,
O- h$ |% l# u/ t) l! s. {0 ^ .gpio = DA850_USER_LED0,% X8 q( `6 A; c
.name = "user_led0",9 O D, g U! ?& `2 |2 w
.default_trigger = "default-on",: i3 U: G m& z+ f
},2 R1 i+ k( B, m
{
8 l0 c: Z: W3 \ .active_low = 0,. G# x' I$ Q; p( f0 f+ z
.gpio = DA850_USER_LED1,: ~9 d: F9 K! z
.name = "user_led1",
7 @7 N" `# g. c) d2 S. Y .default_trigger = "default-on",
8 H$ E* F8 f2 @8 {" K$ j8 L },7 e# t; N7 L j b# g2 b! b
{, l0 d! d, _, M
.active_low = 0,
( B# _2 A- |) V4 V5 E9 n .gpio = DA850_USER_LED2,+ }) P* O) G( b; u2 g6 k
.name = "user_led2",
# L. R$ g* ~8 k8 q: u .default_trigger = "default-on",
+ M: U5 G6 Y$ w3 f; j7 n2 L },
Z5 U1 b' l) w$ o' L9 K& E6 F& N {
1 I! k! Y4 Q/ @: o+ x( G .active_low = 0,
5 u6 i6 M; l* I" M .gpio = DA850_USER_LED3,
! ~, m& O2 z. d/ y; O .name = "user_led3",
* b9 ?5 B) T1 Q. V .default_trigger = "default-on",
% r9 O% y6 O, A' f* ~ },
( A, r/ H3 c- J/ s" f};
# k+ l- @* G% }5 @1 K: E- W# j! C
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
7 p0 M8 z f0 T+ m" B2 i .leds = da850_evm_tl_leds,
) r9 b6 ^5 i3 w2 ~7 A6 N- X .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
% J c4 G# g. V6 |4 o};
6 A! _2 p$ e! M" s' g
1 r' L- V% e' _& L( a/ `8 j7 D( d3 Gstatic void led_dev_release(struct device *dev)
W( N- A3 H' k/ t8 @{
& e8 v e" y* ?) j};; v. W4 Z& W& D/ [2 m O5 V; t9 O
; Y7 t/ E& y9 J+ m
static struct platform_device da850_evm_tl_leds_device = {
- _! Y& T g( t/ p .name = "leds-gpio",
1 N* ~0 I- X" R: ]6 K, v& } .id = 1,. w& f! j' [! \! _* z8 z! W
.dev = {
9 E$ {8 l4 N% A2 T/ M, c .platform_data = &da850_evm_tl_leds_pdata,
L1 C k' Z0 O! P) _, w: ?) c: Y% @! @ .release = led_dev_release,
/ m& M) P! \6 c; _ }
. O! s* [7 @+ r( `! y- ]};
& F( k( S% h5 y' u# T5 w; c$ T6 O0 w, k
static int __init led_platform_init(void)
, e, l0 V8 O/ D( f, X{- T- s4 g& S$ P$ h! F1 ~/ i
int ret;
3 c& F& H9 L6 y+ k' ]( M1 q#if 0" h" X6 q3 O o/ T- y( S* q4 O
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
6 P" d4 V! g1 }/ S9 H if (ret)
_2 k- k. @8 Z8 p& X" Z' G pr_warning("da850_evm_tl_leds_init : User LED mux failed :"8 u" a! V" g' E2 B W. `
"%d\n", ret);
9 S" g* n$ C5 a: `4 j' ~7 V1 L# b#endif
& c+ w6 G' }0 q ret = platform_device_register(&da850_evm_tl_leds_device);
. l4 {" e3 B5 Q; E if (ret)7 h- v" H+ ?0 i
pr_warning("Could not register som GPIO expander LEDS");
u* F; [2 I& h, V% x1 K else. {, P, g, B. t) @( v2 H
printk(KERN_INFO "LED register sucessful!\n");
. A+ f$ {+ N- e/ ^5 ` R- }5 U/ f6 i, I
return ret;$ z" H! G/ W& Y) B Y
}5 B1 p m: A+ L) `) U3 T; o
8 U5 k& P! D4 X! Ostatic void __exit led_platform_exit(void)
: X0 {; U) P8 c{/ f" Y3 E0 f, T- B
platform_device_unregister(&da850_evm_tl_leds_device);
0 ]- r3 j3 M+ w0 t8 }' c8 _+ G; F3 o, [$ m# W. f
printk(KERN_INFO "LED unregister!\n");' J, {4 h s. D& D
}- Y2 F0 [- i5 R* v# F9 y# ^; Z" c+ e
5 Z A9 m# ]- f5 O2 b9 dmodule_init(led_platform_init);. r2 @% A+ t% k0 h
module_exit(led_platform_exit);' s! t+ d2 ~5 g3 X
; B' ~4 r! H7 g! s7 H* t
MODULE_DESCRIPTION("Led platform driver");: b( C( M I7 v/ D. X: ]1 z
MODULE_AUTHOR("Tronlong");
+ M# f! a' V# f% KMODULE_LICENSE("GPL");
; |! O9 B2 W: S, T; x2 v3 n9 X& O# m$ D/ [) y4 v. |
|
|