|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
' p0 ~- e# R) j/ V8 k8 t8 }#include <linux/init.h>2 d }4 f& N8 ~! i+ Y
#include <linux/module.h>$ r8 F* X+ Q# _) X# G
#include <linux/kernel.h>
* W; [9 f+ t6 ~$ G3 r#include <linux/types.h>0 X( {; |) V9 o/ g9 n$ d, ~
#include <linux/gpio.h>
" D9 ?6 r4 A8 F#include <linux/leds.h>
( x$ L i* y5 ]: G8 p/ W5 u#include <linux/platform_device.h>
! r7 t/ n0 z9 E' `- W; D5 l% Y( s# h" A' R
#include <asm/mach-types.h>
$ u, [- K) y: M9 A/ j6 ]#include <asm/mach/arch.h>& k5 {! H8 d. ? D; }
#include <mach/da8xx.h>
2 x* {9 O0 u5 j0 J9 x#include <mach/mux.h>! M Y- V: w* T7 O, Y2 j
) y2 k$ D" h+ h d7 W
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)' z/ {9 n. ]9 P' _) k- x
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)* I+ K1 d7 W+ q% q
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
/ ]5 |( `$ q* c) r+ X+ l#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
) q! b- P% M7 m" t4 w: i8 k9 s5 @( }
/* assign the tl som board LED-GPIOs*/; ~! d& ~5 w" _
static const short da850_evm_tl_user_led_pins[] = {6 z. r$ d6 N, D( z1 C" W2 X- l
/* These pins are definition at <mach/mux.h> file */
1 ^# T8 G& W/ O+ J) ^ DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,5 w8 ]. ~+ J3 B* W! d( B( o
-11 p& [9 p& H% J% z
};& G9 b0 s+ _ y/ D- Y t v
L* l; z; v% f& Xstatic struct gpio_led da850_evm_tl_leds[] = {4 @" ~1 t. r6 }- r& u
{) W9 T1 |$ I6 `5 i, O; _
.active_low = 0,$ V2 e+ C$ H: u: E9 Z
.gpio = DA850_USER_LED0,/ \$ F' i T( t o& B
.name = "user_led0",
- _' z+ u: s9 d1 b9 \, S/ K9 \ .default_trigger = "default-on",
+ Q6 u9 U0 n5 ?& |7 @5 e/ Z }, ~$ X3 i' }% C$ y! e0 |6 h! j6 m4 @
{4 |% w7 v5 m4 ?& l: L# g: O# i c
.active_low = 0,
3 W3 m* R7 H8 L .gpio = DA850_USER_LED1,, U& i0 x+ z8 X: W. R. H
.name = "user_led1",! S9 \; K! I/ S9 ?: i/ t! t
.default_trigger = "default-on",
6 n6 y. n& r$ E2 L; { t },
/ C# V& D! F" Z/ Z {
& Q# _% x' b5 k! c- P9 r .active_low = 0,
; q& n1 ]- V( N" | .gpio = DA850_USER_LED2,4 ?. Z& }5 Q* S& y( A( h! u
.name = "user_led2",* g3 y; ]5 d! A5 ?/ t) x, d R, {2 g
.default_trigger = "default-on",9 @. R' b, u f2 _: t3 U/ @
},
! Y+ j+ @" }4 L% U( k2 } {
" L, R- d$ y& @( p* y .active_low = 0,
/ B; @. i. A9 U* a) _9 ^, R .gpio = DA850_USER_LED3,2 V" H4 h- M/ P, F$ Q! t
.name = "user_led3",; f* c5 B0 Y- ~ A8 m
.default_trigger = "default-on",& C4 d1 R) b# c% z9 _% ]0 ~/ i
},& r2 Y y) A3 T+ N2 K
};
- W5 a8 b, B. P# R1 @# k
/ Z7 y5 Z; N" C# C' t1 ?/ G& Dstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
s7 [, D2 T2 q3 k# l0 q u .leds = da850_evm_tl_leds,
$ h4 ?$ o6 r: q3 ^" F2 }+ e .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
+ z- a( b8 {+ Y6 }, C9 }1 t) ~};' Y( P) }( H( Z+ S; b
# v! W/ i9 b9 T( zstatic void led_dev_release(struct device *dev)# @0 ?; W! W9 q3 V7 C' z6 J
{( R7 f# b" y2 b
};
# u4 z9 R( {$ I- A
- p7 o3 I! @0 r2 }( Kstatic struct platform_device da850_evm_tl_leds_device = {* k6 S$ n1 B5 n( E+ F5 | h2 W/ i
.name = "leds-gpio",
* ^0 x3 m( Z2 T3 V$ P9 f5 k* s .id = 1,1 h: |0 [% c; j" S# c
.dev = {3 u8 z4 ~) `: d# N
.platform_data = &da850_evm_tl_leds_pdata,' d+ | H `/ e9 [
.release = led_dev_release,
3 ?8 G6 |/ b" [7 y: f7 h- Z }
z! j6 w; Z3 I& t' W};
; ^' M }$ w/ [! H1 w. n8 `/ }$ K( p# y1 W7 X
static int __init led_platform_init(void)+ v1 p2 x( t) d4 |" L
{
8 I3 E' M* y1 w; n) S int ret;0 I+ m' q# j; R" r# c
#if 05 r6 e( I9 W3 `
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);& r5 M3 `8 r' Y, s6 J0 M
if (ret)0 h' k7 G9 k4 d9 N) a1 E, |) i
pr_warning("da850_evm_tl_leds_init : User LED mux failed :") n% u# J& D1 U7 d6 c
"%d\n", ret);- r% D+ h+ j) L0 g0 E9 @
#endif
: k$ n6 {2 _+ r- }+ S; c ret = platform_device_register(&da850_evm_tl_leds_device);. X6 X* I( u# O. q0 { L
if (ret)
9 B. V! B* P# Y pr_warning("Could not register som GPIO expander LEDS");' k1 R+ v$ A( ?8 k: X
else" S- W- o) \# l0 s; M3 `- W
printk(KERN_INFO "LED register sucessful!\n");
* k' g- m2 j) b) u6 M$ B# S, _! l6 @+ j! }: S- b
return ret;8 p7 ^) L/ Z U% P/ j o% A. `
}' }6 w& c8 d" N# k4 q% Q
; \5 @7 m( {5 r; u9 ostatic void __exit led_platform_exit(void)4 U# i/ u$ @/ B0 w/ Q6 S( F) X# j& H
{
& {/ J: b- z% z' l* { platform_device_unregister(&da850_evm_tl_leds_device);
: y) _9 c3 r5 R* A" {9 l' N2 L: A5 d0 t8 q2 L& f0 a0 N
printk(KERN_INFO "LED unregister!\n");& ?9 @# Y% y- A6 K3 x/ _: j' G1 \
}2 C I9 a. o" q( r8 X I8 P/ S
. [& @( C) q8 Q8 O ?module_init(led_platform_init);
2 z" N3 B/ ]% `module_exit(led_platform_exit);9 ^" m, T" ]1 w" O8 \- U
- o. A2 g/ }2 {3 f8 X( \' H
MODULE_DESCRIPTION("Led platform driver");4 `4 Y' Y, y3 E; |) H* J( g
MODULE_AUTHOR("Tronlong");
. A% M( j. c: A9 C/ T; U+ P7 h% gMODULE_LICENSE("GPL");
. E9 f/ f' c% q( M) t; D. b7 I+ n2 ~; a3 I+ n7 B! w/ D& |- t
|
|