|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
. p% Y2 y* b, ~7 b0 f#include <linux/init.h>
5 b" u% e- L- l#include <linux/module.h>) L! i, B8 u' |9 D; ]* r& H3 _
#include <linux/kernel.h>$ L* j0 {9 l1 Z& Q* A1 w1 R0 m
#include <linux/types.h>
' b0 G: j. ~+ j7 [( Y8 [#include <linux/gpio.h>
* \$ [6 n1 x! R' k2 v5 l1 o3 P/ f#include <linux/leds.h>
) y+ P: u. E/ B( g4 u+ ^- ^8 \#include <linux/platform_device.h>. l5 g# q" b" s; ~
+ n# ~' ?. }9 \' o* L" Q2 Y
#include <asm/mach-types.h>' E# h; v! @1 X% I6 w% U c
#include <asm/mach/arch.h>
" Z$ B8 j/ ^7 ` z#include <mach/da8xx.h>! ~, _3 `6 f, I0 p8 P& }
#include <mach/mux.h>
% ?2 N6 x3 j# a. j9 g& o e" P
4 T K2 e5 A+ E" p9 Q% K#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)- @) a- F- Z' F- O- c
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)% ]; _; I( L6 N
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)2 g8 U8 Z! z: R+ A8 Z8 f* ?
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
1 b* `& ~' p% x$ d; Q: K
3 q) r! [3 S4 j% B: a/* assign the tl som board LED-GPIOs*/' S+ c Q8 K2 }) y& S# x
static const short da850_evm_tl_user_led_pins[] = {* @# x8 w" a- w% R: |
/* These pins are definition at <mach/mux.h> file */; N1 T: ~" I4 \ ~7 R
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
1 Q. Y5 j, z1 F4 C: w( b -1
. ^5 b. K8 q; @% ~3 [ U};
& l! d: g7 T0 @: f' a( z4 e+ z) u9 L
static struct gpio_led da850_evm_tl_leds[] = {
+ ?6 l% l7 [: f$ X1 \ {! w! Z; r4 {: J, D; N
.active_low = 0,; n" d& k- \% c* z# U J# U
.gpio = DA850_USER_LED0,
5 P8 e1 i9 j% v; k .name = "user_led0",
6 `# Z: ?- w" Y9 u* g .default_trigger = "default-on",. T2 ?' [. Q& z0 c( x& a5 x; z6 S/ S
},/ W& M* \# i1 |% J, U! t" @/ F
{
9 ?2 k- D" ]& v9 L. K% N .active_low = 0,
# S0 O n: p$ G$ o/ J .gpio = DA850_USER_LED1,* q' T- R+ Y9 o6 l- E
.name = "user_led1",+ c8 ~2 G! t. s; }/ k( H- V
.default_trigger = "default-on",( f- m( o6 w3 Z' I) h
},# n9 ~- x* c2 q' i& u$ J, Q
{
! r" s1 o! L" x# C" C6 J3 i4 p .active_low = 0,
* Q3 I; @, V* _5 d .gpio = DA850_USER_LED2,+ v. p5 q0 U# `! E# g9 _
.name = "user_led2",
- s9 x' ?6 {1 x% S3 f7 w) J7 p .default_trigger = "default-on",
0 X% H- Q5 E7 o1 q3 M4 r },
& B, p' H/ p) K Z( Q' D {
% s- U; y! K0 O* d .active_low = 0,
$ e2 l4 N% R$ d. S3 S- _ .gpio = DA850_USER_LED3,. W, ^, u! G! X3 {9 M8 u! P" A
.name = "user_led3",
/ L" l5 J: g; ~2 v7 F z; O .default_trigger = "default-on",0 ]" T5 U- _8 N/ j
}," P7 u' D- ]5 ]. U* Z* l/ a2 {
};0 d" }" b3 Q& n
4 J$ u4 K; b% f
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {6 Z' F' w! \+ c7 v0 p
.leds = da850_evm_tl_leds,# {% j2 H) \ w
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),
. b( [& [0 [' _};' X, W+ @- ~" |# L& y2 Q2 A
* f F& p, x8 v: T7 m& C1 F
static void led_dev_release(struct device *dev)0 U6 S* R3 e# c
{7 g3 B' r V7 q# w, j& w
};
, P! w* R, U, Q
6 D% R$ l$ a" l, M2 N' vstatic struct platform_device da850_evm_tl_leds_device = {/ A4 x: A; z7 x7 z ~: l( d4 a
.name = "leds-gpio",
' v) R- ?$ D7 l& p .id = 1,
, f" j8 ^- Y' X1 y. }0 |- A W .dev = {# R' b) S5 |9 O# F2 C! m
.platform_data = &da850_evm_tl_leds_pdata,
2 q0 @" V" {2 o( A' O# w .release = led_dev_release,
( [ W( I) C# ~9 b6 G" q }7 ^. s' g( `% I3 e
};
, r- p9 }$ W/ p* }. l+ \" G. a1 d% D$ @( S9 R" K
static int __init led_platform_init(void); k+ E4 a% D+ o7 Z/ A
{
' |6 z: K3 H3 h% k! l& Z int ret;
# d3 C; v/ E% a- @#if 0
# R; x$ {/ n: M6 D: g7 z, _: C ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
5 y* Q# F0 k9 @7 u0 g7 f9 A if (ret)
3 g5 R; T+ V# Q pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
. ?" { s+ F1 O. }4 C "%d\n", ret);4 W: O! t2 H* h. u
#endif1 v- h @0 B& @9 z4 S. M/ ~. r
ret = platform_device_register(&da850_evm_tl_leds_device);, H# O$ s8 q R- D
if (ret)
3 z# N8 h. B `0 X% b pr_warning("Could not register som GPIO expander LEDS");/ E2 P8 ?% y, p7 Y% d n9 m
else
' G" W. H K* m! s# d& D printk(KERN_INFO "LED register sucessful!\n");, [* h' |' x0 y1 B0 a0 b4 F
( L1 {9 s+ v: G
return ret;
" O! L1 k* ~& z3 ^- p' n. K}
! O4 t9 w" L( w- \( G6 X1 G# y) h) Z0 V" v! O, p7 y
static void __exit led_platform_exit(void)
@& ~5 a" Z0 ]7 f- O! i4 |( J0 m. o3 P{/ \0 ^1 p1 f8 k& Q! I
platform_device_unregister(&da850_evm_tl_leds_device);
* u& [& z! q2 f5 ?3 }- p: q* n$ J4 w4 k% v
printk(KERN_INFO "LED unregister!\n");
# b f* }2 h3 j" |7 U}* @! s0 E# O* ^! W3 ^7 U0 r
# i3 Z- s1 b5 C# i# @
module_init(led_platform_init);
1 n& K1 Y s* x5 A* K0 }module_exit(led_platform_exit);
. O7 l9 W' s0 s+ k, V
( i# m- q5 p z% S8 P/ L- C$ @5 YMODULE_DESCRIPTION("Led platform driver");
% t, ~+ S1 [4 T5 `6 U8 UMODULE_AUTHOR("Tronlong");
" l- l7 C. d# {" y- }8 O% u" VMODULE_LICENSE("GPL");
9 p( d7 c5 o& h% h; S" E
^7 x1 M" ^7 g# U- s; r |
|