|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
' J/ m6 j2 y7 T; @5 P7 W#include <linux/init.h>
8 j& l3 ]/ V3 H#include <linux/module.h>8 X- |1 K. a$ w d8 N1 h2 d+ e$ g
#include <linux/kernel.h>
- O u1 f2 O& d# m$ b+ j0 K#include <linux/types.h>4 N( t! z3 [7 O( v2 D
#include <linux/gpio.h>
& T* x1 N: q. n. {1 o/ F#include <linux/leds.h>5 h% `! U. K4 L1 D
#include <linux/platform_device.h>
3 s- d. x0 _% L( ~& B) u
) C4 N- G: U% }) g& X' x#include <asm/mach-types.h>& Y5 K R) H) Q: f
#include <asm/mach/arch.h>8 B. |8 b( I/ ^! t! W! W
#include <mach/da8xx.h>" W# h' T, M W, {8 K
#include <mach/mux.h>
4 l$ O# b3 \. b5 c/ J
2 ?' k& I$ S0 b3 n, ~5 B$ K: z#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
! [1 [7 c7 B+ |( s: f# j6 q, Z#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
2 |+ B# q4 c; F; { F4 r6 v w D# ~0 S#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
+ b+ e* C2 C. i7 a#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)$ |, D4 Y+ {, j. U+ k, z
( V) y2 w! E8 k5 u$ x4 p/* assign the tl som board LED-GPIOs*/: h" @7 S2 t* N) u6 _1 y
static const short da850_evm_tl_user_led_pins[] = {
5 U6 m% q' R' A ^ /* These pins are definition at <mach/mux.h> file */9 Q9 f: v% s" {) F5 T1 c
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,) M3 \ d H$ l7 \! h& q
-18 J4 k }# d( R$ f) L4 Z0 E
};
, G" m1 [. ^3 x7 S3 C. p! M; l( t& f: N# m
static struct gpio_led da850_evm_tl_leds[] = {
8 }: B+ j( z! n. l {
+ F4 R9 L' r1 @5 h, Y .active_low = 0,
1 r: \; t& D# p4 k6 o: v, w" _ .gpio = DA850_USER_LED0,) _1 I* w* K5 r( n' I o/ f
.name = "user_led0",) b2 Z U0 j* j# A7 P- D( \
.default_trigger = "default-on",( \: ?( A& z! c" y* O
},2 j3 D# v! e, V0 c p' o9 v
{
" {3 {1 W+ f# {1 n2 Z% X/ u% E .active_low = 0,7 U7 p" w q* b' ~8 y4 c0 e$ O2 p
.gpio = DA850_USER_LED1,
: a# _. \( y* R# f: u .name = "user_led1",
% }$ M3 {8 |4 _5 Z/ V( ?9 R7 G .default_trigger = "default-on",) U) d$ U2 d) z/ }9 F6 p
},
7 g7 V& h! ^' |" ]3 |; M. P {
; Z" E% f9 {5 x: Z; T: ^% } .active_low = 0,
! H" R9 ~1 e1 A, R9 K# X .gpio = DA850_USER_LED2,
; m- R' y5 @7 `, n* f. C) z3 f1 ] .name = "user_led2",
; D' v0 g1 ^: ]: ]. {! _% Y5 Z# c .default_trigger = "default-on",0 R4 [- |1 N, y$ d, W' Q2 g9 q" L
},8 k" h9 Y# Z; M/ Z! v4 [7 E) g
{
3 a/ {8 ?& Z9 j/ l8 b .active_low = 0,- X" ~8 W5 K+ a1 }) A
.gpio = DA850_USER_LED3,
; q0 {* L6 e9 c# Q' J4 u- J .name = "user_led3",
( N+ a! Z) ?7 b# g R .default_trigger = "default-on",
" O! x {( _& C, G+ j) I$ }8 |" S2 X# _ },7 s N' ~) B8 e; x7 Y
};6 g! H& _6 O; G9 c' p1 _5 L; L* e5 P. h
$ P, ]6 p4 o& n& a# Mstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
- t" m& R7 [8 s& [0 M6 | .leds = da850_evm_tl_leds,5 z0 g: X2 W ?8 W8 e
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),) A9 R. ?! F0 g! M
};
9 Q3 C. T' n, ^( `7 T( J
1 I: F7 K( ^8 \( n* Xstatic void led_dev_release(struct device *dev)
; a/ k9 V. ]6 g) X) r' E! i{
# f% t) e5 @; F};3 B7 ^5 \2 c: D3 Z; d# c# c1 H
9 X6 Z' ]8 R( n" S2 D( W9 qstatic struct platform_device da850_evm_tl_leds_device = {& D+ p6 M7 u7 f0 D# J
.name = "leds-gpio",/ w( ?* Z- G* b7 [
.id = 1, Z# p" V+ a& B; F# @: N( l1 u
.dev = { {# E# t" I7 p/ m% Z% ]
.platform_data = &da850_evm_tl_leds_pdata,
, d7 m0 z7 N0 Z! j: S6 M" v .release = led_dev_release,
7 k6 @1 X5 f" }' F0 ?* D: C }
' j$ S, k l' g& I; A};9 }3 |+ ] _3 p6 j; q5 p. i0 a
) K1 ]! D9 Q; V: ~. Z3 h$ l
static int __init led_platform_init(void). ^3 \; e& O% e+ I& h
{1 ]: l' v: z6 {9 J
int ret;; m3 W2 w5 n7 L; W
#if 0. o! d. Q9 f2 Y+ k
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);8 x- }3 ~& a9 N4 \* i* N0 E
if (ret), b$ T7 J1 l: z; j) {0 c" k) x5 `" q
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"+ r2 Z0 \, W% H, g" u# Z, g; B5 n
"%d\n", ret);
% T) Q# u' D6 h! Y! {- U#endif
H' R' x; I, l' J8 I ret = platform_device_register(&da850_evm_tl_leds_device);
+ v% L9 _ b2 N! Y! T z if (ret)) e! G! g% i. n/ V+ b% a1 x
pr_warning("Could not register som GPIO expander LEDS");
4 W6 G7 o' p- b1 A+ ]1 M else
/ t9 k- s9 q2 F. h Z; ^* g0 b printk(KERN_INFO "LED register sucessful!\n");
4 j b2 v# S: q a
4 T& b- h# k# H return ret;
8 I; i7 T0 ?+ c% q}! d, O# v" t [* @3 C$ r
- p/ S" k& D7 b) `0 istatic void __exit led_platform_exit(void)+ n4 N; F, k2 M( R9 @
{
5 S4 ^" h) w% ]% m8 h A% L5 L platform_device_unregister(&da850_evm_tl_leds_device);
( _% @( u% D- A2 |3 c$ B0 K' J) j$ z r- q( O
printk(KERN_INFO "LED unregister!\n");0 S( l' e$ y; E3 |( h0 m: ^
}/ `/ o. s, `& q% o3 t- m# u
, ^1 H j0 r3 v, s* R9 G: Nmodule_init(led_platform_init);: m/ B. l3 `4 t7 B8 a
module_exit(led_platform_exit);
) O6 A7 K7 ~7 G7 |# g
0 ~( S; b( _9 G/ a( wMODULE_DESCRIPTION("Led platform driver");: \6 k m3 \% [8 G( l+ V" f
MODULE_AUTHOR("Tronlong");* r6 Q" j9 h7 ~
MODULE_LICENSE("GPL");
0 F0 |# ]+ Z; y" Q$ m9 Q% c' W
" ~ p6 F, N( N5 `9 N |
|