|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
% q" s; X# v0 A9 W% l$ B#include <linux/init.h>6 J7 i. x* L, M" d* A( z
#include <linux/module.h>4 {5 W; U: g5 g) u
#include <linux/kernel.h>
: Q3 E9 V# M: X Z8 r; U3 ~9 ^#include <linux/types.h>
% W- c- L4 n" H/ b& ~' t; ~/ R#include <linux/gpio.h>1 t9 T6 c1 @4 e8 w
#include <linux/leds.h>
1 m0 E" Y! y* g* e/ A q#include <linux/platform_device.h>: t! u6 \& k+ ? u2 h
( F7 ^8 U7 c7 P2 `4 y! N#include <asm/mach-types.h>* a [. I" J& v5 ?5 Y
#include <asm/mach/arch.h># a$ x. C4 I" s' m8 L
#include <mach/da8xx.h>
( H! [6 `" q" ?1 t7 E0 T#include <mach/mux.h>/ d* e. a" K0 C7 c7 t. w2 f# S
K1 u% x3 W' f+ K
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)+ h& q! y$ B6 t, U
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)0 s: d, z5 |$ f8 u
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
/ |$ o7 \8 E. ]- B5 }#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
; W% ^6 ? A8 {5 M6 k
, x3 j% F3 @! P# d' c J/* assign the tl som board LED-GPIOs*/1 Q7 e5 ]; K6 p
static const short da850_evm_tl_user_led_pins[] = {
. X' @9 c' r3 Y& t& ^& X1 ^5 G6 t /* These pins are definition at <mach/mux.h> file */
1 [* S2 K" W7 }, b8 g DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
( x3 V, N0 D( } -1
' B9 e/ Z! L8 ^+ J7 @};
+ y9 N$ u0 K8 @, E: r4 b$ M! n' W3 }" c8 l j% d" b
static struct gpio_led da850_evm_tl_leds[] = {- u0 F1 y$ L& u0 Z
{1 E1 h. M$ _4 K: d
.active_low = 0,
0 `9 M; `: L" u$ C& Z: Q .gpio = DA850_USER_LED0,. ~. y( j% {2 _/ d
.name = "user_led0",
: k0 ?; m. A" e0 p .default_trigger = "default-on",
/ L3 f7 o6 A# T7 G },
% |: I6 l/ b' D# S2 X6 G {
% l0 z; x) O" k! d0 f0 d! K .active_low = 0,$ g! H$ C% f( s. R# d
.gpio = DA850_USER_LED1,9 e# p& b! ^: V9 m$ `, i% E) u
.name = "user_led1",1 U# ?8 U7 |. z, P/ \; F7 J
.default_trigger = "default-on",
9 ?6 @# b4 Q1 W( Z% F! } },7 N% m- O8 _1 D( y1 b
{3 a, } w# T. M0 j# B1 I
.active_low = 0,
2 I7 _. r1 \# m3 `, {( c# B, k; c .gpio = DA850_USER_LED2,% H) R/ Y# E/ B" k
.name = "user_led2",
4 Y( ?% I' A+ J# E/ \ .default_trigger = "default-on",/ O" c9 ]6 b1 k4 F
},
0 S1 J9 G# w$ E( h4 w. r {
" e" T0 E7 x7 _ j; r .active_low = 0,& B( T$ b' D7 i$ C3 w5 `
.gpio = DA850_USER_LED3,8 t! h+ @0 Y; t6 h: e) A
.name = "user_led3",7 b) l3 I( z4 C# S% q4 v* B4 h& l
.default_trigger = "default-on",
+ |; h: J/ o+ `# p t- { },6 F! R# t1 b$ n& V
};
0 j# e! o) D1 |- n
( Z5 `. F, S8 G9 e8 u: Zstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
4 ^- d0 `6 R! e0 Z9 a% v .leds = da850_evm_tl_leds,8 o, a5 s3 r% G+ s, M: U. ?
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),) a) P1 s4 j3 ]7 {
};2 Q: F+ |% ~$ s3 G N
' e: _3 F. f* ?5 \0 ~static void led_dev_release(struct device *dev)
8 W& ?7 ^/ x. Y9 G. A{! N% i h3 k: G# T6 M0 l
};
7 b, L8 u, [: v% }& U1 H; z. }7 G" W% H" w* @" [, v
static struct platform_device da850_evm_tl_leds_device = {' n; X0 ], R7 k G1 ?' o. B
.name = "leds-gpio",
# e! z1 @5 l! A .id = 1,
6 i. q% P8 m, [; }6 M .dev = {
- j2 _: m" H# O3 Q .platform_data = &da850_evm_tl_leds_pdata,; N* M$ G& H8 F0 e/ q
.release = led_dev_release,5 J0 n# A- I, Z# t
}1 k- r+ O( z8 k( i
};
) T# k6 d4 p' _3 n- B" b
& |$ Z6 b- b. i! ?static int __init led_platform_init(void)
9 O! h8 P( O$ e8 x6 D' U+ o/ {) I{
" s5 S1 a/ }6 q+ z: s6 i5 }2 p; g int ret;4 F2 G' H/ x `9 \3 _; f
#if 0
3 W- L0 _2 ?! ~# U: W0 ^( h ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
7 _- ?; J* r+ V( x- l5 l* e1 h if (ret)- G+ g9 ~% V* k- o2 d9 ~9 s
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"5 a+ b; u& j& O/ p5 P) e4 d; e
"%d\n", ret);
# E/ X6 _- N) @% c$ F2 K#endif4 h; t2 L3 s9 I/ s, _
ret = platform_device_register(&da850_evm_tl_leds_device);; n/ ?# j& h5 m# _' U. L* `
if (ret)
2 ?: F' ^9 L: |2 I; G1 q0 Q c% D pr_warning("Could not register som GPIO expander LEDS");
4 q& [1 H9 ^0 f3 z. I else, N2 w' H! [0 C' h- S& r- c9 a
printk(KERN_INFO "LED register sucessful!\n");
' O4 L: Y# S6 e6 g4 }2 s, U7 ]4 l* o3 |0 k4 d
return ret;
7 J/ I( z7 g( K3 I8 t. F; O}
* r, b4 x9 T$ ]. b1 b+ Z$ a8 w1 F5 |1 @8 |1 C( O6 I, z9 z) W/ E4 W
static void __exit led_platform_exit(void)
& G1 R; z% s( M# F) @{
( T9 H5 s. V, o b }) Y platform_device_unregister(&da850_evm_tl_leds_device);1 \7 U- R- u7 w" Q# U& T3 |, M
4 j5 Q6 }" c% j
printk(KERN_INFO "LED unregister!\n");
/ X' m- \; a5 s% _" a0 f2 ~}$ m5 s. \- M/ X
- }- `% h6 W, A
module_init(led_platform_init);
% v* K: z% C# `module_exit(led_platform_exit);* b% G( {, E7 i" X& Z/ m6 C
% z: Q" D" L+ c9 t0 p
MODULE_DESCRIPTION("Led platform driver");
" y0 `) h( V( IMODULE_AUTHOR("Tronlong");- m( f$ z/ \7 H* P: i
MODULE_LICENSE("GPL");3 E* M( _ ~* Q: T6 e7 Y
5 l7 |2 T4 }& e# L; @ |
|