|
|
求大神给下面的程序做注解,请稍详细些,谢谢。* b Q9 z" l2 K- A. w6 ^& d
#include <linux/init.h>
; k* E5 V1 @, ]+ x: S1 M, K& L5 G#include <linux/module.h>" B5 C/ O* `/ T% z: d, \
#include <linux/kernel.h>+ a" {/ r0 y$ h/ H
#include <linux/types.h>
% N) v2 ^, i5 M9 V6 s8 e6 A L#include <linux/gpio.h>; p. X8 k: z F) }
#include <linux/leds.h>& U ^# d4 o, f0 P: I1 w
#include <linux/platform_device.h>
; u0 n7 I' c: u1 M8 B
7 w: s1 [& K. V" {" e# U4 G#include <asm/mach-types.h>! L! R2 Q2 t* ?7 W @* r
#include <asm/mach/arch.h>3 z! w, c \& Y- Y6 a8 ]" W/ l, l
#include <mach/da8xx.h>
4 p( a, `; i! [9 {# }#include <mach/mux.h>
0 b7 z8 K5 `# ^1 Z2 X. J* {8 W% k1 L8 S
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
- W5 _( @! T5 w, ?; b' O#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
" U5 ~3 j0 N* U0 D#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
4 R7 i& G) I* ?) g#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
& |( o, e n O% n x, E8 _, S9 {. E/ j& w
/* assign the tl som board LED-GPIOs*/& t. g. ? X" P2 G! X- z/ j
static const short da850_evm_tl_user_led_pins[] = {
- f: A: D+ W- O& F /* These pins are definition at <mach/mux.h> file */$ f# T, X: N- h+ W" p0 [0 O
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,8 \& ]! r6 D9 k
-1- {( e7 W7 o2 F: e
};
6 T0 @4 _- F" |: e1 |/ C3 M+ V! s; c, s3 A+ x
static struct gpio_led da850_evm_tl_leds[] = {6 R- [" \) Y' S$ t1 R7 [
{4 }, P! {5 j/ a% g8 m5 Y
.active_low = 0,
) F! C; r( E; q' H! ]( G .gpio = DA850_USER_LED0,, J8 h0 b8 |1 o' K
.name = "user_led0",
6 x* }7 {3 S4 d( S .default_trigger = "default-on",
6 K2 s* }7 p$ _& |3 C- q0 Y },
% s: K1 ?- L4 i; ?5 p+ X {
8 Q$ P0 l8 w0 }/ M% z .active_low = 0,7 e; @( Y/ S1 ]& R% W4 |
.gpio = DA850_USER_LED1,& Z0 \0 e- C) `/ ]7 l' @* R/ K
.name = "user_led1",
9 d5 D3 _8 ~( q .default_trigger = "default-on",: u( G4 l5 V6 Y( H7 j
},
- M6 `) v6 E3 V h6 ]7 ?0 n9 l$ Y/ l { ^/ w: F2 w4 z# f3 z
.active_low = 0,
4 S' d* b6 x# [; l, d# a5 t0 x .gpio = DA850_USER_LED2,; K5 c+ j5 F. n$ k3 f# q
.name = "user_led2",( q. i/ L7 m( V; j2 k
.default_trigger = "default-on",4 @6 Z& Z0 r5 x/ k( z5 k
},8 }" N6 T: O3 _$ s$ v$ E/ q( ~
{$ \" ~: I- r' h# g
.active_low = 0,( @$ w5 ~( g D9 q4 Q# [4 h* J, j
.gpio = DA850_USER_LED3,
{: K$ t& ~' c; f% T, r/ { .name = "user_led3",& j7 Y, n: Q. v" |
.default_trigger = "default-on",
' w. V1 u3 d: b5 ~7 n' }3 _ }," }+ a9 P9 Q' R e2 n, p
};
0 q8 ~+ j: H2 l! T5 v
0 a' z" q. B* \. ~ z( Sstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
6 ~' @3 I1 z! M( L# h" I .leds = da850_evm_tl_leds,
0 s2 a. @8 e* h( `/ t' B5 h .num_leds = ARRAY_SIZE(da850_evm_tl_leds),# \ X& {3 ?5 m6 T3 s
};
+ }8 s- ^# W- c- E r3 p% C% V5 f% Y- M" {/ Q$ B9 s Q- T
static void led_dev_release(struct device *dev)
& _, h, O& ?" ]# a{, E4 e% D5 {" J4 G- F
};
1 g/ \# D0 x5 ^3 y$ \" M: m- E. H& n. x
static struct platform_device da850_evm_tl_leds_device = {
- \. t3 G. }0 x: B& Z' Y' G8 r .name = "leds-gpio",: w7 x( v/ b# o
.id = 1,
% h) M% |9 W! o. r .dev = {6 x7 f: Q: P- G! _
.platform_data = &da850_evm_tl_leds_pdata,
6 C" C4 {. i7 x7 Y0 L .release = led_dev_release,4 m% ]8 R* M) \5 D' g& N
}2 m) f( n9 } x2 o" C1 U
};
$ s4 b/ e8 r4 }* ^$ b: X& O' F* z( | Z
static int __init led_platform_init(void). O/ P6 C. K& f$ ~5 H
{$ g: G9 `) W% z
int ret;
( o& M/ Z; g8 j) ~) e6 T& y#if 07 z9 E* c0 H7 k9 {
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);( c x7 n2 M1 y1 m
if (ret)9 l& m+ @) c& F) p" j4 T6 I
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"7 s0 J: a: ~; V: z+ v5 Q
"%d\n", ret);
) ^+ D1 E j" M#endif& F2 E- G9 q- E5 b" q, Y
ret = platform_device_register(&da850_evm_tl_leds_device);
# g/ O9 [- q: G. N if (ret)5 N: d: S r( @+ W, N: E9 y( |2 ^
pr_warning("Could not register som GPIO expander LEDS");
, [/ N, e$ o' i: D# c U. b else
! F1 X8 }+ c3 {1 a printk(KERN_INFO "LED register sucessful!\n");7 `0 ^ J" z( j* l& h
/ i8 M$ b! i0 d$ c) P return ret;
1 L( Q# D6 F: T$ F! E}9 Y' D# L! M. u4 N3 Z9 T
, p3 s6 @4 {* s) k) p7 g
static void __exit led_platform_exit(void)
+ {' ?6 C7 d6 R, F) w{, @ K/ s4 _; l4 \
platform_device_unregister(&da850_evm_tl_leds_device);
8 `" j" b' B! o2 I1 x% ~
6 D; [- o( ?1 l( @, f printk(KERN_INFO "LED unregister!\n");
3 O0 L: N+ X8 d& z+ h& x3 b' M}
2 e1 S$ h" b; B4 M
% W( E- K. {6 H% e& e9 Z0 x7 W) Umodule_init(led_platform_init);
: W: A0 o S' Q% `: d, vmodule_exit(led_platform_exit);5 i. f0 c" ] n- y1 s
0 w$ d }0 o! w* ^6 I
MODULE_DESCRIPTION("Led platform driver");& {: Z0 T, a; u) a
MODULE_AUTHOR("Tronlong");$ s) P5 b, ~/ a* I4 i
MODULE_LICENSE("GPL");9 u5 Q! {, C+ c9 `- d; W6 W1 F6 n
" [8 e0 N& M6 V- H2 I" @5 z
|
|