|
|
求大神给下面的程序做注解,请稍详细些,谢谢。& ?/ Y3 t+ W) _; p; N% J* ~! M4 M1 J
#include <linux/init.h>
+ W9 T5 W( a* s#include <linux/module.h>
B+ Z" ^' I& r. K+ f#include <linux/kernel.h>
( Z. C2 }$ F) o/ T#include <linux/types.h>
( P9 c- ~$ O9 w y' m4 [#include <linux/gpio.h>- ^* b c, [. q9 X* `+ }+ n
#include <linux/leds.h>- \2 v; a# K3 E/ r. r
#include <linux/platform_device.h>
0 @% v. k a6 f" o; h! m
" v* p- _5 T+ {' F/ C( I( k% p#include <asm/mach-types.h>
7 a/ k, s% o) b" M7 V#include <asm/mach/arch.h>7 `4 E+ z4 n# G% }5 ^8 s
#include <mach/da8xx.h>; r5 E% l9 M3 x; `' X
#include <mach/mux.h>
% P- R" k( q6 B1 G' P3 Y3 I7 H4 r
. l0 g1 [ \1 g0 R! ?#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
* p G7 p* Q9 y/ n6 T#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
$ z# R+ d8 E& f/ W* G#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)2 w i7 ?7 O& `$ K0 U% f
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
6 E) S- C) d4 w f5 E& f( s" c$ p9 @( M. x
/* assign the tl som board LED-GPIOs*/$ C/ H! m; n5 z e. K$ p6 j) T
static const short da850_evm_tl_user_led_pins[] = {
% P. I# {! Z" I7 d8 R0 C /* These pins are definition at <mach/mux.h> file */
: l: I% e$ y* B) g DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,* c! T7 d( |2 O6 K9 E. H
-1
8 r7 c8 Q) k' |* K, L w8 S};
* O k3 j; Y- E) M
5 d0 _! ~7 E3 ]5 X# wstatic struct gpio_led da850_evm_tl_leds[] = {
, `9 v8 B9 Z- ?* K1 u {. t. \' F8 X4 L. D, y+ g
.active_low = 0,6 G+ R" D3 b) ^& i
.gpio = DA850_USER_LED0,( t- q1 F7 j4 {" o
.name = "user_led0",
, W, L/ C; z) J1 I. ]. a2 K: y0 T+ H .default_trigger = "default-on",: H) ~* C; |4 k" f: B) H
},
e; u% r( g, q# a. ~' }. z {: u3 x2 Q4 R: c% a" o" ~
.active_low = 0,
4 S. {0 W5 i8 _0 {7 x .gpio = DA850_USER_LED1,
% X4 g9 R' w9 A q9 q% |: x .name = "user_led1",
4 n5 H& H c {; Y' I9 Y- U .default_trigger = "default-on",. }* V4 H* j1 _0 p% E* n* b6 [
},
7 ?( J* [) w( E2 |" J6 [1 z* F {
8 l! w- n' O$ U3 h: ^ .active_low = 0,, x: X5 Y. {0 Q' F
.gpio = DA850_USER_LED2,
% N1 S- {% G; z2 X1 S3 r0 j .name = "user_led2",. i# c8 u0 }( P. i) \" t
.default_trigger = "default-on",
% n7 i; f5 [; |+ p% y },
* S5 F: {" f0 F# F1 K {' L; d P) i! m$ W
.active_low = 0,* a2 ]9 H5 G# Z, I
.gpio = DA850_USER_LED3,2 F2 z/ u( o* _, G
.name = "user_led3",
8 K5 u, |, S" o: t .default_trigger = "default-on",
8 y/ H+ U7 Y7 g& ^* A3 Q0 n },
/ f8 t' v6 ~1 _};
, r, B% C1 w- L. w+ L. m' ^+ r; n
2 Q" d( q! k! w2 Q9 A- tstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {- P. Y0 m- ~4 p& J
.leds = da850_evm_tl_leds,
+ }$ _' l! G" s! x, B .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
2 z0 I# ], c; r! L2 d* c; O4 Q};) n r/ B0 G( w* ~6 G
9 }; e6 b; V9 |5 tstatic void led_dev_release(struct device *dev), U$ J! S' o2 r4 ]8 B, \
{7 z& C, G' t) S) ]; G! k" A
};
% |& o* O, |9 Y! V/ G |- B; E% h$ I" s$ t' j
static struct platform_device da850_evm_tl_leds_device = {
7 K' A$ W0 }1 ^" O" {$ ]2 I- V0 l .name = "leds-gpio",
2 ]$ R* z" Y# d |3 l0 P) h* G8 e .id = 1,5 F1 L% N* `3 A
.dev = {
( z/ L+ n0 \0 U' {$ h .platform_data = &da850_evm_tl_leds_pdata,; s! C% n7 p% h0 Y1 N4 k- ~
.release = led_dev_release,
# q: l9 o, y/ I/ I' |6 J" f: v }
" d+ G- T( l0 Q1 T# Z};$ |, L4 [5 h: K, f f, Q
+ X4 W& w1 e) N. |
static int __init led_platform_init(void)
1 K- t8 b& M# J! [{
6 @% I/ o: k" P% W int ret;6 c) i7 i2 _5 }7 j8 L$ L- {
#if 0
+ h6 I J6 A; @, j ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
1 z! n+ ?, d# d+ t! B: u if (ret)
2 K: B& o) T: a# g" d9 _ pr_warning("da850_evm_tl_leds_init : User LED mux failed :"( U! Z+ \9 m' U! p
"%d\n", ret);
0 i4 b5 v; g: x8 d4 x#endif
6 s1 P1 N0 f) L4 ^. o4 H ret = platform_device_register(&da850_evm_tl_leds_device);
1 @4 J: O* s0 R/ W' u if (ret)
! S y- `: m' K: P; M' b pr_warning("Could not register som GPIO expander LEDS");4 q0 g6 O( ?0 W3 l) P1 ?
else
* {/ B/ Y! W0 b& t) _9 t printk(KERN_INFO "LED register sucessful!\n");, D, x1 S0 s4 E- y
1 m5 l/ d+ H) v3 a return ret;6 v! L0 t6 w `' f1 G
}
- X6 c" C- W; J2 D
# d# W& o* P. b/ s0 e( Q+ Ustatic void __exit led_platform_exit(void)4 |4 q7 I. q0 f1 V# X
{
- |/ [. v. m& d. h1 v platform_device_unregister(&da850_evm_tl_leds_device);( F! A* R2 U+ N- c" ^9 i z4 t
7 p" X3 T2 j# t' n6 o- D4 [
printk(KERN_INFO "LED unregister!\n");6 Z9 Y7 m' Q$ X$ ^# i X+ p2 A
}
' a% o: m( `. C8 t4 Y3 K5 V7 M9 k& S' H& W3 D, A
module_init(led_platform_init);
4 a9 d2 s! C5 q0 K" omodule_exit(led_platform_exit);" U" C# Z2 } c4 \. @5 E0 o* G
# G4 j' S- v8 h5 ], ]6 O; L+ c& hMODULE_DESCRIPTION("Led platform driver");
/ z7 D% m; g/ VMODULE_AUTHOR("Tronlong");
7 B3 n5 C) `( G Z4 ]) S" R/ x3 |MODULE_LICENSE("GPL");( c; S6 g. i- t# Y/ j
[9 `+ B [* I" ~! e2 [
|
|