|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
0 G9 I" E* h: A8 s3 W#include <linux/init.h>
1 _8 ]! c; O5 q1 [1 P/ J; o#include <linux/module.h>
( c! C& w6 O# j: a* i7 ]7 M3 X1 u#include <linux/kernel.h>
. Y1 {6 g! V* d- r; |% G# L- _, T6 M#include <linux/types.h>
: b& G/ J+ S5 X Y+ u+ R1 N#include <linux/gpio.h>. S, S9 v% V5 v4 J# b0 O# {; \, t
#include <linux/leds.h>! \5 T9 H6 b4 y/ q& d; Q* z
#include <linux/platform_device.h>" Z2 K: n S6 l% R8 {
9 ^1 T% a# [% J/ R1 j0 I6 n, h#include <asm/mach-types.h>) x- b: d; u3 j9 q; H/ f. d$ N
#include <asm/mach/arch.h>
- _; ~, J* i/ E#include <mach/da8xx.h>
' H' o' K8 C! `# j5 ^4 L4 D#include <mach/mux.h>& x8 ~$ K* O# Q
' t0 w$ V" R8 }
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
9 O7 {* x- I+ N) A1 T; w! P5 M#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
% m: J) m" L* l! I2 m- x6 g#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
# L6 ?/ ^" e' b; A4 j3 ]#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
, |' x# U- _( ^
2 O2 d" n Z$ V! T! m/ ~/* assign the tl som board LED-GPIOs*/
' K5 \+ c0 y ]/ }9 W& g5 @! {static const short da850_evm_tl_user_led_pins[] = {( c, v4 U5 x' N: h0 M/ K
/* These pins are definition at <mach/mux.h> file */
5 \# n9 z/ |" B. k/ ]( X DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
: m. z5 q+ f; X; _ -1, V, y2 G1 k: D- Y* M) L" Z1 D( e
};
) x0 V Y. ~2 Z% F
/ v0 u9 [3 q7 O+ `7 astatic struct gpio_led da850_evm_tl_leds[] = {( t- ^0 M I3 T" c& N- ?5 B" D
{
& q. w' l5 f" O$ F% M" R1 y .active_low = 0,
: p( e3 P. l/ F .gpio = DA850_USER_LED0,4 M2 w, q' k& m+ u6 u; |$ m
.name = "user_led0",6 z7 j" Q* Z1 ]6 g7 @6 x2 g8 |
.default_trigger = "default-on",
4 i; x/ X/ n- P. G, i },. _8 ~2 d( M/ H4 R P3 O/ C
{4 p/ s3 r, G7 s2 E6 t
.active_low = 0,. i" |' l8 w9 I S- |2 y3 v
.gpio = DA850_USER_LED1,
& e0 P# x4 k; L0 T .name = "user_led1",2 v8 {: g7 l% Y6 G. J5 G& I3 v' T
.default_trigger = "default-on",
$ q4 p; T* e6 D, G+ Z },. o8 Y |2 |: E# ]
{- h$ D: b6 r; m
.active_low = 0,7 v, y% I7 z2 j7 j/ c
.gpio = DA850_USER_LED2,1 q; ?$ K8 L# N- L8 H% h: F% p
.name = "user_led2",3 Q) J# T2 s. R( Z6 P5 I4 Y
.default_trigger = "default-on",
+ F) L: p ]1 }( B6 q1 l$ M },+ Z+ ?& o% q" c8 \
{
# g0 Q7 ?; }: q2 N; w+ f' A! X$ t .active_low = 0,% b$ A" Y7 k( u- e" C7 }6 w: c
.gpio = DA850_USER_LED3,0 g; q# \( f) U, \# p' i3 p
.name = "user_led3",
) E j) Y# t, N% }; Z4 T V9 v# u .default_trigger = "default-on",
% }4 U9 `: C9 Z/ p( Y }," l# P# t( q- F: h2 s; J" V
};
5 }- B" k% A; X& |$ B9 K. K% R. }3 O4 @, a
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
1 f' r7 z: X: o {' P6 F7 v( }6 n .leds = da850_evm_tl_leds,! T R) f4 E# G
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),
: X/ f- E& Y/ g4 {# K6 d& a};! J; p! p0 f, \( T6 T+ r
4 E4 v6 Q. b1 d6 Z9 n$ T
static void led_dev_release(struct device *dev)
+ x1 m O, Y' I7 N* |% H$ c$ t{
( H: B9 f9 _$ h% M" x- e};
$ C' }; ~2 `+ ?, h0 B. O' [5 O
9 h/ l; Y) O& L/ N* M' Fstatic struct platform_device da850_evm_tl_leds_device = {
) J6 r! k$ Y$ H! l .name = "leds-gpio",, h; v9 U+ f8 T; }9 q
.id = 1,5 @" [; w/ [% Y* c
.dev = {; o1 s5 K" U1 k; t
.platform_data = &da850_evm_tl_leds_pdata,
. e9 ?/ ]$ @ Y" ?1 n .release = led_dev_release,) K( |1 u# i9 X1 m7 P8 l
}4 G9 ?4 f2 A3 b9 \1 D. D4 ^9 K
};
" `7 G" W) C4 u: k8 \- _% X8 ~! x( a! \ B
static int __init led_platform_init(void)# B$ B8 `* Z9 T" T; j p1 g; v! Z& }
{
! s7 a' r) _5 n9 w k3 i int ret;. G; ?- T# H0 q7 z* g7 Q
#if 0
, ~ X4 D( L% O ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);# e4 B! n* P$ @) f( [% d# x8 K$ q
if (ret)
( r1 w7 O6 ~9 p pr_warning("da850_evm_tl_leds_init : User LED mux failed :": R# |6 S1 W( b" M+ \; a& Y6 H
"%d\n", ret);
" P) T j* K; w' O. o+ P9 c#endif
6 k! w4 @0 N' o$ p7 e, t ret = platform_device_register(&da850_evm_tl_leds_device);
! s0 }( [# `" d+ N8 a if (ret)+ U8 L3 F3 {2 G$ {) r4 S
pr_warning("Could not register som GPIO expander LEDS");
$ r5 j+ {9 v; ^! Y3 ^- B else
: f0 P5 W. l. n# ]2 ~) [ printk(KERN_INFO "LED register sucessful!\n");
* l$ ^5 ?8 L; b5 u/ O L' }+ {% `8 a9 L
return ret;0 q8 S4 [4 e4 e9 Q. g
}* e) c# h% V i
, J' E1 j9 X2 B, @ F& E
static void __exit led_platform_exit(void)2 I( s& r1 C: Q) E0 f1 g6 ~
{$ U; V: ?4 q; B9 G: j4 u! W
platform_device_unregister(&da850_evm_tl_leds_device);3 p2 c% U5 W1 V% W
$ X/ T. y$ X0 r% H# z" t
printk(KERN_INFO "LED unregister!\n");
" |8 r* s& a$ n3 @0 U5 R* G2 g2 f}
, |' E" k5 X* M5 d1 I! `: u1 e9 ~, x( ^1 N; h1 ^$ H( f
module_init(led_platform_init);5 L- F& K3 _- p9 j/ _
module_exit(led_platform_exit);, f0 g7 [8 b' i) {! {7 i
+ e* }1 u& V. o) [' @" }MODULE_DESCRIPTION("Led platform driver");7 i2 j' A" G$ q2 Z/ [2 a
MODULE_AUTHOR("Tronlong");) e) h ]1 e! r# b
MODULE_LICENSE("GPL");
" v) _3 `5 S) I0 K2 w& Q' h, B1 t
|
|