|
|
求大神给下面的程序做注解,请稍详细些,谢谢。* U' Q! c4 V5 w3 v# }7 r
#include <linux/init.h>
+ n* x a& h9 X/ n#include <linux/module.h>) O5 y8 p: a) W7 M" A: s
#include <linux/kernel.h>
+ O! ~/ f' b8 R! F; Q3 R s! r#include <linux/types.h>
6 ?; S" ~! N2 i" G4 Z% p* j#include <linux/gpio.h>0 ~0 D6 {& _. S% R; I8 I) X
#include <linux/leds.h>
1 `9 s! `3 o5 x( O* ]5 h, h+ Z#include <linux/platform_device.h>0 `, c" z) x/ R" e1 N
, ]8 `5 y R' _8 y
#include <asm/mach-types.h>: q7 J' F* T8 j4 q. x
#include <asm/mach/arch.h>8 t! T/ h) F3 g, M( c
#include <mach/da8xx.h>, C/ q; { h- X* k, h$ e1 Z6 J
#include <mach/mux.h>
, s( J& t5 B1 u; b. n W2 x4 U' c
) w3 N) h" C; c) [5 z#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
* W4 c0 Z$ P/ ]. X0 _#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
" G% b% ?1 \ A/ \# D; e#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)0 \& W: M( [9 Z# ?
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)8 K3 I0 ~/ L' Q5 K5 D3 Z8 q& H- y
6 N$ M6 f- ~ h- h5 _4 i$ @/* assign the tl som board LED-GPIOs*/
* |- V. L0 b- o% o) P: j( astatic const short da850_evm_tl_user_led_pins[] = {
1 ^& K/ `. n" W5 y! U; [ /* These pins are definition at <mach/mux.h> file */
7 P& l) t2 W# K4 I/ l$ B- o3 {- a: E DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,- Q1 I: `3 w( U1 F& g
-1
- y1 B/ ^6 B4 D! c- v" [' m. D5 ^};1 v8 C$ _' W K) t1 d
. e" \- p9 _& g
static struct gpio_led da850_evm_tl_leds[] = {
* W& e2 E1 x2 y# P. [/ F/ C {
! H R9 I4 w, E" B- \ .active_low = 0,( M" V8 }1 \+ h* t# I/ H2 a
.gpio = DA850_USER_LED0,, P5 D7 h& A0 u; R8 R% _1 V# a
.name = "user_led0",2 Q5 z: Q" m" M- S1 E
.default_trigger = "default-on",' k) i) }) k: K% H4 _- W7 u9 M! W2 p3 K
},4 U% K8 `$ D1 n' P/ B7 b& c
{
- r+ N# K0 z4 s4 \- q .active_low = 0,$ l) Q0 L' U4 b; d* n3 i# m/ L
.gpio = DA850_USER_LED1,8 r7 Y2 F& e3 Y+ _, H
.name = "user_led1",& d L3 e7 q( Y( N2 W
.default_trigger = "default-on",; ^$ _& ~. B; z2 L8 l
},! ]( D6 G% l3 |
{9 s5 ^2 t' t8 Y' m8 X
.active_low = 0,2 _" y' @! e4 K% J- `
.gpio = DA850_USER_LED2,
, m7 M7 s2 C$ j5 Z. M5 ` .name = "user_led2",
2 n1 D8 ?. y7 Q( |- u .default_trigger = "default-on",
& R7 ?: o9 e0 k; \8 X },
2 b* k( a* H4 U" V {2 o" i% R2 m2 b! b; ^4 h
.active_low = 0,
* c ]4 m' n& R5 d2 e: Q .gpio = DA850_USER_LED3,
. O; E( g, \8 r+ ^' N7 o .name = "user_led3",
, ~0 }3 C# J$ b! K. }3 t4 o7 ^ .default_trigger = "default-on",$ W+ Z4 V- ~3 n2 m% o
},
8 |3 m0 ~7 c6 m( S, |% ^$ T' }9 R( w};* B6 R P* k) ]6 O7 [
1 j* c3 X* B m2 N* J# Mstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
& |/ D& n G4 ^7 C .leds = da850_evm_tl_leds,1 @8 t+ j# ?- {) k; k2 p, m
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),( r7 M [ C4 v. u
};4 }0 U+ d- p7 X' f2 E' I% E$ {
# `% K1 L7 Z1 p1 E1 Q5 ^static void led_dev_release(struct device *dev)
}* {- q5 A4 [0 ~$ y{
4 F8 h2 N0 N$ [ v/ j};
- ]% G' B) a) E7 B( x# ]( g# }4 h; ^% k2 M% b: r" x
static struct platform_device da850_evm_tl_leds_device = {
* ?7 t2 N( [4 v" U$ J .name = "leds-gpio"," H$ U s% T" a( b# b! d; c1 L
.id = 1,
3 z: d1 a- E! S% p$ p .dev = {7 ~0 Z4 O9 |* j+ A& F' b" D2 R
.platform_data = &da850_evm_tl_leds_pdata,# i& k. p# }, K2 Q
.release = led_dev_release,6 e& k9 D0 ^2 t8 q
}
0 i6 u: F) V& ]. B; ]};
" z2 H. a& k: [3 @5 y: ^, {
2 A$ i4 @$ j! |* @static int __init led_platform_init(void)- l. S( j5 {2 E# u4 p. a
{+ I. u. Y) n5 ?1 K3 N
int ret;# ]: S, L2 x; k: a! w
#if 0
4 p) @; b; P \& E0 y) I+ B: { ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
& h9 v, k+ P0 J% P1 }% ] if (ret)2 D& k$ |. {9 W# Q% s
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"# y/ N p- x; Q/ y' [ O# M
"%d\n", ret);
0 T1 e" m& V+ H% J2 b#endif" b/ }3 M+ O1 v$ C; G
ret = platform_device_register(&da850_evm_tl_leds_device);
% \0 _( S: L4 q5 i4 b( S4 R7 A" s, l if (ret)1 H9 z" B' f) d) `3 j
pr_warning("Could not register som GPIO expander LEDS");6 x, u% V7 @2 \ ^+ {
else7 p0 k; }/ [* X: I
printk(KERN_INFO "LED register sucessful!\n");! |/ b* E2 P7 Y R
- f5 L6 A' }' b+ ]+ B
return ret;
4 @6 Q& u) w. l}, [2 E* Z2 R/ y: _1 G0 r( Y
( N' l3 ^7 y9 ^0 V, t1 N
static void __exit led_platform_exit(void)
5 N1 g( k1 L' K; K{
; O5 i/ L9 d! {9 C; r* C platform_device_unregister(&da850_evm_tl_leds_device);
7 j9 ]/ }9 S& U, p8 o! L3 m; Y: p8 w. g V
printk(KERN_INFO "LED unregister!\n");
( M6 i4 F3 P% e- z& @; J% ]}7 c h* Y' S, t# [! e+ j5 t8 _/ J
* n. R" k; Y+ q, s5 K! ^' _
module_init(led_platform_init);9 W/ a7 `- c$ F) J" c
module_exit(led_platform_exit);
* P3 O3 e0 b9 f3 \" ]+ C+ V- q' p5 C( U$ ]: U
MODULE_DESCRIPTION("Led platform driver");
& R7 l- ?1 B+ ?; u9 U% j# SMODULE_AUTHOR("Tronlong");1 Q8 ]: V+ F f) D" }/ e
MODULE_LICENSE("GPL");
) }) x! r. e9 r9 g, v G
4 }7 [2 Q; K% Y3 s2 c8 s* M |
|