|
|
求大神给下面的程序做注解,请稍详细些,谢谢。: b- Y9 `! [! f6 n6 O5 _ q0 x8 o8 a
#include <linux/init.h>
- k; |3 Q( e" I" N#include <linux/module.h>
% w' T8 {6 g8 Y; z* }#include <linux/kernel.h>7 G, M3 s; u5 `6 Y
#include <linux/types.h>
# ]8 F; f- p: e# B$ F#include <linux/gpio.h>6 ^* W3 C, \4 y2 F) S6 |
#include <linux/leds.h>
0 R0 Z* g$ y4 `: K s* A#include <linux/platform_device.h>
! t$ L" c+ A6 c y/ ]9 o) V! ]1 W3 O3 u2 E' o' H% J( u/ O
#include <asm/mach-types.h>
' U3 z& e, t2 w2 o" J6 @- A#include <asm/mach/arch.h>
2 f9 o/ n! }. Z, j; F#include <mach/da8xx.h>, H9 U- h+ H0 [( |& {
#include <mach/mux.h># m; `5 O* r; I
: X! `/ B5 D* i* k' z#define DA850_USER_LED0 GPIO_TO_PIN(0, 0), h- L7 l, F, Z! Q' T
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
Q3 [! W, \* q, X" }#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
9 _. _( I: `- A. R#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)* x O9 y' P x) \4 s
E: [1 e, j4 X' \3 J5 A! Z
/* assign the tl som board LED-GPIOs*/2 Z6 a3 b4 r: Z$ m0 f4 X6 E' J
static const short da850_evm_tl_user_led_pins[] = { q: [! A: q4 ] [2 h' M* q
/* These pins are definition at <mach/mux.h> file */5 @ v' a O! M2 g7 S0 B% L3 E
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
$ \7 x* I0 g7 b; r9 ~. [ -1/ z+ T s' i& U( K- O3 s9 j
};& s c* C j7 ?6 {) D3 F: h
) x, w6 M4 x0 p! i- h8 a7 Dstatic struct gpio_led da850_evm_tl_leds[] = {
* ~; E, y. u8 J- N2 j {
I$ R% t7 }2 b .active_low = 0,% @# _2 }$ a7 O& U( ^! W
.gpio = DA850_USER_LED0,) d! {& j7 F3 q' s- n* }) m
.name = "user_led0",
5 P+ e3 f9 V z0 { ^% D; G .default_trigger = "default-on",
3 k0 u/ [5 Z" k: J6 F# c; s9 Z },
' i* o. P6 p% m: V, u {; c/ L# ?( I9 R$ f( R
.active_low = 0,8 B0 ], u: @( s, q6 Z
.gpio = DA850_USER_LED1,
0 ^) n! F8 u& Q0 g .name = "user_led1",
6 z4 m; U% ^2 U0 n/ m .default_trigger = "default-on",
# A7 W. A2 [$ s2 K },
& y* [8 |% h+ q5 D7 c& J; ~4 Z1 c8 [: q( k {+ n2 p% M- Z; t/ {- D: F1 l
.active_low = 0,
2 B7 L! @1 F& {2 ^! z9 T( x .gpio = DA850_USER_LED2,
" t2 `2 Z- u; n$ d7 q .name = "user_led2",
7 z# d1 ?; l `( j- S8 m .default_trigger = "default-on",
: l) a7 c( k7 `/ ]5 d },: e1 F# F5 V) x/ h( C @
{
' [$ T" u0 }7 E, l @7 H9 A, R .active_low = 0,4 p8 l0 F% Z- a0 U
.gpio = DA850_USER_LED3,# g2 w0 Q& v. r% ^! K0 ~, D* W0 ^
.name = "user_led3",& h: k' s! C0 N+ W' N8 Z; u/ d) W+ c* H
.default_trigger = "default-on",: X& Y. v) ~4 I. j u5 Y# ^6 O' O
},5 [ G1 v# E7 d4 z' X% G
};1 |8 C/ }( Z0 K
8 X+ I, I$ h, S, H- x# `/ ]" _/ U, ~
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {, `$ `0 B! m* \" L+ k7 x
.leds = da850_evm_tl_leds,/ N" F8 U* o' g+ H* @5 X# i
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),
) |5 V& w2 ^& u};
/ i5 R1 L5 P; Q+ e9 B
% A7 s( c9 N* V/ t) C: g, [static void led_dev_release(struct device *dev)
, L/ K" Y8 T- u- W: A, X- M+ r b{. V' b4 n1 r: T
};
' x4 d( [; y' G( ^' X L8 Y
- I% ]. \7 V f: ~; c0 Kstatic struct platform_device da850_evm_tl_leds_device = {( T% O5 ^9 ]& j/ f& b. I, @! e* A
.name = "leds-gpio",( D# p9 p2 N6 p) w- c& I' n2 ~
.id = 1,
! H- D3 N# i/ |1 R .dev = {' {' E" Z! {9 N4 L* q3 g \8 J+ X
.platform_data = &da850_evm_tl_leds_pdata,! v$ n O3 h6 |+ |
.release = led_dev_release,9 S$ Z* R+ F% T# I1 H! r R7 m
}
- ] ~# T' g) \& w! M( ]' J};
) ?: n% a$ X& B3 p& H: b) U
8 `4 D2 I% O# H& j: {) Dstatic int __init led_platform_init(void)
3 a3 B5 f2 s6 o+ X{
4 I7 Y+ l5 `. t" S8 O3 [, N& b int ret;
4 e. q$ G' ^( j/ j( y# V7 a, m& V#if 0
$ @" f4 S& L# M ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
0 c! J7 ?/ L1 p& l1 Z if (ret)+ ~5 m0 u: W1 s3 `$ O6 d- ?; z" R
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
( t7 a. ~, `, R2 D" m- u7 w "%d\n", ret);2 p* R) K9 W) Q Z+ P! W, C
#endif
3 \7 u0 q/ W/ A% @ ret = platform_device_register(&da850_evm_tl_leds_device);
% g( [$ j! n7 d& G# k if (ret)9 G2 d' m. w" `
pr_warning("Could not register som GPIO expander LEDS");
$ D' L3 v5 ]8 y9 U else
3 l$ h1 U3 \, A! @0 ?/ v printk(KERN_INFO "LED register sucessful!\n");
5 }% m8 J& |' A/ X
* z [* n7 b$ o return ret;2 h) R: \- {# ]5 x: A6 N
}1 d$ K K9 j! }4 x( k6 r3 X
1 Y. `$ [( F' F: @" S& |) f
static void __exit led_platform_exit(void)
; s3 ^! u! i6 P{* o2 V, O2 R# R5 }, F
platform_device_unregister(&da850_evm_tl_leds_device);
% P% s" f( D3 t9 V# i" Z7 B; b2 z4 r5 z5 ?! c# Y* U: u3 S
printk(KERN_INFO "LED unregister!\n");
( J! F* `$ P4 \% h: Z}$ f- r" e. ~; a8 C8 `" r3 h4 X' Q
1 J# W c* c, H9 W4 z
module_init(led_platform_init);
O% `6 S7 f; xmodule_exit(led_platform_exit);
3 M! M6 m& `& Y$ \9 }
! R( B' `1 ^9 t i' |% [7 tMODULE_DESCRIPTION("Led platform driver");
0 z! ~7 D; j \4 O, b* \* H/ R! U; aMODULE_AUTHOR("Tronlong");" r! Y* l% Q) H0 u7 B$ O. C* h" E
MODULE_LICENSE("GPL");
2 T4 b0 K/ ^3 S3 T0 u0 S! z3 t
' g- V. ^% Z h; ]% @6 N |
|