|
|
求大神给下面的程序做注解,请稍详细些,谢谢。: ?$ U+ [0 n9 L/ Y, h& e
#include <linux/init.h>8 V4 z/ ?! q6 C
#include <linux/module.h>( u4 w0 c) d- h* J# B
#include <linux/kernel.h>* J X2 A2 E) W
#include <linux/types.h>! Y$ o& U, e1 ]) `
#include <linux/gpio.h>9 Y+ z$ Q; @! D. V T
#include <linux/leds.h>
2 C0 p/ |' s* k$ y: y#include <linux/platform_device.h>8 N: U! F: N- C6 L. A) l p& p
8 q( m4 z; }" s3 o$ J
#include <asm/mach-types.h>
2 d x+ d! V4 H6 @7 m% C- l% U#include <asm/mach/arch.h>- [. [5 k8 |1 u$ l9 T& l
#include <mach/da8xx.h>
5 |. k3 U) M" V+ A& \#include <mach/mux.h>
4 @# q4 a8 F# a6 m
$ X) L) j% B# v6 [. m& o#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)) T/ e) l5 y0 R1 L6 {
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
+ b6 y/ I+ |# L5 o* Z i2 R0 H#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
a: W) n- j! Z3 Q+ y#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)1 A) h; j' j3 o! @6 u5 h
+ @! a) I( e4 F0 \: V0 e/* assign the tl som board LED-GPIOs*/
6 ]0 x# j. ~ h/ D; f& Mstatic const short da850_evm_tl_user_led_pins[] = {
- J4 P# d# ?, c8 V8 \* m- K /* These pins are definition at <mach/mux.h> file */6 E- t5 d; e: L1 t K/ i
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5, A( {1 P! q/ @! {6 J9 I! |. k) s
-12 N& E$ G! i: A% l3 d
};' \% U2 E0 ^% C O$ q4 y E- I" S
& ?0 p+ B5 L ~, j; `) u3 I5 e
static struct gpio_led da850_evm_tl_leds[] = {: K8 M0 ~9 g: @1 S
{
- O0 J( V7 e8 Y- }; K, ` .active_low = 0,6 Y. P+ b& K# W& o! c6 v" A5 V d; J' o
.gpio = DA850_USER_LED0,; c: U% Y" d, g9 c0 A' f' P [) d
.name = "user_led0",
1 ]' |+ P l9 X- c$ I& g .default_trigger = "default-on",
( H6 L# H' ^& i },
5 o6 x; c0 E; S4 u8 }/ H' x {
, K" P2 y6 Q) N7 M .active_low = 0,
, E& D6 C5 y6 o; V; B5 B5 Q0 E- I" A .gpio = DA850_USER_LED1,* h9 e# q4 m6 |# `) F
.name = "user_led1",
/ b3 ~0 [$ C1 |4 Z' ]- R2 R .default_trigger = "default-on",
5 v7 }# |+ ^- U% D0 a },$ T& N: R3 s6 b6 R% P1 ?( e
{
; `8 k- [) A+ R i$ V3 X .active_low = 0,
$ x4 T, n, D. r .gpio = DA850_USER_LED2,
6 K, i! ^7 y8 | .name = "user_led2",6 \* \" k0 s* U, ?
.default_trigger = "default-on",
$ f- l4 c9 O S% r( t6 P: v" n },
0 R% G, w( W1 r! O. A {
3 e) x# k: C: X; ~4 z6 Z4 U3 e .active_low = 0,; R" Q1 r" b$ o; Y' [; }% u
.gpio = DA850_USER_LED3,/ q5 Q& s+ V: V; l C1 i
.name = "user_led3",4 b' j4 a' i. e, e+ }
.default_trigger = "default-on",
6 s8 e, o, f1 K4 W ~. D7 E },
$ w$ \/ K) O) \% W( n+ u7 f2 p3 w};
/ `# J% |2 E4 a+ y. G ?) ^
4 d# I' I! \( ~* Vstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
3 a# c! e% e2 L! i( H .leds = da850_evm_tl_leds,
E8 s/ o$ p5 o/ H. y .num_leds = ARRAY_SIZE(da850_evm_tl_leds),3 j* Q2 N5 G3 L# G) A* ` u- M4 s3 Y
};7 t8 p- R; r6 D! I. G' D& s. x
( n: o6 S/ B J; X) J$ t b
static void led_dev_release(struct device *dev)2 S! ~: a$ _$ E; \) x
{
/ M; C9 ?4 ^* I/ [1 f};( b+ Z: x& t. t! I6 B' b
5 l" v' w8 n9 O% G9 r
static struct platform_device da850_evm_tl_leds_device = {: J0 [( w9 f7 k$ |: ]
.name = "leds-gpio"," U# |) w: T4 h8 I7 W
.id = 1,+ H# C% s* z& R+ [
.dev = {
$ Y( ~/ v7 X& ~# o/ ]( \) [7 G' X .platform_data = &da850_evm_tl_leds_pdata,* X1 \# q f. h. ?* x( C; J
.release = led_dev_release,
0 a1 |) M4 s) c3 P }
% z3 G3 A4 J4 Q% e; m. i};
( X' D% _5 F7 y+ a8 n2 x+ A
o0 ` ~8 j$ ^3 I& t+ p* ostatic int __init led_platform_init(void) E9 g$ Z2 L; M
{! p( W/ Y) P0 l
int ret;
2 W! t. P7 `9 k; q% R5 T1 [+ y#if 0
- D, V. v5 y3 n" i+ c: b, m- _ c( B# q ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
# _* `* _5 \7 X9 }& S) ]/ H if (ret)
- s% W1 {/ u' | pr_warning("da850_evm_tl_leds_init : User LED mux failed :"1 S9 A2 C3 k1 F* c) X' m
"%d\n", ret);1 e2 \, r2 C) C2 J( @
#endif$ v5 p* @8 |; w
ret = platform_device_register(&da850_evm_tl_leds_device);% {, u' c, ^0 a$ i
if (ret): c% [ T" ^$ l/ r
pr_warning("Could not register som GPIO expander LEDS");# R* P) s7 {% _0 e! R" b. {( B% S
else
+ C, I; Y" R. j" c printk(KERN_INFO "LED register sucessful!\n");8 s# x, {/ y$ ^+ u4 F+ {
* Z* Q* O2 G8 Y5 A' u: ] _
return ret;; M8 }* f% H8 b4 V$ t V6 \1 c
}
% I+ @, O& p, Y6 \9 _9 E4 r2 y/ U4 y* Z7 L& J3 p6 l3 \
static void __exit led_platform_exit(void)4 r$ i- d7 K7 |: Z) d- T& l$ Z6 t" v% i
{
1 |8 q3 z) S8 Y: B$ K( } platform_device_unregister(&da850_evm_tl_leds_device);$ L" I: A/ e+ Y) R
% n# g& h- Y% O) T$ H) d
printk(KERN_INFO "LED unregister!\n");
( R: B, N- j9 [! q% I}
; p Y. m% r- y8 q5 ]+ e6 {$ F' S* f' g
module_init(led_platform_init);' R1 V. t+ c' ^
module_exit(led_platform_exit);
) Z8 t, g8 w; [0 E1 q% ~" z. c8 J. O4 d
MODULE_DESCRIPTION("Led platform driver");; T, Z, G5 N6 s r3 A7 ?) H
MODULE_AUTHOR("Tronlong");
- c' l' }* T5 G9 {MODULE_LICENSE("GPL");
/ i" u7 p" K: ^) E6 x! c/ b
6 \+ _' ]% p" q& k% n |
|